-
Notifications
You must be signed in to change notification settings - Fork 4.5k
Migrate keyboard-navigable-blocks e2e tests from puppeteer to playwright #54944
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
Conversation
Size Change: +177 B (0%) Total Size: 1.62 MB
ℹ️ View Unchanged
|
The tests pass and the code makes sense to me but I'll let someone with more experience approve. |
test/e2e/specs/editor/various/keyboard-navigable-blocks.spec.js
Outdated
Show resolved
Hide resolved
Thank you, @jeryj! Currently, the test produced ESLint warnings for We might want to refactor the test a bit to satisfy this rule or ignore it at the file level. P.S. If you have an ESLint add-on, then it makes really annoying viewing the test file 😅 How to test
Screenshot |
test/e2e/specs/editor/various/keyboard-navigable-blocks.spec.js
Outdated
Show resolved
Hide resolved
const ariaLabel = await this.page.evaluate( () => { | ||
const { activeElement } = | ||
document.activeElement.contentDocument ?? document; | ||
return ( | ||
activeElement.getAttribute( 'aria-label' ) || | ||
activeElement.innerText | ||
); | ||
} ); | ||
|
||
expect( ariaLabel ).toBe( label ); |
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.
Btw, the page.locator( ':focus' )
or editor.canvas.locator( ':focus' )
can be used for locating active elements.
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 tried refactoring this to use :focus
but couldn't get the tests to pass. The conditional of checking either the aria label or the innerText was getting in the way. If there was a toHaveAccessibleName()
check, that would be really useful, but I couldn't find a good way of doing 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.
Thank you, @jeryj. It makes sense.
- Disable expect/expect - Use :focus locator where possible
Thank you for the review, @Mamaduka! I've addressed the feedback as best I could. |
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.
Thanks for the followups, @jeryj!
What?
Migrating keyboard-navigable-blocks e2e tests from puppeteer to playwright
Why?
Part of the larger migration effort in #38851, also because I'm going to be modifying this test as part of #54513 and figured I may as well migrate it before making changes.
How?
Followed the migration guide.
Testing Instructions
npm run test:e2e:playwright -- editor/various/keyboard-navigable-blocks.spec.js