-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Updating testing documentation and exposing some testing utils #5508
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
35 commits
Select commit
Hold shift + click to select a range
a8b8627
progress on updating the testing docs
LFDanLu 790e8ad
setup and testing of new util packages
LFDanLu 5c5b8c9
move test utils to react-spectrum and add provider wrapper
LFDanLu 80b67c1
restoring StrictModeWrapper
LFDanLu 9c8ef8f
add desktop and mobile mock util setup
LFDanLu 8d02268
starting to remove triggerPress in favor of user event library click
LFDanLu 3c1eadf
remove triggerPress
LFDanLu 04c7290
fix SSR tests and react 16/17 tests
LFDanLu 7760e95
work around weird react16/17 test failure for now
LFDanLu 4848110
get rid of triggerTouch and typeText
LFDanLu af7ce33
move stuff to aria/test-utils package
LFDanLu 488da8e
fix menutrigger tests
LFDanLu a84a6df
replacing fireEvent with userEvent equivalents in hooks tests pt1
LFDanLu 1d80361
wrapping up hooks tests fireEvent replacements
LFDanLu 0cc42d5
fix some lint issues
LFDanLu 79a71f4
first batch of spectrum test fireEvent -> userEvent replacement
LFDanLu 6537adb
fix tests in 16/17 again
LFDanLu 409e8b4
updating testing docs and linking to it from various components
LFDanLu 8d839cb
temporarily restore old test util package and move ssr stuff there
LFDanLu 215c2e8
make react-spectrum/test-util-internal to limit what is exposed from …
LFDanLu e17318e
adding docs for installmouseevent
LFDanLu dc74ebe
add peer deps
LFDanLu ad731c2
Merge branch 'main' of github.com:adobe/react-spectrum into updating_…
LFDanLu 0ef44bf
fix combobox test
LFDanLu 2ff15bf
try to fix tsfork
LFDanLu 808670d
fix ts fork pt 2
LFDanLu 755f06b
test lower version requirements
LFDanLu 44bf80e
Merge branch 'main' into updating_testing_docs
LFDanLu 66e34cf
fix tests
LFDanLu 0017ae4
missed one test update
LFDanLu 03fdd4d
review updates
LFDanLu c07d8e9
Merge branch 'main' of github.com:adobe/react-spectrum into updating_…
LFDanLu 8e6611e
Merge branch 'main' of github.com:adobe/react-spectrum into updating_…
LFDanLu 81cf49b
removing todo
LFDanLu b2200df
messed up a copy paste
LFDanLu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10,18 +10,22 @@ | |
| * governing permissions and limitations under the License. | ||
| */ | ||
|
|
||
| import {act, fireEvent, render, triggerPress, waitFor} from '@react-spectrum/test-utils'; | ||
| import {act, pointerMap, render, simulateMobile, waitFor} from '@react-spectrum/test-utils-internal'; | ||
| import {ActionButton, Button} from '@react-spectrum/button'; | ||
| import {Content} from '@react-spectrum/view'; | ||
| import {Dialog, DialogTrigger} from '@react-spectrum/dialog'; | ||
| import {Item, Menu, MenuTrigger, Section} from '@react-spectrum/menu'; | ||
| import {Provider} from '@react-spectrum/provider'; | ||
| import React from 'react'; | ||
| import {theme} from '@react-spectrum/theme-default'; | ||
| import userEvent from '@testing-library/user-event'; | ||
| import {watchModals} from '../'; | ||
|
|
||
| describe('watchModals', () => { | ||
| let user; | ||
|
|
||
| beforeAll(() => { | ||
| user = userEvent.setup({delay: null, pointerMap}); | ||
|
Comment on lines
+25
to
+28
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In some of the tests that didn't have |
||
| jest.useFakeTimers(); | ||
| }); | ||
|
|
||
|
|
@@ -44,9 +48,7 @@ describe('watchModals', () => { | |
| expect(queryByRole('separator')).toBeNull(); | ||
|
|
||
| expect(document.activeElement).toBe(modal); | ||
|
|
||
| fireEvent.keyDown(modal, {key: 'Escape'}); | ||
| fireEvent.keyUp(modal, {key: 'Escape'}); | ||
| await user.keyboard('{Escape}'); | ||
|
|
||
| act(() => { | ||
| jest.runAllTimers(); | ||
|
|
@@ -73,9 +75,7 @@ describe('watchModals', () => { | |
| </> | ||
| ); | ||
| expect(getByRole('separator')).toBeVisible(); | ||
| act(() => { | ||
| triggerPress(getByLabelText('Trigger')); | ||
| }); | ||
| await user.click(getByLabelText('Trigger')); | ||
| act(() => { | ||
| jest.runAllTimers(); | ||
| }); | ||
|
|
@@ -106,9 +106,7 @@ describe('watchModals', () => { | |
| ); | ||
| // expect just the button labeled Trigger, and open the first dialog | ||
| expect(getByRole('separator')).toBeVisible(); | ||
| act(() => { | ||
| triggerPress(getByLabelText('Trigger')); | ||
| }); | ||
| await user.click(getByLabelText('Trigger')); | ||
| act(() => { | ||
| jest.runAllTimers(); | ||
| }); | ||
|
|
@@ -123,9 +121,7 @@ describe('watchModals', () => { | |
| let buttons = getAllByRole('button'); | ||
| expect(buttons.length).toBe(1); | ||
| expect(buttons[0]).toBe(getByLabelText('Nested Trigger')); | ||
| act(() => { | ||
| triggerPress(getByLabelText('Nested Trigger')); | ||
| }); | ||
| await user.click(getByLabelText('Nested Trigger')); | ||
| act(() => { | ||
| jest.runAllTimers(); | ||
| }); | ||
|
|
@@ -139,8 +135,8 @@ describe('watchModals', () => { | |
| expect(queryByRole('separator')).toBeNull(); | ||
|
|
||
| // start closing dialogs | ||
| fireEvent.keyDown(innerDialog, {key: 'Escape'}); | ||
| fireEvent.keyUp(innerDialog, {key: 'Escape'}); | ||
| await user.keyboard('{Escape}'); | ||
|
|
||
| act(() => { | ||
| jest.runAllTimers(); | ||
| }); | ||
|
|
@@ -155,8 +151,7 @@ describe('watchModals', () => { | |
| expect(queryByRole('separator')).toBeNull(); | ||
|
|
||
| // close the outer dialog | ||
| fireEvent.keyDown(dialog, {key: 'Escape'}); | ||
| fireEvent.keyUp(dialog, {key: 'Escape'}); | ||
| await user.keyboard('{Escape}'); | ||
| act(() => { | ||
| jest.runAllTimers(); | ||
| }); | ||
|
|
@@ -196,9 +191,8 @@ describe('watchModals', () => { | |
| </> | ||
| ); | ||
| expect(getByRole('separator')).toBeVisible(); | ||
| act(() => { | ||
| triggerPress(getByLabelText('Trigger')); | ||
| }); | ||
| await user.click(getByLabelText('Trigger')); | ||
|
|
||
| act(() => { | ||
| jest.runAllTimers(); | ||
| }); | ||
|
|
@@ -215,7 +209,7 @@ describe('watchModals', () => { | |
| ]} | ||
| ]; | ||
| // menu should be a tray | ||
| jest.spyOn(window.screen, 'width', 'get').mockImplementation(() => 700); | ||
| simulateMobile(); | ||
| watchModals(); | ||
| let {getByLabelText, getByRole, queryByRole} = render( | ||
| <> | ||
|
|
@@ -235,9 +229,7 @@ describe('watchModals', () => { | |
| </> | ||
| ); | ||
| expect(getByRole('separator')).toBeVisible(); | ||
| act(() => { | ||
| triggerPress(getByLabelText('Trigger')); | ||
| }); | ||
| await user.click(getByLabelText('Trigger')); | ||
| act(() => { | ||
| jest.runAllTimers(); | ||
| }); | ||
|
|
@@ -259,9 +251,7 @@ describe('watchModals', () => { | |
| </> | ||
| ); | ||
| expect(getByRole('separator')).toBeVisible(); | ||
| act(() => { | ||
| triggerPress(getByLabelText('Trigger')); | ||
| }); | ||
| await user.click(getByLabelText('Trigger')); | ||
| act(() => { | ||
| jest.runAllTimers(); | ||
| }); | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In many of the tests, I got rid of triggerPress and typeText where ever possible in favor of userEvent. Also got rid of fireEvent where I could as well. Didn't get to all the tests since there is quite a bit