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: Fix canvas waiter in visitSiteEditor #61816

Merged
merged 2 commits into from
May 21, 2024
Merged

Conversation

WunderBart
Copy link
Member

@WunderBart WunderBart commented May 21, 2024

Reported in: #61629 (comment)
Related convo: https://wordpress.slack.com/archives/C02QB2JS7/p1716226087226579

What?

Fix the canvas loading bar waiter step so that it only applies when we open a page for editing, e.g., by passing the pageId param.

Why?

The current implementation adds 2 minutes to each performance test that visits the site editor's page that doesn't load the canvas, e.g., the All Templates view. It also does that for E2E tests, only there the actionTimeout is 5 seconds instead of 2 minutes, so we don't really notice that.

How?

By checking if the pageId or the canvas query params are present, so that we know the intent is to actually edit content.

Testing Instructions

All E2E tests should pass, and the total time of the performance tests should be reduced from ~50 to ~30 minutes.

Copy link
Member

@ellatrix ellatrix left a comment

Choose a reason for hiding this comment

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

Great, last run was again 34mins 👍

@WunderBart WunderBart force-pushed the fix/perf-tests-running-time branch from 3d36395 to 4adcee6 Compare May 21, 2024 12:17
@WunderBart
Copy link
Member Author

Retriggering the whole thing, something's off with the E2E runner (likely unrelated to this PR). 🤞

Copy link

Flaky tests detected in 4adcee6.
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/9174535670
📝 Reported issues:

@WunderBart WunderBart marked this pull request as ready for review May 21, 2024 14:41
Copy link

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: ellatrix <ellatrix@git.wordpress.org>

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

@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 21, 2024
@WunderBart WunderBart merged commit 7e24ae4 into trunk May 21, 2024
65 of 68 checks passed
@WunderBart WunderBart deleted the fix/perf-tests-running-time branch May 21, 2024 14:46
@github-actions github-actions bot added this to the Gutenberg 18.5 milestone May 21, 2024

// 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' } );
Copy link
Member

Choose a reason for hiding this comment

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

Just wondering: why did it previously pass the check for the existence of the canvas loader, and then continue on to never disappear?

Copy link
Member Author

Choose a reason for hiding this comment

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

It only passed the check because there was an empty catch for the scenarios in which the loader disappeared before the test reached that line. It was a premature optimization on my end – we didn't need it, and it only made things worse by swallowing the error that would prevent the original PR from being merged. 😅

// make it under the default timeout value.
timeout: 60_000,
} );
if ( ! query.size || postId || canvas === 'edit' ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this check is probably a bit fragile and not something that will stay consistent over time. A better check would be to check if the "preview area" exist in the DOM or something like that.

Copy link
Member Author

@WunderBart WunderBart May 23, 2024

Choose a reason for hiding this comment

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

I agree, although checking if something exists is what we had before this PR, and it didn't work well. We were checking whether the loader was there, and if not, we were swallowing the waitFor() promise error and continuing with the test. The downside of such a solution is that whenever the loader element is not there, we add the current actionTimeout value to the test (before the error is swallowed), which is 10s for E2E tests and 120s for perf tests. We could explicitly fix that timeout for that waitFor() call to, e.g., 5s, but it would still add 5s for no-loader situations and wouldn't guarantee stability.

IMO, the most stable solution for these situations is to use locator.or or parallel locator waits with Promise.any, which immediately returns the element first on the page. We need to know which element is there when the canvas is not there and vice-versa, though. For example:

await Promise.any([
  page.locator('.canvas-loader').waitFor(),
  page.locator('.some-panel-instead-of-canvas').waitFor(),
]);

I couldn't quickly trace an element like that when making this fix. Do you know any we could use here?

Copy link
Contributor

Choose a reason for hiding this comment

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

I can't think of a "or" condition that wouldn't break the expected behavior :P

carstingaxion pushed a commit to carstingaxion/gutenberg that referenced this pull request Jun 4, 2024
Co-authored-by: WunderBart <bartkalisz@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
patil-vipul pushed a commit to patil-vipul/gutenberg that referenced this pull request Jun 17, 2024
Co-authored-by: WunderBart <bartkalisz@git.wordpress.org>
Co-authored-by: ellatrix <ellatrix@git.wordpress.org>
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.
3 participants