-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Screen reader should read alert when sending empty message or offline (…
…#4637) * Alert when sending empty message * Add offline error * Fix tests * Cosmetics * Apply suggestions from code review Co-authored-by: Benjamin Yackley <113474767+beyackle2@users.noreply.github.com> --------- Co-authored-by: Benjamin Yackley <113474767+beyackle2@users.noreply.github.com>
- Loading branch information
Showing
28 changed files
with
575 additions
and
159 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
56 changes: 56 additions & 0 deletions
56
__tests__/html/accessibility.sendBox.alertEmptyMessage.multilineTextBox.enter.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,56 @@ | ||
<!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> | ||
run(async function () { | ||
const clock = lolex.install(); | ||
|
||
const store = testHelpers.createStore(); | ||
|
||
const directLine = testHelpers.createDirectLineEmulator(store); | ||
|
||
// GIVEN: With a multiline text area. | ||
WebChat.renderWebChat( | ||
{ | ||
directLine, | ||
store, | ||
styleOptions: { | ||
sendBoxTextWrap: true | ||
} | ||
}, | ||
document.getElementById('webchat') | ||
); | ||
|
||
await pageConditions.webChatRendered(); | ||
|
||
clock.tick(600); | ||
|
||
await pageConditions.uiConnected(); | ||
|
||
const [errorMessage] = document.getElementsByClassName('webchat__submit-error-message'); | ||
|
||
// GIVEN: The send box is empty. | ||
await host.click(pageElements.sendBoxTextBox()); | ||
await host.sendKeys('ENTER'); | ||
|
||
// THEN: The alert message should be empty. | ||
expect(errorMessage.innerText).toBe(''); | ||
clock.tick(50); | ||
|
||
// THEN: After 50 ms, the alert message should read "Cannot send empty message." | ||
expect(errorMessage.innerText).toBe('Cannot send empty message.'); | ||
|
||
// THEN: After 500 ms, the alert message should be empty. | ||
clock.tick(500); | ||
expect(errorMessage.innerText).toBe(''); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
6 changes: 6 additions & 0 deletions
6
__tests__/html/accessibility.sendBox.alertEmptyMessage.multilineTextBox.enter.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 requirement', () => { | ||
describe('when pressing ENTER on an empty multiline send box', () => | ||
test('should alert about empty message', () => runHTML('accessibility.sendBox.alertEmptyMessage.multilineTextBox.enter.html'))); | ||
}); |
67 changes: 67 additions & 0 deletions
67
__tests__/html/accessibility.sendBox.alertEmptyMessage.sendButton.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,67 @@ | ||
<!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> | ||
run(async function () { | ||
const clock = lolex.install(); | ||
|
||
const store = testHelpers.createStore(); | ||
|
||
const directLine = testHelpers.createDirectLineEmulator(store); | ||
|
||
WebChat.renderWebChat( | ||
{ | ||
directLine, | ||
store | ||
}, | ||
document.getElementById('webchat') | ||
); | ||
|
||
await pageConditions.webChatRendered(); | ||
|
||
clock.tick(600); | ||
|
||
await pageConditions.uiConnected(); | ||
|
||
const [errorMessage] = document.getElementsByClassName('webchat__submit-error-message'); | ||
|
||
// GIVEN: The send box is empty. | ||
|
||
// WHEN: Send button is clicked. | ||
await pageObjects.clickSendButton(); | ||
|
||
// THEN: The alert message should be empty. | ||
expect(errorMessage.innerText).toBe(''); | ||
|
||
// THEN: After 50 ms, the alert message should read "Cannot send empty message." | ||
clock.tick(50); | ||
expect(errorMessage.innerText).toBe('Cannot send empty message.'); | ||
|
||
// THEN: After 500 ms, the alert message should be empty. | ||
clock.tick(500); | ||
expect(errorMessage.innerText).toBe(''); | ||
|
||
// WHEN: Send button is clicked again. | ||
await pageObjects.clickSendButton(); | ||
|
||
// THEN: The alert message should be empty. | ||
expect(errorMessage.innerText).toBe(''); | ||
|
||
// THEN: After 50 ms, the alert message should read "Cannot send empty message." | ||
clock.tick(50); | ||
expect(errorMessage.innerText).toBe('Cannot send empty message.'); | ||
|
||
// THEN: After 500 ms, the alert message should be empty. | ||
clock.tick(500); | ||
expect(errorMessage.innerText).toBe(''); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
6 changes: 6 additions & 0 deletions
6
__tests__/html/accessibility.sendBox.alertEmptyMessage.sendButton.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 requirement', () => { | ||
describe('when clicking on send box with an empty send box', () => | ||
test('should alert about empty message', () => runHTML('accessibility.sendBox.alertEmptyMessage.sendButton.html'))); | ||
}); |
53 changes: 53 additions & 0 deletions
53
__tests__/html/accessibility.sendBox.alertEmptyMessage.singleLineTextBox.enter.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,53 @@ | ||
<!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> | ||
run(async function () { | ||
const clock = lolex.install(); | ||
|
||
const store = testHelpers.createStore(); | ||
|
||
const directLine = testHelpers.createDirectLineEmulator(store); | ||
|
||
// GIVEN: With a single line text box. | ||
WebChat.renderWebChat( | ||
{ | ||
directLine, | ||
store | ||
}, | ||
document.getElementById('webchat') | ||
); | ||
|
||
await pageConditions.webChatRendered(); | ||
|
||
clock.tick(600); | ||
|
||
await pageConditions.uiConnected(); | ||
|
||
const [errorMessage] = document.getElementsByClassName('webchat__submit-error-message'); | ||
|
||
// GIVEN: The send box is empty. | ||
await host.click(pageElements.sendBoxTextBox()); | ||
await host.sendKeys('ENTER'); | ||
|
||
// THEN: The alert message should be empty. | ||
expect(errorMessage.innerText).toBe(''); | ||
|
||
// THEN: After 50 ms, the alert message should read "Cannot send empty message." | ||
clock.tick(50); | ||
expect(errorMessage.innerText).toBe('Cannot send empty message.'); | ||
|
||
// THEN: After 500 ms, the alert message should be empty. | ||
clock.tick(500); | ||
expect(errorMessage.innerText).toBe(''); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
6 changes: 6 additions & 0 deletions
6
__tests__/html/accessibility.sendBox.alertEmptyMessage.singleLineTextBox.enter.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 requirement', () => { | ||
describe('when pressing ENTER on an empty single line send box', () => | ||
test('should alert about empty message', () => runHTML('accessibility.sendBox.alertEmptyMessage.singleLineTextBox.enter.html'))); | ||
}); |
53 changes: 53 additions & 0 deletions
53
__tests__/html/accessibility.sendBox.alertOffline.sendButton.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,53 @@ | ||
<!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> | ||
run(async function () { | ||
const clock = lolex.install(); | ||
|
||
const store = testHelpers.createStore(); | ||
|
||
const directLine = testHelpers.createDirectLineEmulator(store, { autoConnect: false }); | ||
|
||
WebChat.renderWebChat( | ||
{ | ||
directLine, | ||
store | ||
}, | ||
document.getElementById('webchat') | ||
); | ||
|
||
await pageConditions.webChatRendered(); | ||
|
||
// GIVEN: Connection is still establishing. | ||
expect(pageElements.connectivityStatus().innerText).toBe('Connecting…'); | ||
|
||
const [errorMessage] = document.getElementsByClassName('webchat__submit-error-message'); | ||
|
||
// GIVEN: "Hello, World!" is in the send box. | ||
await pageObjects.typeInSendBox('Hello, World!'); | ||
|
||
// WHEN: Send button is clicked. | ||
await pageObjects.clickSendButton(); | ||
|
||
// THEN: The alert message should be empty. | ||
expect(errorMessage.innerText).toBe(''); | ||
|
||
// THEN: After 50 ms, the alert message should read "Unable to connect." | ||
clock.tick(50); | ||
expect(errorMessage.innerText).toBe('Unable to connect.'); | ||
|
||
// THEN: After 500 ms, the alert message should be empty. | ||
clock.tick(500); | ||
expect(errorMessage.innerText).toBe(''); | ||
}); | ||
</script> | ||
</body> | ||
</html> |
6 changes: 6 additions & 0 deletions
6
__tests__/html/accessibility.sendBox.alertOffline.sendButton.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 requirement', () => { | ||
describe('when clicking on send button while offline', () => | ||
test('should alert about offline', () => runHTML('accessibility.sendBox.alertOffline.sendButton.html'))); | ||
}); |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.