Skip to content

Commit

Permalink
Use sync render temporarily to fix tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniGuardiola committed Aug 2, 2024
1 parent f6a302c commit d48ad4d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
11 changes: 8 additions & 3 deletions packages/components/src/dropdown-menu-v2/test/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/**
* External dependencies
*/
import { screen, waitFor } from '@testing-library/react';
// eslint-disable-next-line no-restricted-imports
import { screen, waitFor, render as renderSync } from '@testing-library/react';
import { render } from '@ariakit/test/react';
import { press, click, hover, type } from '@ariakit/test';

Expand Down Expand Up @@ -326,7 +327,9 @@ describe( 'DropdownMenu', () => {
} );

it( 'should navigate menu items and subitems using the arrow, spacebar and enter keys', async () => {
await render(
// TODO: temporarily using the sync version of render until we figure out why it fails when async
// see: https://github.com/WordPress/gutenberg/pull/64180
renderSync(
<DropdownMenu
defaultOpen
trigger={ <button>Open dropdown</button> }
Expand All @@ -352,7 +355,9 @@ describe( 'DropdownMenu', () => {
);

// The menu is focused automatically when `defaultOpen` is set.
expect( await screen.findByRole( 'menu' ) ).toHaveFocus();
await waitFor( () =>
expect( screen.getByRole( 'menu' ) ).toHaveFocus()
);

// Arrow up/down selects menu items
// The selection wraps around from last to first and viceversa
Expand Down
11 changes: 8 additions & 3 deletions packages/components/src/toggle-group-control/test/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/**
* External dependencies
*/
import { screen, waitFor } from '@testing-library/react';
// eslint-disable-next-line no-restricted-imports
import { screen, waitFor, render as renderSync } from '@testing-library/react';
import { render } from '@ariakit/test/react';
import { press, click, hover, sleep } from '@ariakit/test';

Expand Down Expand Up @@ -104,7 +105,9 @@ describe.each( [
describe( 'should render correctly', () => {
it( 'with text options', async () => {
const container = createContainer();
await render(
// TODO: temporarily using the sync version of render until we figure what to do with these snapshots
// see: https://github.com/WordPress/gutenberg/pull/64180
renderSync(
<Component label="Test Toggle Group Control">
{ options }
</Component>,
Expand All @@ -116,7 +119,9 @@ describe.each( [

it( 'with icons', async () => {
const container = createContainer();
await render(
// TODO: temporarily using the sync version of render until we figure what to do with these snapshots
// see: https://github.com/WordPress/gutenberg/pull/64180
renderSync(
<Component value="uppercase" label="Test Toggle Group Control">
<ToggleGroupControlOptionIcon
value="uppercase"
Expand Down

0 comments on commit d48ad4d

Please sign in to comment.