-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathtranscript.navigation.focusActivity.scrollIntoView.keyboard.html
More file actions
110 lines (89 loc) · 4.41 KB
/
transcript.navigation.focusActivity.scrollIntoView.keyboard.html
File metadata and controls
110 lines (89 loc) · 4.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!DOCTYPE html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<script crossorigin="anonymous" src="/test-harness.js"></script>
<script crossorigin="anonymous" src="/test-page-object.js"></script>
<script crossorigin="anonymous" src="/__dist__/webchat-es5.js"></script>
</head>
<body>
<main id="webchat"></main>
<script>
run(async function () {
WebChat.renderWebChat(
{
directLine: testHelpers.createDirectLineWithTranscript(
testHelpers.transcriptNavigation.generateTranscript()
),
store: testHelpers.createStore()
},
document.getElementById('webchat')
);
await pageConditions.uiConnected();
await pageConditions.numActivitiesShown(32);
await pageConditions.scrollToBottomCompleted();
await pageObjects.focusSendBoxTextBox();
// Tests according to https://www.w3.org/TR/wai-aria-practices-1.1/#kbd_focus_activedescendant:
// Keyboard: TAB/SHIFT-TAB to focus on transcript should scroll activity into view.
// Keyboard: UP/DOWN arrow key should scroll them into view.
// Keyboard: Blurring the transcript, should still keep `aria-activedescendant`.
// WHEN: Pressing SHIFT-TAB x 3 to focus on the transcript.
await host.sendShiftTab();
await host.sendShiftTab();
await host.sendShiftTab();
// THEN: It should show focus indicator around the last activity.
expect(pageElements.activeActivity()).toBe([...pageElements.activities()].reverse()[0]);
await host.snapshot();
// WHEN: Press up arrow 2 times.
await host.sendKeys('ARROW_UP');
await host.sendKeys('ARROW_UP');
// THEN: It should show focus indicator around activity #29 and scroll it into view.
await pageConditions.focusedActivityInView();
expect(pageElements.activeActivity()).toBe([...pageElements.activities()].reverse()[2]);
await host.snapshot();
// WHEN: Press up arrow 3 times.
await host.sendKeys('ARROW_UP');
await host.sendKeys('ARROW_UP');
await host.sendKeys('ARROW_UP');
// THEN: Activity #26 should be top aligned with appropriate spacing.
// Activity #29 should be partially off the screen on the bottom side.
await host.snapshot();
// WHEN: Press down arrow 3 times.
await host.sendKeys('ARROW_DOWN');
await host.sendKeys('ARROW_DOWN');
await host.sendKeys('ARROW_DOWN');
// THEN: Activity #29 should be displayed completed and aligned to the bottom of the screen with appropriate spacing.
const activity29 = [...pageElements.activities()].reverse()[2];
await pageConditions.focusedActivityInView();
expect(pageElements.transcriptScrollable().scrollTop + pageElements.transcriptScrollable().offsetHeight).toBe(
activity29.offsetTop + activity29.offsetHeight + 10 // account for gap between activities
);
await host.snapshot();
// WHEN: Pressing TAB 3 times.
await host.sendTab();
await host.sendTab();
await host.sendTab();
// THEN: It should focus on the send box.
expect(document.activeElement).toBe(pageElements.sendBoxTextBox());
// THEN: It should continue to keep activity #29 as the `aria-activedescendant`.
expect(pageElements.activeActivity()).toBe([...pageElements.activities()].reverse()[2]);
// WHEN: Scroll the transcript to the bottom.
pageElements.transcriptScrollable().scrollTop =
pageElements.transcriptScrollable().scrollHeight - pageElements.transcriptScrollable().clientHeight;
// THEN: Transcript should be at the bottom.
await host.snapshot();
// WHEN: SHIFT-TAB to focus back on the transcript.
await host.sendShiftTab();
await host.sendShiftTab();
await host.sendShiftTab();
// THEN: It should scroll activity #29 in the view.
await pageConditions.focusedActivityInView();
expect(pageElements.transcriptScrollable().scrollTop).toBe(
[...pageElements.activities()].reverse()[2].offsetTop - 10 // account for gap between activities
);
// THEN: It should show activity #29 completely with top aligned and appropriate spacing.
await host.snapshot();
});
</script>
</body>
</html>