Skip to content

Commit

Permalink
feat(PPDSC-2242): switch to user-event for floating-ui tests
Browse files Browse the repository at this point in the history
- https://floating-ui.com/docs/react-dom#testing
- https://testing-library.com/docs/user-event/intro/#difference-to-fireevent
- testing-library/react-testing-library#1051
- Switch from fireEvent to userEvent for floating-ui tests.
- Because floating-ui styling is applied async, a state update occurs in a Promise microtask leading to errors and warnings after upgrading React.
- Migrating to userEvent solves this issue.
- Some snapshot updates required as async styling unrelated to test that was not previously applied now is.
  • Loading branch information
mstuartf committed Aug 12, 2022
1 parent 932bbf8 commit 2f6d5e2
Show file tree
Hide file tree
Showing 3 changed files with 150 additions and 190 deletions.
8 changes: 6 additions & 2 deletions src/popover/__tests__/__snapshots__/popover.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,8 @@ exports[`Popover close button should show left-aligned 1`] = `
border-radius: 8px;
z-index: 80;
position: absolute;
left: 0px;
top: 0px;
}
@media screen and (prefers-reduced-motion: no-preference) {
Expand Down Expand Up @@ -972,7 +974,7 @@ exports[`Popover close button should show left-aligned 1`] = `
<div
aria-labelledby="ref-MOCK-ID"
class="nk-popover-enter-done emotion-0"
class=" nk-popover-enter-done emotion-0"
id="floating-MOCK-ID"
role="dialog"
tabindex="-1"
Expand Down Expand Up @@ -1046,6 +1048,8 @@ exports[`Popover close button should show right-aligned 1`] = `
border-radius: 8px;
z-index: 80;
position: absolute;
left: 0px;
top: 0px;
}
@media screen and (prefers-reduced-motion: no-preference) {
Expand Down Expand Up @@ -1309,7 +1313,7 @@ exports[`Popover close button should show right-aligned 1`] = `
<div
aria-labelledby="ref-MOCK-ID"
class="nk-popover-enter-done emotion-0"
class=" nk-popover-enter-done emotion-0"
id="floating-MOCK-ID"
role="dialog"
tabindex="-1"
Expand Down
Loading

0 comments on commit 2f6d5e2

Please sign in to comment.