Directory

E2E: Ensure SE canvas loader appears before waiting for it to disappear by WunderBart · Pull Request #61629 · WordPress/gutenberg · GitHub
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

E2E: Ensure SE canvas loader appears before waiting for it to disappear #61629

Merged
merged 1 commit into from
May 14, 2024

Conversation

WunderBart
Copy link
Member

@WunderBart WunderBart commented May 13, 2024

What?

When the Site Editor takes longer to load (e.g., due to large canvas content), the visitSiteEditor promise resolves prematurely as it incorrectly assumes the canvas loader has already disappeared. In reality, it hasn't even appeared yet. It can lead to, e.g., subsequent locator assertions timing out as their 10s timeout gets eaten up by the canvas loading time. This PR fixes that by attempting to wait for the loader element immediately after the page is loaded so that we can reliably wait for it to disappear.

Failure example: trace.zip (from WooCommerce Blocks)

Testing Instructions

All tests should pass.

@WunderBart WunderBart changed the title E2E: Make sure the canvas loader appears before waiting for it to disappear E2E: Ensure canvas loader appears before waiting for it to disappear May 13, 2024
@WunderBart WunderBart changed the title E2E: Ensure canvas loader appears before waiting for it to disappear E2E: Ensure SE canvas loader appears before waiting for it to disappear May 13, 2024
Copy link

Flaky tests detected in cda9613.
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/9065822238
📝 Reported issues:

@WunderBart WunderBart self-assigned this May 14, 2024
@WunderBart WunderBart added [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests. [Package] E2E Test Utils /packages/e2e-test-utils labels May 14, 2024
@WunderBart WunderBart marked this pull request as ready for review May 14, 2024 09:45
Copy link

github-actions bot commented May 14, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: WunderBart <bartkalisz@git.wordpress.org>
Co-authored-by: Mamaduka <mamaduka@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

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( () => {} );
Copy link
Member

Choose a reason for hiding this comment

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

What's the error we're expecting to catch here?

Copy link
Member Author

Choose a reason for hiding this comment

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

In an unlikely case where the loader has already disappeared by the time we get to this line, it shouldn't fail the test – the action should continue executing. TBH, it hasn't happened to me so far, but it is possible so I think it's worth having this extra precaution as it doesn't really hurt us. Does that make sense?

Copy link
Member

Choose a reason for hiding this comment

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

Makes sense

Copy link
Member

Choose a reason for hiding this comment

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

@ellatrix, I think this line is the cause of regression. Now, each Site Editor > Navigation test takes around 2 minutes to run locally, instead of 5 seconds when I comment out this line. Running the tests in UI Mode gives a better breakdown of locator timers.

@WunderBart, I also realized that the util expects every site editor page it visits to have a canvasLoader, which isn't true. The DataView routes have no loaders for the moment.

Copy link
Member Author

Choose a reason for hiding this comment

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

For reference: #61816

Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

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

Works for me 👍

@WunderBart WunderBart merged commit d301cf7 into trunk May 14, 2024
74 of 76 checks passed
@WunderBart WunderBart deleted the fix/e2e-visit-site-editor-canvas-loading-waiter branch May 14, 2024 12:09
@ellatrix
Copy link
Member

ellatrix commented May 20, 2024

Looks like this increased e2e tests times by quite a bit! The performance test increased by ~20 mins. Parent commit finished in 34 mins, while this one finished in 54 mins.

// 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,
Copy link
Member

Choose a reason for hiding this comment

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

What is 60_000? Is this a typo?

Copy link
Member

Choose a reason for hiding this comment

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

It is called a numeric separator that helps readability.

Copy link
Member

Choose a reason for hiding this comment

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

Lol, how is this the first time I hear about this after all these years 🫠

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] E2E Test Utils /packages/e2e-test-utils [Type] Automated Testing Testing infrastructure changes impacting the execution of end-to-end (E2E) and/or unit tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants