@kindly/react-chat 2.48.2 β 2.48.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +40 -40
- package/.storybook/main.js +0 -56
- package/.storybook/preview.js +0 -119
- package/stories/.eslintrc +0 -11
- package/stories/assets/settingsJson.js +0 -472
- package/stories/decorators/withContainer.js +0 -13
- package/stories/decorators/withProvider.js +0 -22
- package/stories/screens.stories/Chat/Composer.stories.jsx +0 -174
- package/stories/screens.stories/Chat/DateTime.stories.jsx +0 -136
- package/stories/screens.stories/Chat/FormStates.stories.jsx +0 -669
- package/stories/screens.stories/Chat/ImageCarousel.stories.jsx +0 -203
- package/stories/screens.stories/Chat/Notifications.stories.jsx +0 -184
- package/stories/screens.stories/Chat/TypingIndicator.stories.jsx +0 -143
- package/stories/screens.stories/Chat/index.stories.jsx +0 -798
- package/stories/screens.stories/ClosedButton.stories.jsx +0 -99
- package/stories/screens.stories/Feedback.stories.jsx +0 -108
- package/stories/screens.stories/Nudge.stories.jsx +0 -123
- package/stories/screens.stories/Options.stories.jsx +0 -220
- package/stories/screens.stories/PushGreeting.stories.jsx +0 -81
- package/stories/screens.stories/StartChat.stories.jsx +0 -109
- package/stories/utils/wait.js +0 -2
|
@@ -1,798 +0,0 @@
|
|
|
1
|
-
import { expect } from '@storybook/jest';
|
|
2
|
-
import { fireEvent, userEvent, waitFor, within } from '@storybook/testing-library';
|
|
3
|
-
import MockDate from 'mockdate';
|
|
4
|
-
import React from 'react';
|
|
5
|
-
|
|
6
|
-
import { HANDLERS } from 'app/constants';
|
|
7
|
-
|
|
8
|
-
import { chromaticViewports } from '../../../.storybook/preview';
|
|
9
|
-
import KindlyChatButton from '../../../src/features/KindlyChatButton/KindlyChatButton';
|
|
10
|
-
import mockMessage from '../../../testing/mockMessage';
|
|
11
|
-
import settingsJSON from '../../assets/settingsJson';
|
|
12
|
-
import withContainer from '../../decorators/withContainer';
|
|
13
|
-
import withMockProvider from '../../decorators/withProvider';
|
|
14
|
-
import wait from '../../utils/wait';
|
|
15
|
-
|
|
16
|
-
MockDate.set(0);
|
|
17
|
-
|
|
18
|
-
const defaultBotSettings = {
|
|
19
|
-
welcomePage: settingsJSON.welcome_page,
|
|
20
|
-
feedbackForm: settingsJSON.feedback_form,
|
|
21
|
-
maintenanceAlert: settingsJSON.maintenance_alert,
|
|
22
|
-
...settingsJSON.settings,
|
|
23
|
-
...settingsJSON,
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
function Template(args, context) {
|
|
27
|
-
return <KindlyChatButton {...args} {...context} />;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export default {
|
|
31
|
-
title: 'Screen/Chat',
|
|
32
|
-
component: KindlyChatButton,
|
|
33
|
-
decorators: [withContainer, withMockProvider],
|
|
34
|
-
argTypes: {
|
|
35
|
-
initialStateModifierFromArgs: {
|
|
36
|
-
table: {
|
|
37
|
-
disable: true,
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
|
|
43
|
-
const todayTime = new Date();
|
|
44
|
-
todayTime.setHours(13);
|
|
45
|
-
todayTime.setMinutes(37);
|
|
46
|
-
const created = todayTime.toISOString();
|
|
47
|
-
|
|
48
|
-
const defaultParameters = {
|
|
49
|
-
botSettings: defaultBotSettings,
|
|
50
|
-
initialStateModifier: {
|
|
51
|
-
chatbubble: {
|
|
52
|
-
active: true,
|
|
53
|
-
chatHasStarted: true,
|
|
54
|
-
currentLanguage: 'en',
|
|
55
|
-
},
|
|
56
|
-
messages: {
|
|
57
|
-
chatMessages: [
|
|
58
|
-
{
|
|
59
|
-
session_id: '1',
|
|
60
|
-
bot_id: 1234,
|
|
61
|
-
chat_id: '1',
|
|
62
|
-
chat_source: 'web',
|
|
63
|
-
chat_language_code: 'en',
|
|
64
|
-
from_bot: true,
|
|
65
|
-
sender: 'BOT',
|
|
66
|
-
message:
|
|
67
|
-
"Hi! I'm Kindly's Chatbot. I can answer questions about Kindly and our services. How can I help you? π\n<br>\n<br>Feel free to ask me a short and concise question!",
|
|
68
|
-
message_format: 'txt',
|
|
69
|
-
exchange_type: 'greeting',
|
|
70
|
-
exchange_id: '1',
|
|
71
|
-
reply_type: 'STANDARD',
|
|
72
|
-
created,
|
|
73
|
-
id: '1',
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
id: '2',
|
|
77
|
-
created,
|
|
78
|
-
message: 'What is the meaning of life?',
|
|
79
|
-
status: null,
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
session_id: '6061c1d4-54da-4886-85a2-7f555c9cd42c',
|
|
83
|
-
bot_id: 3875,
|
|
84
|
-
chat_id: '1',
|
|
85
|
-
chat_source: 'web',
|
|
86
|
-
chat_language_code: 'en',
|
|
87
|
-
from_bot: true,
|
|
88
|
-
sender: 'BOT',
|
|
89
|
-
reply_to_id: '2',
|
|
90
|
-
last_user_message_id: '2',
|
|
91
|
-
message:
|
|
92
|
-
'Well... I don\'t have a conclusive answer for what the meaning of life is, but here are some suggestions:\n<ul style="padding-left:12px;">\n<li>To live a good life\n<li>To spread love\n<li>42\n</ul>',
|
|
93
|
-
message_format: 'txt',
|
|
94
|
-
exchange_type: 'usersays',
|
|
95
|
-
exchange_id: '3',
|
|
96
|
-
title: 'The meaning of life',
|
|
97
|
-
created,
|
|
98
|
-
id: '3',
|
|
99
|
-
},
|
|
100
|
-
],
|
|
101
|
-
messageSentTime: '2020-12-01T12:00:00.000Z',
|
|
102
|
-
lastMessageSeen: {
|
|
103
|
-
id: '3',
|
|
104
|
-
index: 3,
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
},
|
|
108
|
-
};
|
|
109
|
-
|
|
110
|
-
export const Regular = Template.bind({});
|
|
111
|
-
Regular.parameters = {
|
|
112
|
-
...defaultParameters,
|
|
113
|
-
chromatic: { viewports: chromaticViewports },
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
export const Announcement = Template.bind({});
|
|
117
|
-
Announcement.args = {
|
|
118
|
-
type: 'WARNING',
|
|
119
|
-
text: 'You seem to be offline, please check your internet connection',
|
|
120
|
-
initialStateModifierFromArgs: ({ type, text }) => ({
|
|
121
|
-
...defaultParameters.initialStateModifier,
|
|
122
|
-
announcement: {
|
|
123
|
-
show: true,
|
|
124
|
-
type,
|
|
125
|
-
text,
|
|
126
|
-
},
|
|
127
|
-
}),
|
|
128
|
-
};
|
|
129
|
-
Announcement.argTypes = {
|
|
130
|
-
type: {
|
|
131
|
-
options: ['WARNING', 'CRITICAL'],
|
|
132
|
-
control: {
|
|
133
|
-
type: 'select',
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
};
|
|
137
|
-
Announcement.parameters = {
|
|
138
|
-
botSettings: defaultBotSettings,
|
|
139
|
-
};
|
|
140
|
-
|
|
141
|
-
export const HiddenInput = Template.bind({});
|
|
142
|
-
HiddenInput.parameters = {
|
|
143
|
-
botSettings: defaultBotSettings,
|
|
144
|
-
initialStateModifier: {
|
|
145
|
-
chatbubble: {
|
|
146
|
-
active: true,
|
|
147
|
-
chatHasStarted: true,
|
|
148
|
-
currentLanguage: 'en',
|
|
149
|
-
hideInputField: true,
|
|
150
|
-
},
|
|
151
|
-
messages: {
|
|
152
|
-
chatMessages: [
|
|
153
|
-
{
|
|
154
|
-
id: '1',
|
|
155
|
-
chat_source: 'web',
|
|
156
|
-
chat_language_code: 'en',
|
|
157
|
-
from_bot: true,
|
|
158
|
-
sender: 'BOT',
|
|
159
|
-
message: 'Here is a button',
|
|
160
|
-
message_format: 'txt',
|
|
161
|
-
buttons: [
|
|
162
|
-
{
|
|
163
|
-
id: '1',
|
|
164
|
-
button_type: 'quick_reply',
|
|
165
|
-
language_code: 'en',
|
|
166
|
-
label: 'Click here to continue',
|
|
167
|
-
value: 'clicked',
|
|
168
|
-
index: 0,
|
|
169
|
-
created,
|
|
170
|
-
is_active: true,
|
|
171
|
-
},
|
|
172
|
-
],
|
|
173
|
-
created,
|
|
174
|
-
title: 'noinput',
|
|
175
|
-
chatbubble_hide_input_field: true,
|
|
176
|
-
},
|
|
177
|
-
],
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
|
-
};
|
|
181
|
-
|
|
182
|
-
export const MimirBotMessage = Template.bind({});
|
|
183
|
-
|
|
184
|
-
MimirBotMessage.storyName = 'Mimir Message';
|
|
185
|
-
MimirBotMessage.parameters = {
|
|
186
|
-
...defaultParameters,
|
|
187
|
-
botSettings: {
|
|
188
|
-
...defaultBotSettings,
|
|
189
|
-
typing_duration: 0,
|
|
190
|
-
},
|
|
191
|
-
initialStateModifier: {
|
|
192
|
-
...defaultParameters.initialStateModifier,
|
|
193
|
-
},
|
|
194
|
-
};
|
|
195
|
-
|
|
196
|
-
MimirBotMessage.args = {
|
|
197
|
-
gptSearchResultText: settingsJSON.text.gpt_search_result_text.en,
|
|
198
|
-
gptTooltipDisclaimer: settingsJSON.text.gpt_tooltip_disclaimer.en,
|
|
199
|
-
initialStateModifierFromArgs: ({ gptSearchResultText, gptTooltipDisclaimer }) => {
|
|
200
|
-
return {
|
|
201
|
-
...defaultParameters.initialStateModifier,
|
|
202
|
-
bot: {
|
|
203
|
-
text: {
|
|
204
|
-
gpt_search_result_text: {
|
|
205
|
-
en: gptSearchResultText,
|
|
206
|
-
},
|
|
207
|
-
gpt_tooltip_disclaimer: {
|
|
208
|
-
en: gptTooltipDisclaimer,
|
|
209
|
-
},
|
|
210
|
-
},
|
|
211
|
-
},
|
|
212
|
-
messages: {
|
|
213
|
-
chatMessages: [
|
|
214
|
-
{
|
|
215
|
-
from_bot: true,
|
|
216
|
-
sender: 'BOT',
|
|
217
|
-
handler: HANDLERS.MIMIR,
|
|
218
|
-
message: 'This is a message from Mimir, our KindlyGPT bot.',
|
|
219
|
-
created,
|
|
220
|
-
key: '1',
|
|
221
|
-
id: '1',
|
|
222
|
-
},
|
|
223
|
-
],
|
|
224
|
-
},
|
|
225
|
-
};
|
|
226
|
-
},
|
|
227
|
-
};
|
|
228
|
-
|
|
229
|
-
MimirBotMessage.argTypes = {
|
|
230
|
-
gptSearchResultText: 'string',
|
|
231
|
-
gptTooltipDisclaimer: 'string',
|
|
232
|
-
};
|
|
233
|
-
|
|
234
|
-
MimirBotMessage.play = async ({ canvasElement }) => {
|
|
235
|
-
await within(canvasElement).findByTestId('chat-body-container');
|
|
236
|
-
|
|
237
|
-
const tooltip = await within(canvasElement).findByTestId('tooltip');
|
|
238
|
-
fireEvent.mouseEnter(tooltip);
|
|
239
|
-
|
|
240
|
-
const tooltipMessage = await within(canvasElement).findByTestId('tooltip-text');
|
|
241
|
-
|
|
242
|
-
expect(tooltipMessage).toBeInTheDocument();
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
export const MultilineBotMessage = Template.bind({});
|
|
246
|
-
const MESSAGES = {
|
|
247
|
-
single: 'Single-line lonely message',
|
|
248
|
-
double: "Double-line message \n\n vibin'",
|
|
249
|
-
multi: 'This is a \n\n three-multiline \n\n message',
|
|
250
|
-
};
|
|
251
|
-
MultilineBotMessage.storyName = 'Multiline Bot & User Messages';
|
|
252
|
-
MultilineBotMessage.parameters = {
|
|
253
|
-
...Regular.parameters,
|
|
254
|
-
botSettings: {
|
|
255
|
-
...defaultBotSettings,
|
|
256
|
-
typing_duration: 0,
|
|
257
|
-
},
|
|
258
|
-
initialStateModifier: {
|
|
259
|
-
...defaultParameters.initialStateModifier,
|
|
260
|
-
messages: {
|
|
261
|
-
chatMessages: [
|
|
262
|
-
{
|
|
263
|
-
from_bot: true,
|
|
264
|
-
sender: 'BOT',
|
|
265
|
-
message: MESSAGES.single,
|
|
266
|
-
created,
|
|
267
|
-
id: '1',
|
|
268
|
-
},
|
|
269
|
-
{
|
|
270
|
-
from_bot: true,
|
|
271
|
-
sender: 'BOT',
|
|
272
|
-
message: MESSAGES.double,
|
|
273
|
-
created,
|
|
274
|
-
id: '2',
|
|
275
|
-
},
|
|
276
|
-
{
|
|
277
|
-
from_bot: true,
|
|
278
|
-
sender: 'BOT',
|
|
279
|
-
message: MESSAGES.multi,
|
|
280
|
-
created,
|
|
281
|
-
id: '3',
|
|
282
|
-
},
|
|
283
|
-
{
|
|
284
|
-
from_bot: false,
|
|
285
|
-
sender: 'USER',
|
|
286
|
-
message: MESSAGES.single,
|
|
287
|
-
created,
|
|
288
|
-
id: '1',
|
|
289
|
-
},
|
|
290
|
-
{
|
|
291
|
-
from_bot: false,
|
|
292
|
-
sender: 'USER',
|
|
293
|
-
message: MESSAGES.double,
|
|
294
|
-
created,
|
|
295
|
-
id: '2',
|
|
296
|
-
},
|
|
297
|
-
{
|
|
298
|
-
from_bot: false,
|
|
299
|
-
sender: 'USER',
|
|
300
|
-
message: MESSAGES.multi,
|
|
301
|
-
created,
|
|
302
|
-
id: '3',
|
|
303
|
-
},
|
|
304
|
-
],
|
|
305
|
-
},
|
|
306
|
-
},
|
|
307
|
-
};
|
|
308
|
-
|
|
309
|
-
MultilineBotMessage.play = async ({ canvasElement }) => {
|
|
310
|
-
const chatBody = await within(canvasElement).findByTestId('chat-body-container');
|
|
311
|
-
await within(canvasElement).findAllByText('Single-line lonely message');
|
|
312
|
-
// wait for the auto-scroll to execute
|
|
313
|
-
await wait(300);
|
|
314
|
-
|
|
315
|
-
// Some screen sizes won't have a scrollbar
|
|
316
|
-
const hasScrollbar = chatBody.scrollTop > 0;
|
|
317
|
-
|
|
318
|
-
if (hasScrollbar) {
|
|
319
|
-
fireEvent.scroll(chatBody, { target: { scrollTop: 0 } });
|
|
320
|
-
|
|
321
|
-
const chatNewMessage = await within(canvasElement).findByTestId('chat-new-message');
|
|
322
|
-
expect(chatNewMessage).not.toBeVisible();
|
|
323
|
-
|
|
324
|
-
await waitFor(
|
|
325
|
-
async () => {
|
|
326
|
-
await expect(chatNewMessage).toBeVisible();
|
|
327
|
-
},
|
|
328
|
-
{ timeout: 5000 },
|
|
329
|
-
);
|
|
330
|
-
}
|
|
331
|
-
};
|
|
332
|
-
|
|
333
|
-
export const NewUnreadMessages = Template.bind({});
|
|
334
|
-
NewUnreadMessages.parameters = MultilineBotMessage.parameters;
|
|
335
|
-
NewUnreadMessages.play = async ({ canvasElement }) => {
|
|
336
|
-
const chatBody = await within(canvasElement).findByTestId('chat-body-container');
|
|
337
|
-
// wait for the auto-scroll to execute
|
|
338
|
-
await wait(300);
|
|
339
|
-
|
|
340
|
-
// Some screen sizes won't have a scrollbar
|
|
341
|
-
const hasScrollbar = chatBody.scrollTop > 0;
|
|
342
|
-
|
|
343
|
-
if (hasScrollbar) {
|
|
344
|
-
fireEvent.scroll(chatBody, { target: { scrollTop: 0 } });
|
|
345
|
-
const chatNewMessage = await within(canvasElement).findByTestId('chat-new-message');
|
|
346
|
-
|
|
347
|
-
await waitFor(
|
|
348
|
-
async () => {
|
|
349
|
-
await expect(chatNewMessage).toBeVisible();
|
|
350
|
-
},
|
|
351
|
-
{ timeout: 5000 },
|
|
352
|
-
);
|
|
353
|
-
mockMessage(window.store, 'This is a new message');
|
|
354
|
-
|
|
355
|
-
await waitFor(
|
|
356
|
-
async () => {
|
|
357
|
-
await expect(chatNewMessage).toHaveTextContent('This is a new message');
|
|
358
|
-
},
|
|
359
|
-
{ timeout: 5000 },
|
|
360
|
-
);
|
|
361
|
-
}
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
export const GroupsOfMessages = Template.bind({});
|
|
365
|
-
GroupsOfMessages.parameters = {
|
|
366
|
-
botSettings: defaultBotSettings,
|
|
367
|
-
initialStateModifier: {
|
|
368
|
-
chatbubble: {
|
|
369
|
-
active: true,
|
|
370
|
-
chatHasStarted: true,
|
|
371
|
-
currentLanguage: 'en',
|
|
372
|
-
},
|
|
373
|
-
messages: {
|
|
374
|
-
chatMessages: [
|
|
375
|
-
{
|
|
376
|
-
id: '1',
|
|
377
|
-
created,
|
|
378
|
-
message: 'Hipp',
|
|
379
|
-
status: null,
|
|
380
|
-
},
|
|
381
|
-
{
|
|
382
|
-
id: '2',
|
|
383
|
-
created,
|
|
384
|
-
message: 'Hipp',
|
|
385
|
-
status: null,
|
|
386
|
-
},
|
|
387
|
-
{
|
|
388
|
-
id: '3',
|
|
389
|
-
created,
|
|
390
|
-
message: 'Hurra!',
|
|
391
|
-
status: null,
|
|
392
|
-
},
|
|
393
|
-
{
|
|
394
|
-
id: '4',
|
|
395
|
-
from_bot: true,
|
|
396
|
-
sender: 'BOT',
|
|
397
|
-
message: 'Hipp',
|
|
398
|
-
created,
|
|
399
|
-
},
|
|
400
|
-
{
|
|
401
|
-
id: '5',
|
|
402
|
-
from_bot: true,
|
|
403
|
-
sender: 'BOT',
|
|
404
|
-
message: 'Hipp',
|
|
405
|
-
created,
|
|
406
|
-
},
|
|
407
|
-
{
|
|
408
|
-
id: '6',
|
|
409
|
-
from_bot: true,
|
|
410
|
-
sender: 'BOT',
|
|
411
|
-
message: 'Hurra!',
|
|
412
|
-
created,
|
|
413
|
-
},
|
|
414
|
-
],
|
|
415
|
-
},
|
|
416
|
-
},
|
|
417
|
-
};
|
|
418
|
-
|
|
419
|
-
export const HandoverRequested = Template.bind({});
|
|
420
|
-
HandoverRequested.parameters = {
|
|
421
|
-
botSettings: defaultBotSettings,
|
|
422
|
-
initialStateModifier: {
|
|
423
|
-
chatbubble: {
|
|
424
|
-
active: true,
|
|
425
|
-
chatHasStarted: true,
|
|
426
|
-
currentLanguage: 'en',
|
|
427
|
-
},
|
|
428
|
-
agent: {
|
|
429
|
-
requestedTakeover: true,
|
|
430
|
-
takeoverClosed: false,
|
|
431
|
-
},
|
|
432
|
-
messages: {
|
|
433
|
-
chatMessages: [
|
|
434
|
-
{
|
|
435
|
-
id: '1',
|
|
436
|
-
created,
|
|
437
|
-
message: 'Could I please talk with a human person?',
|
|
438
|
-
status: null,
|
|
439
|
-
},
|
|
440
|
-
],
|
|
441
|
-
},
|
|
442
|
-
},
|
|
443
|
-
};
|
|
444
|
-
|
|
445
|
-
export const HandoverCancelled = Template.bind({});
|
|
446
|
-
HandoverCancelled.parameters = HandoverRequested.parameters;
|
|
447
|
-
HandoverCancelled.play = async ({ canvasElement }) => {
|
|
448
|
-
await within(canvasElement).findByText(defaultBotSettings.text.takeover_queue_text.en);
|
|
449
|
-
const leaveQueueButton = await within(canvasElement).findByText(defaultBotSettings.text.takeover_queue_link.en);
|
|
450
|
-
await userEvent.click(leaveQueueButton);
|
|
451
|
-
await within(canvasElement).findByText(defaultBotSettings.text.leave_queue_text.en);
|
|
452
|
-
};
|
|
453
|
-
|
|
454
|
-
export const Checkbox = Template.bind({});
|
|
455
|
-
Checkbox.parameters = {
|
|
456
|
-
...defaultParameters,
|
|
457
|
-
initialStateModifier: {
|
|
458
|
-
...defaultParameters.initialStateModifier,
|
|
459
|
-
messages: {
|
|
460
|
-
chatMessages: [
|
|
461
|
-
{
|
|
462
|
-
chat_language_code: 'en',
|
|
463
|
-
from_bot: true,
|
|
464
|
-
sender: 'BOT',
|
|
465
|
-
message: 'Check out those checkboxes!',
|
|
466
|
-
message_format: 'txt',
|
|
467
|
-
buttons: [
|
|
468
|
-
{
|
|
469
|
-
id: '1',
|
|
470
|
-
button_type: 'checkbox',
|
|
471
|
-
language_code: 'en',
|
|
472
|
-
label: 'Checkbox label',
|
|
473
|
-
value: 'Checkbox value',
|
|
474
|
-
index: 0,
|
|
475
|
-
is_active: true,
|
|
476
|
-
},
|
|
477
|
-
{
|
|
478
|
-
id: '2',
|
|
479
|
-
button_type: 'checkbox',
|
|
480
|
-
language_code: 'en',
|
|
481
|
-
label: 'Checkbox label 2',
|
|
482
|
-
value: 'Checkbox value 2',
|
|
483
|
-
index: 1,
|
|
484
|
-
is_active: true,
|
|
485
|
-
},
|
|
486
|
-
{
|
|
487
|
-
id: '3',
|
|
488
|
-
button_type: 'submit',
|
|
489
|
-
language_code: 'en',
|
|
490
|
-
label: 'Submit',
|
|
491
|
-
index: 2,
|
|
492
|
-
is_active: true,
|
|
493
|
-
},
|
|
494
|
-
],
|
|
495
|
-
created,
|
|
496
|
-
},
|
|
497
|
-
],
|
|
498
|
-
},
|
|
499
|
-
},
|
|
500
|
-
};
|
|
501
|
-
|
|
502
|
-
export const Fallback = Template.bind({});
|
|
503
|
-
Fallback.parameters = {
|
|
504
|
-
...defaultParameters,
|
|
505
|
-
initialStateModifier: {
|
|
506
|
-
...defaultParameters.initialStateModifier,
|
|
507
|
-
messages: {
|
|
508
|
-
chatMessages: [
|
|
509
|
-
{
|
|
510
|
-
id: '0',
|
|
511
|
-
created,
|
|
512
|
-
message: 'What does recursive mean?',
|
|
513
|
-
status: null,
|
|
514
|
-
},
|
|
515
|
-
{
|
|
516
|
-
id: '1',
|
|
517
|
-
from_bot: true,
|
|
518
|
-
sender: 'BOT',
|
|
519
|
-
reply_to_message: 'What does recursive mean?',
|
|
520
|
-
message: "I didn't quite understand this.",
|
|
521
|
-
exchange_type: 'fallback_suggestion',
|
|
522
|
-
title: "I didn't quite understand this.",
|
|
523
|
-
chatbubble_hide_input_field: true,
|
|
524
|
-
handler: 'FALLBACK_SUGGESTION',
|
|
525
|
-
suggestions: [
|
|
526
|
-
{
|
|
527
|
-
preface: 'Did you mean:',
|
|
528
|
-
message: 'What does recursive mean?',
|
|
529
|
-
buttons: [
|
|
530
|
-
{
|
|
531
|
-
id: '2',
|
|
532
|
-
label: 'Yes',
|
|
533
|
-
value: '1',
|
|
534
|
-
button_type: 'suggestion_dialogue_trigger',
|
|
535
|
-
is_active: true,
|
|
536
|
-
},
|
|
537
|
-
{
|
|
538
|
-
id: '2',
|
|
539
|
-
label: 'No',
|
|
540
|
-
value: 'SUGGESTION_FALLBACK',
|
|
541
|
-
exchange_id: 'SUGGESTION_FALLBACK',
|
|
542
|
-
button_type: 'suggestion_dialogue_trigger',
|
|
543
|
-
is_active: true,
|
|
544
|
-
},
|
|
545
|
-
],
|
|
546
|
-
},
|
|
547
|
-
],
|
|
548
|
-
created,
|
|
549
|
-
},
|
|
550
|
-
{
|
|
551
|
-
from_bot: true,
|
|
552
|
-
sender: 'BOT',
|
|
553
|
-
reply_to_message: 'π
[Fallback suggestion dismissed by user]',
|
|
554
|
-
message:
|
|
555
|
-
"I'm having trouble understanding what you mean. Feel free to rephrase your question and remember that I understand short and precise sentences the best.",
|
|
556
|
-
exchange_type: 'fallback',
|
|
557
|
-
title: 'π
[Fallback suggestion dismissed by user]',
|
|
558
|
-
handler: 'FALLBACK',
|
|
559
|
-
created,
|
|
560
|
-
id: '2',
|
|
561
|
-
},
|
|
562
|
-
],
|
|
563
|
-
},
|
|
564
|
-
},
|
|
565
|
-
};
|
|
566
|
-
|
|
567
|
-
export const Slider = Template.bind({});
|
|
568
|
-
Slider.parameters = {
|
|
569
|
-
...defaultParameters,
|
|
570
|
-
initialStateModifier: {
|
|
571
|
-
...defaultParameters.initialStateModifier,
|
|
572
|
-
messages: {
|
|
573
|
-
chatMessages: [
|
|
574
|
-
{
|
|
575
|
-
chat_source: 'web',
|
|
576
|
-
chat_language_code: 'en',
|
|
577
|
-
from_bot: true,
|
|
578
|
-
sender: 'BOT',
|
|
579
|
-
message: 'Slide me!',
|
|
580
|
-
message_format: 'txt',
|
|
581
|
-
buttons: [
|
|
582
|
-
{
|
|
583
|
-
id: '1',
|
|
584
|
-
button_type: 'slider',
|
|
585
|
-
language_code: 'en',
|
|
586
|
-
label: 'Choose a value between 1 and 42',
|
|
587
|
-
index: 0,
|
|
588
|
-
slider_details: {
|
|
589
|
-
id: '1',
|
|
590
|
-
from_value: 1,
|
|
591
|
-
to_value: 42,
|
|
592
|
-
step_value: 1,
|
|
593
|
-
value: 10,
|
|
594
|
-
affix: 'SUFFIX',
|
|
595
|
-
affix_value: '%',
|
|
596
|
-
},
|
|
597
|
-
},
|
|
598
|
-
{
|
|
599
|
-
id: '2',
|
|
600
|
-
button_type: 'submit',
|
|
601
|
-
language_code: 'en',
|
|
602
|
-
label: 'Submit',
|
|
603
|
-
value: '1',
|
|
604
|
-
index: 1,
|
|
605
|
-
},
|
|
606
|
-
],
|
|
607
|
-
created,
|
|
608
|
-
title: 'slider',
|
|
609
|
-
id: '1',
|
|
610
|
-
},
|
|
611
|
-
],
|
|
612
|
-
},
|
|
613
|
-
},
|
|
614
|
-
};
|
|
615
|
-
|
|
616
|
-
const videoSources = [
|
|
617
|
-
['YouTube', 'https://www.youtube.com/watch?v=vvg5AfQEmUc'],
|
|
618
|
-
['Vimeo', 'https://vimeo.com/153882097'],
|
|
619
|
-
['Self hosted', 'https://www.crockpot.se/wp-content/uploads/2019/02/Comp-1-1.mp4'],
|
|
620
|
-
];
|
|
621
|
-
export const VideoEmbed = Template.bind({});
|
|
622
|
-
VideoEmbed.args = {
|
|
623
|
-
videoSource: videoSources[0][0],
|
|
624
|
-
videoSourceList: videoSources,
|
|
625
|
-
initialStateModifierFromArgs: ({ videoSource, videoSourceList }) => ({
|
|
626
|
-
...defaultParameters.initialStateModifier,
|
|
627
|
-
messages: {
|
|
628
|
-
chatMessages: [
|
|
629
|
-
{
|
|
630
|
-
id: '1',
|
|
631
|
-
chat_language_code: 'en',
|
|
632
|
-
from_bot: true,
|
|
633
|
-
sender: 'BOT',
|
|
634
|
-
message: 'Here is Video embed',
|
|
635
|
-
message_format: 'txt',
|
|
636
|
-
video_source: videoSourceList.find((videoSourceMap) => videoSourceMap[0] === videoSource)[1],
|
|
637
|
-
title: 'embed',
|
|
638
|
-
created,
|
|
639
|
-
},
|
|
640
|
-
],
|
|
641
|
-
},
|
|
642
|
-
}),
|
|
643
|
-
};
|
|
644
|
-
VideoEmbed.argTypes = {
|
|
645
|
-
videoSource: {
|
|
646
|
-
options: videoSources.map((videoSource) => videoSource[0]),
|
|
647
|
-
control: { type: 'select' },
|
|
648
|
-
},
|
|
649
|
-
videoSourceList: {
|
|
650
|
-
table: {
|
|
651
|
-
disable: true,
|
|
652
|
-
},
|
|
653
|
-
},
|
|
654
|
-
};
|
|
655
|
-
VideoEmbed.parameters = {
|
|
656
|
-
botSettings: defaultBotSettings,
|
|
657
|
-
};
|
|
658
|
-
|
|
659
|
-
export const LeaveContactDetails = Template.bind({});
|
|
660
|
-
LeaveContactDetails.parameters = {
|
|
661
|
-
...defaultParameters,
|
|
662
|
-
initialStateModifier: {
|
|
663
|
-
...defaultParameters.initialStateModifier,
|
|
664
|
-
messages: {
|
|
665
|
-
chatMessages: [
|
|
666
|
-
{
|
|
667
|
-
id: '1',
|
|
668
|
-
chat_language_code: 'en',
|
|
669
|
-
from_bot: true,
|
|
670
|
-
sender: 'BOT',
|
|
671
|
-
message: "Let's get in touch!",
|
|
672
|
-
message_format: 'txt',
|
|
673
|
-
buttons: [
|
|
674
|
-
{
|
|
675
|
-
id: '1',
|
|
676
|
-
button_type: 'phone',
|
|
677
|
-
language_code: 'en',
|
|
678
|
-
label: 'Call us',
|
|
679
|
-
value: '69420',
|
|
680
|
-
index: 0,
|
|
681
|
-
is_active: true,
|
|
682
|
-
},
|
|
683
|
-
{
|
|
684
|
-
id: '2',
|
|
685
|
-
button_type: 'email',
|
|
686
|
-
language_code: 'en',
|
|
687
|
-
label: 'Email us',
|
|
688
|
-
value: "contact@kindly.ai?subject=Email%20from%20storybook&body=Don't%20send%20that!",
|
|
689
|
-
index: 1,
|
|
690
|
-
is_active: true,
|
|
691
|
-
email_details: {
|
|
692
|
-
id: '1',
|
|
693
|
-
subject: 'Email from storybook',
|
|
694
|
-
body: "Don't send that!",
|
|
695
|
-
},
|
|
696
|
-
},
|
|
697
|
-
{
|
|
698
|
-
id: '3',
|
|
699
|
-
button_type: 'contact_details',
|
|
700
|
-
label: 'Contact me back',
|
|
701
|
-
index: 2,
|
|
702
|
-
is_active: true,
|
|
703
|
-
contact_details: {
|
|
704
|
-
id: 'ae14453c-0156-40c9-a13a-0037f46bd14a',
|
|
705
|
-
contact_type: 'email',
|
|
706
|
-
label: 'Your email:',
|
|
707
|
-
edit_text: 'Edit email',
|
|
708
|
-
placeholder: 'me@example.com',
|
|
709
|
-
},
|
|
710
|
-
},
|
|
711
|
-
],
|
|
712
|
-
title: 'Contacts',
|
|
713
|
-
created,
|
|
714
|
-
},
|
|
715
|
-
],
|
|
716
|
-
},
|
|
717
|
-
},
|
|
718
|
-
};
|
|
719
|
-
LeaveContactDetails.play = async ({ canvasElement }) => {
|
|
720
|
-
const LeaveContactButton = await within(canvasElement).findByText(
|
|
721
|
-
LeaveContactDetails.parameters.initialStateModifier.messages.chatMessages[0].buttons[2].label,
|
|
722
|
-
);
|
|
723
|
-
await userEvent.click(LeaveContactButton);
|
|
724
|
-
const composer = await within(canvasElement).findByPlaceholderText(
|
|
725
|
-
LeaveContactDetails.parameters.initialStateModifier.messages.chatMessages[0].buttons[2].contact_details.placeholder,
|
|
726
|
-
);
|
|
727
|
-
await userEvent.type(composer, 'contact@example.com');
|
|
728
|
-
const submitButton = await within(canvasElement).getByTestId('send-contact-details-button');
|
|
729
|
-
await userEvent.click(submitButton);
|
|
730
|
-
const EditContactButton = await within(canvasElement).findByText(
|
|
731
|
-
LeaveContactDetails.parameters.initialStateModifier.messages.chatMessages[0].buttons[2].contact_details.edit_text,
|
|
732
|
-
);
|
|
733
|
-
await userEvent.click(EditContactButton);
|
|
734
|
-
};
|
|
735
|
-
|
|
736
|
-
export const MessageReference = Template.bind({});
|
|
737
|
-
MessageReference.parameters = {
|
|
738
|
-
botSettings: defaultBotSettings,
|
|
739
|
-
initialStateModifier: {
|
|
740
|
-
chatbubble: {
|
|
741
|
-
active: true,
|
|
742
|
-
chatHasStarted: true,
|
|
743
|
-
currentLanguage: 'en',
|
|
744
|
-
},
|
|
745
|
-
messages: {
|
|
746
|
-
chatMessages: [
|
|
747
|
-
{
|
|
748
|
-
...defaultParameters.initialStateModifier.messages.chatMessages[2],
|
|
749
|
-
message: 'Kahoot: Fun quizzes, big learning.\n\nPlay, learn, Kahoot!',
|
|
750
|
-
message_references: [{ url: 'http://example.com', offset: 19 }],
|
|
751
|
-
from_bot: true,
|
|
752
|
-
handler: 'MIMIR',
|
|
753
|
-
},
|
|
754
|
-
{
|
|
755
|
-
...defaultParameters.initialStateModifier.messages.chatMessages[1],
|
|
756
|
-
},
|
|
757
|
-
{
|
|
758
|
-
...defaultParameters.initialStateModifier.messages.chatMessages[2],
|
|
759
|
-
message:
|
|
760
|
-
"As a player in a Kahoot game, you cannot hide the answers of other players πͺπΏπ. The game is designed to display all answers on the host's screen and on individual player devices for transparency and fairness.",
|
|
761
|
-
message_references: [
|
|
762
|
-
{
|
|
763
|
-
url: 'http://example.com#1',
|
|
764
|
-
offset: 79,
|
|
765
|
-
},
|
|
766
|
-
{
|
|
767
|
-
url: 'http://example.com#2',
|
|
768
|
-
offset: 79,
|
|
769
|
-
},
|
|
770
|
-
{
|
|
771
|
-
url: 'http://example.com#3',
|
|
772
|
-
offset: 79,
|
|
773
|
-
},
|
|
774
|
-
{
|
|
775
|
-
url: 'http://example.com#2',
|
|
776
|
-
offset: 144,
|
|
777
|
-
},
|
|
778
|
-
{
|
|
779
|
-
url: 'http://example.com#4',
|
|
780
|
-
offset: 208,
|
|
781
|
-
},
|
|
782
|
-
{
|
|
783
|
-
url: 'http://example.com#1',
|
|
784
|
-
offset: 208,
|
|
785
|
-
},
|
|
786
|
-
],
|
|
787
|
-
from_bot: true,
|
|
788
|
-
handler: 'MIMIR',
|
|
789
|
-
},
|
|
790
|
-
],
|
|
791
|
-
messageSentTime: '2020-12-01T12:00:00.000Z',
|
|
792
|
-
lastMessageSeen: {
|
|
793
|
-
id: '3',
|
|
794
|
-
index: 3,
|
|
795
|
-
},
|
|
796
|
-
},
|
|
797
|
-
},
|
|
798
|
-
};
|