-
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.
Allow implementors to change the WAI-ARIA role of the container (#3658)…
… (#3669) * Allow implementors to change the WAI-ARIA role of the container (#3658) * Adding tests for `containerRole` and `useContainerRole` (#3658) * Plus CHANGELOG entry * Use role attribute * Move role checks to BasicWebChat Co-authored-by: William Wong <[email protected]> Co-authored-by: William Wong <[email protected]>
- Loading branch information
1 parent
72c98bb
commit 8f435f7
Showing
7 changed files
with
1,058 additions
and
958 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,38 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-US"> | ||
<head> | ||
<script crossorigin="anonymous" src="/__dist__/testharness.js"></script> | ||
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script> | ||
</head> | ||
<body> | ||
<div id="webchat"></div> | ||
<script type="text/babel" data-presets="env,stage-3,react"> | ||
const { | ||
WebChat: { createDirectLine }, | ||
WebChatTest: { conditions, createStore, expect, host, pageObjects, timeouts, token } | ||
} = window; | ||
|
||
(async function () { | ||
window.WebChat.renderWebChat( | ||
{ | ||
directLine: createDirectLine({ token: await token.fetchDirectLineToken() }), | ||
role: 'invalid', | ||
store: createStore() | ||
}, | ||
document.getElementById('webchat') | ||
); | ||
|
||
await pageObjects.wait(conditions.uiConnected(), timeouts.directLine); | ||
|
||
// Should fallback to "complementary" if the role specified is not a valid landmark role. | ||
await expect(document.querySelector('#webchat > *').getAttribute('role')).toBe('complementary'); | ||
|
||
await host.done(); | ||
})().catch(async err => { | ||
console.error(err); | ||
|
||
await host.error(err); | ||
}); | ||
</script> | ||
</body> | ||
</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,8 @@ | ||
/** | ||
* @jest-environment ./__tests__/html/__jest__/WebChatEnvironment.js | ||
*/ | ||
|
||
describe('accessibility feature to support "role" attribute', () => { | ||
test('should fallback to "complementary" if not a valid landmark role', () => | ||
runHTMLTest('accessibility.landmarkRole.invalid', { ignoreConsoleError: true })); | ||
}); |
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,36 @@ | ||
<!DOCTYPE html> | ||
<html lang="en-US"> | ||
<head> | ||
<script crossorigin="anonymous" src="/__dist__/testharness.js"></script> | ||
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script> | ||
</head> | ||
<body> | ||
<div id="webchat"></div> | ||
<script type="text/babel" data-presets="env,stage-3,react"> | ||
const { | ||
WebChat: { createDirectLine }, | ||
WebChatTest: { conditions, createStore, expect, host, pageObjects, timeouts, token } | ||
} = window; | ||
|
||
(async function () { | ||
window.WebChat.renderWebChat( | ||
{ | ||
directLine: createDirectLine({ token: await token.fetchDirectLineToken() }), | ||
role: 'main', | ||
store: createStore() | ||
}, | ||
document.getElementById('webchat') | ||
); | ||
|
||
await pageObjects.wait(conditions.uiConnected(), timeouts.directLine); | ||
await expect(document.querySelector('#webchat > *').getAttribute('role')).toBe('main'); | ||
|
||
await host.done(); | ||
})().catch(async err => { | ||
console.error(err); | ||
|
||
await host.error(err); | ||
}); | ||
</script> | ||
</body> | ||
</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,8 @@ | ||
/** | ||
* @jest-environment ./__tests__/html/__jest__/WebChatEnvironment.js | ||
*/ | ||
|
||
describe('accessibility feature to support "role" attribute', () => { | ||
test('should set "role" if it is valid landmark role', () => | ||
runHTMLTest('accessibility.landmarkRole.valid')); | ||
}); |
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