From 659120085ec158d6dfe2b35e86921f80b0f8cbea Mon Sep 17 00:00:00 2001 From: Ankit Kumar Shah Date: Fri, 21 Feb 2025 10:27:49 +0530 Subject: [PATCH 1/3] Add e2e test for 404 page --- test/e2e/specs/site-editor/navigation.spec.js | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/test/e2e/specs/site-editor/navigation.spec.js b/test/e2e/specs/site-editor/navigation.spec.js index 18eb6c9904b449..a5ed23ed4abac5 100644 --- a/test/e2e/specs/site-editor/navigation.spec.js +++ b/test/e2e/specs/site-editor/navigation.spec.js @@ -106,6 +106,25 @@ test.describe( 'Site editor navigation', () => { // We should have our editor canvas button back await expect( editorCanvasButton ).toBeVisible(); } ); + + test( 'Should show 404 page when navigating to non-existent template', async ( { + admin, + page, + } ) => { + await admin.visitSiteEditor(); + + // Navigate to a non-existent template. + await page.goto( '/wp-admin/site-editor.php?p=%2Ftemplate-foo-bar' ); + + // Verify the 404 error notice is displayed with the correct message. + await expect( + page + .locator( '.components-notice__content' ) + .getByText( + 'The requested page could not be found. Please check the URL.' + ) + ).toBeVisible(); + } ); } ); class EditorNavigationUtils { From a037e71b82ef8d7faece7696953418c80e5967c4 Mon Sep 17 00:00:00 2001 From: Ankit Kumar Shah Date: Mon, 24 Feb 2025 11:16:28 +0530 Subject: [PATCH 2/3] Improve navigation test --- test/e2e/specs/site-editor/navigation.spec.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/test/e2e/specs/site-editor/navigation.spec.js b/test/e2e/specs/site-editor/navigation.spec.js index a5ed23ed4abac5..365ee8bf33e0e9 100644 --- a/test/e2e/specs/site-editor/navigation.spec.js +++ b/test/e2e/specs/site-editor/navigation.spec.js @@ -114,16 +114,16 @@ test.describe( 'Site editor navigation', () => { await admin.visitSiteEditor(); // Navigate to a non-existent template. - await page.goto( '/wp-admin/site-editor.php?p=%2Ftemplate-foo-bar' ); + await admin.visitAdminPage( 'site-editor.php', 'p=/template-foo-bar' ); // Verify the 404 error notice is displayed with the correct message. await expect( - page - .locator( '.components-notice__content' ) - .getByText( - 'The requested page could not be found. Please check the URL.' - ) - ).toBeVisible(); + page.locator( + '.edit-site-layout__area .components-notice__content' + ) + ).toHaveText( + 'The requested page could not be found. Please check the URL.' + ); } ); } ); From 6eb63c2edc7f35cc4249f3b845cdc1fcbd030cf0 Mon Sep 17 00:00:00 2001 From: Ankit Kumar Shah Date: Tue, 25 Feb 2025 13:14:20 +0530 Subject: [PATCH 3/3] Remove unnecessery `visitSiteEditor()` --- test/e2e/specs/site-editor/navigation.spec.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/test/e2e/specs/site-editor/navigation.spec.js b/test/e2e/specs/site-editor/navigation.spec.js index 365ee8bf33e0e9..2a886c2048f886 100644 --- a/test/e2e/specs/site-editor/navigation.spec.js +++ b/test/e2e/specs/site-editor/navigation.spec.js @@ -111,8 +111,6 @@ test.describe( 'Site editor navigation', () => { admin, page, } ) => { - await admin.visitSiteEditor(); - // Navigate to a non-existent template. await admin.visitAdminPage( 'site-editor.php', 'p=/template-foo-bar' );