@capillarytech/creatives-library 8.0.34-alpha.0 → 8.0.35

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 (73) hide show
  1. package/containers/App/constants.js +1 -1
  2. package/containers/App/test/saga.test.js +11 -0
  3. package/containers/Assets/Gallery/sagas.js +2 -1
  4. package/containers/Assets/Gallery/tests/saga.test.js +161 -0
  5. package/containers/Cap/tests/saga.test.js +8 -1
  6. package/containers/Dashboard/test/saga.test.js +9 -0
  7. package/containers/Ebill/test/saga.test.js +11 -0
  8. package/containers/Email/sagas.js +1 -1
  9. package/containers/Email/test/saga.test.js +278 -0
  10. package/containers/Line/Create/tests/saga.test.js +209 -0
  11. package/containers/Line/Edit/sagas.js +4 -4
  12. package/containers/Line/Edit/test/saga.test.js +164 -0
  13. package/containers/MobilePush/Create/test/saga.test.js +19 -0
  14. package/containers/MobilePush/Edit/tests/saga.test.js +255 -0
  15. package/containers/Sms/Create/test/saga.test.js +12 -0
  16. package/containers/Sms/Edit/test/saga.test.js +13 -0
  17. package/containers/Templates/test/saga.test.js +244 -0
  18. package/containers/WeChat/MapTemplates/test/saga.test.js +159 -0
  19. package/containers/WeChat/RichmediaTemplates/Create/test/saga.test.js +13 -0
  20. package/containers/WeChat/RichmediaTemplates/Edit/test/saga.test.js +12 -0
  21. package/hoc/test/WithReactRouterV3Compatibility.test.js +135 -0
  22. package/hoc/withReactRouterV3Compatibility.js +4 -4
  23. package/package.json +2 -2
  24. package/tests/integration/TemplateCreation/TemplateCreation.integration.test.js +15 -10
  25. package/tests/integration/TemplateCreation/api-response.js +10 -1
  26. package/tests/integration/TemplateCreation/msw-handler.js +3 -0
  27. package/utils/authWrapper.js +0 -6
  28. package/utils/tagValidations.js +1 -1
  29. package/utils/tests/authWrapper.test.js +142 -0
  30. package/utils/tests/checkStore.test.js +72 -0
  31. package/utils/tests/customAuth.test.js +30 -0
  32. package/utils/tests/tagValidations.test.js +7 -7
  33. package/v2Components/FormBuilder/index.js +1 -1
  34. package/v2Components/NavigationBar/tests/saga.test.js +35 -0
  35. package/v2Containers/Assets/Gallery/sagas.js +1 -1
  36. package/v2Containers/Assets/Gallery/tests/saga.test.js +41 -0
  37. package/v2Containers/BeeEditor/index.js +2 -2
  38. package/v2Containers/BeeEditor/test/saga.test.js +13 -0
  39. package/v2Containers/CallTask/test/saga.test.js +13 -0
  40. package/v2Containers/Cap/sagas.js +3 -3
  41. package/v2Containers/Cap/tests/Cap.test.js +2 -18
  42. package/v2Containers/Cap/tests/saga.test.js +73 -1
  43. package/v2Containers/CapFacebookPreview/tests/saga.test.js +13 -0
  44. package/v2Containers/CreativesContainer/index.js +1 -1
  45. package/v2Containers/Ebill/test/saga.test.js +13 -0
  46. package/v2Containers/Email/sagas.js +3 -2
  47. package/v2Containers/Email/tests/sagas.test.js +216 -0
  48. package/v2Containers/FTP/test/saga.test.js +12 -0
  49. package/v2Containers/Facebook/test/saga.test.js +171 -0
  50. package/v2Containers/InApp/tests/sagas.test.js +13 -0
  51. package/v2Containers/LanguageProvider/sagas.js +1 -1
  52. package/v2Containers/LanguageProvider/tests/saga.test.js +40 -0
  53. package/v2Containers/Line/Container/test/saga.test.js +228 -0
  54. package/v2Containers/MobilePush/Create/index.js +1 -1
  55. package/v2Containers/MobilePush/Create/test/saga.test.js +19 -0
  56. package/v2Containers/MobilePush/Edit/index.js +5 -4
  57. package/v2Containers/MobilePush/Edit/test/saga.test.js +255 -0
  58. package/v2Containers/Rcs/tests/saga.test.js +13 -0
  59. package/v2Containers/Sms/Create/test/saga.test.js +8 -0
  60. package/v2Containers/Sms/Edit/test/saga.test.js +12 -0
  61. package/v2Containers/SmsTrai/Create/tests/saga.test.js +13 -0
  62. package/v2Containers/TagList/index.js +20 -8
  63. package/v2Containers/TagList/tests/TagList.test.js +11 -4
  64. package/v2Containers/TagList/tests/mockdata.js +5 -20
  65. package/v2Containers/Templates/sagas.js +8 -8
  66. package/v2Containers/Templates/tests/sagas.test.js +138 -0
  67. package/v2Containers/Viber/tests/saga.test.js +187 -0
  68. package/v2Containers/WeChat/MapTemplates/test/saga.test.js +160 -0
  69. package/v2Containers/WeChat/RichmediaTemplates/Create/test/saga.test.js +12 -0
  70. package/v2Containers/WeChat/RichmediaTemplates/Edit/test/saga.test.js +13 -0
  71. package/v2Containers/Whatsapp/tests/saga.test.js +9 -1
  72. package/v2Containers/Zalo/tests/saga.test.js +8 -1
  73. package/reducers.js +0 -54
