Skip to content

Commit 63943ea

Browse files
authored
Fix grouped sorting (#5632)
1 parent 13f9a8e commit 63943ea

14 files changed

+330
-26
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,7 @@ Notes: web developers are advised to use [`~` (tilde range)](https://github.com/
329329
- Fixed citation links are not properly matched against markdown links, in PR [#5614](https://github.com/microsoft/BotFramework-WebChat/pull/5614), by [@OEvgeny](https://github.com/OEvgeny)
330330
- Fixed `botframework-webchat/decorator` import in legacy CommonJS environments, in [#5616](https://github.com/microsoft/BotFramework-WebChat/pull/5616), by [@OEvgeny](https://github.com/OEvgeny)
331331
- Fixed `npm start` for efficiency and reliability, in PR [#5621](https://github.com/microsoft/BotFramework-WebChat/pull/5621) and [#5629](https://github.com/microsoft/BotFramework-WebChat/pull/5629), by [@compulim](https://github.com/compulim)
332+
- Fixed activity sorting introduced in PR [#5622](https://github.com/microsoft/BotFramework-WebChat/pull/5622), part grouping, and livestreaming, by [@compulim](https://github.com/compulim) in PR [#XXX](https://github.com/microsoft/BotFramework-WebChat/pull/XXX)
332333

333334
### Removed
334335

Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
<!doctype html>
2+
<html lang="en-US">
3+
<head>
4+
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
5+
</head>
6+
<body>
7+
<main id="webchat"></main>
8+
<script type="importmap">
9+
{
10+
"imports": {
11+
"botframework-webchat": "/__dist__/packages/bundle/static/botframework-webchat.js",
12+
"react": "/__dist__/packages/bundle/static/react.js",
13+
"react-dom": "/__dist__/packages/bundle/static/react-dom.js"
14+
}
15+
}
16+
</script>
17+
<script type="module">
18+
import '/test-harness.mjs';
19+
import '/test-page-object.mjs';
20+
21+
import { createDirectLine, createStoreWithOptions, renderWebChat } from 'botframework-webchat';
22+
import { version } from 'react';
23+
24+
run(async function () {
25+
const {
26+
testHelpers: { createDirectLineEmulator }
27+
} = window;
28+
29+
// TODO: This is for `createDirectLineEmulator` only, should find ways to eliminate this line.
30+
window.WebChat = { createStoreWithOptions };
31+
32+
const { directLine, store } = createDirectLineEmulator();
33+
34+
renderWebChat({ directLine, store }, document.getElementById('webchat'));
35+
36+
await pageConditions.uiConnected();
37+
38+
await directLine.emulateIncomingActivity({
39+
channelData: {
40+
streamSequence: 1,
41+
streamType: 'streaming'
42+
},
43+
from: { role: 'bot' },
44+
id: 'a-00001',
45+
text: 'a-00001: Stream 1 revision 1 at t = 0',
46+
timestamp: new Date(0).toISOString(),
47+
type: 'typing'
48+
});
49+
50+
expect(pageElements.activityContents().map(({ textContent }) => textContent)).toEqual([
51+
'a-00001: Stream 1 revision 1 at t = 0'
52+
]);
53+
54+
await host.snapshot('local');
55+
56+
// A "Hello, World!" inserted between two thoughts.
57+
await directLine.emulateIncomingActivity({
58+
from: { role: 'bot' },
59+
id: 'a-00002',
60+
text: 'a-00002: Hello, World at t = 1',
61+
timestamp: new Date(86_400_000).toISOString(),
62+
type: 'message'
63+
});
64+
65+
expect(pageElements.activityContents().map(({ textContent }) => textContent)).toEqual([
66+
'a-00001: Stream 1 revision 1 at t = 0',
67+
'a-00002: Hello, World at t = 1'
68+
]);
69+
70+
await host.snapshot('local');
71+
72+
await directLine.emulateIncomingActivity({
73+
channelData: {
74+
streamId: 'a-00001',
75+
streamSequence: 2,
76+
streamType: 'streaming'
77+
},
78+
from: { role: 'bot' },
79+
id: 'a-00003',
80+
text: 'a-00003: Stream 1 revision 2 at t = 2',
81+
timestamp: new Date(2 * 86_400_000).toISOString(),
82+
type: 'typing'
83+
});
84+
85+
expect(pageElements.activityContents().map(({ textContent }) => textContent)).toEqual([
86+
'a-00003: Stream 1 revision 2 at t = 2',
87+
'a-00002: Hello, World at t = 1'
88+
]);
89+
90+
await host.snapshot('local');
91+
92+
await directLine.emulateIncomingActivity({
93+
channelData: {
94+
streamSequence: 1,
95+
streamType: 'streaming'
96+
},
97+
from: { role: 'bot' },
98+
id: 'a-00004',
99+
text: 'a-00004: Stream 2 revision 1 at t = 3',
100+
timestamp: new Date(3 * 86_400_000).toISOString(),
101+
type: 'typing'
102+
});
103+
104+
expect(pageElements.activityContents().map(({ textContent }) => textContent)).toEqual([
105+
'a-00003: Stream 1 revision 2 at t = 2',
106+
'a-00002: Hello, World at t = 1',
107+
'a-00004: Stream 2 revision 1 at t = 3'
108+
]);
109+
110+
await host.snapshot('local');
111+
112+
await directLine.emulateIncomingActivity({
113+
channelData: {
114+
streamId: 'a-00004',
115+
streamSequence: 2,
116+
streamType: 'streaming'
117+
},
118+
from: { role: 'bot' },
119+
id: 'a-00005',
120+
text: 'a-00005: Stream 2 revision 2 at t = 0',
121+
timestamp: new Date(0).toISOString(),
122+
type: 'typing'
123+
});
124+
125+
expect(pageElements.activityContents().map(({ textContent }) => textContent)).toEqual([
126+
'a-00003: Stream 1 revision 2 at t = 2',
127+
'a-00002: Hello, World at t = 1',
128+
'a-00005: Stream 2 revision 2 at t = 0'
129+
]);
130+
131+
await host.snapshot('local');
132+
});
133+
</script>
134+
</body>
135+
</html>
9.23 KB
Loading
11.5 KB
Loading
11.8 KB
Loading
14.8 KB
Loading
14.8 KB
Loading
Lines changed: 164 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
<!doctype html>
2+
<html lang="en-US">
3+
<head>
4+
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
5+
</head>
6+
<body>
7+
<main id="webchat"></main>
8+
<script type="importmap">
9+
{
10+
"imports": {
11+
"botframework-webchat": "/__dist__/packages/bundle/static/botframework-webchat.js",
12+
"react": "/__dist__/packages/bundle/static/react.js",
13+
"react-dom": "/__dist__/packages/bundle/static/react-dom.js"
14+
}
15+
}
16+
</script>
17+
<script type="module">
18+
import '/test-harness.mjs';
19+
import '/test-page-object.mjs';
20+
21+
import { createDirectLine, createStoreWithOptions, renderWebChat } from 'botframework-webchat';
22+
import { version } from 'react';
23+
24+
run(async function () {
25+
const {
26+
testHelpers: { createDirectLineEmulator }
27+
} = window;
28+
29+
// TODO: This is for `createDirectLineEmulator` only, should find ways to eliminate this line.
30+
window.WebChat = { createStoreWithOptions };
31+
32+
const { directLine, store } = createDirectLineEmulator();
33+
34+
renderWebChat({ directLine, store }, document.getElementById('webchat'));
35+
36+
await pageConditions.uiConnected();
37+
38+
await directLine.emulateIncomingActivity({
39+
entities: [
40+
{
41+
'@context': 'https://schema.org',
42+
'@id': '',
43+
'@type': 'Message',
44+
type: 'https://schema.org/Message',
45+
isPartOf: { '@id': 'c-00001', '@type': 'HowTo' },
46+
position: 1
47+
}
48+
],
49+
from: { role: 'bot' },
50+
id: 'a-00001',
51+
text: 'a-00001: Chain 1 thought 1 at t = 0',
52+
timestamp: new Date(0).toISOString(),
53+
type: 'message'
54+
});
55+
56+
expect(pageElements.activityContents().map(({ textContent }) => textContent)).toEqual([
57+
'a-00001: Chain 1 thought 1 at t = 0'
58+
]);
59+
60+
await host.snapshot('local');
61+
62+
// A "Hello, World!" inserted between two thoughts.
63+
await directLine.emulateIncomingActivity({
64+
from: { role: 'bot' },
65+
id: 'a-00002',
66+
text: 'a-00002: Hello, World at t = 1',
67+
timestamp: new Date(86_400_000).toISOString(),
68+
type: 'message'
69+
});
70+
71+
expect(pageElements.activityContents().map(({ textContent }) => textContent)).toEqual([
72+
'a-00001: Chain 1 thought 1 at t = 0',
73+
'a-00002: Hello, World at t = 1'
74+
]);
75+
76+
await host.snapshot('local');
77+
78+
// The second thought should be grouped with the first one.
79+
await directLine.emulateIncomingActivity({
80+
entities: [
81+
{
82+
'@context': 'https://schema.org',
83+
'@id': '',
84+
'@type': 'Message',
85+
type: 'https://schema.org/Message',
86+
isPartOf: { '@id': 'c-00001', '@type': 'HowTo' },
87+
position: 2
88+
}
89+
],
90+
from: { role: 'bot' },
91+
id: 'a-00003',
92+
text: 'a-00003: Chain 1 thought 2 at t = 2',
93+
timestamp: new Date(2 * 86_400_000).toISOString(),
94+
type: 'message'
95+
});
96+
97+
expect(pageElements.activityContents().map(({ textContent }) => textContent)).toEqual([
98+
'a-00001: Chain 1 thought 1 at t = 0',
99+
'a-00003: Chain 1 thought 2 at t = 2',
100+
'a-00002: Hello, World at t = 1'
101+
]);
102+
103+
await host.snapshot('local');
104+
105+
await directLine.emulateIncomingActivity({
106+
entities: [
107+
{
108+
'@context': 'https://schema.org',
109+
'@id': '',
110+
'@type': 'Message',
111+
type: 'https://schema.org/Message',
112+
isPartOf: { '@id': 'c-00002', '@type': 'HowTo' },
113+
position: 1
114+
}
115+
],
116+
from: { role: 'bot' },
117+
id: 'a-00004',
118+
text: 'a-00004: Chain 2 thought 1 at t = 3',
119+
timestamp: new Date(3 * 86_400_000).toISOString(),
120+
type: 'message'
121+
});
122+
123+
expect(pageElements.activityContents().map(({ textContent }) => textContent)).toEqual([
124+
'a-00001: Chain 1 thought 1 at t = 0',
125+
'a-00003: Chain 1 thought 2 at t = 2',
126+
'a-00002: Hello, World at t = 1',
127+
'a-00004: Chain 2 thought 1 at t = 3'
128+
]);
129+
130+
await host.snapshot('local');
131+
132+
await directLine.emulateIncomingActivity({
133+
entities: [
134+
{
135+
'@context': 'https://schema.org',
136+
'@id': '',
137+
'@type': 'Message',
138+
type: 'https://schema.org/Message',
139+
isPartOf: { '@id': 'c-00002', '@type': 'HowTo' },
140+
position: 2
141+
}
142+
],
143+
from: { role: 'bot' },
144+
id: 'a-00005',
145+
text: 'a-00005: Chain 2 thought 2 at t = 0',
146+
// Intentionally roll back the date.
147+
// It should be grouped and not appear before "Hello, World!'
148+
timestamp: new Date(0).toISOString(),
149+
type: 'message'
150+
});
151+
152+
expect(pageElements.activityContents().map(({ textContent }) => textContent)).toEqual([
153+
'a-00001: Chain 1 thought 1 at t = 0',
154+
'a-00003: Chain 1 thought 2 at t = 2',
155+
'a-00002: Hello, World at t = 1',
156+
'a-00004: Chain 2 thought 1 at t = 3',
157+
'a-00005: Chain 2 thought 2 at t = 0'
158+
]);
159+
160+
await host.snapshot('local');
161+
});
162+
</script>
163+
</body>
164+
</html>
10.5 KB
Loading
12.8 KB
Loading

0 commit comments

Comments
 (0)