From 9a495f826ed344359df89b79f26b5759e36451fe Mon Sep 17 00:00:00 2001 From: Ankit Kumar Shah Date: Tue, 25 Feb 2025 13:55:50 +0530 Subject: [PATCH] Test: Add e2e test for 404 page (#69272) * Add e2e test for 404 page * Improve navigation test * Remove unnecessery `visitSiteEditor()` Co-authored-by: Infinite-Null Co-authored-by: t-hamano Co-authored-by: Mamaduka --- test/e2e/specs/site-editor/navigation.spec.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/e2e/specs/site-editor/navigation.spec.js b/test/e2e/specs/site-editor/navigation.spec.js index 18eb6c9904b449..2a886c2048f886 100644 --- a/test/e2e/specs/site-editor/navigation.spec.js +++ b/test/e2e/specs/site-editor/navigation.spec.js @@ -106,6 +106,23 @@ 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, + } ) => { + // Navigate to a non-existent template. + 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( + '.edit-site-layout__area .components-notice__content' + ) + ).toHaveText( + 'The requested page could not be found. Please check the URL.' + ); + } ); } ); class EditorNavigationUtils {