@capillarytech/creatives-library 8.0.125-alpha.6 → 8.0.126

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.
Files changed (105) hide show
  1. package/config/app.js +6 -0
  2. package/containers/App/constants.js +0 -1
  3. package/containers/Email/index.js +5 -5
  4. package/containers/WeChat/RichmediaTemplates/Create/index.js +1 -1
  5. package/initialReducer.js +2 -0
  6. package/package.json +1 -1
  7. package/services/api.js +94 -1
  8. package/services/tests/api.test.js +191 -0
  9. package/tests/integration/TemplateCreation/TemplateCreation.integration.test.js +3 -8
  10. package/tests/integration/TemplateCreation/api-response.js +0 -5
  11. package/tests/integration/TemplateCreation/msw-handler.js +63 -42
  12. package/utils/common.js +0 -7
  13. package/utils/commonUtils.js +6 -2
  14. package/v2Components/CapImageUpload/index.js +45 -51
  15. package/v2Components/CapInAppCTA/index.js +0 -1
  16. package/v2Components/CapTagList/index.js +120 -177
  17. package/v2Components/CapVideoUpload/constants.js +0 -3
  18. package/v2Components/CapVideoUpload/index.js +110 -167
  19. package/v2Components/CapVideoUpload/messages.js +0 -16
  20. package/v2Components/Carousel/index.js +13 -15
  21. package/v2Components/CustomerSearchSection/_customerSearch.scss +309 -0
  22. package/v2Components/CustomerSearchSection/constants.js +5 -0
  23. package/v2Components/CustomerSearchSection/index.js +362 -0
  24. package/v2Components/CustomerSearchSection/messages.js +20 -0
  25. package/v2Components/CustomerSearchSection/tests/utils.test.js +334 -0
  26. package/v2Components/CustomerSearchSection/utils.js +49 -0
  27. package/v2Components/ErrorInfoNote/style.scss +0 -1
  28. package/v2Components/MobilePushPreviewV2/index.js +5 -37
  29. package/v2Components/TemplatePreview/_templatePreview.scss +72 -114
  30. package/v2Components/TemplatePreview/index.js +50 -178
  31. package/v2Components/TemplatePreview/messages.js +0 -4
  32. package/v2Components/TestAndPreviewSlidebox/_testAndPreviewSlidebox.scss +543 -0
  33. package/v2Components/TestAndPreviewSlidebox/actions.js +67 -0
  34. package/v2Components/TestAndPreviewSlidebox/constants.js +67 -0
  35. package/v2Components/TestAndPreviewSlidebox/index.js +771 -0
  36. package/v2Components/TestAndPreviewSlidebox/messages.js +147 -0
  37. package/v2Components/TestAndPreviewSlidebox/reducer.js +233 -0
  38. package/v2Components/TestAndPreviewSlidebox/sagas.js +258 -0
  39. package/v2Components/TestAndPreviewSlidebox/selectors.js +142 -0
  40. package/v2Components/TestAndPreviewSlidebox/tests/actions.test.js +80 -0
  41. package/v2Components/TestAndPreviewSlidebox/tests/reducer.test.js +367 -0
  42. package/v2Components/TestAndPreviewSlidebox/tests/saga.rtl.test.js +192 -0
  43. package/v2Components/TestAndPreviewSlidebox/tests/saga.test.js +652 -0
  44. package/v2Components/TestAndPreviewSlidebox/tests/selector.test.js +182 -0
  45. package/v2Containers/CreativesContainer/SlideBoxContent.js +21 -9
  46. package/v2Containers/CreativesContainer/SlideBoxFooter.js +23 -2
  47. package/v2Containers/CreativesContainer/index.js +160 -195
  48. package/v2Containers/CreativesContainer/messages.js +4 -0
  49. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +21 -0
  50. package/v2Containers/Email/index.js +18 -6
  51. package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +10 -0
  52. package/v2Containers/EmailWrapper/index.js +6 -0
  53. package/v2Containers/InApp/constants.js +0 -1
  54. package/v2Containers/InApp/index.js +13 -13
  55. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +3 -0
  56. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +2 -0
  57. package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +2 -0
  58. package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +9 -0
  59. package/v2Containers/MobilePush/Create/index.js +0 -1
  60. package/v2Containers/MobilePush/commonMethods.js +14 -7
  61. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +23 -5
  62. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +4 -0
  63. package/v2Containers/TagList/index.js +10 -56
  64. package/v2Containers/Templates/_templates.scss +1 -101
  65. package/v2Containers/Templates/index.js +35 -147
  66. package/v2Containers/Templates/messages.js +0 -8
  67. package/v2Containers/Templates/sagas.js +0 -2
  68. package/v2Containers/WeChat/RichmediaTemplates/Create/index.js +1 -1
  69. package/v2Containers/Whatsapp/constants.js +0 -1
  70. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +35 -0
  71. package/utils/createPayload.js +0 -270
  72. package/utils/tests/createPayload.test.js +0 -761
  73. package/v2Components/CapMpushCTA/constants.js +0 -25
  74. package/v2Components/CapMpushCTA/index.js +0 -332
  75. package/v2Components/CapMpushCTA/index.scss +0 -95
  76. package/v2Components/CapMpushCTA/messages.js +0 -89
  77. package/v2Components/TemplatePreview/assets/images/Android _ With date and time.svg +0 -29
  78. package/v2Components/TemplatePreview/assets/images/android.svg +0 -9
  79. package/v2Components/TemplatePreview/assets/images/iOS _ With date and time.svg +0 -26
  80. package/v2Components/TemplatePreview/assets/images/ios.svg +0 -9
  81. package/v2Containers/Email/tests/index.test.js +0 -35
  82. package/v2Containers/MobilePushNew/actions.js +0 -116
  83. package/v2Containers/MobilePushNew/components/CtaButtons.js +0 -170
  84. package/v2Containers/MobilePushNew/components/MediaUploaders.js +0 -686
  85. package/v2Containers/MobilePushNew/components/PlatformContentFields.js +0 -279
  86. package/v2Containers/MobilePushNew/components/index.js +0 -5
  87. package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +0 -779
  88. package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +0 -2114
  89. package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +0 -343
  90. package/v2Containers/MobilePushNew/constants.js +0 -115
  91. package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +0 -1299
  92. package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +0 -1223
  93. package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +0 -246
  94. package/v2Containers/MobilePushNew/hooks/useUpload.js +0 -709
  95. package/v2Containers/MobilePushNew/index.js +0 -2170
  96. package/v2Containers/MobilePushNew/index.scss +0 -308
  97. package/v2Containers/MobilePushNew/messages.js +0 -226
  98. package/v2Containers/MobilePushNew/reducer.js +0 -160
  99. package/v2Containers/MobilePushNew/sagas.js +0 -198
  100. package/v2Containers/MobilePushNew/selectors.js +0 -55
  101. package/v2Containers/MobilePushNew/tests/reducer.test.js +0 -741
  102. package/v2Containers/MobilePushNew/tests/sagas.test.js +0 -863
  103. package/v2Containers/MobilePushNew/tests/selectors.test.js +0 -425
  104. package/v2Containers/MobilePushNew/tests/utils.test.js +0 -322
  105. package/v2Containers/MobilePushNew/utils.js +0 -33
