-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Screen reader: support "do primary action" (#4041)
* Screen reader: support "do primary action" * Don't render suggested actions container initially * Add entry * Add tests * Refactor * Add snapshots * Add test * Update entry * Clean up * Update for NVDA * Clean up * Clean up * Add tests * Fix tests * Remove workaround for NVDA 2020.2 * Temporary disable internal HTTP tests * Prepare to re-lit test
- Loading branch information
Showing
25 changed files
with
455 additions
and
75 deletions.
There are no files selected for viewing
This file contains 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
Binary file modified
BIN
-944 Bytes
(98%)
...tachments-in-live-region-should-narrate-speak-property-adaptive-card-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-959 Bytes
(97%)
...nt-file-js-accessibility-requirement-attachments-in-live-region-file-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-962 Bytes
(98%)
...rd-js-accessibility-requirement-attachments-in-live-region-hero-card-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-994 Bytes
(97%)
...js-accessibility-requirement-attachments-in-live-region-sign-in-card-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+28.4 KB
...igation-should-focus-inside-the-attachment-when-enter-key-is-pressed-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+28.4 KB
...browse-mode-should-focus-inside-the-attachment-when-enter-is-pressed-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+28.4 KB
...ould-focus-inside-the-attachment-when-do-primary-action-is-performed-1-snap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
101 changes: 101 additions & 0 deletions
101
__tests__/html/accessibility.usability.suggestedActions.hideOnInitial.html
This file contains 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,101 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-US"> | ||
<head> | ||
<link href="/assets/index.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> | ||
<div id="webchat"></div> | ||
<script> | ||
// (Related to #4021) | ||
run(async function () { | ||
const directLine = await testHelpers.createDirectLineWithTranscript(); | ||
|
||
WebChat.renderWebChat( | ||
{ | ||
directLine, | ||
store: testHelpers.createStore() | ||
}, | ||
document.getElementById('webchat') | ||
); | ||
|
||
// GIVEN: Web Chat is loaded initially. | ||
await pageConditions.uiConnected(); | ||
|
||
// WHEN: No suggested actions were shown before. | ||
await pageConditions.numActivitiesShown(0); | ||
|
||
// THEN: Suggested actions container should not be rendered, or not to render "empty" alt text. | ||
expect( | ||
~(document.querySelector('.webchat__suggested-actions')?.innerText || '').indexOf( | ||
'Suggested Actions Container: Is empty' | ||
) | ||
).toBeFalsy(); | ||
|
||
// GIVEN: Suggested actions is shown. | ||
directLine.activityDeferredObservable.next({ | ||
from: { | ||
role: 'bot' | ||
}, | ||
suggestedActions: { | ||
actions: [ | ||
{ | ||
title: 'Coffee', | ||
type: 'imBack', | ||
value: 'I like coffee.' | ||
}, | ||
{ | ||
title: 'Milk', | ||
type: 'imBack', | ||
value: 'I like milk.' | ||
}, | ||
{ | ||
title: 'Orange juice', | ||
type: 'imBack', | ||
value: 'I like orange juice.' | ||
}, | ||
{ | ||
title: 'Tea', | ||
type: 'imBack', | ||
value: 'I like tea.' | ||
} | ||
], | ||
to: [] | ||
}, | ||
text: 'What drink is best?', | ||
type: 'message' | ||
}); | ||
|
||
await pageConditions.numActivitiesShown(1); | ||
await pageConditions.suggestedActionsShown(); | ||
|
||
expect( | ||
~document | ||
.querySelector('.webchat__suggested-actions') | ||
.innerText.indexOf('Suggested Actions Container: Has content.') | ||
).toBeTruthy(); | ||
|
||
// WHEN: After a suggested action is selected and sent to the bot. | ||
await host.click(pageElements.suggestedActions()[1]); | ||
|
||
await pageConditions.numActivitiesShown(2); | ||
await pageConditions.became( | ||
'no suggested actions are shown', | ||
() => !pageElements.suggestedActions().length, | ||
1000 | ||
); | ||
|
||
// THEN: Suggested actions container should be rendered with alt text "Suggested Actions Container: Is empty". | ||
expect( | ||
~document | ||
.querySelector('.webchat__suggested-actions') | ||
.innerText.indexOf('Suggested Actions Container: Is empty') | ||
).toBeTruthy(); | ||
|
||
// We are not taking snapshot in this test because snapshot cannot show the alt text. | ||
}); | ||
</script> | ||
</body> | ||
</html> |
6 changes: 6 additions & 0 deletions
6
__tests__/html/accessibility.usability.suggestedActions.hideOnInitial.js
This file contains 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,6 @@ | ||
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */ | ||
|
||
describe('accessibility usability', () => { | ||
test('should not render suggested actions container at initial', () => | ||
runHTML('accessibility.usability.suggestedActions.hideOnInitial.html')); | ||
}); |
59 changes: 59 additions & 0 deletions
59
__tests__/html/transcript.navigation.focusAttachment.enterKey.html
This file contains 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,59 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-US"> | ||
<head> | ||
<link href="/assets/index.css" rel="stylesheet" type="text/css" /> | ||
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react.production.min.js"></script> | ||
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react-dom.production.min.js"></script> | ||
<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> | ||
<script | ||
crossorigin="anonymous" | ||
src="https://unpkg.com/[email protected]/umd/react-dom-test-utils.production.min.js" | ||
></script> | ||
</head> | ||
<body> | ||
<div id="webchat"></div> | ||
<script> | ||
run(async function () { | ||
WebChat.renderWebChat( | ||
{ | ||
directLine: WebChat.createDirectLine({ token: await testHelpers.token.fetchDirectLineToken() }), | ||
store: testHelpers.createStore() | ||
}, | ||
document.getElementById('webchat') | ||
); | ||
|
||
// GIVEN: An "input" card is shown and the focus is on the transcript and the card input activity. | ||
await pageConditions.uiConnected(); | ||
await pageObjects.sendMessageViaSendBox('card inputs'); | ||
await pageConditions.numActivitiesShown(2); | ||
await pageConditions.scrollStabilized(); | ||
await pageConditions.became( | ||
'focus is on the send box', | ||
() => document.activeElement === pageElements.sendBoxTextBox(), | ||
1000 | ||
); | ||
await host.sendShiftTab(3); | ||
await pageConditions.became( | ||
'focus is on the input card', | ||
() => pageElements.focusedActivity() === pageElements.activities()[1], | ||
1000 | ||
); | ||
await pageConditions.scrollStabilized(); | ||
|
||
// WHEN: ENTER key is pressed. | ||
await host.sendKeys('ENTER'); | ||
|
||
// THEN: The first text box in the input card should be focused. | ||
await pageConditions.became( | ||
'focus is on the first text box in the input card', | ||
() => document.activeElement === document.querySelector('.ac-input ,ac-textInput'), | ||
1000 | ||
); | ||
|
||
await host.snapshot(); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
5 changes: 5 additions & 0 deletions
5
__tests__/html/transcript.navigation.focusAttachment.enterKey.js
This file contains 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,5 @@ | ||
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */ | ||
|
||
describe('transcript navigation', () => { | ||
test('should focus inside the attachment when ENTER key is pressed', () => runHTML('transcript.navigation.focusAttachment.enterKey')); | ||
}); |
60 changes: 60 additions & 0 deletions
60
__tests__/html/transcript.navigation.focusAttachment.screenReaderPrimaryAction.nvda.html
This file contains 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,60 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-US"> | ||
<head> | ||
<link href="/assets/index.css" rel="stylesheet" type="text/css" /> | ||
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react.production.min.js"></script> | ||
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react-dom.production.min.js"></script> | ||
<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> | ||
<script | ||
crossorigin="anonymous" | ||
src="https://unpkg.com/[email protected]/umd/react-dom-test-utils.production.min.js" | ||
></script> | ||
</head> | ||
<body> | ||
<div id="webchat"></div> | ||
<script> | ||
run(async function () { | ||
WebChat.renderWebChat( | ||
{ | ||
directLine: WebChat.createDirectLine({ token: await testHelpers.token.fetchDirectLineToken() }), | ||
store: testHelpers.createStore() | ||
}, | ||
document.getElementById('webchat') | ||
); | ||
|
||
// GIVEN: An "input" card is shown and the focus is on the transcript and the card input activity. | ||
await pageConditions.uiConnected(); | ||
await pageObjects.sendMessageViaSendBox('card inputs'); | ||
await pageConditions.numActivitiesShown(2); | ||
await pageConditions.scrollStabilized(); | ||
await pageConditions.became( | ||
'focus is on the send box', | ||
() => document.activeElement === pageElements.sendBoxTextBox(), | ||
1000 | ||
); | ||
await host.sendShiftTab(3); | ||
await pageConditions.became( | ||
'focus is on the input card', | ||
() => pageElements.focusedActivity() === pageElements.activities()[1], | ||
1000 | ||
); | ||
await pageConditions.scrollStabilized(); | ||
|
||
// WHEN: "click" event is fired, which mimic pressing ENTER key while NVDA is in browse mode. | ||
// Per React requirement, `ReactTestUtils` is required to fire artificial "click" event, instead of `createEvent`/`dispatchEvent`. | ||
ReactTestUtils.Simulate.click(pageElements.focusedActivity().querySelector('.webchat__screen-reader-activity :first-child')); | ||
|
||
// THEN: The first text box in the input card should be focused. | ||
await pageConditions.became( | ||
'focus is on the first text box in the input card', | ||
() => document.activeElement === document.querySelector('.ac-input ,ac-textInput'), | ||
1000 | ||
); | ||
|
||
await host.snapshot(); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
5 changes: 5 additions & 0 deletions
5
__tests__/html/transcript.navigation.focusAttachment.screenReaderPrimaryAction.nvda.js
This file contains 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,5 @@ | ||
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */ | ||
|
||
describe('transcript navigation with NVDA in browse mode', () => { | ||
test('should focus inside the attachment when ENTER is pressed', () => runHTML('transcript.navigation.focusAttachment.screenReaderPrimaryAction.nvda')); | ||
}); |
60 changes: 60 additions & 0 deletions
60
...html/transcript.navigation.focusAttachment.screenReaderPrimaryAction.windowsNarrator.html
This file contains 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,60 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-US"> | ||
<head> | ||
<link href="/assets/index.css" rel="stylesheet" type="text/css" /> | ||
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react.production.min.js"></script> | ||
<script crossorigin="anonymous" src="https://unpkg.com/[email protected]/umd/react-dom.production.min.js"></script> | ||
<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> | ||
<script | ||
crossorigin="anonymous" | ||
src="https://unpkg.com/[email protected]/umd/react-dom-test-utils.production.min.js" | ||
></script> | ||
</head> | ||
<body> | ||
<div id="webchat"></div> | ||
<script> | ||
run(async function () { | ||
WebChat.renderWebChat( | ||
{ | ||
directLine: WebChat.createDirectLine({ token: await testHelpers.token.fetchDirectLineToken() }), | ||
store: testHelpers.createStore() | ||
}, | ||
document.getElementById('webchat') | ||
); | ||
|
||
// GIVEN: An "input" card is shown and the focus is on the transcript and the card input activity. | ||
await pageConditions.uiConnected(); | ||
await pageObjects.sendMessageViaSendBox('card inputs'); | ||
await pageConditions.numActivitiesShown(2); | ||
await pageConditions.scrollStabilized(); | ||
await pageConditions.became( | ||
'focus is on the send box', | ||
() => document.activeElement === pageElements.sendBoxTextBox(), | ||
1000 | ||
); | ||
await host.sendShiftTab(3); | ||
await pageConditions.became( | ||
'focus is on the input card', | ||
() => pageElements.focusedActivity() === pageElements.activities()[1], | ||
1000 | ||
); | ||
await pageConditions.scrollStabilized(); | ||
|
||
// WHEN: "click" event is fired, which mimic Windows Narrator "do primary action", or CAPSLOCK + ENTER. | ||
// Per React requirement, `ReactTestUtils` is required to fire artificial "click" event, instead of `createEvent`/`dispatchEvent`. | ||
ReactTestUtils.Simulate.click(pageElements.focusedActivity()); | ||
|
||
// THEN: The first text box in the input card should be focused. | ||
await pageConditions.became( | ||
'focus is on the first text box in the input card', | ||
() => document.activeElement === document.querySelector('.ac-input ,ac-textInput'), | ||
1000 | ||
); | ||
|
||
await host.snapshot(); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
5 changes: 5 additions & 0 deletions
5
..._/html/transcript.navigation.focusAttachment.screenReaderPrimaryAction.windowsNarrator.js
This file contains 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,5 @@ | ||
/** @jest-environment ./packages/test/harness/src/host/jest/WebDriverEnvironment.js */ | ||
|
||
describe('transcript navigation with Windows Narrator', () => { | ||
test('should focus inside the attachment when "do primary action" is performed', () => runHTML('transcript.navigation.focusAttachment.screenReaderPrimaryAction.windowsNarrator')); | ||
}); |
This file contains 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 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 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.