-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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 performance tests by making inserter search container waiting optional #46268
Conversation
Size Change: +23 B (0%) Total Size: 1.33 MB
ℹ️ View Unchanged
|
@@ -103,7 +103,13 @@ async function waitForInserterCloseAndContentFocus() { | |||
* Wait for the inserter search to yield results because that input is debounced. | |||
*/ | |||
async function waitForInserterSearch() { | |||
await page.waitForSelector( '.block-editor-inserter__no-tab-container' ); | |||
try { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Potentially we could use Promise.any
and only wait like 2 seconds or so
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
True, we could. We could also reduce the timeout of waitForSelector()
to like 2 seconds, which should be more than enough. No need to wait for the full 30 seconds. Done in fc8f801
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a universal solution to this could be using the Page.waitForResponse
method. AFAIR, both previous and current Inserter versions use the /search
endpoint, so something like this should improve stability and require less maintenance at the same time:
async function waitForInserterSearch() {
return await page.waitForResponse( '/search' );
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be extra sure the response is not returned before the waitForInserterSearch
is called, I'd refactor a bit further and couple waitForRequest
with the term input so that we start waiting before the search request is triggered, for example:
async function inserterSearch( searchTerm ) {
return await Promise.all( [
page.waitForResponse( `/search?term=${ searchTerm }` ),
page.keyboard.type( searchTerm )
] );
}
Puppeteer doesn't seem to recommend this convention, but Playwright does. I think both implementations work the same way, so my recommendation would be going with the Playwright convention, also because we're currently migrating to it :)
Does that make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes a lot of sense! Thanks for offering a better alternative @WunderBart! Would you like to follow up with that, or should I give it a go?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a bunch, @WunderBart 🙌
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sharing an early WiP #46366 - did a bit more than planned, but it's mostly removing unnecessary waits and code duplication. Waiting for the test results now! 🤞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @WunderBart! Let me know when you feel it's ready for a look.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's basically ready, @tyxla. I'm still looking at the few tests that keep failing, but they don't seem to be related to the change, and they do pass for me locally. 🤔 I've just updated the branch with the current trunk, so hopefully it helps. 🤞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will keep an eye on it 👍
Performance tests are now passing in |
…g optional (WordPress#46268) * E2E: Fix performance tests by making inserter search container waiting optional * Set timeout to 2s
What?
In #46153 we broke the performance tests because we started waiting for a selector that doesn't exist in older versions. This PR fixes it by making that selector optional.
Why?
In older versions, this wrapper doesn't exist, nor is the inserter search debounced.
How?
We're still waiting for the selector, but catching the error if it's not found in order to continue with the e2e test execution.
Testing Instructions
Verify all e2e tests and performance tests still pass.