diff --git a/packages/components/src/menu/test/index.tsx b/packages/components/src/menu/test/index.tsx index d1d4e665b9d657..7b889661c9bf7e 100644 --- a/packages/components/src/menu/test/index.tsx +++ b/packages/components/src/menu/test/index.tsx @@ -156,7 +156,7 @@ describe( 'Menu', () => { await waitForFocusedMenuItem( 'First item' ); } ); - it( 'should open and focus the first item when pressing the space key on the trigger', async () => { + it( 'should open when pressing the space key on the trigger', async () => { render( Open dropdown @@ -181,11 +181,16 @@ describe( 'Menu', () => { expect( screen.queryByRole( 'menuitem' ) ).not.toBeInTheDocument(); // Keyboard-triggered clicks have `detail: 0`, which Ariakit uses to - // choose the initial item focus path instead of the pointer path. + // distinguish keyboard activation from pointer activation. await press.Space( toggleButton, { detail: 0 } ); - // Menu open, focus is on the first focusable item - await waitForFocusedMenuItem( 'First item' ); + await waitFor( () => + expect( toggleButton ).toHaveAttribute( + 'aria-expanded', + 'true' + ) + ); + expect( screen.getByRole( 'menu' ) ).toBeVisible(); } ); it( 'should close when pressing the escape key', async () => {