From f52f15eeebe78ab539b28c1fa5a2abc68f72455d Mon Sep 17 00:00:00 2001 From: Jerry Jones Date: Thu, 20 Jul 2023 11:58:46 -0500 Subject: [PATCH 1/3] Intentionally break some tests to debug why routing to / works on the github e2e tests --- test/e2e/specs/editor/blocks/navigation.spec.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/test/e2e/specs/editor/blocks/navigation.spec.js b/test/e2e/specs/editor/blocks/navigation.spec.js index 4403cce4ca0fb..88851fcb89aec 100644 --- a/test/e2e/specs/editor/blocks/navigation.spec.js +++ b/test/e2e/specs/editor/blocks/navigation.spec.js @@ -75,7 +75,7 @@ test.describe( 'Navigation block', () => { ).toBeVisible(); // 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', @@ -84,13 +84,15 @@ test.describe( 'Navigation block', () => { ] ); // Check the block in the frontend. - await page.goto( `/` ); + await page.goto( `/?p=${ postId }` ); await expect( page.locator( `role=navigation >> role=link[name="WordPress"i]` ) ).toBeVisible(); + + expect( true ).toBe( false ); } ); test( 'default to the only existing classic menu if there are no block menus', async ( { @@ -126,6 +128,8 @@ test.describe( 'Navigation block', () => { `role=navigation >> role=link[name="Custom link"i]` ) ).toBeVisible(); + + expect( true ).toBe( false ); } ); test( 'default to my most recently created menu', async ( { @@ -154,7 +158,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', @@ -170,13 +174,15 @@ test.describe( 'Navigation block', () => { ).toBeVisible(); // Check the block in the frontend. - await page.goto( `/` ); + await page.goto( `/?p=${ postId }` ); await expect( page.locator( `role=navigation >> role=link[name="Menu 2 Link"i]` ) ).toBeVisible(); + + expect( true ).toBe( false ); } ); } ); @@ -216,6 +222,8 @@ test.describe( 'Navigation block', () => { `role=navigation >> role=button[name="example.com submenu "i]` ) ).toBeVisible(); + + expect( true ).toBe( false ); } ); test( 'submenu converts to link automatically', async ( { From bfc1c1dbe3c88a7af8f03a0cccb8cb3d0111c5bf Mon Sep 17 00:00:00 2001 From: Jerry Jones Date: Thu, 20 Jul 2023 15:56:53 -0500 Subject: [PATCH 2/3] Use twenty twenty one and route directly to published posts to check menu markup --- .../specs/editor/blocks/navigation.spec.js | 28 +++++-------------- 1 file changed, 7 insertions(+), 21 deletions(-) diff --git a/test/e2e/specs/editor/blocks/navigation.spec.js b/test/e2e/specs/editor/blocks/navigation.spec.js index 88851fcb89aec..0da5cd6a87d60 100644 --- a/test/e2e/specs/editor/blocks/navigation.spec.js +++ b/test/e2e/specs/editor/blocks/navigation.spec.js @@ -4,20 +4,12 @@ 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() ] ); } ); test.afterAll( async ( { requestUtils } ) => { - await Promise.all( [ - requestUtils.deleteAllMenus(), - requestUtils.activateTheme( 'twentytwentyone' ), - ] ); + await Promise.all( [ requestUtils.deleteAllMenus() ] ); } ); test.afterEach( async ( { requestUtils } ) => { @@ -74,8 +66,9 @@ test.describe( 'Navigation block', () => { ) ).toBeVisible(); - // Check the markup of the block is correct. const postId = await editor.publishPost(); + + // Check the markup of the block is correct. await expect.poll( editor.getBlocks ).toMatchObject( [ { name: 'core/navigation', @@ -91,8 +84,6 @@ test.describe( 'Navigation block', () => { `role=navigation >> role=link[name="WordPress"i]` ) ).toBeVisible(); - - expect( true ).toBe( false ); } ); test( 'default to the only existing classic menu if there are no block menus', async ( { @@ -120,16 +111,15 @@ 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( `role=navigation >> role=link[name="Custom link"i]` ) ).toBeVisible(); - - expect( true ).toBe( false ); } ); test( 'default to my most recently created menu', async ( { @@ -181,8 +171,6 @@ test.describe( 'Navigation block', () => { `role=navigation >> role=link[name="Menu 2 Link"i]` ) ).toBeVisible(); - - expect( true ).toBe( false ); } ); } ); @@ -214,16 +202,14 @@ 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( `role=navigation >> role=button[name="example.com submenu "i]` ) ).toBeVisible(); - - expect( true ).toBe( false ); } ); test( 'submenu converts to link automatically', async ( { From 23673017bc3189cfbf2562a433293c47e8461656 Mon Sep 17 00:00:00 2001 From: Jerry Jones Date: Fri, 21 Jul 2023 11:14:59 -0500 Subject: [PATCH 3/3] Use Promise.all on multiple requests and normal await on single items --- test/e2e/specs/editor/blocks/navigation.spec.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/test/e2e/specs/editor/blocks/navigation.spec.js b/test/e2e/specs/editor/blocks/navigation.spec.js index 0da5cd6a87d60..4757ccbb4a00f 100644 --- a/test/e2e/specs/editor/blocks/navigation.spec.js +++ b/test/e2e/specs/editor/blocks/navigation.spec.js @@ -5,16 +5,18 @@ const { test, expect } = require( '@wordpress/e2e-test-utils-playwright' ); test.describe( 'Navigation block', () => { test.beforeEach( async ( { requestUtils } ) => { - await Promise.all( [ requestUtils.deleteAllMenus() ] ); + await requestUtils.deleteAllMenus(); } ); test.afterAll( async ( { requestUtils } ) => { - await Promise.all( [ requestUtils.deleteAllMenus() ] ); + 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', () => {