From 5d7b39f12c419fb54c62a1188f10040fdd25139e Mon Sep 17 00:00:00 2001 From: Bart Kalisz Date: Tue, 21 May 2024 11:51:43 +0200 Subject: [PATCH 1/2] Ensure we're on a page where canvas is present --- .../src/admin/visit-site-editor.ts | 35 ++++++++++--------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/packages/e2e-test-utils-playwright/src/admin/visit-site-editor.ts b/packages/e2e-test-utils-playwright/src/admin/visit-site-editor.ts index 0c9da7b695be0..da77bad79c90e 100644 --- a/packages/e2e-test-utils-playwright/src/admin/visit-site-editor.ts +++ b/packages/e2e-test-utils-playwright/src/admin/visit-site-editor.ts @@ -37,31 +37,32 @@ export async function visitSiteEditor( query.set( 'canvas', canvas ); } - const canvasLoader = this.page.locator( - // Spinner was used instead of the progress bar in an earlier version of - // the site editor. - '.edit-site-canvas-loader, .edit-site-canvas-spinner' - ); - await this.visitAdminPage( 'site-editor.php', query.toString() ); - // Try waiting for the canvas loader to appear first, so that the locator - // that waits for it to disappear doesn't resolve prematurely. - await canvasLoader.waitFor().catch( () => {} ); - /** * @todo This is a workaround for the fact that the editor canvas is seen as * ready and visible before the loading spinner is hidden. Ideally, the * content underneath the loading overlay should be marked inert until the * loading is done. */ - await canvasLoader.waitFor( { - state: 'hidden', - // Bigger timeout is needed for larger entities, like the Large Post - // HTML fixture that we load for performance tests, which often doesn't - // make it under the default timeout value. - timeout: 60_000, - } ); + if ( postId || canvas === 'edit' ) { + const canvasLoader = this.page.locator( + // Spinner was used instead of the progress bar in an earlier + // version of the site editor. + '.edit-site-canvas-loader, .edit-site-canvas-spinner' + ); + + // Wait for the canvas loader to appear first, so that the locator that + // waits for the hidden state doesn't resolve prematurely. + await canvasLoader.waitFor( { state: 'visible' } ); + await canvasLoader.waitFor( { + state: 'hidden', + // Bigger timeout is needed for larger entities, like the Large Post + // HTML fixture that we load for performance tests, which often + // doesn't make it under the default timeout value. + timeout: 60_000, + } ); + } if ( ! options.showWelcomeGuide ) { await this.editor.setPreferences( 'core/edit-site', { From 4adcee65c14ee47521bf8fe355870f4fb27a72d9 Mon Sep 17 00:00:00 2001 From: Bart Kalisz Date: Tue, 21 May 2024 13:23:27 +0200 Subject: [PATCH 2/2] Account for a plain site editor visit --- .../e2e-test-utils-playwright/src/admin/visit-site-editor.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/e2e-test-utils-playwright/src/admin/visit-site-editor.ts b/packages/e2e-test-utils-playwright/src/admin/visit-site-editor.ts index da77bad79c90e..f0a7db5ad966f 100644 --- a/packages/e2e-test-utils-playwright/src/admin/visit-site-editor.ts +++ b/packages/e2e-test-utils-playwright/src/admin/visit-site-editor.ts @@ -45,7 +45,7 @@ export async function visitSiteEditor( * content underneath the loading overlay should be marked inert until the * loading is done. */ - if ( postId || canvas === 'edit' ) { + if ( ! query.size || postId || canvas === 'edit' ) { const canvasLoader = this.page.locator( // Spinner was used instead of the progress bar in an earlier // version of the site editor.