Skip to content

Commit

Permalink
Apply workaround for false-positive detection of pointer-events
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinpalkovic committed Aug 2, 2024
1 parent 2dd7fb5 commit 14bd586
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
7 changes: 7 additions & 0 deletions WORKAROUNDS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## FALSE_POSITIVE_POINTER_EVENTS

When running vitest in browser mode, the pointer events are not correctly simulated. This can be related to this [known issue](https://github.com/microsoft/playwright/issues/12821). The bug also appears not only in chromium, but also in webkit. The workaround is to use `userEvent` events with the setting `{ pointerEventsCheck: 0 }` to disable the pointer events check.

```javascript
await userEvent.type(titleInput, 'New Note Title', { pointerEventsCheck: 0 })
```
9 changes: 7 additions & 2 deletions app/note/edit/[id]/page.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,16 @@ export const SavingExistingNoteShouldUpdateDBAndRedirect: Story = {
)

await userEvent.clear(titleInput)
await userEvent.type(titleInput, 'Edited Title')
// WORKAROUND: FALSE_POSITIVE_POINTER_EVENTS
await userEvent.type(titleInput, 'Edited Title', { pointerEventsCheck: 0 })
await userEvent.clear(bodyInput)
await userEvent.type(bodyInput, 'Edited Body')
// WORKAROUND: FALSE_POSITIVE_POINTER_EVENTS
await userEvent.type(bodyInput, 'Edited Body', { pointerEventsCheck: 0 })

await userEvent.click(
await canvas.findByRole('menuitem', { name: /done/i }),
// WORKAROUND: FALSE_POSITIVE_POINTER_EVENTS
{ pointerEventsCheck: 0 }
)

await expectRedirect('/note/2')
Expand All @@ -94,6 +98,7 @@ export const DeleteNoteRemovesFromDBAndSidebar: Story = {

await userEvent.click(
await canvas.findByRole('menuitem', { name: /delete/i }),
{ pointerEventsCheck: 0 }
)

await expectRedirect('/')
Expand Down
8 changes: 6 additions & 2 deletions app/note/edit/page.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,15 @@ export const SaveNewNote: Story = {
'Enter the body for your note',
)
await userEvent.clear(titleInput)
await userEvent.type(titleInput, 'New Note Title')
await userEvent.type(bodyInput, 'New Note Body')
// WORKAROUND: FALSE_POSITIVE_POINTER_EVENTS
await userEvent.type(titleInput, 'New Note Title', { pointerEventsCheck: 0 })
// WORKAROUND: FALSE_POSITIVE_POINTER_EVENTS
await userEvent.type(bodyInput, 'New Note Body', { pointerEventsCheck: 0 })

await userEvent.click(
await canvas.findByRole('menuitem', { name: /done/i }),
// WORKAROUND: FALSE_POSITIVE_POINTER_EVENTS
{ pointerEventsCheck: 0 }
)

await expectRedirect('/note/3')
Expand Down

0 comments on commit 14bd586

Please sign in to comment.