Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
talldan committed Aug 15, 2022
1 parent e2a7a30 commit 59e8a5d
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions packages/e2e-tests/specs/editor/blocks/navigation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1444,10 +1444,10 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
);
} );

it( 'should always focus the menu item after navigation menu selection', async () => {
it( 'keeps focus the menu item after navigation menu selection', async () => {
// Create some navigation menus to work with.
await createNavigationMenu( {
title: 'Example Navigation',
title: 'First Example Navigation',
content:
'<!-- wp:navigation-link {"label":"WordPress","type":"custom","url":"http://www.wordpress.org/","kind":"custom","isTopLevelLink":true} /-->',
} );
Expand All @@ -1465,17 +1465,26 @@ Expected mock function not to be called but it was called with: ["POST", "http:/
await waitForBlock( 'Navigation' );
await page.waitForXPath( START_EMPTY_XPATH );

// Change menus via the select menu toolbar button.
// First select a menu from the block placeholder
const selectMenuDropdown = await page.waitForSelector(
'[aria-label="Select Menu"]'
);
await selectMenuDropdown.click();
const exampleNavigationOption = await page.waitForXPath(
'//span[contains(text(), "Second Example Navigation")]'
const firstNavigationOption = await page.waitForXPath(
'//button[.="First Example Navigation"]'
);
await firstNavigationOption.click();

// Next switch menu using the toolbar.
await clickBlockToolbarButton( 'Select Menu' );

const secondNavigationOption = await page.waitForXPath(
'//button[.="Second Example Navigation"]'
);
await exampleNavigationOption.click();
await secondNavigationOption.click();

await expect( exampleNavigationOption ).toHaveFocus();
// The menu item should still have focus.
await expect( secondNavigationOption ).toHaveFocus();
} );
} );
} );

0 comments on commit 59e8a5d

Please sign in to comment.