From 4085555f8acb3d827539507810ebfc7d1f6d76f1 Mon Sep 17 00:00:00 2001 From: Aki Hamano <54422211+t-hamano@users.noreply.github.com> Date: Wed, 15 Jan 2025 18:35:58 +0900 Subject: [PATCH] Fix flaky navigation-frontend-interactivity e2e tests (#68667) Co-authored-by: t-hamano Co-authored-by: Mamaduka --- .../src/admin/visit-site-editor.ts | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 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 1e79a30306e4c7..bc6e3e23d078b5 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 @@ -61,15 +61,22 @@ export async function visitSiteEditor( '.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', timeout: 60_000 } ); - 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, - } ); + try { + // 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', timeout: 60_000 } ); + 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, + } ); + } catch ( error ) { + // If the canvas loader is already disappeared, skip the waiting. + await this.page + .getByRole( 'region', { name: 'Editor content' } ) + .waitFor(); + } } }