@@ -0,0 +1,142 @@
1
+ /**
2
+ * Customer Search Section Selectors
3
+ */
4
+
5
+ import { createSelector } from 'reselect';
6
+
7
+ const selectPreviewAndTestDomain = (state) => state.get('previewAndTest');
8
+
9
+ const makeSelectPreviewAndTest = () => createSelector(
10
+ selectPreviewAndTestDomain,
11
+ (substate) => substate
12
+ );
13
+
14
+ const makeSelectCustomers = () => createSelector(
15
+ selectPreviewAndTestDomain,
16
+ (substate) => substate.get('customers'),
17
+ );
18
+
19
+ const makeSelectExtractedTags = () => createSelector(
20
+ selectPreviewAndTestDomain,
21
+ (substate) => substate.get('extractedTags')
22
+ );
23
+
24
+ const makeSelectIsSearchingCustomer = () => createSelector(
25
+ selectPreviewAndTestDomain,
26
+ (substate) => substate.get('isSearchingCustomer')
27
+ );
28
+
29
+ const makeSelectIsExtractingTags = () => createSelector(
30
+ selectPreviewAndTestDomain,
31
+ (substate) => substate.get('isExtractingTags')
32
+ );
33
+
34
+ const makeSelectSearchError = () => createSelector(
35
+ selectPreviewAndTestDomain,
36
+ (substate) => substate.get('searchError')
37
+ );
38
+
39
+ const makeSelectHasSearched = () => createSelector(
40
+ selectPreviewAndTestDomain,
41
+ (substate) => substate.get('hasSearched')
42
+ );
43
+
44
+ const makeSelectApiWarnings = () => createSelector(
45
+ selectPreviewAndTestDomain,
46
+ (substate) => substate.get('apiWarnings')
47
+ );
48
+
49
+ const makeSelectApiErrors = () => createSelector(
50
+ selectPreviewAndTestDomain,
51
+ (substate) => substate.get('apiErrors')
52
+ );
53
+
54
+ const makeSelectPreviewData = () => createSelector(
55
+ selectPreviewAndTestDomain,
56
+ (substate) => substate.get('previewData')
57
+ );
58
+
59
+ const makeSelectIsUpdatingPreview = () => createSelector(
60
+ selectPreviewAndTestDomain,
61
+ (substate) => substate.get('isUpdatingPreview')
62
+ );
63
+
64
+ const makeSelectIsSendingTestEmail = () => createSelector(
65
+ selectPreviewAndTestDomain,
66
+ (substate) => substate.get('isSendingTestEmail')
67
+ );
68
+
69
+ const makeSelectTags = () => createSelector(
70
+ selectPreviewAndTestDomain,
71
+ (substate) => substate.get('tags'),
72
+ );
73
+
74
+ const makeSelectTestCustomers = () => createSelector(
75
+ selectPreviewAndTestDomain,
76
+ (substate) => substate.get('testCustomers'),
77
+ );
78
+
79
+ const makeSelectIsFetchingTestCustomers = () => createSelector(
80
+ selectPreviewAndTestDomain,
81
+ (substate) => substate.get('isFetchingTestCustomers'),
82
+ );
83
+
84
+ const makeSelectTestGroups = () => createSelector(
85
+ selectPreviewAndTestDomain,
86
+ (substate) => substate.get('testGroups'),
87
+ );
88
+
89
+ const makeSelectIsFetchingTestGroups = () => createSelector(
90
+ selectPreviewAndTestDomain,
91
+ (substate) => substate.get('isFetchingTestGroups'),
92
+ );
93
+
94
+ const makeSelectMessageMetaConfigId = () => createSelector(
95
+ selectPreviewAndTestDomain,
96
+ (substate) => substate.get('messageMetaConfigId'),
97
+ );
98
+
99
+ const makeSelectIsCreatingMessageMeta = () => createSelector(
100
+ selectPreviewAndTestDomain,
101
+ (substate) => substate.get('isCreatingMessageMeta'),
102
+ );
103
+
104
+ const makeSelectPrefilledValues = () => createSelector(
105
+ selectPreviewAndTestDomain,
106
+ (substate) => substate.get('prefilledValues')?.toJS(),
107
+ );
108
+
109
+ const makeSelectTestMessageResponse = () => createSelector(
110
+ selectPreviewAndTestDomain,
111
+ (substate) => substate.get('testMessageResponse'),
112
+ );
113
+
114
+ const makeSelectIsSendingTestMessage = () => createSelector(
115
+ selectPreviewAndTestDomain,
116
+ (substate) => substate.get('isSendingTestMessage'),
117
+ );
118
+
119
+ export {
120
+ makeSelectPreviewAndTest,
121
+ makeSelectCustomers,
122
+ makeSelectExtractedTags,
123
+ makeSelectIsSearchingCustomer,
124
+ makeSelectIsExtractingTags,
125
+ makeSelectSearchError,
126
+ makeSelectHasSearched,
127
+ makeSelectApiWarnings,
128
+ makeSelectApiErrors,
129
+ makeSelectPreviewData,
130
+ makeSelectIsUpdatingPreview,
131
+ makeSelectIsSendingTestEmail,
132
+ makeSelectTags,
133
+ makeSelectTestCustomers,
134
+ makeSelectIsFetchingTestCustomers,
135
+ makeSelectTestGroups,
136
+ makeSelectIsFetchingTestGroups,
137
+ makeSelectMessageMetaConfigId,
138
+ makeSelectIsCreatingMessageMeta,
139
+ makeSelectPrefilledValues,
140
+ makeSelectTestMessageResponse,
141
+ makeSelectIsSendingTestMessage,
142
+ };
@@ -0,0 +1,80 @@
1
+ import * as actions from '../actions';
2
+ import * as types from '../constants';
3
+
4
+ describe('TestAndPreviewSlidebox actions', () => {
5
+ it('should have a type of SEARCH_CUSTOMERS_REQUESTED', () => {
6
+ const expected = {
7
+ type: types.SEARCH_CUSTOMERS_REQUESTED,
8
+ payload: { query: 'test' },
9
+ };
10
+ expect(actions.searchCustomersRequested('test')).toEqual(expected);
11
+ });
12
+ it('should have a type of EXTRACT_TAGS_REQUEST', () => {
13
+ const expected = {
14
+ type: types.EXTRACT_TAGS_REQUEST,
15
+ payload: { templateSubject: 'test', templateContent: 'test' },
16
+ };
17
+ expect(actions.extractTagsRequested('test', 'test')).toEqual(expected);
18
+ });
19
+ it('should have a type of UPDATE_PREVIEW_REQUEST', () => {
20
+ const expected = {
21
+ type: types.UPDATE_PREVIEW_REQUEST,
22
+ payload: 'test',
23
+ };
24
+ expect(actions.updatePreviewRequested('test')).toEqual(expected);
25
+ });
26
+ it('should have a type of SEND_TEST_MESSAGE_REQUESTED', () => {
27
+ const expected = {
28
+ type: types.SEND_TEST_MESSAGE_REQUESTED,
29
+ payload: 'test',
30
+ callback: undefined,
31
+ };
32
+ expect(actions.sendTestMessageRequested('test')).toEqual(expected);
33
+ });
34
+ it('should have a type of CLEAR_CUSTOMER_SEARCH_STATE', () => {
35
+ const expected = {
36
+ type: types.CLEAR_CUSTOMER_SEARCH_STATE,
37
+ };
38
+ expect(actions.clearCustomerSearchState()).toEqual(expected);
39
+ });
40
+ it('should have a type of CLEAR_SEARCH_RESULTS', () => {
41
+ const expected = {
42
+ type: types.CLEAR_SEARCH_RESULTS,
43
+ };
44
+ expect(actions.clearSearchResults()).toEqual(expected);
45
+ });
46
+ it('should have a type of FETCH_TEST_CUSTOMERS_REQUESTED', () => {
47
+ const expected = {
48
+ type: types.FETCH_TEST_CUSTOMERS_REQUESTED,
49
+ };
50
+ expect(actions.fetchTestCustomersRequested()).toEqual(expected);
51
+ });
52
+ it('should have a type of FETCH_TEST_GROUPS_REQUESTED', () => {
53
+ const expected = {
54
+ type: types.FETCH_TEST_GROUPS_REQUESTED,
55
+ };
56
+ expect(actions.fetchTestGroupsRequested()).toEqual(expected);
57
+ });
58
+ it('should have a type of CREATE_MESSAGE_META_REQUESTED', () => {
59
+ const expected = {
60
+ type: types.CREATE_MESSAGE_META_REQUESTED,
61
+ payload: 'test',
62
+ messageMetaConfigId: 'test',
63
+ callback: undefined,
64
+ };
65
+ expect(actions.createMessageMetaRequested('test', 'test')).toEqual(expected);
66
+ });
67
+ it('should have a type of GET_PREFILLED_VALUES_REQUESTED', () => {
68
+ const expected = {
69
+ type: types.GET_PREFILLED_VALUES_REQUESTED,
70
+ payload: 'test',
71
+ };
72
+ expect(actions.getPrefilledValuesRequested('test')).toEqual(expected);
73
+ });
74
+ it('should have a type of CLEAR_PREFILLED_VALUES', () => {
75
+ const expected = {
76
+ type: types.CLEAR_PREFILLED_VALUES,
77
+ };
78
+ expect(actions.clearPrefilledValues()).toEqual(expected);
79
+ });
80
+ });
@@ -0,0 +1,367 @@
1
+ import { fromJS } from "immutable";
2
+ import previewAndTestReducer from "../reducer";
3
+ import {
4
+ SEARCH_CUSTOMERS_REQUESTED,
5
+ SEARCH_CUSTOMERS_SUCCESS,
6
+ SEARCH_CUSTOMERS_FAILURE,
7
+ FETCH_TEST_CUSTOMERS_SUCCESS,
8
+ FETCH_TEST_CUSTOMERS_FAILURE,
9
+ FETCH_TEST_CUSTOMERS_REQUESTED,
10
+ CLEAR_PREFILLED_VALUES,
11
+ GET_PREFILLED_VALUES_REQUESTED,
12
+ GET_PREFILLED_VALUES_SUCCESS,
13
+ GET_PREFILLED_VALUES_FAILURE,
14
+ FETCH_TEST_GROUPS_SUCCESS,
15
+ FETCH_TEST_GROUPS_FAILURE,
16
+ FETCH_TEST_GROUPS_REQUESTED,
17
+ EXTRACT_TAGS_REQUEST,
18
+ EXTRACT_TAGS_SUCCESS,
19
+ EXTRACT_TAGS_FAILURE,
20
+ UPDATE_PREVIEW_REQUEST,
21
+ UPDATE_PREVIEW_SUCCESS,
22
+ UPDATE_PREVIEW_FAILURE,
23
+ SEND_TEST_MESSAGE_REQUESTED,
24
+ SEND_TEST_MESSAGE_SUCCESS,
25
+ SEND_TEST_MESSAGE_FAILURE,
26
+ CLEAR_SEARCH_RESULTS,
27
+ CREATE_MESSAGE_META_REQUESTED,
28
+ CREATE_MESSAGE_META_SUCCESS,
29
+ CREATE_MESSAGE_META_FAILURE,
30
+ CLEAR_CUSTOMER_SEARCH_STATE,
31
+ } from "../constants";
32
+
33
+ describe("previewAndTestReducer", () => {
34
+ it("should handle SEARCH_CUSTOMERS_REQUESTED action", () => {
35
+ const state = fromJS({
36
+ searchQuery: "test",
37
+ isSearchingCustomer: false,
38
+ searchError: null,
39
+ hasSearched: false,
40
+ });
41
+ const action = { type: SEARCH_CUSTOMERS_REQUESTED, payload: { query: "test" } };
42
+ const expectedResult = state.set("isSearchingCustomer", true);
43
+ expect(previewAndTestReducer(state, action)).toEqual(expectedResult);
44
+ });
45
+
46
+ it("should handle SEARCH_CUSTOMERS_SUCCESS action", () => {
47
+ const state = fromJS({
48
+ searchQuery: "",
49
+ isSearchingCustomer: false,
50
+ searchError: null,
51
+ hasSearched: false,
52
+ });
53
+ const action = { type: SEARCH_CUSTOMERS_SUCCESS, payload: { customers: [{ id: 1, name: "John Doe" }] } };
54
+ const expectedResult = state.set("isSearchingCustomer", false).set("hasSearched", true).set("customers", [{ id: 1, name: "John Doe" }]);
55
+ expect(previewAndTestReducer(state, action)).toEqual(expectedResult);
56
+ });
57
+
58
+ it("should handle SEARCH_CUSTOMERS_FAILURE action", () => {
59
+ const state = fromJS({
60
+ searchQuery: "",
61
+ isSearchingCustomer: false,
62
+ searchError: null,
63
+ hasSearched: false,
64
+ });
65
+ const action = { type: SEARCH_CUSTOMERS_FAILURE, payload: { error: "Search failed" } };
66
+ const expectedResult = state.set("isSearchingCustomer", false).set("searchError", "Search failed").set("hasSearched", true).set("customers", []);
67
+ expect(previewAndTestReducer(state, action)).toEqual(expectedResult);
68
+ });
69
+
70
+ it("should handle EXTRACT_TAGS_REQUEST action", () => {
71
+ const state = fromJS({
72
+ isExtractingTags: false,
73
+ extractTagsError: null,
74
+ apiWarnings: [],
75
+ apiErrors: [],
76
+ });
77
+ const action = { type: EXTRACT_TAGS_REQUEST };
78
+ const expectedResult = state.set("isExtractingTags", true).set("extractTagsError", null).set("apiWarnings", []).set("apiErrors", []).set("tags.loading", true).set("tags.error", null);
79
+ expect(previewAndTestReducer(state, action)).toEqual(expectedResult);
80
+ });
81
+ it("should handle EXTRACT_TAGS_SUCCESS action", () => {
82
+ const state = fromJS({
83
+ isExtractingTags: false,
84
+ extractTagsError: null,
85
+ apiWarnings: [],
86
+ apiErrors: [],
87
+ });
88
+ const action = { type: EXTRACT_TAGS_SUCCESS, payload: { extractedtags: [{ id: 1, name: "John Doe" }] } };
89
+ const expectedResult = state.set("isExtractingTags", false).set("extractTagsError", null).set("apiWarnings", fromJS([])).set("apiErrors", fromJS([])).set("tags.loading", false).set("tags.error", null).set("extractedTags", [{ id: 1, name: "John Doe" }]);
90
+ expect(previewAndTestReducer(state, action)).toEqual(expectedResult);
91
+ });
92
+ it("should handle EXTRACT_TAGS_FAILURE action", () => {
93
+ const state = fromJS({
94
+ isExtractingTags: false,
95
+ extractTagsError: null,
96
+ apiWarnings: [],
97
+ apiErrors: [],
98
+ });
99
+ const action = { type: EXTRACT_TAGS_FAILURE, payload: { error: "Extract tags failed" } };
100
+ const expectedResult = state.set("isExtractingTags", false).set("extractTagsError", "Extract tags failed").set("apiWarnings", []).set("apiErrors", []).set("tags.loading", false).set("tags.error", "Extract tags failed").set("extractedTags", []);
101
+ expect(previewAndTestReducer(state, action)).toEqual(expectedResult);
102
+ });
103
+
104
+ it("should handle UPDATE_PREVIEW_REQUEST action", () => {
105
+ const state = fromJS({
106
+ isUpdatingPreview: false,
107
+ updatePreviewError: null,
108
+ });
109
+ const action = { type: UPDATE_PREVIEW_REQUEST };
110
+ const expectedResult = state.set("isUpdatingPreview", true).set("updatePreviewError", null);
111
+ expect(previewAndTestReducer(state, action)).toEqual(expectedResult);
112
+ });
113
+ it("should handle UPDATE_PREVIEW_SUCCESS action", () => {
114
+ const state = fromJS({
115
+ isUpdatingPreview: false,
116
+ updatePreviewError: null,
117
+ });
118
+ const action = { type: UPDATE_PREVIEW_SUCCESS, payload: { previewData: "test" } };
119
+ const expectedResult = state.set("isUpdatingPreview", false).set("updatePreviewError", null).set("previewData", "test");
120
+ expect(previewAndTestReducer(state, action)).toEqual(expectedResult);
121
+ });
122
+ it("should handle UPDATE_PREVIEW_FAILURE action", () => {
123
+ const state = fromJS({
124
+ isUpdatingPreview: false,
125
+ updatePreviewError: null,
126
+ });
127
+ const action = { type: UPDATE_PREVIEW_FAILURE, payload: { error: "Update preview failed" } };
128
+ const expectedResult = state.set("isUpdatingPreview", false).set("updatePreviewError", "Update preview failed").set("previewData", null);
129
+ expect(previewAndTestReducer(state, action)).toEqual(expectedResult);
130
+ });
131
+
132
+ it("should handle FETCH_TEST_CUSTOMERS_REQUESTED action", () => {
133
+ const state = fromJS({
134
+ testCustomers: [],
135
+ isFetchingTestCustomers: false,
136
+ fetchTestCustomersError: null,
137
+ });
138
+ const action = { type: FETCH_TEST_CUSTOMERS_REQUESTED };
139
+ const expectedResult = state.set("isFetchingTestCustomers", true);
140
+ expect(previewAndTestReducer(state, action)).toEqual(expectedResult);
141
+ });
142
+ it("should handle FETCH_TEST_CUSTOMERS_SUCCESS action", () => {
143
+ const state = fromJS({
144
+ testCustomers: [],
145
+ isFetchingTestCustomers: false,
146
+ fetchTestCustomersError: null,
147
+ });
148
+ const action = { type: FETCH_TEST_CUSTOMERS_SUCCESS, payload: { customers: [{ id: 1, name: "John Doe" }] } };
149
+ const expectedResult = state.set("isFetchingTestCustomers", false).set("testCustomers", [{ id: 1, name: "John Doe" }]);
150
+ expect(previewAndTestReducer(state, action)).toEqual(expectedResult);
151
+ });
152
+
153
+ it("should handle FETCH_TEST_CUSTOMERS_FAILURE action", () => {
154
+ const state = fromJS({
155
+ testCustomers: [],
156
+ isFetchingTestCustomers: false,
157
+ fetchTestCustomersError: null,
158
+ });
159
+ const action = { type: FETCH_TEST_CUSTOMERS_FAILURE, payload: { error: "Fetch test customers failed" } };
160
+ const expectedResult = state.set("isFetchingTestCustomers", false).set("fetchTestCustomersError", "Fetch test customers failed");
161
+ expect(previewAndTestReducer(state, action)).toEqual(expectedResult);
162
+ });
163
+ it("should handle CLEAR_PREFILLED_VALUES action", () => {
164
+ const state = fromJS({
165
+ prefilledValues: {
166
+ test: "test",
167
+ },
168
+ });
169
+ const action = { type: CLEAR_PREFILLED_VALUES };
170
+ const expectedResult = state.set("prefilledValues", fromJS({}));
171
+ expect(previewAndTestReducer(state, action)).toEqual(expectedResult);
172
+ });
173
+ it("should handle GET_PREFILLED_VALUES_SUCCESS action", () => {
174
+ const state = fromJS({
175
+ prefilledValues: {
176
+ test: "test",
177
+ },
178
+ });
179
+ const action = { type: GET_PREFILLED_VALUES_SUCCESS, payload: { values: { test: "test" } } };
180
+ const expectedResult = state.set("prefilledValues", fromJS({ test: "test" })).set("isFetchingPrefilledValues", false);
181
+ expect(previewAndTestReducer(state, action)).toEqual(expectedResult);
182
+ });
183
+ it("should handle GET_PREFILLED_VALUES_FAILURE action", () => {
184
+ const state = fromJS({
185
+ prefilledValues: {
186
+ test: "test",
187
+ },
188
+ });
189
+ const action = { type: GET_PREFILLED_VALUES_FAILURE, payload: { error: "Fetch prefilled values failed" } };
190
+ const expectedResult = state.set("isFetchingPrefilledValues", false).set("fetchPrefilledValuesError", "Fetch prefilled values failed");
191
+ expect(previewAndTestReducer(state, action)).toEqual(expectedResult);
192
+ });
193
+ it("should handle FETCH_TEST_GROUPS_SUCCESS action", () => {
194
+ const state = fromJS({
195
+ testGroups: [],
196
+ isFetchingTestGroups: false,
197
+ fetchTestGroupsError: null,
198
+ });
199
+ const action = { type: FETCH_TEST_GROUPS_SUCCESS, payload: { groups: [{ id: 1, name: "Test Group" }] } };
200
+ const expectedResult = state.set("isFetchingTestGroups", false).set("testGroups", [{ id: 1, name: "Test Group" }]);
201
+ expect(previewAndTestReducer(state, action)).toEqual(expectedResult);
202
+ });
203
+ it("should handle FETCH_TEST_GROUPS_FAILURE action", () => {
204
+ const state = fromJS({
205
+ testGroups: [],
206
+ isFetchingTestGroups: false,
207
+ fetchTestGroupsError: null,
208
+ });
209
+ const action = { type: FETCH_TEST_GROUPS_FAILURE, payload: { error: "Fetch test groups failed" } };
210
+ const expectedResult = state.set("isFetchingTestGroups", false).set("fetchTestGroupsError", "Fetch test groups failed");
211
+ expect(previewAndTestReducer(state, action)).toEqual(expectedResult);
212
+ });
213
+ it("should handle FETCH_TEST_GROUPS_REQUESTED action", () => {
214
+ const state = fromJS({
215
+ testGroups: [],
216
+ isFetchingTestGroups: false,
217
+ fetchTestGroupsError: null,
218
+ });
219
+ const action = { type: FETCH_TEST_GROUPS_REQUESTED };
220
+ const expectedResult = state.set("isFetchingTestGroups", true);
221
+ expect(previewAndTestReducer(state, action)).toEqual(expectedResult);
222
+ });
223
+ it("should handle default action", () => {
224
+ const state = fromJS({
225
+ testGroups: [],
226
+ isFetchingTestGroups: false,
227
+ fetchTestGroupsError: null,
228
+ });
229
+ const action = { type: "DEFAULT" };
230
+ const expectedResult = state;
231
+ expect(previewAndTestReducer(state, action)).toEqual(expectedResult);
232
+ });
233
+ it("should handle SEND_TEST_MESSAGE_REQUESTED action", () => {
234
+ const state = fromJS({
235
+ isSendingTestMessage: false,
236
+ sendTestMessageError: null,
237
+ });
238
+ const action = { type: SEND_TEST_MESSAGE_REQUESTED };
239
+ const expectedResult = state.set("isSendingTestMessage", true).set("testMessageResponse", null);
240
+ expect(previewAndTestReducer(state, action)).toEqual(expectedResult);
241
+ });
242
+ it("should handle SEND_TEST_MESSAGE_SUCCESS action", () => {
243
+ const state = fromJS({
244
+ isSendingTestMessage: false,
245
+ sendTestMessageError: null,
246
+ });
247
+ const action = { type: SEND_TEST_MESSAGE_SUCCESS, payload: { response: "test" } };
248
+ const expectedResult = state.set("isSendingTestMessage", false).set("sendTestMessageError", null).set("testMessageResponse", "test");
249
+ expect(previewAndTestReducer(state, action)).toEqual(expectedResult);
250
+ });
251
+ it("should handle SEND_TEST_MESSAGE_FAILURE action", () => {
252
+ const state = fromJS({
253
+ isSendingTestMessage: false,
254
+ sendTestMessageError: null,
255
+ });
256
+ const action = { type: SEND_TEST_MESSAGE_FAILURE, payload: { error: "Send test message failed" } };
257
+ const expectedResult = state.set("isSendingTestMessage", false).set("sendTestMessageError", "Send test message failed").set("testMessageResponse", undefined);
258
+ expect(previewAndTestReducer(state, action)).toEqual(expectedResult);
259
+ });
260
+ it("should handle CLEAR_SEARCH_RESULTS action", () => {
261
+ const state = fromJS({
262
+ searchQuery: "test",
263
+ isSearchingCustomer: false,
264
+ searchError: null,
265
+ hasSearched: false,
266
+ });
267
+ const action = { type: CLEAR_SEARCH_RESULTS };
268
+ const expectedResult = state.set("searchQuery", "").set("isSearchingCustomer", false).set("searchError", null).set("hasSearched", false).set("customers", []);
269
+ expect(previewAndTestReducer(state, action)).toEqual(expectedResult);
270
+ });
271
+ it("should handle CREATE_MESSAGE_META_REQUESTED action", () => {
272
+ const state = fromJS({
273
+ isCreatingMessageMeta: false,
274
+ createMessageMetaError: null,
275
+ });
276
+ const action = { type: CREATE_MESSAGE_META_REQUESTED };
277
+ const expectedResult = state.set("isCreatingMessageMeta", true);
278
+ expect(previewAndTestReducer(state, action)).toEqual(expectedResult);
279
+ });
280
+ it("should handle CREATE_MESSAGE_META_SUCCESS action", () => {
281
+ const state = fromJS({
282
+ isCreatingMessageMeta: false,
283
+ createMessageMetaError: null,
284
+ });
285
+ const action = { type: CREATE_MESSAGE_META_SUCCESS, payload: { response: { entity: "test" } } };
286
+ const expectedResult = state.set("isCreatingMessageMeta", false).set("createMessageMetaError", null).set("messageMetaConfigId", "test");
287
+ expect(previewAndTestReducer(state, action)).toEqual(expectedResult);
288
+ });
289
+ it("should handle CREATE_MESSAGE_META_FAILURE action", () => {
290
+ const state = fromJS({
291
+ isCreatingMessageMeta: false,
292
+ createMessageMetaError: null,
293
+ });
294
+ const action = { type: CREATE_MESSAGE_META_FAILURE, payload: { error: "Create message meta failed" } };
295
+ const expectedResult = state.set("isCreatingMessageMeta", false).set("createMessageMetaError", "Create message meta failed");
296
+ expect(previewAndTestReducer(state, action)).toEqual(expectedResult);
297
+ });
298
+ it("should handle CLEAR_CUSTOMER_SEARCH_STATE action", () => {
299
+ const state = fromJS({
300
+ isSearchingCustomer: false,
301
+ searchError: null,
302
+ hasSearched: false,
303
+ });
304
+ const action = { type: CLEAR_CUSTOMER_SEARCH_STATE };
305
+ const initialState = fromJS({
306
+ // Search state
307
+ searchQuery: '',
308
+ customers: [],
309
+ isSearchingCustomer: false,
310
+ searchError: null,
311
+ hasSearched: false,
312
+
313
+ // Selected customer and tags
314
+ extractedTags: [],
315
+ requiredTags: [],
316
+ optionalTags: [],
317
+ isExtractingTags: false,
318
+ extractTagsError: null,
319
+ apiWarnings: [],
320
+ apiErrors: [],
321
+
322
+ // Preview state
323
+ previewData: null,
324
+ isUpdatingPreview: false,
325
+ updatePreviewError: null,
326
+
327
+ // Test email state
328
+ isSendingTestMessage: false,
329
+ sendTestMessageError: null,
330
+ testMessageResponse: null,
331
+
332
+ tags: {
333
+ loading: false,
334
+ error: null,
335
+ required: [],
336
+ optional: [],
337
+ },
338
+
339
+ // Test Customers
340
+ testCustomers: [],
341
+ isFetchingTestCustomers: false,
342
+ fetchTestCustomersError: null,
343
+
344
+ // Test Groups
345
+ testGroups: [],
346
+ isFetchingTestGroups: false,
347
+ fetchTestGroupsError: null,
348
+
349
+ messageMetaConfigId: null,
350
+ isCreatingMessageMeta: false,
351
+ createMessageMetaError: null,
352
+ prefilledValues: {},
353
+ isFetchingPrefilledValues: false,
354
+ fetchPrefilledValuesError: null,
355
+ });
356
+ expect(previewAndTestReducer(state, action)).toEqual(initialState);
357
+ });
358
+ it("should handle GET_PREFILLED_VALUES_REQUESTED action", () => {
359
+ const state = fromJS({
360
+ isFetchingPrefilledValues: false,
361
+ fetchPrefilledValuesError: null,
362
+ });
363
+ const action = { type: GET_PREFILLED_VALUES_REQUESTED };
364
+ const expectedResult = state.set("isFetchingPrefilledValues", true);
365
+ expect(previewAndTestReducer(state, action)).toEqual(expectedResult);
366
+ });
367
+ });