@kindly/react-chat 2.42.1 → 2.44.0
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/main.js +1 -30
- package/.storybook/preview.js +16 -6
- package/dist/index.js +1 -1
- package/dist/index.js.LICENSE.txt +28 -13
- package/dist/index.js.map +1 -1
- package/package.json +46 -33
- package/stories/assets/settingsJson.js +19 -7
- package/stories/screens.stories/Chat/Composer.stories.jsx +174 -0
- package/stories/screens.stories/Chat/Notifications.stories.jsx +184 -0
- package/stories/screens.stories/Chat/TypingIndicator.stories.jsx +143 -0
- package/stories/screens.stories/Chat/index.stories.jsx +65 -44
- package/stories/screens.stories/Options.stories.jsx +4 -9
|
@@ -2,7 +2,7 @@ import { expect } from '@storybook/jest';
|
|
|
2
2
|
import { fireEvent, userEvent, waitFor, within } from '@storybook/testing-library';
|
|
3
3
|
import React from 'react';
|
|
4
4
|
|
|
5
|
-
import { IMAGE_WIDTH } from 'app/constants';
|
|
5
|
+
import { HANDLERS, IMAGE_WIDTH } from 'app/constants';
|
|
6
6
|
|
|
7
7
|
import { chromaticViewports } from '../../../.storybook/preview';
|
|
8
8
|
import KindlyChatButton from '../../../src/features/KindlyChatButton/KindlyChatButton';
|
|
@@ -135,49 +135,6 @@ Annoucement.parameters = {
|
|
|
135
135
|
botSettings: defaultBotSettings,
|
|
136
136
|
};
|
|
137
137
|
|
|
138
|
-
export const BotIsTyping = Template.bind({});
|
|
139
|
-
BotIsTyping.parameters = {
|
|
140
|
-
botSettings: defaultBotSettings,
|
|
141
|
-
initialStateModifier: {
|
|
142
|
-
chatbubble: {
|
|
143
|
-
active: true,
|
|
144
|
-
chatHasStarted: true,
|
|
145
|
-
currentLanguage: 'en',
|
|
146
|
-
},
|
|
147
|
-
messages: {
|
|
148
|
-
chatMessages: [
|
|
149
|
-
{
|
|
150
|
-
id: '2',
|
|
151
|
-
created,
|
|
152
|
-
message: 'What is the meaning of life?',
|
|
153
|
-
status: null,
|
|
154
|
-
},
|
|
155
|
-
],
|
|
156
|
-
},
|
|
157
|
-
bot: {
|
|
158
|
-
isTyping: true,
|
|
159
|
-
},
|
|
160
|
-
},
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
export const Maintenance = Template.bind({});
|
|
164
|
-
Maintenance.parameters = {
|
|
165
|
-
botSettings: defaultBotSettings,
|
|
166
|
-
initialStateModifier: {
|
|
167
|
-
chatbubble: {
|
|
168
|
-
active: true,
|
|
169
|
-
chatHasStarted: true,
|
|
170
|
-
currentLanguage: 'en',
|
|
171
|
-
},
|
|
172
|
-
maintenanceAlert: {
|
|
173
|
-
show: true,
|
|
174
|
-
textContent: 'Maintenance mode!',
|
|
175
|
-
linkText: 'Click here to know more',
|
|
176
|
-
linkLocation: 'https://example.com',
|
|
177
|
-
},
|
|
178
|
-
},
|
|
179
|
-
};
|
|
180
|
-
|
|
181
138
|
export const Announcement = Template.bind({});
|
|
182
139
|
Announcement.parameters = {
|
|
183
140
|
botSettings: defaultBotSettings,
|
|
@@ -237,6 +194,69 @@ HiddenInput.parameters = {
|
|
|
237
194
|
},
|
|
238
195
|
};
|
|
239
196
|
|
|
197
|
+
export const MimirBotMessage = Template.bind({});
|
|
198
|
+
|
|
199
|
+
MimirBotMessage.storyName = 'Mimir Message';
|
|
200
|
+
MimirBotMessage.parameters = {
|
|
201
|
+
...defaultParameters,
|
|
202
|
+
botSettings: {
|
|
203
|
+
...defaultBotSettings,
|
|
204
|
+
typing_duration: 0,
|
|
205
|
+
},
|
|
206
|
+
initialStateModifier: {
|
|
207
|
+
...defaultParameters.initialStateModifier,
|
|
208
|
+
},
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
MimirBotMessage.args = {
|
|
212
|
+
gptSearchResultText: settingsJSON.text.gpt_search_result_text.en,
|
|
213
|
+
gptTooltipDisclaimer: settingsJSON.text.gpt_tooltip_disclaimer.en,
|
|
214
|
+
initialStateModifierFromArgs: ({ gptSearchResultText, gptTooltipDisclaimer }) => {
|
|
215
|
+
return {
|
|
216
|
+
...defaultParameters.initialStateModifier,
|
|
217
|
+
bot: {
|
|
218
|
+
text: {
|
|
219
|
+
gpt_search_result_text: {
|
|
220
|
+
en: gptSearchResultText,
|
|
221
|
+
},
|
|
222
|
+
gpt_tooltip_disclaimer: {
|
|
223
|
+
en: gptTooltipDisclaimer,
|
|
224
|
+
},
|
|
225
|
+
},
|
|
226
|
+
},
|
|
227
|
+
messages: {
|
|
228
|
+
chatMessages: [
|
|
229
|
+
{
|
|
230
|
+
from_bot: false,
|
|
231
|
+
sender: 'BOT',
|
|
232
|
+
handler: HANDLERS.MIMIR,
|
|
233
|
+
message: 'This is a message from Mimir, our KindlyGPT bot.',
|
|
234
|
+
created,
|
|
235
|
+
key: '1',
|
|
236
|
+
id: '1',
|
|
237
|
+
},
|
|
238
|
+
],
|
|
239
|
+
},
|
|
240
|
+
};
|
|
241
|
+
},
|
|
242
|
+
};
|
|
243
|
+
|
|
244
|
+
MimirBotMessage.argTypes = {
|
|
245
|
+
gptSearchResultText: 'string',
|
|
246
|
+
gptTooltipDisclaimer: 'string',
|
|
247
|
+
};
|
|
248
|
+
|
|
249
|
+
MimirBotMessage.play = async ({ canvasElement }) => {
|
|
250
|
+
await within(canvasElement).findByTestId('chat-body-container');
|
|
251
|
+
|
|
252
|
+
const tooltip = await within(canvasElement).findByTestId('tooltip');
|
|
253
|
+
fireEvent.mouseEnter(tooltip);
|
|
254
|
+
|
|
255
|
+
const tooltipMessage = await within(canvasElement).findByTestId('tooltip-text');
|
|
256
|
+
|
|
257
|
+
expect(tooltipMessage).toBeInTheDocument();
|
|
258
|
+
};
|
|
259
|
+
|
|
240
260
|
export const MultilineBotMessage = Template.bind({});
|
|
241
261
|
const MESSAGES = {
|
|
242
262
|
single: 'Single-line lonely message',
|
|
@@ -300,6 +320,7 @@ MultilineBotMessage.parameters = {
|
|
|
300
320
|
},
|
|
301
321
|
},
|
|
302
322
|
};
|
|
323
|
+
|
|
303
324
|
MultilineBotMessage.play = async ({ canvasElement }) => {
|
|
304
325
|
const chatBody = await within(canvasElement).findByTestId('chat-body-container');
|
|
305
326
|
await within(canvasElement).findAllByText('Single-line lonely message');
|
|
@@ -3,6 +3,7 @@ import React from 'react';
|
|
|
3
3
|
|
|
4
4
|
import { chromaticViewports } from '../../.storybook/preview';
|
|
5
5
|
import KindlyChatButton from '../../src/features/KindlyChatButton/KindlyChatButton';
|
|
6
|
+
import { OPTION_VIEW } from '../../src/features/OptionsScreen/constants';
|
|
6
7
|
import settingsJSON from '../assets/settingsJson';
|
|
7
8
|
import withContainer from '../decorators/withContainer';
|
|
8
9
|
import withMockProvider from '../decorators/withProvider';
|
|
@@ -32,7 +33,7 @@ const defaultParameters = {
|
|
|
32
33
|
active: true,
|
|
33
34
|
chatHasStarted: true,
|
|
34
35
|
currentLanguage: 'en',
|
|
35
|
-
|
|
36
|
+
optionsScreenView: OPTION_VIEW.GENERIC,
|
|
36
37
|
},
|
|
37
38
|
},
|
|
38
39
|
};
|
|
@@ -74,7 +75,7 @@ WithLanguageChoice.parameters = {
|
|
|
74
75
|
active: true,
|
|
75
76
|
chatHasStarted: true,
|
|
76
77
|
currentLanguage: 'en',
|
|
77
|
-
|
|
78
|
+
optionsScreenView: OPTION_VIEW.GENERIC,
|
|
78
79
|
},
|
|
79
80
|
},
|
|
80
81
|
};
|
|
@@ -145,7 +146,7 @@ LanguageChoice.args = {
|
|
|
145
146
|
active: true,
|
|
146
147
|
chatHasStarted: true,
|
|
147
148
|
currentLanguage: 'en',
|
|
148
|
-
|
|
149
|
+
optionsScreenView: OPTION_VIEW.LANGUAGE_SELECT,
|
|
149
150
|
},
|
|
150
151
|
bot: {
|
|
151
152
|
languages: availableLanguages.slice(0, languageQuantity),
|
|
@@ -162,10 +163,6 @@ LanguageChoice.parameters = {
|
|
|
162
163
|
...defaultBotSettings,
|
|
163
164
|
},
|
|
164
165
|
};
|
|
165
|
-
LanguageChoice.play = async ({ canvasElement }) => {
|
|
166
|
-
const languageButton = await within(canvasElement).findByText(defaultBotSettings.text.change_language_button.en);
|
|
167
|
-
await userEvent.click(languageButton);
|
|
168
|
-
};
|
|
169
166
|
|
|
170
167
|
export const LanguageChoiceConfirm = Template.bind({});
|
|
171
168
|
LanguageChoiceConfirm.args = {
|
|
@@ -175,8 +172,6 @@ LanguageChoiceConfirm.args = {
|
|
|
175
172
|
LanguageChoiceConfirm.argTypes = LanguageChoice.argTypes;
|
|
176
173
|
LanguageChoiceConfirm.parameters = LanguageChoice.parameters;
|
|
177
174
|
LanguageChoiceConfirm.play = async ({ canvasElement }) => {
|
|
178
|
-
const languageButton = await within(canvasElement).findByText(defaultBotSettings.text.change_language_button.en);
|
|
179
|
-
await userEvent.click(languageButton);
|
|
180
175
|
const norskButton = await within(canvasElement).findByText(availableLanguages[1].name);
|
|
181
176
|
await userEvent.click(norskButton);
|
|
182
177
|
};
|