Skip to content

Commit

Permalink
E2E: Fix canvas waiter in visitSiteEditor (WordPress#61816)
Browse files Browse the repository at this point in the history
Co-authored-by: WunderBart <[email protected]>
Co-authored-by: ellatrix <[email protected]>
  • Loading branch information
3 people authored May 21, 2024
1 parent 9e28f24 commit 7e24ae4
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions packages/e2e-test-utils-playwright/src/admin/visit-site-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 ( ! 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.
'.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', {
Expand Down

0 comments on commit 7e24ae4

Please sign in to comment.