-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathlivestreamWithMovingTimestamp.html
More file actions
108 lines (92 loc) · 3.35 KB
/
Copy pathlivestreamWithMovingTimestamp.html
File metadata and controls
108 lines (92 loc) · 3.35 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
<!doctype html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
</head>
<body>
<main id="webchat"></main>
<script type="importmap">
{
"imports": {
"botframework-webchat": "/__dist__/packages/bundle/static/botframework-webchat.js",
"react": "/__dist__/packages/bundle/static/react.js",
"react-dom": "/__dist__/packages/bundle/static/react-dom.js"
}
}
</script>
<script type="module">
import '/test-harness.mjs';
import '/test-page-object.mjs';
import { createDirectLine, createStoreWithOptions, renderWebChat } from 'botframework-webchat';
import { version } from 'react';
run(async function () {
const {
testHelpers: { createDirectLineEmulator }
} = window;
// TODO: This is for `createDirectLineEmulator` only, should find ways to eliminate this line.
window.WebChat = { createStoreWithOptions };
const { directLine, store } = createDirectLineEmulator();
renderWebChat({ directLine, store }, document.getElementById('webchat'));
await pageConditions.uiConnected();
await directLine.emulateIncomingActivity({
from: { role: 'bot' },
id: 'a-00001',
text: 'Hello, World!',
timestamp: new Date(86_400_000).toISOString()
});
await directLine.emulateIncomingActivity({
channelData: {
streamSequence: 1,
streamType: 'streaming'
},
from: { role: 'bot' },
id: 'a-00002',
text: '`t=undefined`\n\nA quick',
timestamp: undefined,
type: 'typing'
});
expect(pageElements.activityContents().map(({ textContent }) => textContent)).toEqual([
'Hello, World!',
't=undefined\nA quick'
]);
// THEN: Screenshot should show no timestamp below the second message.
await host.snapshot('local');
await directLine.emulateIncomingActivity({
channelData: {
streamId: 'a-00002',
streamSequence: 2,
streamType: 'streaming'
},
from: { role: 'bot' },
id: 'a-00003',
text: '`t=0`\n\nA quick brown fox',
timestamp: new Date(0).toISOString(),
type: 'typing'
});
expect(pageElements.activityContents().map(({ textContent }) => textContent)).toEqual([
'Hello, World!',
't=0\nA quick brown fox'
]);
// THEN: Should show the livestream message on second position as it should not be moved.
await host.snapshot('local');
await directLine.emulateIncomingActivity({
channelData: {
streamId: 'a-00002',
streamType: 'final'
},
from: { role: 'bot' },
id: 'a-00004',
text: '`t=0`\n\nA quick brown fox jumped over the lazy dogs.',
timestamp: new Date(0).toISOString(),
type: 'message'
});
// THEN: Should have the livestream message as the first one.
expect(pageElements.activityContents().map(({ textContent }) => textContent)).toEqual([
't=0\nA quick brown fox jumped over the lazy dogs.',
'Hello, World!'
]);
await host.snapshot('local');
});
</script>
</body>
</html>