-
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.
Remove bogus aria-labelledby (#3697)
* Remove bogus aria-labelledby * Add test * Update entry * Update __tests__/html/accessibility.stackedLayout.withoutText.html Co-authored-by: Corina <[email protected]> * Update accessibility.stackedLayout.withoutText.html Co-authored-by: Corina <[email protected]>
- Loading branch information
Showing
4 changed files
with
83 additions
and
1 deletion.
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
73 changes: 73 additions & 0 deletions
73
__tests__/html/accessibility.stackedLayout.withoutText.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,73 @@ | ||
<!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 { | ||
WebChatTest: { conditions, createDirectLineWithTranscript, createStore, host, pageObjects, timeouts, token } | ||
} = window; | ||
|
||
(async function () { | ||
window.WebChat.renderWebChat( | ||
{ | ||
directLine: createDirectLineWithTranscript([ | ||
{ | ||
attachments: [ | ||
{ | ||
content: 'Attachment 1', | ||
contentType: 'text/plain' | ||
}, | ||
{ | ||
content: 'Attachment 2', | ||
contentType: 'text/plain' | ||
} | ||
], | ||
type: 'message', | ||
id: 'CONVERSATION_ID-o|00000', | ||
timestamp: '2000-01-23T12:34:56.12345Z', | ||
channelId: 'directline', | ||
from: { | ||
id: 'webchat-mockbot', | ||
name: 'webchat-mockbot' | ||
}, | ||
conversation: { | ||
id: 'CONVERSATION_ID-o' | ||
}, | ||
locale: 'en-US' | ||
} | ||
]), | ||
store: createStore() | ||
}, | ||
document.getElementById('webchat') | ||
); | ||
|
||
await pageObjects.wait(conditions.uiConnected(), timeouts.directLine); | ||
|
||
// This test is to verify that all elements with aria-labelledby have a corresponding element with the same ID. | ||
|
||
const labelledBys = [].map.call(document.querySelectorAll('[aria-labelledby]'), element => ({ | ||
element, | ||
id: element.getAttribute('aria-labelledby') | ||
})); | ||
|
||
for (let { element, id } of labelledBys) { | ||
if (!document.getElementById(id)) { | ||
console.warn(`Cannot find element with ID of ${id}`, { element }); | ||
|
||
throw new Error(`Cannot find element with ID of ${id}`); | ||
} | ||
} | ||
|
||
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 requirement', () => { | ||
test('should not inject "aria-labelledby" for activities without text content in stacked layout', () => | ||
runHTMLTest('accessibility.stackedLayout.withoutText.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