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

Route to published post instead of homepage on navigation e2e tests #52802

Merged
merged 3 commits into from
Jul 21, 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
34 changes: 15 additions & 19 deletions test/e2e/specs/editor/blocks/navigation.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,19 @@
const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' );

test.describe( 'Navigation block', () => {
test.beforeAll( async ( { requestUtils } ) => {
//TT3 is preferable to emptytheme because it already has the navigation block on its templates.
await requestUtils.activateTheme( 'twentytwentythree' );
} );

test.beforeEach( async ( { requestUtils } ) => {
await Promise.all( [ requestUtils.deleteAllMenus() ] );
await requestUtils.deleteAllMenus();
} );

test.afterAll( async ( { requestUtils } ) => {
await Promise.all( [
requestUtils.deleteAllMenus(),
requestUtils.activateTheme( 'twentytwentyone' ),
] );
await requestUtils.deleteAllMenus();
} );

test.afterEach( async ( { requestUtils } ) => {
await requestUtils.deleteAllPosts();
await requestUtils.deleteAllMenus();
await Promise.all( [
requestUtils.deleteAllPosts(),
requestUtils.deleteAllMenus(),
] );
} );

test.describe( 'As a user I want the navigation block to fallback to the best possible default', () => {
Expand Down Expand Up @@ -74,8 +68,9 @@ test.describe( 'Navigation block', () => {
)
).toBeVisible();

const postId = await editor.publishPost();

// Check the markup of the block is correct.
await editor.publishPost();
await expect.poll( editor.getBlocks ).toMatchObject( [
{
name: 'core/navigation',
Expand All @@ -84,7 +79,7 @@ test.describe( 'Navigation block', () => {
] );

// Check the block in the frontend.
await page.goto( `/` );
await page.goto( `/?p=${ postId }` );

await expect(
page.locator(
Expand Down Expand Up @@ -118,8 +113,9 @@ test.describe( 'Navigation block', () => {
)
).toBeVisible( { timeout: 10000 } ); // allow time for network request.

const postId = await editor.publishPost();
// Check the block in the frontend.
await page.goto( `/` );
await page.goto( `/?p=${ postId }` );

await expect(
page.locator(
Expand Down Expand Up @@ -154,7 +150,7 @@ test.describe( 'Navigation block', () => {
await editor.insertBlock( { name: 'core/navigation' } );

// Check the markup of the block is correct.
await editor.publishPost();
const postId = await editor.publishPost();
await expect.poll( editor.getBlocks ).toMatchObject( [
{
name: 'core/navigation',
Expand All @@ -170,7 +166,7 @@ test.describe( 'Navigation block', () => {
).toBeVisible();

// Check the block in the frontend.
await page.goto( `/` );
await page.goto( `/?p=${ postId }` );

await expect(
page.locator(
Expand Down Expand Up @@ -208,8 +204,8 @@ test.describe( 'Navigation block', () => {
} );
await addSubmenuButton.click();

await editor.publishPost();
await page.goto( `/` );
const postId = await editor.publishPost();
await page.goto( `/?p=${ postId }` );

await expect(
page.locator(
Expand Down
Loading