Skip to content

Commit

Permalink
Fix flaky Navigation focus mode test (#57016)
Browse files Browse the repository at this point in the history
* Add missing assertion

* Test expect url

* Do setup before entering editor
  • Loading branch information
getdave authored and artemiomorales committed Jan 4, 2024
1 parent 8a22d90 commit d37f9b8
Showing 1 changed file with 24 additions and 18 deletions.
42 changes: 24 additions & 18 deletions test/e2e/specs/site-editor/navigation-editor.spec.js
Expand Up @@ -20,20 +20,6 @@ test.describe( 'Editing Navigation Menus', () => {
editor,
} ) => {
await test.step( 'Manually browse to focus mode for a Navigation Menu', async () => {
// We could Navigate directly to editing the Navigation Menu but we intentionally do not do this.
//
// Why? To provide coverage for a bug that caused the Navigation Editor behaviours to fail
// only when navigating through the editor screens (rather than going directly to the editor by URL).
// See: https://github.com/WordPress/gutenberg/pull/56856.
//
// Example (what we could do):
// await admin.visitSiteEditor( {
// postId: createdMenu?.id,
// postType: 'wp_navigation',
// } );
//
await admin.visitSiteEditor();

// create a Navigation Menu called "Test Menu" using the REST API helpers
const createdMenu = await requestUtils.createNavigationMenu( {
title: 'Primary Menu',
Expand All @@ -48,6 +34,20 @@ test.describe( 'Editing Navigation Menus', () => {
'<!-- wp:navigation-link {"label":"Another Item","type":"custom","url":"http://www.wordpress.org/","kind":"custom"} /-->',
} );

// We could Navigate directly to editing the Navigation Menu but we intentionally do not do this.
//
// Why? To provide coverage for a bug that caused the Navigation Editor behaviours to fail
// only when navigating through the editor screens (rather than going directly to the editor by URL).
// See: https://github.com/WordPress/gutenberg/pull/56856.
//
// Example (what we could do):
// await admin.visitSiteEditor( {
// postId: createdMenu?.id,
// postType: 'wp_navigation',
// } );
//
await admin.visitSiteEditor();

const editorSidebar = page.getByRole( 'region', {
name: 'Navigation',
} );
Expand All @@ -66,6 +66,10 @@ test.describe( 'Editing Navigation Menus', () => {
} )
).toBeVisible();

await expect( page ).toHaveURL(
`wp-admin/site-editor.php?path=%2Fnavigation`
);

await editorSidebar
.getByRole( 'button', {
name: 'Primary Menu',
Expand All @@ -77,10 +81,12 @@ test.describe( 'Editing Navigation Menus', () => {
);

// Wait for list of Navigations to appear.
editorSidebar.getByRole( 'heading', {
name: 'Primary Menu',
level: 1,
} );
await expect(
editorSidebar.getByRole( 'heading', {
name: 'Primary Menu',
level: 1,
} )
).toBeVisible();

// Switch to editing the Navigation Menu
await editorSidebar
Expand Down

0 comments on commit d37f9b8

Please sign in to comment.