Skip to content

Commit

Permalink
Revert "Refactor to use userEvent instead of fireEvent"
Browse files Browse the repository at this point in the history
This reverts commit f97baf6.
  • Loading branch information
tyxla committed Dec 16, 2022
1 parent f97baf6 commit 172644f
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions packages/data/src/components/use-select/test/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
/**
* External dependencies
*/
import { act, render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { act, render, fireEvent, screen } from '@testing-library/react';

/**
* WordPress dependencies
Expand Down Expand Up @@ -436,9 +435,7 @@ describe( 'useSelect', () => {
);
} );

it( 'captures state changes scheduled between render and effect', async () => {
const user = userEvent.setup();

it( 'captures state changes scheduled between render and effect', () => {
registry.registerStore( 'store-1', counterStore );

class ChildComponent extends Component {
Expand Down Expand Up @@ -487,7 +484,7 @@ describe( 'useSelect', () => {
</RegistryProvider>
);

await user.click( screen.getByText( 'triggerChildDispatch' ) );
fireEvent.click( screen.getByText( 'triggerChildDispatch' ) );

expect( selectCount1AndDep ).toHaveBeenCalledTimes( 3 );
expect( screen.getByRole( 'status' ) ).toHaveTextContent(
Expand Down Expand Up @@ -1151,9 +1148,7 @@ describe( 'useSelect', () => {
} );

describe( 'static store selection mode', () => {
it( 'can read the current value from store', async () => {
const user = userEvent.setup();

it( 'can read the current value from store', () => {
registry.registerStore( 'testStore', {
reducer: ( s = 0, a ) => ( a.type === 'INC' ? s + 1 : s ),
actions: { inc: () => ( { type: 'INC' } ) },
Expand All @@ -1175,13 +1170,13 @@ describe( 'useSelect', () => {
</RegistryProvider>
);

await user.click( screen.getByRole( 'button' ) );
fireEvent.click( screen.getByRole( 'button' ) );
expect( record ).toHaveBeenLastCalledWith( 0 );

// no need to act() as the component doesn't react to the updates
registry.dispatch( 'testStore' ).inc();

await user.click( screen.getByRole( 'button' ) );
fireEvent.click( screen.getByRole( 'button' ) );
expect( record ).toHaveBeenLastCalledWith( 1 );
} );
} );
Expand Down

1 comment on commit 172644f

@github-actions
Copy link

@github-actions github-actions bot commented on 172644f Dec 16, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/3712332263
📝 Reported issues:

Please sign in to comment.