Skip to content

Commit

Permalink
E2E: Fix canvas waiter in visitSiteEditor (#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' } );

This comment has been minimized.

Copy link
@youknowriad

youknowriad May 28, 2024

Contributor

What if the loader never appears?

E2E tests are failing for me in this PR #61579 in this line and I'm wondering why, I can't reproduce locally.

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

1 comment on commit 7e24ae4

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Flaky tests detected in 7e24ae4.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/9176666002
📝 Reported issues:

Please sign in to comment.