Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix flaky Navigation focus mode test #57016

Merged
merged 3 commits into from
Dec 14, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading