Skip to content
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

test: Fix testing-library/no-await-sync-events violations #82768

Merged
merged 1 commit into from
Dec 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ export default typescript.config([
plugins: jestDom.configs['flat/recommended'].plugins,
},
{
name: 'testing-library/react - ts files',
name: 'testing-library/react',
files: ['**/*.spec.{ts,js,tsx,jsx}', 'tests/js/**/*.{ts,js,tsx,jsx}'],
...testingLibrary.configs['flat/react'],
rules: {
Expand All @@ -959,7 +959,6 @@ export default typescript.config([
files: ['**/*.spec.{tsx,jsx}', 'tests/js/**/*.{tsx,jsx}'],
...testingLibrary.configs['flat/react'],
rules: {
'testing-library/no-await-sync-events': 'warn', // TODO(ryan953): Fix the violations, then delete this line
'testing-library/no-container': 'warn', // TODO(ryan953): Fix the violations, then delete this line
'testing-library/no-node-access': 'warn', // TODO(ryan953): Fix the violations, then delete this line
'testing-library/no-render-in-lifecycle': 'warn', // TODO(ryan953): Fix the violations, then delete this line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ describe('EnvironmentPageFilter', function () {
await userEvent.click(screen.getByRole('button', {name: 'All Envs'}));

// Select prod & stage by clicking on their checkboxes
await fireEvent.click(screen.getByRole('checkbox', {name: 'Select prod'}));
await fireEvent.click(screen.getByRole('checkbox', {name: 'Select stage'}));
fireEvent.click(screen.getByRole('checkbox', {name: 'Select prod'}));
fireEvent.click(screen.getByRole('checkbox', {name: 'Select stage'}));

// Click "Apply"
await userEvent.click(screen.getByRole('button', {name: 'Apply'}));
Expand Down
16 changes: 8 additions & 8 deletions static/app/components/organizations/hybridFilter.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ describe('ProjectPageFilter', function () {
// Clicking on the checkboxes in Option One & Option Two _adds_ the options to the
// current selection state (multiple selection mode)
await userEvent.click(screen.getByRole('button', {expanded: false}));
await fireEvent.click(screen.getByRole('checkbox', {name: 'Select Option One'}));
await fireEvent.click(screen.getByRole('checkbox', {name: 'Select Option Two'}));
fireEvent.click(screen.getByRole('checkbox', {name: 'Select Option One'}));
fireEvent.click(screen.getByRole('checkbox', {name: 'Select Option Two'}));
expect(screen.getByRole('checkbox', {name: 'Select Option One'})).toBeChecked();
expect(screen.getByRole('checkbox', {name: 'Select Option Two'})).toBeChecked();

Expand Down Expand Up @@ -92,10 +92,10 @@ describe('ProjectPageFilter', function () {
which: 17,
ctrlKey: true,
};
await fireEvent.keyDown(screen.getByRole('grid'), ctrlKeyOpts); // Press & hold Ctrl
fireEvent.keyDown(screen.getByRole('grid'), ctrlKeyOpts); // Press & hold Ctrl
await userEvent.click(screen.getByRole('row', {name: 'Option One'}));
await fireEvent.click(screen.getByRole('row', {name: 'Option Two'}));
await fireEvent.keyUp(screen.getByRole('grid'), ctrlKeyOpts); // Release Ctrl
fireEvent.click(screen.getByRole('row', {name: 'Option Two'}));
fireEvent.keyUp(screen.getByRole('grid'), ctrlKeyOpts); // Release Ctrl
expect(screen.getByRole('checkbox', {name: 'Select Option One'})).not.toBeChecked();
expect(screen.getByRole('checkbox', {name: 'Select Option Two'})).not.toBeChecked();

Expand All @@ -110,7 +110,7 @@ describe('ProjectPageFilter', function () {

// Open the menu, select Option One
await userEvent.click(screen.getByRole('button', {expanded: false}));
await fireEvent.click(screen.getByRole('checkbox', {name: 'Select Option One'}));
fireEvent.click(screen.getByRole('checkbox', {name: 'Select Option One'}));

// Press Cancel
await userEvent.click(screen.getByRole('button', {name: 'Cancel'}));
Expand Down Expand Up @@ -140,7 +140,7 @@ describe('ProjectPageFilter', function () {
expect(screen.queryByRole('button', {name: 'Reset'})).not.toBeInTheDocument();

// Select Option Two, Reset button shows up
await fireEvent.click(screen.getByRole('checkbox', {name: 'Select Option Two'}));
fireEvent.click(screen.getByRole('checkbox', {name: 'Select Option Two'}));
expect(screen.getByRole('checkbox', {name: 'Select Option Two'})).toBeChecked();
expect(screen.getByRole('button', {name: 'Reset'})).toBeInTheDocument();

Expand Down Expand Up @@ -181,7 +181,7 @@ describe('ProjectPageFilter', function () {
// focused to activate it. With RTL, however, onChange events aren't fired on Space
// key press (https://github.com/testing-library/react-testing-library/issues/122),
// so we'll have to simulate a click event instead.
await fireEvent.click(screen.getByRole('checkbox', {name: 'Select Option One'}));
fireEvent.click(screen.getByRole('checkbox', {name: 'Select Option One'}));
expect(screen.getByRole('checkbox', {name: 'Select Option One'})).toBeChecked();

// Click "Apply" button, onChange is called
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ describe('ProjectPageFilter', function () {
await userEvent.click(screen.getByRole('button', {name: 'My Projects'}));

// Deselect project-1 & project-2 by clicking on their checkboxes
await fireEvent.click(screen.getByRole('checkbox', {name: 'Select project-1'}));
await fireEvent.click(screen.getByRole('checkbox', {name: 'Select project-2'}));
fireEvent.click(screen.getByRole('checkbox', {name: 'Select project-1'}));
fireEvent.click(screen.getByRole('checkbox', {name: 'Select project-2'}));

// Select project-3 by clicking on its checkbox
await fireEvent.click(screen.getByRole('checkbox', {name: 'Select project-3'}));
fireEvent.click(screen.getByRole('checkbox', {name: 'Select project-3'}));

// Click "Apply"
await userEvent.click(screen.getByRole('button', {name: 'Apply'}));
Expand Down
Loading