Skip to content

Commit 9f00e6c

Browse files
authored
HTML tests: fix accessibility issues in HTML files (#4685)
* Fix HTML test accessibility issues * Fix ESBuild * Add entry * Add image alt text * Fix crypto
1 parent 0e770c8 commit 9f00e6c

8 files changed

+34
-13
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
3030
- HTML test: changed contrast ratio in tests that use different background colors, by [@compulim](https://github.com/compulim), in PR [#4686](https://github.com/microsoft/BotFramework-WebChat/pull/4686)
3131
- Added `ponyfill` prop to `<ReactWebChat>`/`<Composer>` and `createStoreWithOptions`, by [@compulim](https://github.com/compulim), in PR [#4662](https://github.com/microsoft/BotFramework-WebChat/pull/4662)
3232
- This is for development scenarios where fake timer is needed and will only applies to Web Chat only
33+
- HTML test: fix accessibility issues on HTML file, by [@compulim](https://github.com/compulim), in PR [#4685](https://github.com/microsoft/BotFramework-WebChat/pull/4685)
3334

3435
### Fixed
3536

Loading

__tests__/html/autoScroll.withPostBack.activity.html

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,10 @@
6666
spacing: 'None',
6767
wrap: true
6868
},
69-
{
70-
type: 'TextBlock',
71-
text: 'Snooze for',
72-
wrap: true
73-
},
7469
{
7570
type: 'Input.ChoiceSet',
7671
id: 'snooze',
72+
label: 'Snooze for',
7773
value: '5',
7874
choices: [
7975
{

__tests__/html/autoScroll.withPostBack.page.html

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,10 @@
6666
spacing: 'None',
6767
wrap: true
6868
},
69-
{
70-
type: 'TextBlock',
71-
text: 'Snooze for',
72-
wrap: true
73-
},
7469
{
7570
type: 'Input.ChoiceSet',
7671
id: 'snooze',
72+
label: 'Snooze for',
7773
value: '5',
7874
choices: [
7975
{

__tests__/setup/setupCryptoGetRandomValues.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,6 @@ import { randomFillSync } from 'crypto';
22

33
// When microsoft-cognitiveservices-speech-sdk is loaded, it call "uuid" package to create a new GUID.
44
// "uuid" package requires crypto.getRandomValues().
5-
global.crypto = { ...global.crypto, getRandomValues: randomFillSync };
5+
if (!global.crypto?.getRandomValues) {
6+
global.crypto = { ...global.crypto, getRandomValues: randomFillSync };
7+
}

packages/test/harness/src/browser/globals/run.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,26 @@ export default function () {
66
(window.run = (fn, doneOptions) => {
77
const host = getHost();
88

9+
// Accessibility: [document-title] add a page title if not specified.
10+
document.title = document.title || location.pathname.split('/').reverse()[0];
11+
12+
// Accessibility: [page-has-heading-one] artificially inject a page header.
13+
const header = document.createElement('header');
14+
const headingOne = document.createElement('h1');
15+
16+
headingOne.textContent = 'Web Chat test';
17+
18+
header.style.color = 'transparent';
19+
header.style.height = '1px';
20+
header.style.overflow = 'hidden';
21+
header.style.position = 'absolute';
22+
header.style.top = '0';
23+
header.style.whiteSpace = 'nowrap';
24+
header.style.width = '1px';
25+
header.append(headingOne);
26+
27+
document.body.prepend(header);
28+
929
window.addEventListener('error', event => host.error(event.error));
1030

1131
// Run the test, signal start by host.ready().
@@ -19,6 +39,11 @@ export default function () {
1939
})
2040
// Some tests may have changed the time zone, we should unset it.
2141
.then(() => host.sendDevToolsCommand('Emulation.setTimezoneOverride', { timezoneId: 'Etc/UTC' }))
42+
.catch(error =>
43+
// Chrome occasionally said timezone already set when we navigate away. Need extra F5 to clear it.
44+
// We did set the timezone, but page navigation should undo it.
45+
error.message?.includes('"Timezone override is already in effect"') ? undefined : Promise.reject(error)
46+
)
2247
.then(host.ready)
2348
.then(fn)
2449
.then(() => host.done(doneOptions))

packages/test/page-object/src/globals/testHelpers/transcriptNavigation.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,10 @@ function createInputCardActivity(index = 0) {
7979
width: 1,
8080
items: [
8181
{
82+
altText: 'a diver under the sea',
83+
size: 'auto',
8284
type: 'Image',
83-
url: 'https://upload.wikimedia.org/wikipedia/commons/b/b2/Diver_Silhouette%2C_Great_Barrier_Reef.jpg',
84-
size: 'auto'
85+
url: 'https://upload.wikimedia.org/wikipedia/commons/b/b2/Diver_Silhouette%2C_Great_Barrier_Reef.jpg'
8586
}
8687
]
8788
}

0 commit comments

Comments
 (0)