Skip to content

Commit a2f7438

Browse files
author
Eugene Olonov
committed
Show the live region copy in role description snapshots
1 parent d550e7f commit a2f7438

3 files changed

Lines changed: 25 additions & 1 deletion

File tree

‎__tests__/html2/accessibility/aria-roledescription.localized.html‎

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
<html lang="en-US">
33
<head>
44
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
5+
<!-- Shows the live region, so the snapshots show the copy sent to screen readers. -->
6+
<link href="/assets/accessibility.liveRegionAttachment.css" rel="stylesheet" type="text/css" />
57
</head>
68
<body>
79
<main id="webchat"></main>
@@ -34,7 +36,13 @@
3436
const root = createRoot(document.getElementById('webchat'));
3537
const render = props =>
3638
root.render(
37-
createElement(ReactWebChat, { directLine, store, styleOptions: { hideSendBox: true }, ...props })
39+
createElement(ReactWebChat, {
40+
directLine,
41+
store,
42+
// Keeps the live region copy of new messages, so it can be seen in the snapshots.
43+
styleOptions: { hideSendBox: true, internalLiveRegionFadeAfter: 60000 },
44+
...props
45+
})
3846
);
3947

4048
// Role descriptions of the message and attachments, per activity.
@@ -68,8 +76,10 @@
6876
}
6977

7078
await pageConditions.numActivitiesShown(2);
79+
await pageConditions.liveRegionStabilized();
7180

7281
// THEN: A stacked message, then a carousel message, each with its text and 2 cards.
82+
// THEN: The live region (top) shows what screen readers announce for each: "Bot said:", the text, and "A card:" per card, without role descriptions.
7383
await host.snapshot('local');
7484

7585
// THEN: Message and attachments are described in English.
@@ -94,6 +104,20 @@
94104
['Nachricht', 'Anhang', 'Anhang']
95105
])
96106
);
107+
108+
// WHEN: The bot sends another message.
109+
await directLine.emulateIncomingActivity({
110+
attachments: [{ content: { title: 'Card 3' }, contentType: 'application/vnd.microsoft.card.hero' }],
111+
from: { role: 'bot' },
112+
text: 'Message after switching to German',
113+
type: 'message'
114+
});
115+
116+
await pageConditions.numActivitiesShown(3);
117+
await pageConditions.liveRegionStabilized();
118+
119+
// THEN: The live region shows the new message announced in German ("Bot sagte:", "Eine Karte:", from de-DE); the earlier copies are re-rendered in German too.
120+
await host.snapshot('local');
97121
});
98122
</script>
99123
</body>
16.2 KB
Loading
40.9 KB
Loading

0 commit comments

Comments
 (0)