-
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
Template part e2e fix: try and force waiting for button xpath #33169
Conversation
Size Change: 0 B Total Size: 1.05 MB ℹ️ View Unchanged
|
Hi, @getdave How can I help to get this test fixed? I've seen this a few more a lot in the last couple of days. |
This might be a good candidate for using |
@Mamaduka So what I think is happening is that when the placeholder for Template Part first loads the This process means the selector required to click that button changes. I wonder whether because we're selecting the button by XPath Pupeteer has some internal resolution system which caches the selector as This is largely hypothetical and there could be a simpler explanation. Another option might be to try using a hardcoded testID on the target button and see if that improves the reliability fo the test in the short term with a view to returning and using a more resilient selector in the future. This is a hard one because I cannot replicate locally and even on CI it's sometimes passing. |
@@ -100,10 +100,13 @@ describe( 'Multi-entity save flow', () => { | |||
|
|||
// Add a template part and edit it. | |||
await insertBlock( 'Template Part' ); | |||
|
|||
await page.waitForXPath( createNewButtonSelector ); | |||
const [ createNewButton ] = await page.$x( | |||
createNewButtonSelector |
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.
Let's try updating this selector to use a hardcoded test id or something. If that improves stability then we know my theory is might be correct.
@getdave, you're right. The Puppeteer might be holding a different kind of reference internally for that button. Here's a screencast simulating button switching via Network throttling: CleanShot.2021-07-08.at.14.04.52.mp4 |
Yes that's the only thing I can think...currently occupied with debugging perf tests for 11.0.0 but will look after that is resolved. Feel free to dig in or take over though 😄 |
From the screencast above, I think the reason is because of layout shifting. So the way puppeteer's
All of the above are asynchronous and independent, so if layout shifting is happening between 2 and 3, it will click on the wrong element. I think the solution isn't to solve it in test, but rather to fix it in our code. Whatever puppeteer is experiencing is likely to happen on users too. A solution would be to delay showing the buttons until all requests are resolved, eliminating the intermediate result. Instead, just show a spinner when it's loading, just like how other blocks work. I'm not familiar with template parts blocks though, so no idea if there're any other aspects that I'm not aware of. |
Aha. Thanks for that knowledge. I had thought the click was triggered programmatically not like a user click. This is solvable now as you suggest. |
Fix made elsewhere based on findings here. Closing. |
Description
This e2e test keeps failing
Looking at the failure artifacts it looks like we've clicked the wrong button and activated the "Choose existing" button.
This is because
*[data-type="core/template-part"].block-editor-block-list__layout
will only exist once we've click theNew template part
button.The test selects the "New template part" button by xpath and that resolves to a DOM node with class variant
primary
. However the button variant is set to change totertiary
as soon as the "Choose existing" button is rendered. I wonder if this causes the test to click the wrong button?This PR tries to force waiting for the xpath before clicking. We'll see...
How has this been tested?
Screenshots
Types of changes
Checklist:
*.native.js
files for terms that need renaming or removal).