Skip to content

Commit

Permalink
HTML tests: fix accessibility issues in HTML files (#4685)
Browse files Browse the repository at this point in the history
* Fix HTML test accessibility issues

* Fix ESBuild

* Add entry

* Add image alt text

* Fix crypto
  • Loading branch information
compulim authored Apr 6, 2023
1 parent 0e770c8 commit 9f00e6c
Show file tree
Hide file tree
Showing 8 changed files with 34 additions and 13 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- 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)
- 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)
- This is for development scenarios where fake timer is needed and will only applies to Web Chat only
- 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)

### Fixed

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 1 addition & 5 deletions __tests__/html/autoScroll.withPostBack.activity.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,10 @@
spacing: 'None',
wrap: true
},
{
type: 'TextBlock',
text: 'Snooze for',
wrap: true
},
{
type: 'Input.ChoiceSet',
id: 'snooze',
label: 'Snooze for',
value: '5',
choices: [
{
Expand Down
6 changes: 1 addition & 5 deletions __tests__/html/autoScroll.withPostBack.page.html
Original file line number Diff line number Diff line change
Expand Up @@ -66,14 +66,10 @@
spacing: 'None',
wrap: true
},
{
type: 'TextBlock',
text: 'Snooze for',
wrap: true
},
{
type: 'Input.ChoiceSet',
id: 'snooze',
label: 'Snooze for',
value: '5',
choices: [
{
Expand Down
4 changes: 3 additions & 1 deletion __tests__/setup/setupCryptoGetRandomValues.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ import { randomFillSync } from 'crypto';

// When microsoft-cognitiveservices-speech-sdk is loaded, it call "uuid" package to create a new GUID.
// "uuid" package requires crypto.getRandomValues().
global.crypto = { ...global.crypto, getRandomValues: randomFillSync };
if (!global.crypto?.getRandomValues) {
global.crypto = { ...global.crypto, getRandomValues: randomFillSync };
}
25 changes: 25 additions & 0 deletions packages/test/harness/src/browser/globals/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,26 @@ export default function () {
(window.run = (fn, doneOptions) => {
const host = getHost();

// Accessibility: [document-title] add a page title if not specified.
document.title = document.title || location.pathname.split('/').reverse()[0];

// Accessibility: [page-has-heading-one] artificially inject a page header.
const header = document.createElement('header');
const headingOne = document.createElement('h1');

headingOne.textContent = 'Web Chat test';

header.style.color = 'transparent';
header.style.height = '1px';
header.style.overflow = 'hidden';
header.style.position = 'absolute';
header.style.top = '0';
header.style.whiteSpace = 'nowrap';
header.style.width = '1px';
header.append(headingOne);

document.body.prepend(header);

window.addEventListener('error', event => host.error(event.error));

// Run the test, signal start by host.ready().
Expand All @@ -19,6 +39,11 @@ export default function () {
})
// Some tests may have changed the time zone, we should unset it.
.then(() => host.sendDevToolsCommand('Emulation.setTimezoneOverride', { timezoneId: 'Etc/UTC' }))
.catch(error =>
// Chrome occasionally said timezone already set when we navigate away. Need extra F5 to clear it.
// We did set the timezone, but page navigation should undo it.
error.message?.includes('"Timezone override is already in effect"') ? undefined : Promise.reject(error)
)
.then(host.ready)
.then(fn)
.then(() => host.done(doneOptions))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,10 @@ function createInputCardActivity(index = 0) {
width: 1,
items: [
{
altText: 'a diver under the sea',
size: 'auto',
type: 'Image',
url: 'https://upload.wikimedia.org/wikipedia/commons/b/b2/Diver_Silhouette%2C_Great_Barrier_Reef.jpg',
size: 'auto'
url: 'https://upload.wikimedia.org/wikipedia/commons/b/b2/Diver_Silhouette%2C_Great_Barrier_Reef.jpg'
}
]
}
Expand Down

0 comments on commit 9f00e6c

Please sign in to comment.