-
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
Migrate 'block-locking' to Playwright #41050
Conversation
Size Change: 0 B Total Size: 1.24 MB ℹ️ View Unchanged
|
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.
Looks good, thanks!
Thanks for the review, Nik 🙇 |
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.
Perfect! The only gotcha here is the case insensitive flag mentioned below. We can always iterate it in future PRs though 👍
Thanks a lot!
|
||
await editor.clickBlockOptionsMenuItem( 'Lock' ); | ||
|
||
await page.click( 'role=checkbox[name="Prevent removal"]' ); |
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.
Nit: Ideally, we normally want to add the i
flag to indicate case insensitive names:
-await page.click( 'role=checkbox[name="Prevent removal"]' );
+await page.click( 'role=checkbox[name="Prevent removal"i]' );
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 was wondering about the flag since I saw it in other tests. Most labels can be considered case insensitive, should we include this into migration or best practices docs?
I also ended up using .toBe()
instead of .toMatchInlineSnapshot()
. Is this also recommended way to test small pieces of content?
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.
Most labels can be considered case insensitive, should we include this into migration or best practices docs?
That would be nice! However, we're still using the unofficial role-selector created by me. After we switch to the official role selector when it becomes stable, we can just omit the "
to make it more ergonomic.
-await page.click( 'role=checkbox[name="Prevent removal"i]' );
+await page.click( 'role=checkbox[name=Prevent removal]' );
We can do this in one go though.
I also ended up using
.toBe()
instead of.toMatchInlineSnapshot()
. Is this also recommended way to test small pieces of content?
Yes, I don't think it's currently possible to use toMatchInlineSnapshot()
in playwright test runner. So we either have to use .toMatchSnapshot()
or just .toBe()
.
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.
After we switch to the official role selector when it becomes stable, we can just omit the " to make it more ergonomic.
I thought it became stable in v1.22.0.
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.
Oh awesome! Didn't catch that. I think we can migrate it to the official selector then :)
What?
Port of #38851.
Migrate Block Lockings e2e tests to Playwright
Why?
These are relatively new e2e tests, and I should've used Playwright from the beginning. I'm also planning to add more test cases, so I decided to migrate early.
How?
I followed migration steps - https://github.com/WordPress/gutenberg/blob/trunk/test/e2e/MIGRATION.md.
Testing Instructions