-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathkeepPositionWhenFocused.html
More file actions
43 lines (35 loc) · 1.45 KB
/
keepPositionWhenFocused.html
File metadata and controls
43 lines (35 loc) · 1.45 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
<!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();
// THEN: The last message should be focused.
expect(document.activeElement).toBe(systemUnderTest.chatMessages[2]);
// WHEN: New message is added while the focus is on the chat history.
window.dispatchEvent(new CustomEvent('addmessage'));
await waitFor(() => expect(systemUnderTest.chatMessages).toHaveLength(4));
// THEN: The third message should be focused, it was previously the last message.
expect(document.activeElement).toBe(systemUnderTest.chatMessages[2]);
// WHEN: Down arrow key is pressed.
await host.sendKeys('ARROW_UP');
// THEN: The second message should be focused.
expect(document.activeElement).toBe(systemUnderTest.chatMessages[1]);
},
{ skipCheckAccessibility: true }
);
</script>
</body>
</html>