@kindly/react-chat 2.48.3 → 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,669 +0,0 @@
|
|
|
1
|
-
import { expect } from '@storybook/jest';
|
|
2
|
-
import { fireEvent, userEvent, within } from '@storybook/testing-library';
|
|
3
|
-
import React from 'react';
|
|
4
|
-
|
|
5
|
-
import { FIELDS } from '../../../src/components/Form/utils/constants';
|
|
6
|
-
import KindlyChatButton from '../../../src/features/KindlyChatButton/KindlyChatButton';
|
|
7
|
-
import settingsJSON from '../../assets/settingsJson';
|
|
8
|
-
import withContainer from '../../decorators/withContainer';
|
|
9
|
-
import withMockProvider from '../../decorators/withProvider';
|
|
10
|
-
import wait from '../../utils/wait';
|
|
11
|
-
|
|
12
|
-
const defaultBotSettings = {
|
|
13
|
-
welcomePage: settingsJSON.welcome_page,
|
|
14
|
-
feedbackForm: settingsJSON.feedback_form,
|
|
15
|
-
maintenanceAlert: settingsJSON.maintenance_alert,
|
|
16
|
-
...settingsJSON.settings,
|
|
17
|
-
...settingsJSON,
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export default {
|
|
21
|
-
title: 'Screen/Chat/Form',
|
|
22
|
-
component: KindlyChatButton,
|
|
23
|
-
decorators: [withContainer, withMockProvider],
|
|
24
|
-
argTypes: {
|
|
25
|
-
initialStateModifierFromArgs: {
|
|
26
|
-
table: {
|
|
27
|
-
disable: true,
|
|
28
|
-
},
|
|
29
|
-
},
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
const defaultParameters = {
|
|
34
|
-
botSettings: defaultBotSettings,
|
|
35
|
-
initialStateModifier: {
|
|
36
|
-
chatbubble: {
|
|
37
|
-
active: true,
|
|
38
|
-
chatHasStarted: true,
|
|
39
|
-
currentLanguage: 'en',
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
function Template(args, context) {
|
|
45
|
-
return <KindlyChatButton {...args} {...context} />;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
export const FormActive = Template.bind({});
|
|
49
|
-
FormActive.parameters = {
|
|
50
|
-
...defaultParameters,
|
|
51
|
-
initialStateModifier: {
|
|
52
|
-
...defaultParameters.initialStateModifier,
|
|
53
|
-
messages: {
|
|
54
|
-
chatMessages: [
|
|
55
|
-
{
|
|
56
|
-
chat_source: 'web',
|
|
57
|
-
chat_language_code: 'en',
|
|
58
|
-
from_bot: true,
|
|
59
|
-
sender: 'BOT',
|
|
60
|
-
message: '',
|
|
61
|
-
message_format: 'txt',
|
|
62
|
-
buttons: [],
|
|
63
|
-
created: '2022-06-15T19:03:46.186495Z',
|
|
64
|
-
id: '1',
|
|
65
|
-
form: {
|
|
66
|
-
submission_id: 'submissionId',
|
|
67
|
-
id: 'formId',
|
|
68
|
-
dialogue_id: '2',
|
|
69
|
-
submit_dialogue_id: 'c0d685d3-3f11-41b8-9cfd-e35d54df2c95',
|
|
70
|
-
abandon_dialogue_id: 'b1cde0f3-0715-48eb-8482-a9355fa11ba8',
|
|
71
|
-
languageCode: 'en',
|
|
72
|
-
texts: {
|
|
73
|
-
title: 'This is a form',
|
|
74
|
-
error_text: 'There was an error around here',
|
|
75
|
-
submit_button_text: 'Submit',
|
|
76
|
-
cancel_button_text: 'Exit',
|
|
77
|
-
unanswered_text: 'You failed to answer this form',
|
|
78
|
-
cancel_text: 'You have cancelled/exited this form',
|
|
79
|
-
},
|
|
80
|
-
fields: [
|
|
81
|
-
{
|
|
82
|
-
input_type: FIELDS.CHECKBOX,
|
|
83
|
-
order: 1,
|
|
84
|
-
required: true,
|
|
85
|
-
slug: 'checkbox-field',
|
|
86
|
-
attributes: {
|
|
87
|
-
options: [
|
|
88
|
-
{
|
|
89
|
-
value: 'volvo',
|
|
90
|
-
label: 'Volvo',
|
|
91
|
-
},
|
|
92
|
-
{
|
|
93
|
-
value: 'mercedes',
|
|
94
|
-
label: 'Mercedes',
|
|
95
|
-
},
|
|
96
|
-
{
|
|
97
|
-
value: 'audi',
|
|
98
|
-
label: 'Audi',
|
|
99
|
-
},
|
|
100
|
-
],
|
|
101
|
-
},
|
|
102
|
-
texts: {
|
|
103
|
-
label: 'Checkbox',
|
|
104
|
-
},
|
|
105
|
-
validators: [],
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
input_type: FIELDS.SELECT,
|
|
109
|
-
order: 2,
|
|
110
|
-
required: true,
|
|
111
|
-
slug: 'select-field',
|
|
112
|
-
attributes: {
|
|
113
|
-
default_value: '2',
|
|
114
|
-
options: [
|
|
115
|
-
{
|
|
116
|
-
value: '1',
|
|
117
|
-
label: 'One',
|
|
118
|
-
},
|
|
119
|
-
{
|
|
120
|
-
value: '2',
|
|
121
|
-
label: 'Two',
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
value: '3',
|
|
125
|
-
label: 'Three',
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
value: '4',
|
|
129
|
-
label: 'Four',
|
|
130
|
-
},
|
|
131
|
-
{
|
|
132
|
-
value: 'Very long message',
|
|
133
|
-
label: 'Very long message, this is a very long message',
|
|
134
|
-
},
|
|
135
|
-
],
|
|
136
|
-
},
|
|
137
|
-
texts: {
|
|
138
|
-
label: 'Select',
|
|
139
|
-
placeholder_text: 'Please select option',
|
|
140
|
-
},
|
|
141
|
-
validators: [],
|
|
142
|
-
},
|
|
143
|
-
{
|
|
144
|
-
input_type: FIELDS.TEXT,
|
|
145
|
-
order: 3,
|
|
146
|
-
slug: 'first-name-field',
|
|
147
|
-
texts: {
|
|
148
|
-
label: 'First name',
|
|
149
|
-
help_text: 'Please input your name here',
|
|
150
|
-
placeholder_text: 'First name',
|
|
151
|
-
// required_text: 'This field is absolutely required',
|
|
152
|
-
},
|
|
153
|
-
required: true,
|
|
154
|
-
validators: [
|
|
155
|
-
{
|
|
156
|
-
max_length: 30,
|
|
157
|
-
texts: {
|
|
158
|
-
text: 'Maximum number of length is 30',
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
],
|
|
162
|
-
},
|
|
163
|
-
{
|
|
164
|
-
input_type: FIELDS.TEXT,
|
|
165
|
-
order: 4,
|
|
166
|
-
slug: 'text-field',
|
|
167
|
-
texts: {
|
|
168
|
-
label: 'Text field',
|
|
169
|
-
placeholder_text: 'Free text',
|
|
170
|
-
required_text: 'This field is required',
|
|
171
|
-
},
|
|
172
|
-
required: true,
|
|
173
|
-
validators: [
|
|
174
|
-
{
|
|
175
|
-
min_length: 5,
|
|
176
|
-
texts: {
|
|
177
|
-
text: 'This field should be at least 5 characters long',
|
|
178
|
-
},
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
max_length: 15,
|
|
182
|
-
},
|
|
183
|
-
],
|
|
184
|
-
},
|
|
185
|
-
{
|
|
186
|
-
input_type: FIELDS.EMAIL,
|
|
187
|
-
order: 5,
|
|
188
|
-
slug: 'email-field',
|
|
189
|
-
texts: {
|
|
190
|
-
label: 'Email',
|
|
191
|
-
placeholder_text: 'Email',
|
|
192
|
-
},
|
|
193
|
-
},
|
|
194
|
-
{
|
|
195
|
-
input_type: FIELDS.NUMBER,
|
|
196
|
-
order: 6,
|
|
197
|
-
affix: 'PREFIX',
|
|
198
|
-
slug: 'number-field',
|
|
199
|
-
texts: {
|
|
200
|
-
label: 'Number',
|
|
201
|
-
affix_value: 'NOK',
|
|
202
|
-
placeholder_text: 'Number',
|
|
203
|
-
},
|
|
204
|
-
validators: [
|
|
205
|
-
{
|
|
206
|
-
minimum: 1,
|
|
207
|
-
},
|
|
208
|
-
{
|
|
209
|
-
maximum: 12,
|
|
210
|
-
},
|
|
211
|
-
],
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
input_type: FIELDS.RANGE,
|
|
215
|
-
order: 7,
|
|
216
|
-
affix: 'SUFFIX',
|
|
217
|
-
slug: 'range-field',
|
|
218
|
-
attributes: {
|
|
219
|
-
default_value: '50',
|
|
220
|
-
step: 10,
|
|
221
|
-
},
|
|
222
|
-
texts: {
|
|
223
|
-
label: 'Slider',
|
|
224
|
-
affix_value: 'NOK',
|
|
225
|
-
placeholder_text: 'Slider',
|
|
226
|
-
},
|
|
227
|
-
validators: [
|
|
228
|
-
{
|
|
229
|
-
minimum: 1,
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
maximum: 100,
|
|
233
|
-
},
|
|
234
|
-
],
|
|
235
|
-
},
|
|
236
|
-
],
|
|
237
|
-
},
|
|
238
|
-
},
|
|
239
|
-
],
|
|
240
|
-
},
|
|
241
|
-
},
|
|
242
|
-
};
|
|
243
|
-
FormActive.play = async ({ canvasElement }) => {
|
|
244
|
-
await within(canvasElement).findByText('Please input your name here', undefined, { timeout: 5000 });
|
|
245
|
-
const textPlaceholderValue = 'Free text';
|
|
246
|
-
const textInput = await within(canvasElement).findByPlaceholderText(textPlaceholderValue);
|
|
247
|
-
await userEvent.type(textInput, 'This');
|
|
248
|
-
await expect(textInput.value).toBe('This');
|
|
249
|
-
await fireEvent(await within(canvasElement).getByRole('button', { name: /submit/i }), new MouseEvent('click'));
|
|
250
|
-
// await within(canvasElement).findByText('This field is absolutely required');
|
|
251
|
-
await within(canvasElement).findByText('This field should be at least 5 characters long');
|
|
252
|
-
const textInputStyle = window.getComputedStyle(textInput);
|
|
253
|
-
expect(textInputStyle.border).not.toContain('#00000000');
|
|
254
|
-
expect(textInputStyle.border).not.toContain('transparent');
|
|
255
|
-
await userEvent.type(textInput, ' is too long');
|
|
256
|
-
await expect(textInput.value).toBe('This is too lon');
|
|
257
|
-
const emailPlaceholderValue = 'Email';
|
|
258
|
-
const emailInput = await within(canvasElement).findByPlaceholderText(emailPlaceholderValue);
|
|
259
|
-
await userEvent.type(emailInput, 'this@is@not@an@email');
|
|
260
|
-
|
|
261
|
-
const chatBody = await within(canvasElement).findByTestId('chat-body-container');
|
|
262
|
-
await wait(300); // wait for the autoscroll to finish, so we can bottom for the Chromatic snapshot
|
|
263
|
-
fireEvent.scroll(chatBody, { target: { scrollTop: chatBody.clientHeight } });
|
|
264
|
-
};
|
|
265
|
-
|
|
266
|
-
export const FormActive2 = Template.bind({});
|
|
267
|
-
FormActive2.parameters = {
|
|
268
|
-
...defaultParameters,
|
|
269
|
-
initialStateModifier: {
|
|
270
|
-
...defaultParameters.initialStateModifier,
|
|
271
|
-
messages: {
|
|
272
|
-
chatMessages: [
|
|
273
|
-
{
|
|
274
|
-
chat_source: 'web',
|
|
275
|
-
chat_language_code: 'en',
|
|
276
|
-
from_bot: true,
|
|
277
|
-
sender: 'BOT',
|
|
278
|
-
message: '',
|
|
279
|
-
message_format: 'txt',
|
|
280
|
-
buttons: [],
|
|
281
|
-
created: '2022-06-15T19:03:46.186495Z',
|
|
282
|
-
id: '1',
|
|
283
|
-
form: {
|
|
284
|
-
submission_id: 'submissionId',
|
|
285
|
-
id: 'formId',
|
|
286
|
-
dialogue_id: '2',
|
|
287
|
-
submit_dialogue_id: 'c0d685d3-3f11-41b8-9cfd-e35d54df2c95',
|
|
288
|
-
abandon_dialogue_id: 'b1cde0f3-0715-48eb-8482-a9355fa11ba8',
|
|
289
|
-
languageCode: 'en',
|
|
290
|
-
texts: {
|
|
291
|
-
title: 'This is a form',
|
|
292
|
-
error_text: 'There was an error around here',
|
|
293
|
-
submit_button_text: 'Submit',
|
|
294
|
-
cancel_button_text: 'Exit',
|
|
295
|
-
unanswered_text: 'You failed to answer this form',
|
|
296
|
-
cancel_text: 'You have cancelled/exited this form',
|
|
297
|
-
},
|
|
298
|
-
fields: [
|
|
299
|
-
{
|
|
300
|
-
input_type: FIELDS.SELECT,
|
|
301
|
-
order: 5,
|
|
302
|
-
required: true,
|
|
303
|
-
slug: 'select-field',
|
|
304
|
-
attributes: {
|
|
305
|
-
default_value: '2',
|
|
306
|
-
options: [
|
|
307
|
-
{
|
|
308
|
-
value: '1',
|
|
309
|
-
label: 'One',
|
|
310
|
-
},
|
|
311
|
-
{
|
|
312
|
-
value: '2',
|
|
313
|
-
label: 'Two',
|
|
314
|
-
},
|
|
315
|
-
{
|
|
316
|
-
value: '3',
|
|
317
|
-
label: 'Three',
|
|
318
|
-
},
|
|
319
|
-
{
|
|
320
|
-
value: '4',
|
|
321
|
-
label: 'Four',
|
|
322
|
-
},
|
|
323
|
-
{
|
|
324
|
-
value: 'Very long message',
|
|
325
|
-
label: 'Very long message, this is a very long message',
|
|
326
|
-
},
|
|
327
|
-
],
|
|
328
|
-
},
|
|
329
|
-
texts: {
|
|
330
|
-
label: 'Select',
|
|
331
|
-
placeholder_text: 'Please select option',
|
|
332
|
-
},
|
|
333
|
-
validators: [],
|
|
334
|
-
},
|
|
335
|
-
{
|
|
336
|
-
input_type: FIELDS.CHECKBOX,
|
|
337
|
-
order: 6,
|
|
338
|
-
required: true,
|
|
339
|
-
slug: 'checkbox-cars',
|
|
340
|
-
attributes: {
|
|
341
|
-
options: [
|
|
342
|
-
{
|
|
343
|
-
value: 'volvo',
|
|
344
|
-
label: 'Volvo',
|
|
345
|
-
},
|
|
346
|
-
{
|
|
347
|
-
value: 'mercedes',
|
|
348
|
-
label: 'Mercedes',
|
|
349
|
-
},
|
|
350
|
-
{
|
|
351
|
-
value: 'Very long text',
|
|
352
|
-
label:
|
|
353
|
-
'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.',
|
|
354
|
-
},
|
|
355
|
-
],
|
|
356
|
-
},
|
|
357
|
-
texts: {
|
|
358
|
-
label: 'Checkbox',
|
|
359
|
-
},
|
|
360
|
-
validators: [],
|
|
361
|
-
},
|
|
362
|
-
{
|
|
363
|
-
input_type: FIELDS.CHECKBOX,
|
|
364
|
-
order: 6,
|
|
365
|
-
required: true,
|
|
366
|
-
slug: 'checkbox-terms',
|
|
367
|
-
attributes: {
|
|
368
|
-
options: [
|
|
369
|
-
{
|
|
370
|
-
value: 'terms',
|
|
371
|
-
label: 'Terms and conditions',
|
|
372
|
-
},
|
|
373
|
-
],
|
|
374
|
-
},
|
|
375
|
-
texts: {
|
|
376
|
-
label: 'Accept our terms to continue',
|
|
377
|
-
},
|
|
378
|
-
validators: [],
|
|
379
|
-
},
|
|
380
|
-
],
|
|
381
|
-
},
|
|
382
|
-
},
|
|
383
|
-
],
|
|
384
|
-
},
|
|
385
|
-
},
|
|
386
|
-
};
|
|
387
|
-
FormActive2.play = async ({ canvasElement }) => {
|
|
388
|
-
await within(canvasElement).findByText('Submit', undefined, { timeout: 5000 });
|
|
389
|
-
await fireEvent(await within(canvasElement).getByRole('button', { name: /submit/i }), new MouseEvent('click'));
|
|
390
|
-
|
|
391
|
-
const selectPlaceholderValue = 'Please select option';
|
|
392
|
-
const selectInput = await within(canvasElement).findByPlaceholderText(selectPlaceholderValue);
|
|
393
|
-
const selectInputStyle = window.getComputedStyle(selectInput);
|
|
394
|
-
expect(selectInputStyle.border).not.toContain('#00000000');
|
|
395
|
-
expect(selectInputStyle.border).not.toContain('transparent');
|
|
396
|
-
await wait(10); // This fixes inconsistent test results due to composer autofocus
|
|
397
|
-
await userEvent.selectOptions(selectInput, 'Very long message');
|
|
398
|
-
await expect(selectInputStyle.border).toContain('rgba(0, 0, 0, 0)');
|
|
399
|
-
|
|
400
|
-
const checkboxTerms = await within(canvasElement).findByLabelText('Terms and conditions');
|
|
401
|
-
await userEvent.click(checkboxTerms);
|
|
402
|
-
|
|
403
|
-
const chatBody = await within(canvasElement).findByTestId('chat-body-container');
|
|
404
|
-
await wait(300); // wait for the autoscroll to finish, so we can bottom for the Chromatic snapshot
|
|
405
|
-
fireEvent.scroll(chatBody, { target: { scrollTop: chatBody.clientHeight } });
|
|
406
|
-
};
|
|
407
|
-
|
|
408
|
-
export const FormActive3 = Template.bind({});
|
|
409
|
-
FormActive3.parameters = {
|
|
410
|
-
...defaultParameters,
|
|
411
|
-
initialStateModifier: {
|
|
412
|
-
...defaultParameters.initialStateModifier,
|
|
413
|
-
messages: {
|
|
414
|
-
chatMessages: [
|
|
415
|
-
{
|
|
416
|
-
chat_source: 'web',
|
|
417
|
-
chat_language_code: 'en',
|
|
418
|
-
from_bot: true,
|
|
419
|
-
sender: 'BOT',
|
|
420
|
-
message: '',
|
|
421
|
-
message_format: 'txt',
|
|
422
|
-
buttons: [],
|
|
423
|
-
created: '2022-06-15T19:03:46.186495Z',
|
|
424
|
-
id: '1',
|
|
425
|
-
form: {
|
|
426
|
-
submission_id: 'submissionId',
|
|
427
|
-
id: 'formId',
|
|
428
|
-
dialogue_id: '2',
|
|
429
|
-
submit_dialogue_id: 'c0d685d3-3f11-41b8-9cfd-e35d54df2c95',
|
|
430
|
-
abandon_dialogue_id: 'b1cde0f3-0715-48eb-8482-a9355fa11ba8',
|
|
431
|
-
languageCode: 'en',
|
|
432
|
-
texts: {
|
|
433
|
-
title: 'This is a form',
|
|
434
|
-
error_text: 'There was an error around here',
|
|
435
|
-
submit_button_text: 'Submit',
|
|
436
|
-
cancel_button_text: 'Exit',
|
|
437
|
-
unanswered_text: 'You failed to answer this form',
|
|
438
|
-
cancel_text: 'You have cancelled/exited this form',
|
|
439
|
-
},
|
|
440
|
-
fields: [
|
|
441
|
-
{
|
|
442
|
-
input_type: FIELDS.RADIO,
|
|
443
|
-
order: 1,
|
|
444
|
-
required: true,
|
|
445
|
-
slug: 'radui-icecream-option',
|
|
446
|
-
attributes: {
|
|
447
|
-
options: [
|
|
448
|
-
{
|
|
449
|
-
value: 'chocolate',
|
|
450
|
-
label: 'Chocolate',
|
|
451
|
-
},
|
|
452
|
-
{
|
|
453
|
-
value: 'vanilla',
|
|
454
|
-
label: 'Vanilla',
|
|
455
|
-
},
|
|
456
|
-
],
|
|
457
|
-
},
|
|
458
|
-
texts: {
|
|
459
|
-
label: 'Please select an icecream flavour.',
|
|
460
|
-
},
|
|
461
|
-
validators: [],
|
|
462
|
-
},
|
|
463
|
-
{
|
|
464
|
-
input_type: FIELDS.RADIO,
|
|
465
|
-
order: 2,
|
|
466
|
-
required: true,
|
|
467
|
-
slug: 'radui-payment-method',
|
|
468
|
-
attributes: {
|
|
469
|
-
options: [
|
|
470
|
-
{
|
|
471
|
-
value: 'paypal',
|
|
472
|
-
label: 'Paypal',
|
|
473
|
-
},
|
|
474
|
-
{
|
|
475
|
-
value: 'Debit',
|
|
476
|
-
label: 'Debit',
|
|
477
|
-
},
|
|
478
|
-
],
|
|
479
|
-
},
|
|
480
|
-
texts: {
|
|
481
|
-
label: 'Please select a way to pay.',
|
|
482
|
-
},
|
|
483
|
-
validators: [],
|
|
484
|
-
},
|
|
485
|
-
],
|
|
486
|
-
},
|
|
487
|
-
},
|
|
488
|
-
],
|
|
489
|
-
},
|
|
490
|
-
},
|
|
491
|
-
};
|
|
492
|
-
FormActive3.play = async ({ canvasElement }) => {
|
|
493
|
-
await within(canvasElement).findByText('Submit', undefined, { timeout: 5000 });
|
|
494
|
-
await fireEvent(await within(canvasElement).getByRole('button', { name: /submit/i }), new MouseEvent('click'));
|
|
495
|
-
|
|
496
|
-
const checkboxTerms = await within(canvasElement).findByLabelText('Debit');
|
|
497
|
-
await userEvent.click(checkboxTerms);
|
|
498
|
-
|
|
499
|
-
const chatBody = await within(canvasElement).findByTestId('chat-body-container');
|
|
500
|
-
await wait(300); // wait for the autoscroll to finish, so we can bottom for the Chromatic snapshot
|
|
501
|
-
fireEvent.scroll(chatBody, { target: { scrollTop: chatBody.clientHeight } });
|
|
502
|
-
};
|
|
503
|
-
|
|
504
|
-
export const FormWithoutTitle = Template.bind({});
|
|
505
|
-
FormWithoutTitle.parameters = {
|
|
506
|
-
...defaultParameters,
|
|
507
|
-
initialStateModifier: {
|
|
508
|
-
...defaultParameters.initialStateModifier,
|
|
509
|
-
messages: {
|
|
510
|
-
...FormActive.parameters.initialStateModifier.messages,
|
|
511
|
-
chatMessages: [
|
|
512
|
-
{
|
|
513
|
-
chat_source: 'web',
|
|
514
|
-
chat_language_code: 'en',
|
|
515
|
-
from_bot: true,
|
|
516
|
-
sender: 'BOT',
|
|
517
|
-
message: '',
|
|
518
|
-
message_format: 'txt',
|
|
519
|
-
buttons: [],
|
|
520
|
-
created: '2022-06-15T19:03:46.186495Z',
|
|
521
|
-
id: '1',
|
|
522
|
-
form: {
|
|
523
|
-
submission_id: 'submissionId',
|
|
524
|
-
id: 'formId',
|
|
525
|
-
dialogue_id: '2',
|
|
526
|
-
submit_dialogue_id: 'c0d685d3-3f11-41b8-9cfd-e35d54df2c95',
|
|
527
|
-
abandon_dialogue_id: 'b1cde0f3-0715-48eb-8482-a9355fa11ba8',
|
|
528
|
-
languageCode: 'en',
|
|
529
|
-
texts: {
|
|
530
|
-
title: '',
|
|
531
|
-
error_text: 'There was an error around here',
|
|
532
|
-
submit_button_text: 'Submit',
|
|
533
|
-
cancel_button_text: 'Exit',
|
|
534
|
-
unanswered_text: 'You failed to answer this form',
|
|
535
|
-
cancel_text: 'You have cancelled/exited this form',
|
|
536
|
-
},
|
|
537
|
-
fields: [
|
|
538
|
-
{
|
|
539
|
-
input_type: FIELDS.TEXT,
|
|
540
|
-
order: 0,
|
|
541
|
-
slug: 'first-name-field',
|
|
542
|
-
texts: {
|
|
543
|
-
label: 'First name',
|
|
544
|
-
help_text: 'Please input your name here',
|
|
545
|
-
placeholder_text: 'First name',
|
|
546
|
-
},
|
|
547
|
-
required: true,
|
|
548
|
-
validators: [
|
|
549
|
-
{
|
|
550
|
-
max_length: 30,
|
|
551
|
-
text: 'Maximum number of length is 30',
|
|
552
|
-
},
|
|
553
|
-
],
|
|
554
|
-
},
|
|
555
|
-
],
|
|
556
|
-
},
|
|
557
|
-
},
|
|
558
|
-
],
|
|
559
|
-
},
|
|
560
|
-
},
|
|
561
|
-
};
|
|
562
|
-
|
|
563
|
-
export const FormSuccess = Template.bind({});
|
|
564
|
-
FormSuccess.parameters = {
|
|
565
|
-
...defaultParameters,
|
|
566
|
-
initialStateModifier: {
|
|
567
|
-
...defaultParameters.initialStateModifier,
|
|
568
|
-
messages: {
|
|
569
|
-
...FormActive.parameters.initialStateModifier.messages,
|
|
570
|
-
forms: {
|
|
571
|
-
// prettier-ignore
|
|
572
|
-
"formId_submission_submissionId": {
|
|
573
|
-
formKey: 'formId_submission_submissionId',
|
|
574
|
-
formId: 'formId',
|
|
575
|
-
formSubmitState: 'SUBMITTED',
|
|
576
|
-
formCompleteMessage: 'Should not display',
|
|
577
|
-
formValue: {
|
|
578
|
-
'should-not-display': 'Should not display',
|
|
579
|
-
'first-name-field': 'First Name',
|
|
580
|
-
'text-field': 'Text',
|
|
581
|
-
'email-field': 'email@kindly.ai',
|
|
582
|
-
'number-field': '42',
|
|
583
|
-
'range-field': '7',
|
|
584
|
-
'select-field': '2',
|
|
585
|
-
'checkbox-field': 'audi'
|
|
586
|
-
},
|
|
587
|
-
},
|
|
588
|
-
},
|
|
589
|
-
},
|
|
590
|
-
},
|
|
591
|
-
};
|
|
592
|
-
|
|
593
|
-
FormSuccess.play = async ({ canvasElement }) => {
|
|
594
|
-
const selectFieldLabel = await within(canvasElement).findByText('Two');
|
|
595
|
-
await expect(selectFieldLabel).toBeInTheDocument();
|
|
596
|
-
const checkboxFieldLabel = await within(canvasElement).findByText('Audi');
|
|
597
|
-
await expect(checkboxFieldLabel).toBeInTheDocument();
|
|
598
|
-
const shouldNotDisplay = await within(canvasElement).queryByText('Should not display');
|
|
599
|
-
await expect(shouldNotDisplay).not.toBeInTheDocument();
|
|
600
|
-
};
|
|
601
|
-
|
|
602
|
-
export const FormErrored = Template.bind({});
|
|
603
|
-
FormErrored.parameters = {
|
|
604
|
-
...defaultParameters,
|
|
605
|
-
initialStateModifier: {
|
|
606
|
-
...defaultParameters.initialStateModifier,
|
|
607
|
-
messages: {
|
|
608
|
-
...FormActive.parameters.initialStateModifier.messages,
|
|
609
|
-
forms: {
|
|
610
|
-
// prettier-ignore
|
|
611
|
-
"formId_submission_submissionId": {
|
|
612
|
-
formKey: 'formId_submission_submissionId',
|
|
613
|
-
formId: 'formId',
|
|
614
|
-
formSubmitState: 'ERRORED',
|
|
615
|
-
formCompleteMessage: 'Something went wrong',
|
|
616
|
-
formValue: {
|
|
617
|
-
'text-field': 'Text',
|
|
618
|
-
},
|
|
619
|
-
},
|
|
620
|
-
},
|
|
621
|
-
},
|
|
622
|
-
},
|
|
623
|
-
};
|
|
624
|
-
|
|
625
|
-
export const FormCanceled = Template.bind({});
|
|
626
|
-
FormCanceled.parameters = {
|
|
627
|
-
...defaultParameters,
|
|
628
|
-
initialStateModifier: {
|
|
629
|
-
...defaultParameters.initialStateModifier,
|
|
630
|
-
messages: {
|
|
631
|
-
...FormActive.parameters.initialStateModifier.messages,
|
|
632
|
-
forms: {
|
|
633
|
-
// prettier-ignore
|
|
634
|
-
"formId_submission_submissionId": {
|
|
635
|
-
formKey: 'formId_submission_submissionId',
|
|
636
|
-
formId: 'formId',
|
|
637
|
-
formSubmitState: 'CANCELED',
|
|
638
|
-
formCompleteMessage: 'This form was canceled',
|
|
639
|
-
formValue: {
|
|
640
|
-
'text-field': 'Text',
|
|
641
|
-
},
|
|
642
|
-
},
|
|
643
|
-
},
|
|
644
|
-
},
|
|
645
|
-
},
|
|
646
|
-
};
|
|
647
|
-
|
|
648
|
-
export const FormUnanswered = Template.bind({});
|
|
649
|
-
FormUnanswered.parameters = {
|
|
650
|
-
...defaultParameters,
|
|
651
|
-
initialStateModifier: {
|
|
652
|
-
...defaultParameters.initialStateModifier,
|
|
653
|
-
messages: {
|
|
654
|
-
...FormActive.parameters.initialStateModifier.messages,
|
|
655
|
-
forms: {
|
|
656
|
-
// prettier-ignore
|
|
657
|
-
"formId_submission_submissionId": {
|
|
658
|
-
formKey: 'formId_submission_submissionId',
|
|
659
|
-
formId: 'formId',
|
|
660
|
-
formSubmitState: 'UNANSWERED',
|
|
661
|
-
formCompleteMessage: 'This form was unanswered',
|
|
662
|
-
formValue: {
|
|
663
|
-
'text-field': 'Text',
|
|
664
|
-
},
|
|
665
|
-
},
|
|
666
|
-
},
|
|
667
|
-
},
|
|
668
|
-
},
|
|
669
|
-
};
|