@kindly/react-chat 2.39.2 → 2.39.5
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 +4 -4
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/stories/screens.stories/Chat.stories.jsx +77 -163
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kindly/react-chat",
|
|
3
|
-
"version": "2.39.
|
|
3
|
+
"version": "2.39.5",
|
|
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": "cff703081966dda917c36b8c8dc60d42e3e61cec"
|
|
130
130
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { expect } from '@storybook/jest';
|
|
1
2
|
/* eslint-disable react-hooks/exhaustive-deps */
|
|
2
3
|
/* eslint-disable react/prop-types */
|
|
3
|
-
import { screen, userEvent } from '@storybook/testing-library';
|
|
4
|
+
import { fireEvent, screen, userEvent, waitFor } from '@storybook/testing-library';
|
|
4
5
|
import React from 'react';
|
|
5
6
|
import withFetchMock from 'storybook-addon-mock';
|
|
6
7
|
|
|
@@ -268,6 +269,22 @@ MultilineBotMessage.parameters = {
|
|
|
268
269
|
},
|
|
269
270
|
},
|
|
270
271
|
};
|
|
272
|
+
MultilineBotMessage.play = async () => {
|
|
273
|
+
const chatBody = await screen.findByTestId('chat-body-container');
|
|
274
|
+
await screen.findAllByText('Single-line lonely message');
|
|
275
|
+
// wait for the auto-scroll to execute
|
|
276
|
+
await new Promise((resolve) => {
|
|
277
|
+
setTimeout(resolve, 10);
|
|
278
|
+
});
|
|
279
|
+
fireEvent.scroll(chatBody, { target: { scrollTop: 0 } });
|
|
280
|
+
const chatNewMessage = await screen.findByTestId('chat-new-message');
|
|
281
|
+
await waitFor(
|
|
282
|
+
async () => {
|
|
283
|
+
await expect(chatNewMessage).toBeVisible();
|
|
284
|
+
},
|
|
285
|
+
{ timeout: 5000 },
|
|
286
|
+
);
|
|
287
|
+
};
|
|
271
288
|
|
|
272
289
|
export const GroupsOfMessages = Template.bind({});
|
|
273
290
|
GroupsOfMessages.parameters = {
|
|
@@ -687,191 +704,70 @@ Form.parameters = {
|
|
|
687
704
|
message_format: 'txt',
|
|
688
705
|
buttons: [],
|
|
689
706
|
created: '2022-06-15T19:03:46.186495Z',
|
|
690
|
-
title: '',
|
|
691
707
|
id: '1',
|
|
692
708
|
form: {
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
709
|
+
submission_id: '1',
|
|
710
|
+
id: '2',
|
|
711
|
+
dialogue_id: '2',
|
|
712
|
+
slug: 'this-is-a-form',
|
|
696
713
|
submit_dialogue_id: 'c0d685d3-3f11-41b8-9cfd-e35d54df2c95',
|
|
697
714
|
abandon_dialogue_id: 'b1cde0f3-0715-48eb-8482-a9355fa11ba8',
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
},
|
|
708
|
-
],
|
|
715
|
+
languageCode: 'en',
|
|
716
|
+
texts: {
|
|
717
|
+
title: 'This is a form',
|
|
718
|
+
error_text: 'There was an error around here',
|
|
719
|
+
submit_button_text: 'Submit',
|
|
720
|
+
cancel_button_text: 'Exit',
|
|
721
|
+
unanswered_text: 'You failed to answer this form',
|
|
722
|
+
cancel_text: 'You have cancelled/exited this form',
|
|
723
|
+
},
|
|
709
724
|
fields: [
|
|
710
725
|
{
|
|
711
|
-
|
|
726
|
+
input_type: 'text',
|
|
712
727
|
order: 0,
|
|
713
|
-
slug: '
|
|
714
|
-
texts:
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
},
|
|
722
|
-
],
|
|
728
|
+
slug: 'first-name-field',
|
|
729
|
+
texts: {
|
|
730
|
+
label: 'First name',
|
|
731
|
+
help_text: 'Please input your name here',
|
|
732
|
+
placeholder_text: 'First name',
|
|
733
|
+
required_text: 'This field is absolutely required',
|
|
734
|
+
},
|
|
735
|
+
required: true,
|
|
723
736
|
validators: [
|
|
724
737
|
{
|
|
725
|
-
|
|
726
|
-
texts:
|
|
727
|
-
{
|
|
728
|
-
id: 'gruh',
|
|
729
|
-
languageCode: 'en',
|
|
730
|
-
message: undefined,
|
|
731
|
-
},
|
|
732
|
-
],
|
|
733
|
-
},
|
|
734
|
-
{
|
|
735
|
-
maxLength: 30,
|
|
736
|
-
texts: [
|
|
737
|
-
{
|
|
738
|
-
id: 'duh',
|
|
739
|
-
languageCode: 'en',
|
|
740
|
-
message: 'Maximum number of length is 30',
|
|
741
|
-
},
|
|
742
|
-
],
|
|
738
|
+
max_length: 30,
|
|
739
|
+
texts: 'Maximum number of length is 30',
|
|
743
740
|
},
|
|
744
741
|
],
|
|
745
742
|
},
|
|
746
743
|
{
|
|
747
|
-
|
|
744
|
+
input_type: 'text',
|
|
748
745
|
order: 1,
|
|
749
|
-
slug: '
|
|
750
|
-
texts:
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
helper_text: 'Please fill in your email address here so we can contact you',
|
|
757
|
-
},
|
|
758
|
-
],
|
|
746
|
+
slug: 'text-field',
|
|
747
|
+
texts: {
|
|
748
|
+
label: 'Text field',
|
|
749
|
+
placeholder_text: 'Free text',
|
|
750
|
+
required_text: 'This field is required',
|
|
751
|
+
},
|
|
752
|
+
required: true,
|
|
759
753
|
validators: [
|
|
760
754
|
{
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
{
|
|
764
|
-
id: 'gigu',
|
|
765
|
-
languageCode: 'en',
|
|
766
|
-
message: 'This field is required',
|
|
767
|
-
},
|
|
768
|
-
],
|
|
755
|
+
min_length: 5,
|
|
756
|
+
text: 'This field should be at least 5 characters long',
|
|
769
757
|
},
|
|
770
758
|
{
|
|
771
|
-
|
|
772
|
-
texts: [
|
|
773
|
-
{
|
|
774
|
-
id: 'dada',
|
|
775
|
-
languageCode: 'en',
|
|
776
|
-
message: 'Please provide valid email',
|
|
777
|
-
},
|
|
778
|
-
],
|
|
759
|
+
max_length: 15,
|
|
779
760
|
},
|
|
780
761
|
],
|
|
781
762
|
},
|
|
782
763
|
{
|
|
783
|
-
|
|
764
|
+
input_type: 'email',
|
|
784
765
|
order: 2,
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
texts: [
|
|
791
|
-
{
|
|
792
|
-
id: 'blabla',
|
|
793
|
-
languageCode: 'en',
|
|
794
|
-
label: 'Please select a value',
|
|
795
|
-
helper_text: 'Please fill in your full name here',
|
|
796
|
-
affix_value: '$',
|
|
797
|
-
},
|
|
798
|
-
],
|
|
799
|
-
validators: [],
|
|
800
|
-
},
|
|
801
|
-
{
|
|
802
|
-
type: 'checkbox', // not included in the v1
|
|
803
|
-
order: 3,
|
|
804
|
-
slug: 'dodo', // Auto generated by the backend, possibly humanly readable and unique
|
|
805
|
-
texts: [
|
|
806
|
-
{
|
|
807
|
-
id: 'gogo',
|
|
808
|
-
languageCode: 'en',
|
|
809
|
-
label: 'What animals do you like?',
|
|
810
|
-
helper_text: '',
|
|
811
|
-
},
|
|
812
|
-
],
|
|
813
|
-
list: [
|
|
814
|
-
{
|
|
815
|
-
slug: 'hhh', // Not sure if this needs one
|
|
816
|
-
value: 'cows',
|
|
817
|
-
order: 0,
|
|
818
|
-
texts: [
|
|
819
|
-
{
|
|
820
|
-
id: 'gras',
|
|
821
|
-
languageCode: 'en',
|
|
822
|
-
label: 'I like cows',
|
|
823
|
-
},
|
|
824
|
-
],
|
|
825
|
-
},
|
|
826
|
-
{
|
|
827
|
-
slug: 'ddsad',
|
|
828
|
-
value: 'snakes',
|
|
829
|
-
order: 1,
|
|
830
|
-
texts: [
|
|
831
|
-
{
|
|
832
|
-
id: 'grq',
|
|
833
|
-
languageCode: 'en',
|
|
834
|
-
label: 'I like snakes',
|
|
835
|
-
},
|
|
836
|
-
],
|
|
837
|
-
},
|
|
838
|
-
{
|
|
839
|
-
slug: 'abv',
|
|
840
|
-
value: 'foxes',
|
|
841
|
-
order: 2,
|
|
842
|
-
texts: [
|
|
843
|
-
{
|
|
844
|
-
id: 'abc',
|
|
845
|
-
languageCode: 'en',
|
|
846
|
-
label: 'I like foxes',
|
|
847
|
-
},
|
|
848
|
-
],
|
|
849
|
-
},
|
|
850
|
-
{
|
|
851
|
-
slug: '213',
|
|
852
|
-
value: 'owls',
|
|
853
|
-
order: 3,
|
|
854
|
-
texts: [
|
|
855
|
-
{
|
|
856
|
-
id: '321',
|
|
857
|
-
languageCode: 'en',
|
|
858
|
-
label: 'I like owls',
|
|
859
|
-
},
|
|
860
|
-
],
|
|
861
|
-
},
|
|
862
|
-
],
|
|
863
|
-
validators: [
|
|
864
|
-
{
|
|
865
|
-
required: true,
|
|
866
|
-
texts: [
|
|
867
|
-
{
|
|
868
|
-
id: '432',
|
|
869
|
-
languageCode: 'en',
|
|
870
|
-
message: 'This field is required',
|
|
871
|
-
},
|
|
872
|
-
],
|
|
873
|
-
},
|
|
874
|
-
],
|
|
766
|
+
slug: 'email-field',
|
|
767
|
+
texts: {
|
|
768
|
+
label: 'Email',
|
|
769
|
+
placeholder_text: 'Email',
|
|
770
|
+
},
|
|
875
771
|
},
|
|
876
772
|
],
|
|
877
773
|
},
|
|
@@ -880,6 +776,24 @@ Form.parameters = {
|
|
|
880
776
|
},
|
|
881
777
|
},
|
|
882
778
|
};
|
|
779
|
+
Form.play = async () => {
|
|
780
|
+
await screen.findByText('Please input your name here');
|
|
781
|
+
const textPlaceholderValue = 'Free text';
|
|
782
|
+
const textInput = await screen.findByPlaceholderText(textPlaceholderValue);
|
|
783
|
+
await userEvent.type(textInput, 'This');
|
|
784
|
+
await expect(textInput.value).toBe('This');
|
|
785
|
+
await fireEvent(await screen.getByRole('button', { name: /submit/i }), new MouseEvent('click'));
|
|
786
|
+
await screen.findByText('This field is absolutely required');
|
|
787
|
+
await screen.findByText('This field should be at least 5 characters long');
|
|
788
|
+
const textInputStyle = window.getComputedStyle(textInput);
|
|
789
|
+
expect(textInputStyle.border).not.toContain('#00000000');
|
|
790
|
+
expect(textInputStyle.border).not.toContain('transparent');
|
|
791
|
+
await userEvent.type(textInput, ' is too long');
|
|
792
|
+
await expect(textInput.value).toBe('This is too lon');
|
|
793
|
+
const emailPlaceholderValue = 'Email';
|
|
794
|
+
const emailInput = await screen.findByPlaceholderText(emailPlaceholderValue);
|
|
795
|
+
await userEvent.type(emailInput, 'this@is@not@an@email');
|
|
796
|
+
};
|
|
883
797
|
|
|
884
798
|
export const LeaveContactDetails = Template.bind({});
|
|
885
799
|
LeaveContactDetails.parameters = {
|