@kindly/react-chat 2.39.5 → 2.39.6
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/.storybook/preview.js +56 -0
- package/.storybook/test-runner.js +0 -3
- package/dist/index.js +4 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/stories/screens.stories/Chat.stories.jsx +34 -25
- package/stories/screens.stories/ClosedButton.stories.jsx +5 -1
- package/stories/screens.stories/Feedback.stories.jsx +2 -0
- package/stories/screens.stories/Nudge.stories.jsx +2 -1
- package/stories/screens.stories/Options.stories.jsx +13 -7
- package/stories/screens.stories/PushGreeting.stories.jsx +2 -0
- package/stories/screens.stories/StartChat.stories.jsx +2 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kindly/react-chat",
|
|
3
|
-
"version": "2.39.
|
|
3
|
+
"version": "2.39.6",
|
|
4
4
|
"description": "Kindly Chat react component",
|
|
5
5
|
"repository": "https://github.com/kindly-ai/kindly-chat/tree/main/packages/react-chat",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -126,5 +126,5 @@
|
|
|
126
126
|
"silent": true,
|
|
127
127
|
"webpackConfig": "./webpack.config.js"
|
|
128
128
|
},
|
|
129
|
-
"gitHead": "
|
|
129
|
+
"gitHead": "904044d23976aa4fe6dd329b97e52929d3811655"
|
|
130
130
|
}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { expect } from '@storybook/jest';
|
|
2
2
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
3
3
|
/* eslint-disable react/prop-types */
|
|
4
|
-
import { fireEvent, screen, userEvent
|
|
4
|
+
import { fireEvent, screen, userEvent } from '@storybook/testing-library';
|
|
5
5
|
import React from 'react';
|
|
6
6
|
import withFetchMock from 'storybook-addon-mock';
|
|
7
7
|
|
|
8
8
|
import { IMAGE_WIDTH } from 'app/constants';
|
|
9
9
|
|
|
10
|
+
import { chromaticViewports } from '../../.storybook/preview';
|
|
10
11
|
import KindlyChatButton from '../../src/features/KindlyChatButton/KindlyChatButton';
|
|
11
12
|
import settingsJSON from '../assets/settingsJson';
|
|
12
13
|
import withContainer from '../decorators/withContainer';
|
|
@@ -37,8 +38,7 @@ export default {
|
|
|
37
38
|
},
|
|
38
39
|
};
|
|
39
40
|
|
|
40
|
-
|
|
41
|
-
Regular.parameters = {
|
|
41
|
+
const defaultParameters = {
|
|
42
42
|
botSettings: defaultBotSettings,
|
|
43
43
|
initialStateModifier: {
|
|
44
44
|
chatbubble: {
|
|
@@ -100,12 +100,18 @@ Regular.parameters = {
|
|
|
100
100
|
},
|
|
101
101
|
};
|
|
102
102
|
|
|
103
|
+
export const Regular = Template.bind({});
|
|
104
|
+
Regular.parameters = {
|
|
105
|
+
...defaultParameters,
|
|
106
|
+
chromatic: { viewports: chromaticViewports },
|
|
107
|
+
};
|
|
108
|
+
|
|
103
109
|
export const Annoucement = Template.bind({});
|
|
104
110
|
Annoucement.args = {
|
|
105
111
|
type: 'WARNING',
|
|
106
112
|
text: 'You seem to be offline, please check your internet connection',
|
|
107
113
|
initialStateModifierFromArgs: ({ type, text }) => ({
|
|
108
|
-
...
|
|
114
|
+
...defaultParameters.initialStateModifier,
|
|
109
115
|
announcement: {
|
|
110
116
|
show: true,
|
|
111
117
|
type,
|
|
@@ -218,9 +224,9 @@ const MESSAGES = {
|
|
|
218
224
|
};
|
|
219
225
|
MultilineBotMessage.storyName = 'Multiline Bot & User Messages';
|
|
220
226
|
MultilineBotMessage.parameters = {
|
|
221
|
-
...
|
|
227
|
+
...defaultParameters,
|
|
222
228
|
initialStateModifier: {
|
|
223
|
-
...
|
|
229
|
+
...defaultParameters.initialStateModifier,
|
|
224
230
|
messages: {
|
|
225
231
|
chatMessages: [
|
|
226
232
|
{
|
|
@@ -274,16 +280,19 @@ MultilineBotMessage.play = async () => {
|
|
|
274
280
|
await screen.findAllByText('Single-line lonely message');
|
|
275
281
|
// wait for the auto-scroll to execute
|
|
276
282
|
await new Promise((resolve) => {
|
|
277
|
-
setTimeout(resolve,
|
|
283
|
+
setTimeout(resolve, 50);
|
|
278
284
|
});
|
|
279
285
|
fireEvent.scroll(chatBody, { target: { scrollTop: 0 } });
|
|
286
|
+
|
|
280
287
|
const chatNewMessage = await screen.findByTestId('chat-new-message');
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
);
|
|
288
|
+
|
|
289
|
+
// TODO: We used to use `waitFor`, but it seems to fail in Chromatic.
|
|
290
|
+
// Wait for the newMessage button to be visible
|
|
291
|
+
await new Promise((resolve) => {
|
|
292
|
+
setTimeout(resolve, 1400);
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
await expect(chatNewMessage).toBeVisible();
|
|
287
296
|
};
|
|
288
297
|
|
|
289
298
|
export const GroupsOfMessages = Template.bind({});
|
|
@@ -378,9 +387,9 @@ HandoverCancelled.play = async () => {
|
|
|
378
387
|
|
|
379
388
|
export const Checkbox = Template.bind({});
|
|
380
389
|
Checkbox.parameters = {
|
|
381
|
-
...
|
|
390
|
+
...defaultParameters,
|
|
382
391
|
initialStateModifier: {
|
|
383
|
-
...
|
|
392
|
+
...defaultParameters.initialStateModifier,
|
|
384
393
|
messages: {
|
|
385
394
|
chatMessages: [
|
|
386
395
|
{
|
|
@@ -426,9 +435,9 @@ Checkbox.parameters = {
|
|
|
426
435
|
|
|
427
436
|
export const Fallback = Template.bind({});
|
|
428
437
|
Fallback.parameters = {
|
|
429
|
-
...
|
|
438
|
+
...defaultParameters,
|
|
430
439
|
initialStateModifier: {
|
|
431
|
-
...
|
|
440
|
+
...defaultParameters.initialStateModifier,
|
|
432
441
|
messages: {
|
|
433
442
|
chatMessages: [
|
|
434
443
|
{
|
|
@@ -499,7 +508,7 @@ VideoEmbed.args = {
|
|
|
499
508
|
videoSource: videoSources[0][0],
|
|
500
509
|
videoSourceList: videoSources,
|
|
501
510
|
initialStateModifierFromArgs: ({ videoSource, videoSourceList }) => ({
|
|
502
|
-
...
|
|
511
|
+
...defaultParameters.initialStateModifier,
|
|
503
512
|
messages: {
|
|
504
513
|
chatMessages: [
|
|
505
514
|
{
|
|
@@ -554,7 +563,7 @@ ImageGallery.args = {
|
|
|
554
563
|
hasLink,
|
|
555
564
|
newTab,
|
|
556
565
|
}) => ({
|
|
557
|
-
...
|
|
566
|
+
...defaultParameters.initialStateModifier,
|
|
558
567
|
messages: {
|
|
559
568
|
chatMessages: [
|
|
560
569
|
{
|
|
@@ -639,9 +648,9 @@ ImageGalleryWithDescription.parameters = ImageGallery.parameters;
|
|
|
639
648
|
|
|
640
649
|
export const Slider = Template.bind({});
|
|
641
650
|
Slider.parameters = {
|
|
642
|
-
...
|
|
651
|
+
...defaultParameters,
|
|
643
652
|
initialStateModifier: {
|
|
644
|
-
...
|
|
653
|
+
...defaultParameters.initialStateModifier,
|
|
645
654
|
messages: {
|
|
646
655
|
chatMessages: [
|
|
647
656
|
{
|
|
@@ -690,9 +699,9 @@ Slider.parameters = {
|
|
|
690
699
|
|
|
691
700
|
export const Form = Template.bind({});
|
|
692
701
|
Form.parameters = {
|
|
693
|
-
...
|
|
702
|
+
...defaultParameters,
|
|
694
703
|
initialStateModifier: {
|
|
695
|
-
...
|
|
704
|
+
...defaultParameters.initialStateModifier,
|
|
696
705
|
messages: {
|
|
697
706
|
chatMessages: [
|
|
698
707
|
{
|
|
@@ -797,9 +806,9 @@ Form.play = async () => {
|
|
|
797
806
|
|
|
798
807
|
export const LeaveContactDetails = Template.bind({});
|
|
799
808
|
LeaveContactDetails.parameters = {
|
|
800
|
-
...
|
|
809
|
+
...defaultParameters,
|
|
801
810
|
initialStateModifier: {
|
|
802
|
-
...
|
|
811
|
+
...defaultParameters.initialStateModifier,
|
|
803
812
|
messages: {
|
|
804
813
|
chatMessages: [
|
|
805
814
|
{
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import withMock from 'storybook-addon-mock';
|
|
4
4
|
|
|
5
|
+
import { chromaticViewports } from '../../.storybook/preview';
|
|
5
6
|
import KindlyChat from '../../src/KindlyChat';
|
|
6
7
|
import settings from '../assets/settingsJson';
|
|
7
8
|
|
|
@@ -39,7 +40,10 @@ export default {
|
|
|
39
40
|
};
|
|
40
41
|
|
|
41
42
|
export const Regular = Template.bind({});
|
|
42
|
-
Regular.parameters =
|
|
43
|
+
Regular.parameters = {
|
|
44
|
+
...mockSettings(),
|
|
45
|
+
chromatic: { viewports: chromaticViewports },
|
|
46
|
+
};
|
|
43
47
|
|
|
44
48
|
export const Christmas = Template.bind({});
|
|
45
49
|
Christmas.parameters = mockSettings({
|
|
@@ -5,6 +5,7 @@ import withFetchMock from 'storybook-addon-mock';
|
|
|
5
5
|
|
|
6
6
|
import { feedbackFormTypes } from 'app/constants';
|
|
7
7
|
|
|
8
|
+
import { chromaticViewports } from '../../.storybook/preview';
|
|
8
9
|
import KindlyChatButton from '../../src/features/KindlyChatButton/KindlyChatButton';
|
|
9
10
|
import settingsJSON from '../assets/settingsJson';
|
|
10
11
|
import withContainer from '../decorators/withContainer';
|
|
@@ -46,6 +47,7 @@ Emojis.parameters = {
|
|
|
46
47
|
feedbackFormOpen: true,
|
|
47
48
|
},
|
|
48
49
|
},
|
|
50
|
+
chromatic: { viewports: chromaticViewports },
|
|
49
51
|
};
|
|
50
52
|
|
|
51
53
|
export const Binary = Template.bind({});
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import withMock from 'storybook-addon-mock';
|
|
4
4
|
|
|
5
|
+
import { chromaticViewports } from '../../.storybook/preview';
|
|
5
6
|
import KindlyChat from '../../src/KindlyChat';
|
|
6
7
|
import settings from '../assets/settingsJson';
|
|
7
8
|
|
|
@@ -40,7 +41,7 @@ export default {
|
|
|
40
41
|
};
|
|
41
42
|
|
|
42
43
|
export const Product = Template.bind({});
|
|
43
|
-
Product.parameters = mockSettings();
|
|
44
|
+
Product.parameters = { ...mockSettings(), chromatic: { viewports: chromaticViewports } };
|
|
44
45
|
Product.args = {
|
|
45
46
|
slug: settings.nudges.product_nudges[0].slug,
|
|
46
47
|
};
|
|
@@ -4,6 +4,7 @@ import { screen, userEvent } from '@storybook/testing-library';
|
|
|
4
4
|
import React from 'react';
|
|
5
5
|
import withFetchMock from 'storybook-addon-mock';
|
|
6
6
|
|
|
7
|
+
import { chromaticViewports } from '../../.storybook/preview';
|
|
7
8
|
import KindlyChatButton from '../../src/features/KindlyChatButton/KindlyChatButton';
|
|
8
9
|
import settingsJSON from '../assets/settingsJson';
|
|
9
10
|
import withContainer from '../decorators/withContainer';
|
|
@@ -27,8 +28,7 @@ export default {
|
|
|
27
28
|
decorators: [withFetchMock, withContainer, withMockProvider],
|
|
28
29
|
};
|
|
29
30
|
|
|
30
|
-
|
|
31
|
-
Regular.parameters = {
|
|
31
|
+
const defaultParameters = {
|
|
32
32
|
botSettings: defaultBotSettings,
|
|
33
33
|
initialStateModifier: {
|
|
34
34
|
chatbubble: {
|
|
@@ -40,6 +40,12 @@ Regular.parameters = {
|
|
|
40
40
|
},
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
+
export const Regular = Template.bind({});
|
|
44
|
+
Regular.parameters = {
|
|
45
|
+
...defaultParameters,
|
|
46
|
+
chromatic: { viewports: chromaticViewports },
|
|
47
|
+
};
|
|
48
|
+
|
|
43
49
|
export const WithLanguageChoice = Template.bind({});
|
|
44
50
|
WithLanguageChoice.parameters = {
|
|
45
51
|
botSettings: {
|
|
@@ -179,7 +185,7 @@ LanguageChoiceConfirm.play = async () => {
|
|
|
179
185
|
};
|
|
180
186
|
|
|
181
187
|
export const DeleteConfirmation = Template.bind({});
|
|
182
|
-
DeleteConfirmation.parameters =
|
|
188
|
+
DeleteConfirmation.parameters = defaultParameters;
|
|
183
189
|
DeleteConfirmation.play = async () => {
|
|
184
190
|
const deleteButton = await screen.findByText(defaultBotSettings.text.delete_button.en);
|
|
185
191
|
await userEvent.click(deleteButton);
|
|
@@ -187,9 +193,9 @@ DeleteConfirmation.play = async () => {
|
|
|
187
193
|
|
|
188
194
|
export const DeleteSuccess = Template.bind({});
|
|
189
195
|
DeleteSuccess.parameters = {
|
|
190
|
-
...
|
|
196
|
+
...defaultParameters,
|
|
191
197
|
initialStateModifier: {
|
|
192
|
-
...
|
|
198
|
+
...defaultParameters.initialStateModifier,
|
|
193
199
|
privacy: {
|
|
194
200
|
chatDeleted: true,
|
|
195
201
|
},
|
|
@@ -197,7 +203,7 @@ DeleteSuccess.parameters = {
|
|
|
197
203
|
};
|
|
198
204
|
|
|
199
205
|
export const DownloadChat = Template.bind({});
|
|
200
|
-
DownloadChat.parameters =
|
|
206
|
+
DownloadChat.parameters = defaultParameters;
|
|
201
207
|
DownloadChat.play = async () => {
|
|
202
208
|
const downloadButton = await screen.findByText(defaultBotSettings.text.download_button.en);
|
|
203
209
|
await userEvent.click(downloadButton);
|
|
@@ -205,7 +211,7 @@ DownloadChat.play = async () => {
|
|
|
205
211
|
|
|
206
212
|
export const QuitChat = Template.bind({});
|
|
207
213
|
QuitChat.parameters = {
|
|
208
|
-
...
|
|
214
|
+
...defaultParameters,
|
|
209
215
|
initialStateModifier: {
|
|
210
216
|
chatbubble: {
|
|
211
217
|
active: true,
|
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
import React from 'react';
|
|
4
4
|
import withFetchMock from 'storybook-addon-mock';
|
|
5
5
|
|
|
6
|
+
import { chromaticViewports } from '../../.storybook/preview';
|
|
6
7
|
import KindlyChatButton from '../../src/features/KindlyChatButton/KindlyChatButton';
|
|
7
8
|
import settingsJSON from '../assets/settingsJson';
|
|
8
9
|
import withContainer from '../decorators/withContainer';
|
|
@@ -39,6 +40,7 @@ Default.parameters = {
|
|
|
39
40
|
text: 'This is a push greeting',
|
|
40
41
|
},
|
|
41
42
|
},
|
|
43
|
+
chromatic: { viewports: chromaticViewports },
|
|
42
44
|
};
|
|
43
45
|
|
|
44
46
|
export const NewMessage = Template.bind({});
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
/* eslint-disable react/prop-types */
|
|
3
3
|
import React from 'react';
|
|
4
4
|
|
|
5
|
+
import { chromaticViewports } from '../../.storybook/preview';
|
|
5
6
|
import KindlyChatButton from '../../src/features/KindlyChatButton/KindlyChatButton';
|
|
6
7
|
import settingsJSON from '../assets/settingsJson';
|
|
7
8
|
import withContainer from '../decorators/withContainer';
|
|
@@ -34,6 +35,7 @@ export default {
|
|
|
34
35
|
};
|
|
35
36
|
|
|
36
37
|
export const Regular = Template.bind({});
|
|
38
|
+
Regular.parameters = { chromatic: { viewports: chromaticViewports } };
|
|
37
39
|
|
|
38
40
|
export const WithLanguageChoice = Template.bind({});
|
|
39
41
|
WithLanguageChoice.parameters = {
|