Skip to content

Commit

Permalink
CustomSelectControlV2: Stabilize tests (#60133)
Browse files Browse the repository at this point in the history
* CustomSelectControlV2: Stabilize tests

* Add comments

Co-authored-by: mirka <0mirka00@git.wordpress.org>
Co-authored-by: tyxla <tyxla@git.wordpress.org>
Co-authored-by: aaronrobertshaw <aaronrobertshaw@git.wordpress.org>
  • Loading branch information
4 people committed Mar 24, 2024
1 parent aac90ca commit c2d3978
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -388,8 +388,10 @@ describe.each( [
await sleep();
await press.Tab();
expect( currentSelectedItem ).toHaveFocus();
expect( currentSelectedItem ).toHaveTextContent( 'violets' );

await type( 'aq' );
// Ideally we would test a multi-character typeahead, but anything more than a single character is flaky
await type( 'a' );

expect(
screen.queryByRole( 'listbox', {
Expand All @@ -398,8 +400,10 @@ describe.each( [
} )
).not.toBeInTheDocument();

// This Enter is a workaround for flakiness, and shouldn't be necessary in an actual browser
await press.Enter();
expect( currentSelectedItem ).toHaveTextContent( 'aquamarine' );

expect( currentSelectedItem ).toHaveTextContent( 'amber' );
} );

it( 'Should have correct aria-selected value for selections', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,10 @@ describe.each( [
await sleep();
await press.Tab();
expect( currentSelectedItem ).toHaveFocus();
expect( currentSelectedItem ).toHaveTextContent( 'violets' );

await type( 'aq' );
// Ideally we would test a multi-character typeahead, but anything more than a single character is flaky
await type( 'a' );

expect(
screen.queryByRole( 'listbox', {
Expand All @@ -185,8 +187,10 @@ describe.each( [
} )
).not.toBeInTheDocument();

// This Enter is a workaround for flakiness, and shouldn't be necessary in an actual browser
await press.Enter();
expect( currentSelectedItem ).toHaveTextContent( 'aquamarine' );

expect( currentSelectedItem ).toHaveTextContent( 'amber' );
} );

it( 'Should have correct aria-selected value for selections', async () => {
Expand Down

0 comments on commit c2d3978

Please sign in to comment.