@@ -110,4 +110,4 @@ export const BADGES_ISSUE = 'BADGES_ISSUE';
110
110
 
111
111
  export const CUSTOMER_BARCODE_TAG = "customer_barcode";
112
112
  export const COPY_OF = "Copy of";
113
- export const ENTRY_TRIGGER_TAG_REGEX = /\bentryTrigger_\w+(_\w+)?(\(\w+\))?/g;
113
+ export const ENTRY_TRIGGER_TAG_REGEX = /\bentryTrigger\.\w+(?:\.\w+)?(?:\(\w+\))?/g;
@@ -0,0 +1,11 @@
1
+ import { expectSaga } from "redux-saga-test-plan";
2
+
3
+ import {
4
+ appSaga,
5
+ } from "../sagas";
6
+
7
+ describe("appSaga Combined", () => {
8
+ it("should initialize all appSaga-related watcher sagas without error", () => {
9
+ return expectSaga(appSaga).run();
10
+ });
11
+ });
@@ -5,7 +5,8 @@ import * as types from './constants';
5
5
  export function* getAllAssets(assetType, queryParams) {
6
6
  try {
7
7
  const result = yield call(Api.getAllAssets, assetType, queryParams);
8
- yield put({ type: types.GET_ALL_ASSETS_SUCCESS, data: result?.response, isReset: assetType.queryParams.page === 1 });
8
+ //why are we using assetType.queryParams.page ??
9
+ yield put({ type: types.GET_ALL_ASSETS_SUCCESS, data: result?.response, isReset: queryParams.page === 1 });
9
10
  } catch (error) {
10
11
  yield put({ type: types.GET_ALL_ASSETS_FAILURE, error });
11
12
  }
@@ -0,0 +1,161 @@
1
+ import { expectSaga } from 'redux-saga-test-plan';
2
+ import { call, put } from 'redux-saga/effects';
3
+ import { throwError } from 'redux-saga-test-plan/providers';
4
+ import * as Api from '../../../../services/api';
5
+ import * as types from '../constants';
6
+ import * as sagas from '../sagas';
7
+ import {gallerySaga} from '../sagas';
8
+
9
+ describe('Asset and User Management Sagas', () => {
10
+ describe('getAllAssets Saga', () => {
11
+ const assetType = 'image';
12
+ const queryParams = { page: 1 };
13
+
14
+ it('handles fetching all assets successfully', () => {
15
+ const fakeResponse = {
16
+ response: [{ id: 1, url: 'http://example.com/asset.jpg' }],
17
+ };
18
+
19
+ return expectSaga(sagas.getAllAssets, assetType, queryParams)
20
+ .provide([
21
+ [call(Api.getAllAssets, assetType, queryParams), fakeResponse]
22
+ ])
23
+ .put({
24
+ type: types.GET_ALL_ASSETS_SUCCESS,
25
+ data: fakeResponse.response,
26
+ isReset: true
27
+ })
28
+ .run();
29
+ });
30
+
31
+ it('handles failure in fetching all assets', () => {
32
+ const error = new Error('Fetch failed');
33
+
34
+ return expectSaga(sagas.getAllAssets, assetType, queryParams)
35
+ .provide([
36
+ [call(Api.getAllAssets, assetType, queryParams), throwError(error)]
37
+ ])
38
+ .put({
39
+ type: types.GET_ALL_ASSETS_FAILURE,
40
+ error
41
+ })
42
+ .run();
43
+ });
44
+ });
45
+
46
+ describe('uploadAsset Saga', () => {
47
+ const file = new Blob();
48
+ const assetType = 'image';
49
+ const fileParams = { param1: 'value1' };
50
+
51
+ it('handles successful asset upload', () => {
52
+ const fakeResponse = {
53
+ response: { asset: { id: 1, url: 'http://example.com/asset.jpg' } },
54
+ status: { code: 200 }
55
+ };
56
+
57
+ return expectSaga(sagas.uploadAsset, file, assetType, fileParams)
58
+ .provide([
59
+ [call(Api.uploadFile, file, assetType, fileParams), fakeResponse]
60
+ ])
61
+ .put({
62
+ type: types.UPLOAD_ASSET_SUCCESS,
63
+ data: fakeResponse.response.asset,
64
+ statusCode: 200
65
+ })
66
+ .run();
67
+ });
68
+
69
+ it('handles failure in asset upload', () => {
70
+ const error = new Error('Failed to upload asset');
71
+
72
+ return expectSaga(sagas.uploadAsset, file, assetType, fileParams)
73
+ .provide([
74
+ [call(Api.uploadFile, file, assetType, fileParams), throwError(error)]
75
+ ])
76
+ .put({
77
+ type: types.UPLOAD_ASSET_FAILURE,
78
+ error
79
+ })
80
+ .run();
81
+ });
82
+ });
83
+
84
+ describe('deleteAssetById Saga', () => {
85
+ const assetId = '123';
86
+ const assetType = 'image';
87
+
88
+ it('handles deleting an asset successfully', () => {
89
+ const fakeResponse = {
90
+ response: 'Asset deleted successfully'
91
+ };
92
+
93
+ return expectSaga(sagas.deleteAssetById, assetId, assetType)
94
+ .provide([
95
+ [call(Api.deleteAssetById, assetId, assetType), fakeResponse]
96
+ ])
97
+ .put({
98
+ type: types.DELETE_ASSET_SUCCESS,
99
+ data: fakeResponse.response
100
+ })
101
+ .run();
102
+ });
103
+
104
+ it('handles failure in deleting an asset', () => {
105
+ const error = new Error('Deletion failed');
106
+
107
+ return expectSaga(sagas.deleteAssetById, assetId, assetType)
108
+ .provide([
109
+ [call(Api.deleteAssetById, assetId, assetType), throwError(error)]
110
+ ])
111
+ .put({
112
+ type: types.DELETE_ASSET_FAILURE,
113
+ error
114
+ })
115
+ .run();
116
+ });
117
+ });
118
+
119
+ describe('fetchUserList Saga', () => {
120
+ it('handles fetching user list successfully', () => {
121
+ const fakeResponse = {
122
+ data: {
123
+ result: [{ id: 1, name: 'User One' }]
124
+ }
125
+ };
126
+
127
+ return expectSaga(sagas.fetchUserList)
128
+ .provide([
129
+ [call(Api.getUserList), fakeResponse]
130
+ ])
131
+ .put({
132
+ type: types.GET_USER_LIST_SUCCESS,
133
+ data: fakeResponse.data.result
134
+ })
135
+ .run();
136
+ });
137
+
138
+ it('handles failure in fetching user list', () => {
139
+ const error = new Error('Fetch failed');
140
+
141
+ return expectSaga(sagas.fetchUserList)
142
+ .provide([
143
+ [call(Api.getUserList), throwError(error)]
144
+ ])
145
+ .put({
146
+ type: types.GET_USER_LIST_FAILURE,
147
+ data: error
148
+ })
149
+ .run();
150
+ });
151
+ });
152
+
153
+
154
+ // Test combined saga
155
+ describe('Combined gallerySaga', () => {
156
+ it('should initialize all gallery-related watcher sagas without error', () => {
157
+ return expectSaga(gallerySaga)
158
+ .run();
159
+ });
160
+ });
161
+ });
@@ -11,8 +11,15 @@ import {
11
11
  LOGOUT_SUCCESS,
12
12
  LOGOUT_FAILURE,
13
13
  } from '../constants';
14
- import {logoutFlow, watchForLogoutFlow } from '../sagas';
14
+ import {logoutFlow, watchForLogoutFlow,capSaga } from '../sagas';
15
15
  const error = new Error('error');
16
+
17
+ describe('capSaga', () => {
18
+ it("should initialize all capSaga-related watcher sagas without error", () => {
19
+ return expectSaga(capSaga).run();
20
+ });
21
+ });
22
+
16
23
  describe('loginFlow', () => {
17
24
  it('should handle the login flow', () => {
18
25
  const generator = loginFlow();
@@ -0,0 +1,9 @@
1
+ import { expectSaga } from "redux-saga-test-plan";
2
+
3
+ import { dashboardSaga } from "../sagas";
4
+
5
+ describe("dashboardSaga Combined", () => {
6
+ it("should initialize all dashboardSaga-related watcher sagas without error", () => {
7
+ return expectSaga(dashboardSaga).run();
8
+ });
9
+ });
@@ -0,0 +1,11 @@
1
+ import { expectSaga } from "redux-saga-test-plan";
2
+
3
+ import {
4
+ ebillSaga,
5
+ } from "../sagas";
6
+
7
+ describe("ebillSaga Combined", () => {
8
+ it("should initialize all ebill-related watcher sagas without error", () => {
9
+ return expectSaga(ebillSaga).run();
10
+ });
11
+ });
@@ -45,7 +45,7 @@ export function* getTemplateDetails(id) {
45
45
  export function* getAllAssets(assetType, queryParams) {
46
46
  try {
47
47
  const result = yield call(Api.getAllAssets, assetType, queryParams);
48
- yield put({ type: types.GET_ALL_ASSETS_SUCCESS, data: result?.response, isReset: assetType.queryParams.page === 1 });
48
+ yield put({ type: types.GET_ALL_ASSETS_SUCCESS, data: result?.response, isReset: queryParams.page === 1 });
49
49
  } catch (error) {
50
50
  yield put({ type: types.GET_ALL_ASSETS_FAILURE, error });
51
51
  }
@@ -0,0 +1,278 @@
1
+ import { expectSaga } from 'redux-saga-test-plan';
2
+ import { call, put } from 'redux-saga/effects';
3
+ import { throwError } from 'redux-saga-test-plan/providers';
4
+ import * as Api from '../../../services/api';
5
+ import * as types from '../constants';
6
+ import * as sagas from '../sagas';
7
+
8
+ describe('Email Template Sagas', () => {
9
+ describe('createTemplate Saga', () => {
10
+ const template = { name: 'New Template' };
11
+
12
+ it('handles creating a template successfully', () => {
13
+ const fakeResponse = {
14
+ response: { id: 1, name: 'New Template' },
15
+ status: { code: 200 }
16
+ };
17
+
18
+ return expectSaga(sagas.createTemplate, template)
19
+ .provide([
20
+ [call(Api.createEmailTemplate, template), fakeResponse]
21
+ ])
22
+ .put({
23
+ type: types.CREATE_TEMPLATE_SUCCESS,
24
+ data: fakeResponse.response,
25
+ statusCode: 200,
26
+ errorMsg: undefined
27
+ })
28
+ .run();
29
+ });
30
+
31
+ it('handles failure when creating a template', () => {
32
+ const error = new Error('Failed to create template');
33
+
34
+ return expectSaga(sagas.createTemplate, template)
35
+ .provide([
36
+ [call(Api.createEmailTemplate, template), throwError(error)]
37
+ ])
38
+ .put({
39
+ type: types.CREATE_TEMPLATE_FAILURE,
40
+ error,
41
+ errorMsg: undefined
42
+ })
43
+ .run();
44
+ });
45
+ });
46
+
47
+ describe('duplicateTemplate Saga', () => {
48
+ const id = 1;
49
+ const channel = 'email';
50
+
51
+ it('handles duplicating a template successfully', () => {
52
+ const fakeResponse = {
53
+ response: { id: 2, name: 'Duplicated Template' },
54
+ status: { code: 200 }
55
+ };
56
+
57
+ return expectSaga(sagas.duplicateTemplate, id, channel)
58
+ .provide([
59
+ [call(Api.duplicateTemplate, id, channel), fakeResponse]
60
+ ])
61
+ .put({
62
+ type: types.DUPLICATE_TEMPLATE_SUCCESS,
63
+ data: fakeResponse.response,
64
+ statusCode: 200,
65
+ errorMsg: undefined
66
+ })
67
+ .run();
68
+ });
69
+
70
+ it('handles failure when duplicating a template', () => {
71
+ const error = new Error('Failed to duplicate template');
72
+
73
+ return expectSaga(sagas.duplicateTemplate, id, channel)
74
+ .provide([
75
+ [call(Api.duplicateTemplate, id, channel), throwError(error)]
76
+ ])
77
+ .put({
78
+ type: types.DUPLICATE_TEMPLATE_FAILURE,
79
+ error,
80
+ errorMsg: undefined
81
+ })
82
+ .run();
83
+ });
84
+ });
85
+
86
+ describe('getTemplateDetails Saga', () => {
87
+ const id = '123';
88
+
89
+ it('handles fetching template details successfully', () => {
90
+ const fakeResponse = {
91
+ response: { id: 123, name: 'Detailed Template' }
92
+ };
93
+
94
+ return expectSaga(sagas.getTemplateDetails, id)
95
+ .provide([
96
+ [call(Api.getTemplateDetails, id), fakeResponse]
97
+ ])
98
+ .put({
99
+ type: types.GET_TEMPLATE_DETAILS_SUCCESS,
100
+ data: fakeResponse.response
101
+ })
102
+ .run();
103
+ });
104
+
105
+ it('handles failure in fetching template details', () => {
106
+ const error = new Error('Fetch failed');
107
+
108
+ return expectSaga(sagas.getTemplateDetails, id)
109
+ .provide([
110
+ [call(Api.getTemplateDetails, id), throwError(error)]
111
+ ])
112
+ .put({
113
+ type: types.GET_TEMPLATE_DETAILS_FAILURE,
114
+ error
115
+ })
116
+ .run();
117
+ });
118
+ });
119
+
120
+ describe('getAllAssets Saga', () => {
121
+ const assetType = 'image';
122
+ const queryParams = { page: 1 };
123
+
124
+ it('handles fetching all assets successfully', () => {
125
+ const fakeResponse = {
126
+ response: [{ id: 1, url: 'http://example.com/asset.jpg' }],
127
+ };
128
+
129
+ return expectSaga(sagas.getAllAssets, assetType, queryParams)
130
+ .provide([
131
+ [call(Api.getAllAssets, assetType, queryParams), fakeResponse]
132
+ ])
133
+ .put({
134
+ type: types.GET_ALL_ASSETS_SUCCESS,
135
+ data: fakeResponse.response,
136
+ isReset: true
137
+ })
138
+ .run();
139
+ });
140
+
141
+ it('handles failure in fetching all assets', () => {
142
+ const error = new Error('Fetch failed');
143
+
144
+ return expectSaga(sagas.getAllAssets, assetType, queryParams)
145
+ .provide([
146
+ [call(Api.getAllAssets, assetType, queryParams), throwError(error)]
147
+ ])
148
+ .put({
149
+ type: types.GET_ALL_ASSETS_FAILURE,
150
+ error
151
+ })
152
+ .run();
153
+ });
154
+ });
155
+
156
+ describe('getCmsSetting Saga', () => {
157
+ const params = { cmsType: 'email', projectId: '123', cmsMode: 'edit', langId: 'en', isEdmSupport: true };
158
+
159
+ it('handles fetching CMS settings successfully', () => {
160
+ const fakeResponse = {
161
+ data: {
162
+ response: {
163
+ cmsDetails: { id: 1, name: 'CMS Config' }
164
+ }
165
+ }
166
+ };
167
+
168
+ return expectSaga(sagas.getCmsSetting, params)
169
+ .provide([
170
+ [call(Api.getCmsTemplateSettings, params.cmsType, params.projectId, params.cmsMode, params.langId, params.isEdmSupport), fakeResponse]
171
+ ])
172
+ .put({
173
+ type: types.GET_CMS_EDITOR_DETAILS_SUCCESS,
174
+ settings: fakeResponse.data.response.cmsDetails
175
+ })
176
+ .run();
177
+ });
178
+
179
+ it('handles failure in fetching CMS settings', () => {
180
+ const error = new Error('Fetch failed');
181
+
182
+ return expectSaga(sagas.getCmsSetting, params)
183
+ .provide([
184
+ [call(Api.getCmsTemplateSettings, params.cmsType, params.projectId, params.cmsMode, params.langId, params.isEdmSupport), throwError(error)]
185
+ ])
186
+ .put({
187
+ type: types.GET_CMS_EDITOR_DETAILS_FAILURE,
188
+ error
189
+ })
190
+ .run();
191
+ });
192
+ });
193
+
194
+ describe('getCmsData Saga', () => {
195
+ const params = { cmsType: 'email', projectId: '123', langId: 'en' };
196
+
197
+ it('handles fetching CMS data successfully', () => {
198
+ const fakeResponse = {
199
+ data: {
200
+ response: {
201
+ data: { id: 1, content: 'Content here' },
202
+ langId: 'en'
203
+ }
204
+ }
205
+ };
206
+
207
+ return expectSaga(sagas.getCmsData, params)
208
+ .provide([
209
+ [call(Api.getCmsTemplateData, params.cmsType, params.projectId, params.langId), fakeResponse]
210
+ ])
211
+ .put({
212
+ type: types.GET_CMS_EDITOR_DATA_SUCCESS,
213
+ data: fakeResponse.data.response.data,
214
+ langId: fakeResponse.data.response.langId
215
+ })
216
+ .run();
217
+ });
218
+
219
+ it('handles failure in fetching CMS data', () => {
220
+ const error = new Error('Fetch failed');
221
+
222
+ return expectSaga(sagas.getCmsData, params)
223
+ .provide([
224
+ [call(Api.getCmsTemplateData, params.cmsType, params.projectId, params.langId), throwError(error)]
225
+ ])
226
+ .put({
227
+ type: types.GET_CMS_EDITOR_DATA_FAILURE,
228
+ error
229
+ })
230
+ .run();
231
+ });
232
+ });
233
+
234
+ describe('uploadAsset Saga', () => {
235
+ const file = new Blob();
236
+ const assetType = 'image';
237
+ const fileParams = { param1: 'value1' };
238
+
239
+ it('handles successful asset upload', () => {
240
+ const fakeResponse = {
241
+ response: { asset: { id: 1, url: 'http://example.com/asset.jpg' } },
242
+ status: { code: '200' }
243
+ };
244
+
245
+ return expectSaga(sagas.uploadAsset, file, assetType, fileParams)
246
+ .provide([
247
+ [call(Api.uploadFile, file, assetType, fileParams), fakeResponse]
248
+ ])
249
+ .put({
250
+ type: types.UPLOAD_ASSET_SUCCESS,
251
+ data: fakeResponse.response.asset,
252
+ statusCode: '200'
253
+ })
254
+ .run();
255
+ });
256
+
257
+ it('handles failure in asset upload', () => {
258
+ const error = new Error('Failed to upload asset');
259
+
260
+ return expectSaga(sagas.uploadAsset, file, assetType, fileParams)
261
+ .provide([
262
+ [call(Api.uploadFile, file, assetType, fileParams), throwError(error)]
263
+ ])
264
+ .put({
265
+ type: types.UPLOAD_ASSET_FAILURE,
266
+ error
267
+ })
268
+ .run();
269
+ });
270
+ });
271
+
272
+ describe('Combined emailSaga', () => {
273
+ it('should initialize all email-related watcher sagas without error', () => {
274
+ return expectSaga(sagas.emailSaga)
275
+ .run();
276
+ });
277
+ });
278
+ });