-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Navigation Editor e2e tests: migrate from response mocking to rest api util #34869
Navigation Editor e2e tests: migrate from response mocking to rest api util #34869
Conversation
Size Change: +83 B (0%) Total Size: 1.06 MB
ℹ️ View Unchanged
|
ee5986f
to
2ebccfa
Compare
The "Menu name editor" tests fail for me when testing locally—investigating the reason of the failure. |
const snackbar = await page.waitForSelector( | ||
'.components-snackbar' |
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.
This is the selector that causes failure locally for me.
How reliable is this method for checking if the Menu is saved? I remember Widgets had flaky tests because of the Snackbars, but this might not be related.
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.
Yep, unusual, I'm not sure why since it passes with the --puppeteer-interactive
flag.
Anyhow, I changed it to this
const snackbar = await page.waitForSelector(
'.components-snackbar',
{ visible: true }
);
and it makes it work again.
I'm aware of some other bugs in puppeteer
related to waitForSelector
, and using visible: true
forces puppeteer to use a different waiting strategy (MutationObserver
is the default, visible
changes the strategy to polling), so it must be something related to that.
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.
and using visible: true forces puppeteer to use a different waiting strategy
I wasn't aware of this. Thanks for the information.
Looks good on the surface, happy to give it a deeper look on Monday |
Hi, @talldan Unfortunately, I'm still getting the same error when running locally. But it might be the issue on my end, so let's wait for others to run tests and approve. I think we should also rebase updates tests on the latest trunk. The screen is in active development means that things can diverge much faster. We accidentally introduced failing e2e tests because of this last week #34874. |
08c7b4c
to
2d3932b
Compare
I remember that @kevin940726 worked on a similar fix for the Widgets Screen e2e tests. Maybe he has some suggestions. |
I couldn't reproduce that failure locally. If it only happens sometimes, that sounds related to timing. If you can reproduce it every time, it could maybe be related to a WordPress version or a specific message logged by Chrome. E.g. maybe we could let go of matching the exact error string somehow?
Other than that, this PR looks good and I'm okay with skipping the test for now as long as it doesn't stay disabled. |
Description
Fixes #34765 (near enough)
This was a lot more difficult than I anticipated. The tough thing with menu items is that they usually link to other resources (pages, posts, categories), and those need to be created before the menu items so that we have valid ids and urls for the menu items. Otherwise the menu items are considered invalid.
Menu items also require two batch requests, once to create the items initially, and then once we have the ids a second request to set the correct
parent
s using those ids.The last thing is that now we're using the REST API, the ids and urls of items are unstable, they change between test runs, so can no longer be used in snapshots. I wrote a function to go through block attributes and ensure the value of those attributes is not stored in the snapshot (the type of the value is used instead).
What I haven't done (in the interested of not making this PR huge):