|
2 | 2 | <html lang="en-US"> |
3 | 3 | <head> |
4 | 4 | <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" /> |
5 | 7 | </head> |
6 | 8 | <body> |
7 | 9 | <main id="webchat"></main> |
|
34 | 36 | const root = createRoot(document.getElementById('webchat')); |
35 | 37 | const render = props => |
36 | 38 | 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 | + }) |
38 | 46 | ); |
39 | 47 |
|
40 | 48 | // Role descriptions of the message and attachments, per activity. |
|
68 | 76 | } |
69 | 77 |
|
70 | 78 | await pageConditions.numActivitiesShown(2); |
| 79 | + await pageConditions.liveRegionStabilized(); |
71 | 80 |
|
72 | 81 | // 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. |
73 | 83 | await host.snapshot('local'); |
74 | 84 |
|
75 | 85 | // THEN: Message and attachments are described in English. |
|
94 | 104 | ['Nachricht', 'Anhang', 'Anhang'] |
95 | 105 | ]) |
96 | 106 | ); |
| 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'); |
97 | 121 | }); |
98 | 122 | </script> |
99 | 123 | </body> |
|
0 commit comments