-
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
Migrate change-detection
to Playwright
#58767
Conversation
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
|
||
await assertIsDirty( true ); | ||
|
||
expect( console ).toHaveErroredWith( |
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 left out in the migrated test since this is browser-dependent. I don't think it provides much value to the test.
expect( | ||
isCurrentURL( | ||
'/wp-admin/edit.php', | ||
`post_type=post&ids=${ postId }` |
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 actually wrong. isCurrentURL
only returns false when the url is not a WP url, it doesn't check the query params for some reason. The final url also doesn't include the ids=${postId}
part either.
Size Change: 0 B Total Size: 1.71 MB ℹ️ View Unchanged
|
const hasDialog = new Promise( ( resolve ) => { | ||
this.#page.on( 'dialog', ( dialog ) => { | ||
void dialog.accept(); | ||
resolve( true ); | ||
} ); | ||
this.#page.on( 'load', () => resolve( false ) ); | ||
} ); | ||
await this.#page.reload( { waitUntil: 'commit' } ); // No need to wait for the full load. | ||
return hasDialog; |
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 very interesting. Based on docs, PW only handles beforeunload
dialogs when calling page.close({ runBeforeUnload: true })
. They aren't run on page.reload
, so I'm really curious how this assertion is working 😅
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 couldn't find the part where the doc is referencing that though. I think the doc means that it won't wait for the beforeunload
dialogs unless runBeforeUnload
is true. But that's just for page.close()
. beforeunload
dialogs should still be available in the event handler, but since we don't care whether Playwright waits for the dialog to be closed or not, I think this is fine?
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.
Here's the link - https://playwright.dev/docs/dialogs#beforeunload-dialog. You're right; this doc probably refers to page leave context.
I think this is fine?
As long as assertions work, it's golden 😄
Seems like the unit tests for PHP are failing for a known issue in core. |
8372766
to
a05a995
Compare
( url ) => | ||
POST_URLS.some( ( postUrl ) => url.href.includes( postUrl ) ), |
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.
await expect( | ||
page | ||
.getByRole( 'region', { name: 'Editor top bar' } ) | ||
.getByRole( 'button', { name: 'Save draft' } ) | ||
).toBeEnabled(); |
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.
The button isn't restored when making changes in flight. I'm not sure if this is a regression. The behavior can be reproduced manually by throttling the network via DevTools.
I've made a few minor changes/fixes. The migration looks good to land, IMO. @WunderBart, if you have time. Do you mind providing a second opinion and ✅? |
Flaky tests detected in a23241e. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/7840952010
|
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 merge this. I can do a follow-up if any test is marked as flaky.
* trunk: (273 commits) Remove preffered style variations legacy support (#58930) Style theme variations: add property extraction and merge utils (#58803) Migrate `change-detection` to Playwright (#58767) Update Changelog for 17.6.6 Docs: Clarify the status of the wp-block-styles theme support, and its intent (#58915) Use `data_wp_context` helper in core blocks and remove `data-wp-interactive` object (#58943) Try double enter for details block. (#58903) Template revisions API: move from experimental to compat/6.4 (#58920) Editor: Remove inline toolbar preference (#58945) Clean up link control CSS. (#58934) Font Library: Show error message when no fonts found to install (#58914) Block Bindings: lock editing of blocks by default (#58787) Editor: Remove the 'all' rendering mode (#58935) Pagination Numbers: Add `data-wp-key` to pagination numbers if enhanced pagination is enabled (#58189) Close link preview if collapsed selection when creating link (#58896) Fix incorrect useAnchor positioning when switching from virtual to rich text elements (#58900) Upgrade Floating UI packages, fix nested iframe positioning bug (#58932) Site editor: fix start patterns store selector (#58813) Revert "Rich text: pad multiple spaces through en/em replacement (#56341)" (#58792) Documentation: Clarify the performance reference commit and how to pick it (#58927) ...
What?
Part of #38851.
PR migrates
change-detection.test.js
e2e tests to Playwright.Why?
See #38851.
Testing Instructions