Skip to content

Commit

Permalink
Fix util to be more aware of menu expanded state before acting
Browse files Browse the repository at this point in the history
  • Loading branch information
getdave committed Nov 22, 2023
1 parent 301919a commit a35ade3
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/e2e-test-utils/src/toggle-more-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@
export async function toggleMoreMenu( waitFor ) {
const menuSelector = '.interface-more-menu-dropdown [aria-label="Options"]';

const menuToggle = await page.waitForSelector( menuSelector );

const isOpen = await menuToggle.evaluate( ( el ) =>
el.getAttribute( 'aria-expanded' )
);

// If opening and it's already open then exit early.
if ( isOpen === 'true' && waitFor === 'open' ) {
return;
}

// If closing and it's already closed then exit early.
if ( isOpen === 'false' && waitFor === 'close' ) {
return;
}

await page.click( menuSelector );

if ( waitFor ) {
Expand Down

0 comments on commit a35ade3

Please sign in to comment.