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 Dec 14, 2023
1 parent 8a3550b commit 789519e
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
Original file line number Diff line number Diff line change
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

1 comment on commit 789519e

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 789519e.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7207451500
📝 Reported issues:

Please sign in to comment.