Block Comments: Add a11y related e2e tests#72103
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 expect( thread ).toBeFocused(); | ||
| } ); | ||
|
|
||
| test( 'should have accessible name for the comment threads', async ( { |
There was a problem hiding this comment.
When a comment thread is focused, screen readers should read an excerpt of the comment.
Should have the same results as the mentioned test.
| const thread = page | ||
| .getByRole( 'region', { name: 'Editor settings' } ) | ||
| .getByRole( 'listitem', { | ||
| name: 'Comment: Test comment to resolve.', | ||
| } ); | ||
| await thread.click(); | ||
| await expect( thread ).toHaveAttribute( 'aria-expanded', 'true' ); |
There was a problem hiding this comment.
Covers - "Pressing the Resolve Comment button should close the comment and focus it.".
| const threadsContainer = page | ||
| .getByRole( 'region', { | ||
| name: 'Editor settings', | ||
| } ) | ||
| .getByRole( 'list' ); | ||
| const threads = threadsContainer.getByRole( 'listitem' ); | ||
| const activeThread = threadsContainer.locator( '.is-selected' ); |
There was a problem hiding this comment.
Just a minor improvement to existing locators.
P.S. Using the getByRole( 'listitem', { expanded: true ) throws an error in Playwright, saying that listitem doesn't support this attribute/query.
|
Size Change: 0 B Total Size: 1.96 MB ℹ️ View Unchanged
|
|
Flaky tests detected in 99750e0. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/18281469769
|
6531f9e to
99750e0
Compare
| ); | ||
| } ); | ||
|
|
||
| test( 'should expand and focus the thread after clicking the "x more replies" button', async ( { |
t-hamano
left a comment
There was a problem hiding this comment.
LGTM! Everything works as expected.
P.S. Using the
getByRole( 'listitem', { expanded: true )throws an error in Playwright, saying thatlistitemdoesn't support this attribute/query.
Assigning the list-item role to expandable element may not be WAI-ARIA compliant:
<div role="list">
<div tabindex="0" role="listitem" aria-expanded="true" class="editor-collab-sidebar-panel__thread is-selected"></div>
<div tabindex="0" role="listitem" aria-expanded="false" class="editor-collab-sidebar-panel__thread"></div>
</div>Perhaps the treeitem role would be better suited for interactive items:
<div role="tree">
<div tabindex="0" role="treeitem" aria-expanded="true" class="editor-collab-sidebar-panel__thread is-selected"></div>
<div tabindex="0" role="treeitem" aria-expanded="false" class="editor-collab-sidebar-panel__thread"></div>
</div>
With the treeitem role, expanded attribute queries should be available in Playwright. Let's consider fixing this in a follow-up if necessary. cc @joedolson
What?
Closes #71962.
PRs add more e2e tests for the Block Comments feature to cover a11y-related improvements.
Testing Instructions
Testing Instructions for Keyboard
Same.