-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathdontKeepPositionWhenNotFocused.html
More file actions
52 lines (41 loc) · 1.69 KB
/
dontKeepPositionWhenNotFocused.html
File metadata and controls
52 lines (41 loc) · 1.69 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
<!doctype html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<link href="../static/index.css" rel="stylesheet" type="text/css" />
</head>
<body>
<main></main>
<script type="module">
import '/test-harness.mjs';
import '/test-page-object.mjs';
import { waitFor } from 'https://esm.sh/@testduet/wait-for';
import { render, systemUnderTest } from '../static/index.js';
run(
async function () {
await render();
// WHEN: The chat history is focused.
await systemUnderTest.focusChatHistory();
// WHEN: Up arrow key is pressed.
await host.sendKeys('ARROW_UP');
// THEN: Should focus on the second message.
expect(document.activeElement).toBe(systemUnderTest.chatMessages[1]);
// WHEN: Focus on send box, leaving the chat history.
systemUnderTest.sendBoxTextBox.focus();
// WHEN: New message is added.
window.dispatchEvent(new CustomEvent('addmessage'));
await waitFor(() => expect(systemUnderTest.chatMessages).toHaveLength(4));
// WHEN: Focus on the chat history.
await systemUnderTest.focusChatHistory();
// THEN: Then focused message should be the last one.
expect(document.activeElement).toBe(systemUnderTest.chatMessages[3]);
// WHEN: Up arrow key is pressed.
await host.sendKeys('ARROW_UP');
// THEN: Then focus message should be the second last one.
expect(document.activeElement).toBe(systemUnderTest.chatMessages[2]);
},
{ skipCheckAccessibility: true }
);
</script>
</body>
</html>