Migrate 'Meta boxes' e2e tests to Playwright#55915
Conversation
| // eslint-disable-next-line playwright/no-conditional-in-test | ||
| if ( | ||
| ( await excerptButton.getAttribute( 'aria-expanded' ) ) === 'false' | ||
| ) { | ||
| await excerptButton.click(); | ||
| } |
There was a problem hiding this comment.
Maybe we should turn off no-conditional-in-test ESLint rule. Most of the warnings I've seen in our test are false positives, as we need to check the state of panels/sidebars before trying to open them.
There was a problem hiding this comment.
+1 on this. I haven't seen a case yet where this rule would be helpful.
There was a problem hiding this comment.
One question though! 😄 Is the excerptButton state actually unknown (or random?) at this point? Why do we need to check whether it's expanded or not?
There was a problem hiding this comment.
The panel state (excerptButton state) is persisted for a user and is sometimes shared across the e2e test shards. This can result in flaky tests.
There was a problem hiding this comment.
Gotcha. Definitely something to have as a side note there, then! 🙏
Anyhow, I think we should avoid running parallel tests against the same instance since it makes them unpredictable (like this one) and thus unreliable. Do you think it would be possible to run separate instances or at least create separate admin accounts per shard? cc @kevin940726
There was a problem hiding this comment.
This is a known "quirk"; here's the previous discussion - #50851. Some of these details can be absorbed in editor helper utils, just like we do for openDocumentSettingsSidebar.
There was a problem hiding this comment.
Do you think it would be possible to run separate instances or at least create separate admin accounts per shard?
What do you mean by "shard" here? If you mean playwright's --shard then I believe we are testing a different WordPress instance each shard.
Ideally, I think we should aim for fully parallel testing if possible, but the very nature of WordPress makes it very difficult to do. That's also why we still can't enable parallel mode to speed up the tests. Another gotcha as mentioned in #50851 is that the resetPreferences() call doesn't seem very reliable in tests. Perhaps there's something wrong in the API side or we are doing something wrong elsewhere. I never have time to investigate it but I should 😅. The goal is to make every test as isolated and predictable as possible with a clean state, so that we don't have to do some of those conditionals for most cases.
A bit of side-note here is that I had a brief (like literally 3-sentence) discussions with @adamziel about whether we can leverage the architecture of wp-playground somehow to automatically generate a unique WordPress instance (or a clean DB) for each test. This is a much more challenging task though and might not even work for performance reason 😆.
There was a problem hiding this comment.
@kevin940726 it might actually be possible now and perhaps without too much effort. Playground now supports the bits that were missing earlier like proc_open(), system() etc. functions which were crucial for the PHPUnit test suite. Also, almost all core unit tests work with the SQLite integration plugin. I didn't yet try running PHPUnit for WP Core with the new version of https://www.npmjs.com/package/@php-wasm/node, but there's a high likelihood it would just work. Feel free to ping me if you decide to explore it.
|
Size Change: 0 B Total Size: 1.7 MB ℹ️ View Unchanged
|
There was a problem hiding this comment.
One potential candidate for a follow-up. Otherwise, 🚀!
|
|
||
| await expect( | ||
| page.locator( '.wp-block-latest-posts > li' ) | ||
| ).toContainText( [ 'A published post', 'Dynamic block test' ] ); |
There was a problem hiding this comment.
Hey, I noticed this causing a couple flaky tests today and grabbed a screenshot:
And here's a link to the test results: https://github.com/WordPress/gutenberg/actions/runs/6846766063/job/18613885820
It looks like the order of the text can be reversed in the post, but .toContainText enforces the exact order of the input array
There was a problem hiding this comment.
Thank you, @noahtallen! I'll have look shortly.

What?
Part of #38851.
PR migrates
meta-boxes.test.jse2e tests to Playwright.Why?
See #38851.
Testing Instructions