Repository navigation
Read live region messages without article and group role words #5921
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
Draft
Eugene (OEvgeny)
wants to merge
5
commits into
main
Choose a base branch
from
OEvgeny/fix-liveregion-generic-wrappers
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
9084d3b
Use generic containers instead of articles in the live region
a3ba84e
Use InferReactProps for live region props
f897f5e
Hide line containers in the live region from the accessibility tree
e6598ae
Add PR number to changelog
a8e461a
Show the live region copy in the no role words snapshot
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
117 changes: 117 additions & 0 deletions
117
__tests__/html2/accessibility/liveRegion/noRoleWords.html
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| <!doctype html> | ||
| <html lang="en-US"> | ||
| <head> | ||
| <link href="/assets/index.css" rel="stylesheet" type="text/css" /> | ||
| <!-- Shows the live region, so the snapshot shows the copy sent to screen readers. --> | ||
| <link href="/assets/accessibility.liveRegionAttachment.css" rel="stylesheet" type="text/css" /> | ||
| <script crossorigin="anonymous" src="/test-harness.js"></script> | ||
| <script crossorigin="anonymous" src="/test-page-object.js"></script> | ||
| <script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script> | ||
| </head> | ||
| <body> | ||
| <main id="webchat"></main> | ||
| <script type="importmap"> | ||
| { | ||
| "imports": { | ||
| "@testduet/wait-for": "https://esm.sh/@testduet/wait-for" | ||
| } | ||
| } | ||
| </script> | ||
| <script type="module"> | ||
| import { waitFor } from '@testduet/wait-for'; | ||
|
|
||
| run(async function () { | ||
| const { directLine, store } = testHelpers.createDirectLineEmulator(); | ||
|
|
||
| // GIVEN: Web Chat keeps the live region copy of new messages, so it can be seen in the snapshot. | ||
| WebChat.renderWebChat( | ||
| { | ||
| directLine, | ||
| store, | ||
| styleOptions: { botAvatarInitials: 'WC', hideSendBox: true, internalLiveRegionFadeAfter: 60000 } | ||
| }, | ||
| document.getElementById('webchat') | ||
| ); | ||
|
|
||
| await pageConditions.uiConnected(); | ||
|
|
||
| // WHEN: Bot sends a message with an Adaptive Card, a hero card, a file, and a suggested action. | ||
| await directLine.emulateIncomingActivity({ | ||
| attachments: [ | ||
| { | ||
| content: { | ||
| actions: [{ title: 'OK', type: 'Action.Submit' }], | ||
| body: [{ text: 'Card 1', type: 'TextBlock' }], | ||
| speak: 'Card 1', | ||
| type: 'AdaptiveCard', | ||
| version: '1.3' | ||
| }, | ||
| contentType: 'application/vnd.microsoft.card.adaptive' | ||
| }, | ||
| { | ||
| content: { buttons: [{ title: 'Go', type: 'imBack', value: 'go' }], text: 'Hero text', title: 'Card 2' }, | ||
| contentType: 'application/vnd.microsoft.card.hero' | ||
| }, | ||
| { contentType: 'application/octet-stream', name: 'report.zip' } | ||
| ], | ||
| from: { role: 'bot' }, | ||
| suggestedActions: { actions: [{ title: 'Help', type: 'imBack', value: 'help' }] }, | ||
| text: 'Here are 2 cards and a file.', | ||
| type: 'message' | ||
| }); | ||
|
|
||
| await pageConditions.numActivitiesShown(1); | ||
|
|
||
| const liveRegionActivity = await waitFor(() => { | ||
| const element = pageElements.liveRegion().querySelector('.webchat__live-region-activity'); | ||
|
|
||
| expect(element).toBeTruthy(); | ||
|
|
||
| return element; | ||
| }); | ||
|
|
||
| // THEN: The live region should contain the text of the message, the suggested action, the cards, and the file. | ||
| expect(liveRegionActivity.innerText).toBe( | ||
| [ | ||
| 'Bot WC said:', | ||
| 'Here are 2 cards and a file.', | ||
| '', // The suggested actions are in a `<p>`, `innerText` puts a blank line around it. | ||
| 'Help', | ||
| '', | ||
| 'A card: Card 1', | ||
| 'OK', | ||
| 'A card: Card 2 Hero text', | ||
| 'Go', | ||
| 'A file: report.zip' | ||
| ].join('\n') | ||
| ); | ||
|
|
||
| // THEN: The message should still be announced as a whole. | ||
| expect(liveRegionActivity.getAttribute('aria-atomic')).toBe('true'); | ||
|
|
||
| const accessibilityNodes = await Promise.all( | ||
| [liveRegionActivity, ...liveRegionActivity.querySelectorAll('*')].map(element => | ||
| testHelpers.getAccessibilityNode(element) | ||
| ) | ||
| ); | ||
|
|
||
| // THEN: The message should be a generic container, not an article, screen readers would read "article" before it. | ||
| expect(accessibilityNodes[0].role?.value).toBe('generic'); | ||
|
|
||
| // THEN: Inside the message, only the copies of the buttons should be in the accessibility tree, besides the text. | ||
| // On Windows, every other element is a "group" (including generic `<div>` and `<p>`), screen readers would read "group" before each line. | ||
| expect( | ||
| accessibilityNodes | ||
| .slice(1) // The message itself keeps `aria-atomic`, which requires an element in the accessibility tree. | ||
| .filter(({ ignored }) => !ignored) | ||
| .map(({ name, role }) => `${role?.value} "${name?.value}"`) | ||
| ).toEqual(['button "Help"', 'button "OK"', 'button "Go"']); | ||
|
|
||
| await pageConditions.liveRegionStabilized(); | ||
|
|
||
| // THEN: The live region (top) shows the message, "Help", "A card: Card 1", "OK", "A card: Card 2 Hero text", "Go" and "A file: report.zip", with no role words such as "article" or "group". | ||
| await host.snapshot('local'); | ||
| }); | ||
| </script> | ||
| </body> | ||
| </html> | ||
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
TODO: add snapshots with the live region visualized via a CSS provided in the tests instrumentation