-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expand file tree
/
Copy pathactivityGrouping.legacyActivityMiddleware.skip.html
More file actions
205 lines (189 loc) · 7.53 KB
/
activityGrouping.legacyActivityMiddleware.skip.html
File metadata and controls
205 lines (189 loc) · 7.53 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
<!--
Polymiddleware does not support request modification.
Thus, modified `renderAttachment()` from legacy activity middleware is not honored.
This test is testing against "modified attachmentRenderer", thus it is failing.
Polymiddleware could support modified attachment polymiddleware when we finish the following work:
- Upgrade to attachment polymiddleware
- Support cascaded polymiddleware
- Today, polymiddleware are set in <APIComposer>, cascading means we need 2 x <APIComposer>
- Tomorrow, we should allow cascading through <ThemeProvider polymiddleware={}>
- That also means, default poly/middleware should be materialized in <ThemeProvider>, instead of <APIComposer>
-->
<!doctype html>
<html lang="en-US">
<head>
<link href="/assets/index.css" rel="stylesheet" type="text/css" />
<script crossorigin="anonymous" src="https://unpkg.com/@babel/standalone@7.8.7/babel.min.js"></script>
<script crossorigin="anonymous" src="https://unpkg.com/react@16.8.6/umd/react.development.js"></script>
<script crossorigin="anonymous" src="https://unpkg.com/react-dom@16.8.6/umd/react-dom.development.js"></script>
<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>
<style type="text/css">
.decorated-activity {
border: solid 2px limegreen;
}
.decorated-attachment {
border: solid 2px purple;
}
.attachment-figure {
margin: 0;
}
.attachment-figure-caption {
background-color: #eee;
}
</style>
</head>
<body>
<main id="webchat"></main>
<script type="text/babel" data-presets="env,stage-3,react">
run(async function () {
await host.windowSize(undefined, 1280, document.getElementById('webchat'));
const activityMiddleware =
() =>
next =>
(...renderActivityArgs) => {
const [{ activity }] = renderActivityArgs;
const renderActivity = next(...renderActivityArgs);
if (/^1/.test(activity.id)) {
return (children, ...renderAttachmentArgs) => (
<div className="decorated-activity">
{renderActivity(
(...renderAttachmentArgs) => (
<div className="decorated-attachment">{children(...renderAttachmentArgs)}</div>
),
...renderActivityArgs
)}
</div>
);
} else if (/^2/.test(activity.id)) {
return (children, ...renderAttachmentArgs) =>
renderActivity(
(...renderAttachmentArgs) => {
const [firstArg] = renderAttachmentArgs;
const {
attachment,
attachment: { contentType }
} = firstArg;
if (/^image\//.test(contentType)) {
return (
<figure className="attachment-figure">
{children(...renderAttachmentArgs)}
<figcaption className="attachment-figure-caption">
{children(
{
...firstArg,
attachment: {
...attachment,
contentType: 'application/octet-stream'
}
},
...renderAttachmentArgs
)}
</figcaption>
</figure>
);
}
return children(...renderAttachmentArgs);
},
...renderActivityArgs
);
}
return renderActivity;
};
WebChat.renderWebChat(
{
activityMiddleware,
directLine: await testHelpers.createDirectLineWithTranscript([
{
attachmentLayout: 'carousel',
attachments: [
{
contentType: 'image/jpeg',
contentUrl:
'https://raw.githubusercontent.com/compulim/BotFramework-MockBot/master/public/assets/surface1.jpg'
},
{
contentType: 'image/jpeg',
contentUrl:
'https://raw.githubusercontent.com/compulim/BotFramework-MockBot/master/public/assets/surface2.jpg'
}
],
from: {
role: 'bot'
},
id: '1.0',
text: 'Decorating activity of **carousel layout**. Also decorate attachment without using attachment middleware.',
timestamp: 0,
type: 'message'
},
{
attachments: [
{
contentType: 'image/jpeg',
contentUrl:
'https://raw.githubusercontent.com/compulim/BotFramework-MockBot/master/public/assets/surface3.jpg'
}
],
from: {
role: 'bot'
},
id: '1.1',
text: 'Decorating activity of **stacked layout**. Also decorate attachment without using attachment middleware.',
timestamp: 0,
type: 'message'
},
{
attachmentLayout: 'carousel',
attachments: [
{
contentType: 'image/jpeg',
contentUrl:
'https://raw.githubusercontent.com/compulim/BotFramework-MockBot/master/public/assets/surface1.jpg',
name: 'surface1.jpg'
},
{
contentType: 'image/jpeg',
contentUrl:
'https://raw.githubusercontent.com/compulim/BotFramework-MockBot/master/public/assets/surface2.jpg',
name: 'surface2.jpg'
}
],
from: {
role: 'bot'
},
id: '2.10',
text: 'Rendering attachment twice by calling downstreamer twice, in **carousel layout**.',
timestamp: 0,
type: 'message'
},
{
attachments: [
{
contentType: 'image/jpeg',
contentUrl:
'https://raw.githubusercontent.com/compulim/BotFramework-MockBot/master/public/assets/surface4.jpg',
name: 'surface4.jpg'
}
],
from: {
role: 'bot'
},
id: '2.1',
text: 'Rendering attachment twice by calling downstreamer twice, in **stacked layout**.',
timestamp: 0,
type: 'message'
}
]),
store: testHelpers.createStore()
},
document.getElementById('webchat')
);
await pageConditions.uiConnected();
await pageConditions.scrollToBottomCompleted();
await pageConditions.allImagesLoaded();
await host.snapshot('local');
});
</script>
</body>
</html>