@capillarytech/creatives-library 8.0.339 → 8.0.340-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/.npmrc copy +2 -0
- package/package.json +1 -1
- package/utils/tests/tagValidations.test.js +20 -0
- package/v2Components/CapTagList/index.js +28 -23
- package/v2Components/CapTagList/style.scss +29 -0
- package/v2Components/CapTagListWithInput/__tests__/CapTagListWithInput.test.js +63 -0
- package/v2Components/CapTagListWithInput/index.js +4 -0
- package/v2Components/CapWhatsappCTA/index.js +2 -0
- package/v2Components/FormBuilder/index.js +7 -0
- package/v2Components/HtmlEditor/HTMLEditor.js +6 -1
- package/v2Components/HtmlEditor/__tests__/HTMLEditor.apiErrors.test.js +1 -0
- package/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +927 -2
- package/v2Components/HtmlEditor/components/CodeEditorPane/index.js +3 -0
- package/v2Containers/BeeEditor/index.js +3 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +28 -1
- package/v2Containers/CreativesContainer/index.js +3 -0
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +47 -0
- package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +5 -0
- package/v2Containers/Email/index.js +1 -0
- package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +6 -1
- package/v2Containers/EmailWrapper/components/EmailWrapperView.js +3 -0
- package/v2Containers/EmailWrapper/components/__tests__/EmailHTMLEditor.test.js +20 -2
- package/v2Containers/EmailWrapper/components/__tests__/EmailWrapperView.test.js +16 -1
- package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +3 -0
- package/v2Containers/EmailWrapper/index.js +4 -0
- package/v2Containers/EmailWrapper/tests/useEmailWrapper.edgeCases.test.js +1 -0
- package/v2Containers/EmailWrapper/tests/useEmailWrapper.test.js +9 -0
- package/v2Containers/InAppWrapper/hooks/__tests__/useInAppWrapper.test.js +1 -0
- package/v2Containers/MobilePush/Create/index.js +2 -0
- package/v2Containers/MobilePush/Edit/index.js +2 -0
- package/v2Containers/MobilepushWrapper/index.js +3 -1
- package/v2Containers/Rcs/index.js +1 -0
- package/v2Containers/Sms/Create/index.js +2 -0
- package/v2Containers/Sms/Edit/index.js +2 -0
- package/v2Containers/SmsTrai/Edit/index.js +2 -0
- package/v2Containers/SmsWrapper/index.js +2 -0
- package/v2Containers/TagList/index.js +62 -5
- package/v2Containers/TagList/messages.js +4 -0
- package/v2Containers/TagList/tests/TagList.test.js +124 -20
- package/v2Containers/TagList/tests/mockdata.js +17 -0
- package/v2Containers/Viber/constants.js +8 -0
- package/v2Containers/Viber/index.js +8 -0
- package/v2Containers/Viber/reducer.js +44 -21
- package/v2Containers/Viber/sagas.js +62 -21
- package/v2Containers/Viber/tests/index.test.js +80 -0
- package/v2Containers/Viber/tests/reducer.test.js +297 -0
- package/v2Containers/Viber/tests/saga.test.js +365 -40
- package/v2Containers/WebPush/Create/hooks/useTagManagement.js +0 -2
- package/v2Containers/WebPush/Create/index.js +9 -1
- package/v2Containers/Whatsapp/index.js +5 -0
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +20 -0
- package/v2Containers/Zalo/index.js +2 -0
|
@@ -1,50 +1,258 @@
|
|
|
1
1
|
import { expectSaga } from 'redux-saga-test-plan';
|
|
2
|
-
import
|
|
2
|
+
import * as matchers from 'redux-saga-test-plan/matchers';
|
|
3
|
+
import { call } from 'redux-saga/effects';
|
|
3
4
|
import { throwError } from 'redux-saga-test-plan/providers';
|
|
4
5
|
import * as Api from '../../../services/api';
|
|
5
6
|
import * as sagas from '../sagas';
|
|
6
|
-
import { v2ViberSagas } from '../sagas';
|
|
7
7
|
import * as types from '../constants';
|
|
8
|
+
import { pollAssetStatus } from '../../../sagas/assetPolling';
|
|
9
|
+
import { ASSET_STATUS } from '../../../utils/assetStatusConstants';
|
|
8
10
|
|
|
9
11
|
describe('Viber Sagas', () => {
|
|
10
|
-
|
|
11
12
|
describe('uploadViberAsset Saga', () => {
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
const mockAsset = {
|
|
14
|
+
_id: 'asset-123',
|
|
15
|
+
type: 'IMAGE',
|
|
16
|
+
url: 'https://example.com/image.jpg',
|
|
17
|
+
};
|
|
15
18
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
const mockParams = {
|
|
20
|
+
file: new File(['test'], 'test.jpg', { type: 'image/jpeg' }),
|
|
21
|
+
assetType: 'image',
|
|
22
|
+
fileParams: {},
|
|
23
|
+
templateType: 0,
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
it('handles async upload (202) with polling', () => {
|
|
27
|
+
const mockResponse = {
|
|
28
|
+
status: { code: 202 },
|
|
29
|
+
response: {
|
|
30
|
+
assetId: 'asset-123',
|
|
31
|
+
asset: mockAsset,
|
|
32
|
+
processingStatus: ASSET_STATUS.PROCESSING,
|
|
33
|
+
},
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
return expectSaga(sagas.uploadViberAsset, mockParams)
|
|
37
|
+
.provide([
|
|
38
|
+
[matchers.call.fn(Api.uploadFile), mockResponse],
|
|
39
|
+
[matchers.call.fn(pollAssetStatus), undefined],
|
|
40
|
+
])
|
|
41
|
+
.put({
|
|
42
|
+
type: types.UPLOAD_VIBER_ASSET_PROCESSING,
|
|
43
|
+
payload: {
|
|
44
|
+
assetId: 'asset-123',
|
|
45
|
+
asset: mockAsset,
|
|
46
|
+
processingStatus: ASSET_STATUS.PROCESSING,
|
|
47
|
+
},
|
|
48
|
+
})
|
|
49
|
+
.call.fn(Api.uploadFile)
|
|
50
|
+
.call.fn(pollAssetStatus)
|
|
51
|
+
.run();
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
it('handles async when processingStatus is processing with 200 status', () => {
|
|
55
|
+
const mockResponse = {
|
|
56
|
+
status: { code: 200 },
|
|
57
|
+
response: {
|
|
58
|
+
assetId: 'asset-123',
|
|
59
|
+
asset: mockAsset,
|
|
60
|
+
processingStatus: ASSET_STATUS.PROCESSING,
|
|
61
|
+
},
|
|
20
62
|
};
|
|
21
63
|
|
|
22
|
-
return expectSaga(sagas.uploadViberAsset,
|
|
64
|
+
return expectSaga(sagas.uploadViberAsset, mockParams)
|
|
23
65
|
.provide([
|
|
24
|
-
[call(Api.uploadFile
|
|
66
|
+
[matchers.call.fn(Api.uploadFile), mockResponse],
|
|
67
|
+
[matchers.call.fn(pollAssetStatus), undefined],
|
|
68
|
+
])
|
|
69
|
+
.put({
|
|
70
|
+
type: types.UPLOAD_VIBER_ASSET_PROCESSING,
|
|
71
|
+
payload: {
|
|
72
|
+
assetId: 'asset-123',
|
|
73
|
+
asset: mockAsset,
|
|
74
|
+
processingStatus: ASSET_STATUS.PROCESSING,
|
|
75
|
+
},
|
|
76
|
+
})
|
|
77
|
+
.call.fn(pollAssetStatus)
|
|
78
|
+
.run();
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
it('handles sync upload (201) without polling', () => {
|
|
82
|
+
const mockResponse = {
|
|
83
|
+
status: { code: 201 },
|
|
84
|
+
response: {
|
|
85
|
+
asset: mockAsset,
|
|
86
|
+
},
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
return expectSaga(sagas.uploadViberAsset, mockParams)
|
|
90
|
+
.provide([
|
|
91
|
+
[matchers.call.fn(Api.uploadFile), mockResponse],
|
|
25
92
|
])
|
|
26
93
|
.put({
|
|
27
94
|
type: types.UPLOAD_VIBER_ASSET_SUCCESS,
|
|
28
|
-
data:
|
|
29
|
-
statusCode:
|
|
30
|
-
templateType:
|
|
95
|
+
data: mockAsset,
|
|
96
|
+
statusCode: 201,
|
|
97
|
+
templateType: 0,
|
|
31
98
|
})
|
|
99
|
+
.not.call(pollAssetStatus)
|
|
32
100
|
.run();
|
|
33
101
|
});
|
|
34
102
|
|
|
35
|
-
it('
|
|
36
|
-
const
|
|
103
|
+
it('extracts assetId from asset._id when assetId omitted', () => {
|
|
104
|
+
const mockResponse = {
|
|
105
|
+
status: { code: 202 },
|
|
106
|
+
response: {
|
|
107
|
+
asset: { ...mockAsset, _id: 'asset-456' },
|
|
108
|
+
processingStatus: ASSET_STATUS.PROCESSING,
|
|
109
|
+
},
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
return expectSaga(sagas.uploadViberAsset, mockParams)
|
|
113
|
+
.provide([
|
|
114
|
+
[matchers.call.fn(Api.uploadFile), mockResponse],
|
|
115
|
+
[matchers.call.fn(pollAssetStatus), undefined],
|
|
116
|
+
])
|
|
117
|
+
.put({
|
|
118
|
+
type: types.UPLOAD_VIBER_ASSET_PROCESSING,
|
|
119
|
+
payload: {
|
|
120
|
+
assetId: 'asset-456',
|
|
121
|
+
asset: { ...mockAsset, _id: 'asset-456' },
|
|
122
|
+
processingStatus: ASSET_STATUS.PROCESSING,
|
|
123
|
+
},
|
|
124
|
+
})
|
|
125
|
+
.run();
|
|
126
|
+
});
|
|
127
|
+
|
|
128
|
+
it('dispatches FAILED when assetId missing on async response', () => {
|
|
129
|
+
const mockResponse = {
|
|
130
|
+
status: { code: 202 },
|
|
131
|
+
response: {
|
|
132
|
+
processingStatus: ASSET_STATUS.PROCESSING,
|
|
133
|
+
},
|
|
134
|
+
};
|
|
37
135
|
|
|
38
|
-
return expectSaga(sagas.uploadViberAsset,
|
|
136
|
+
return expectSaga(sagas.uploadViberAsset, mockParams)
|
|
39
137
|
.provide([
|
|
40
|
-
[call(Api.uploadFile
|
|
138
|
+
[matchers.call.fn(Api.uploadFile), mockResponse],
|
|
139
|
+
])
|
|
140
|
+
.put({
|
|
141
|
+
type: types.UPLOAD_VIBER_ASSET_FAILED,
|
|
142
|
+
payload: {
|
|
143
|
+
assetId: undefined,
|
|
144
|
+
error: 'Asset upload initiated but no asset ID was returned from the server. Unable to track processing status.',
|
|
145
|
+
},
|
|
146
|
+
templateType: 0,
|
|
147
|
+
})
|
|
148
|
+
.not.call(pollAssetStatus)
|
|
149
|
+
.run();
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
it('handles upload error', () => {
|
|
153
|
+
const uploadError = new Error('Upload failed');
|
|
154
|
+
|
|
155
|
+
return expectSaga(sagas.uploadViberAsset, mockParams)
|
|
156
|
+
.provide([
|
|
157
|
+
[matchers.call.fn(Api.uploadFile), throwError(uploadError)],
|
|
41
158
|
])
|
|
42
159
|
.put({
|
|
43
160
|
type: types.UPLOAD_VIBER_ASSET_FAILURE,
|
|
44
|
-
error
|
|
161
|
+
error: uploadError,
|
|
162
|
+
})
|
|
163
|
+
.run();
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it('falls back to statusCode on response when status object missing', () => {
|
|
167
|
+
const mockResponse = {
|
|
168
|
+
statusCode: 201,
|
|
169
|
+
response: { asset: mockAsset },
|
|
170
|
+
};
|
|
171
|
+
return expectSaga(sagas.uploadViberAsset, mockParams)
|
|
172
|
+
.provide([
|
|
173
|
+
[matchers.call.fn(Api.uploadFile), mockResponse],
|
|
174
|
+
])
|
|
175
|
+
.put({
|
|
176
|
+
type: types.UPLOAD_VIBER_ASSET_SUCCESS,
|
|
177
|
+
data: mockAsset,
|
|
178
|
+
statusCode: 201,
|
|
179
|
+
templateType: 0,
|
|
45
180
|
})
|
|
46
181
|
.run();
|
|
47
182
|
});
|
|
183
|
+
|
|
184
|
+
it('defaults statusCode to 200 when no status info present', () => {
|
|
185
|
+
const mockResponse = { response: { asset: mockAsset } };
|
|
186
|
+
return expectSaga(sagas.uploadViberAsset, mockParams)
|
|
187
|
+
.provide([
|
|
188
|
+
[matchers.call.fn(Api.uploadFile), mockResponse],
|
|
189
|
+
])
|
|
190
|
+
.put({
|
|
191
|
+
type: types.UPLOAD_VIBER_ASSET_SUCCESS,
|
|
192
|
+
data: mockAsset,
|
|
193
|
+
statusCode: 200,
|
|
194
|
+
templateType: 0,
|
|
195
|
+
})
|
|
196
|
+
.run();
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('handles empty response object', () => {
|
|
200
|
+
const mockResponse = { status: { code: 201 } };
|
|
201
|
+
return expectSaga(sagas.uploadViberAsset, mockParams)
|
|
202
|
+
.provide([
|
|
203
|
+
[matchers.call.fn(Api.uploadFile), mockResponse],
|
|
204
|
+
])
|
|
205
|
+
.put({
|
|
206
|
+
type: types.UPLOAD_VIBER_ASSET_SUCCESS,
|
|
207
|
+
data: undefined,
|
|
208
|
+
statusCode: 201,
|
|
209
|
+
templateType: 0,
|
|
210
|
+
})
|
|
211
|
+
.run();
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
it('derives assetType from asset.type when params.assetType omitted', () => {
|
|
215
|
+
const paramsWithoutType = {
|
|
216
|
+
file: new File(['v'], 'v.mp4', { type: 'video/mp4' }),
|
|
217
|
+
fileParams: {},
|
|
218
|
+
templateType: 1,
|
|
219
|
+
};
|
|
220
|
+
const mockResponse = {
|
|
221
|
+
status: { code: 202 },
|
|
222
|
+
response: {
|
|
223
|
+
assetId: 'asset-vid',
|
|
224
|
+
asset: { _id: 'asset-vid', type: 'VIDEO' },
|
|
225
|
+
},
|
|
226
|
+
};
|
|
227
|
+
return expectSaga(sagas.uploadViberAsset, paramsWithoutType)
|
|
228
|
+
.provide([
|
|
229
|
+
[matchers.call.fn(Api.uploadFile), mockResponse],
|
|
230
|
+
[matchers.call.fn(pollAssetStatus), undefined],
|
|
231
|
+
])
|
|
232
|
+
.call.fn(pollAssetStatus)
|
|
233
|
+
.run();
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
it('defaults assetType to image when no type info available', () => {
|
|
237
|
+
const paramsWithoutType = {
|
|
238
|
+
file: new File(['x'], 'x', { type: '' }),
|
|
239
|
+
fileParams: {},
|
|
240
|
+
templateType: 0,
|
|
241
|
+
};
|
|
242
|
+
const mockResponse = {
|
|
243
|
+
status: { code: 202 },
|
|
244
|
+
response: {
|
|
245
|
+
assetId: 'asset-noop',
|
|
246
|
+
},
|
|
247
|
+
};
|
|
248
|
+
return expectSaga(sagas.uploadViberAsset, paramsWithoutType)
|
|
249
|
+
.provide([
|
|
250
|
+
[matchers.call.fn(Api.uploadFile), mockResponse],
|
|
251
|
+
[matchers.call.fn(pollAssetStatus), undefined],
|
|
252
|
+
])
|
|
253
|
+
.call.fn(pollAssetStatus)
|
|
254
|
+
.run();
|
|
255
|
+
});
|
|
48
256
|
});
|
|
49
257
|
|
|
50
258
|
describe('createViberTemplate Saga', () => {
|
|
@@ -54,18 +262,18 @@ describe('Viber Sagas', () => {
|
|
|
54
262
|
it('handles creating template successfully', () => {
|
|
55
263
|
const fakeResponse = {
|
|
56
264
|
response: { id: 2, content: template.content },
|
|
57
|
-
status: { code: 201 }
|
|
265
|
+
status: { code: 201 },
|
|
58
266
|
};
|
|
59
267
|
|
|
60
268
|
return expectSaga(sagas.createViberTemplate, { template, callback })
|
|
61
269
|
.provide([
|
|
62
|
-
[call(Api.createViberTemplate, { template }), fakeResponse]
|
|
270
|
+
[call(Api.createViberTemplate, { template }), fakeResponse],
|
|
63
271
|
])
|
|
64
272
|
.put({
|
|
65
273
|
type: types.CREATE_VIBER_TEMPLATE_SUCCESS,
|
|
66
274
|
data: fakeResponse.response,
|
|
67
275
|
statusCode: fakeResponse.status.code,
|
|
68
|
-
errorMsg: undefined
|
|
276
|
+
errorMsg: undefined,
|
|
69
277
|
})
|
|
70
278
|
.run()
|
|
71
279
|
.then(() => {
|
|
@@ -76,21 +284,74 @@ describe('Viber Sagas', () => {
|
|
|
76
284
|
it('handles failure in creating template', () => {
|
|
77
285
|
const error = new Error({ message: 'Creation failed', status: { code: 400 } });
|
|
78
286
|
|
|
79
|
-
const errorMsg = 'Creation failed';
|
|
80
287
|
return expectSaga(sagas.createViberTemplate, { template, callback })
|
|
81
288
|
.provide([
|
|
82
|
-
[call(Api.createViberTemplate, { template }), throwError(error)]
|
|
289
|
+
[call(Api.createViberTemplate, { template }), throwError(error)],
|
|
83
290
|
])
|
|
84
291
|
.put({
|
|
85
292
|
type: types.CREATE_VIBER_TEMPLATE_FAILURE,
|
|
86
293
|
error,
|
|
87
|
-
errorMsg
|
|
294
|
+
errorMsg: undefined,
|
|
88
295
|
})
|
|
89
296
|
.run()
|
|
90
297
|
.then(() => {
|
|
91
298
|
expect(callback).toHaveBeenCalledWith(null, undefined);
|
|
92
299
|
});
|
|
93
300
|
});
|
|
301
|
+
|
|
302
|
+
it('handles 4xx API response (treated as failure)', () => {
|
|
303
|
+
const cb = jest.fn();
|
|
304
|
+
const fakeResponse = {
|
|
305
|
+
response: {},
|
|
306
|
+
status: { code: 400 },
|
|
307
|
+
message: 'bad request',
|
|
308
|
+
};
|
|
309
|
+
return expectSaga(sagas.createViberTemplate, { template, callback: cb })
|
|
310
|
+
.provide([
|
|
311
|
+
[call(Api.createViberTemplate, { template }), fakeResponse],
|
|
312
|
+
])
|
|
313
|
+
.put({
|
|
314
|
+
type: types.CREATE_VIBER_TEMPLATE_FAILURE,
|
|
315
|
+
error: 'bad request',
|
|
316
|
+
errorMsg: 'bad request',
|
|
317
|
+
})
|
|
318
|
+
.run()
|
|
319
|
+
.then(() => {
|
|
320
|
+
expect(cb).toHaveBeenCalledWith(null, 'bad request');
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
|
|
324
|
+
it('handles success when no callback is supplied', () => {
|
|
325
|
+
const fakeResponse = {
|
|
326
|
+
response: { id: 42 },
|
|
327
|
+
status: { code: 201 },
|
|
328
|
+
};
|
|
329
|
+
return expectSaga(sagas.createViberTemplate, { template })
|
|
330
|
+
.provide([
|
|
331
|
+
[call(Api.createViberTemplate, { template }), fakeResponse],
|
|
332
|
+
])
|
|
333
|
+
.put({
|
|
334
|
+
type: types.CREATE_VIBER_TEMPLATE_SUCCESS,
|
|
335
|
+
data: fakeResponse.response,
|
|
336
|
+
statusCode: 201,
|
|
337
|
+
errorMsg: undefined,
|
|
338
|
+
})
|
|
339
|
+
.run();
|
|
340
|
+
});
|
|
341
|
+
|
|
342
|
+
it('handles failure when no callback is supplied', () => {
|
|
343
|
+
const error = new Error('Creation failed');
|
|
344
|
+
return expectSaga(sagas.createViberTemplate, { template })
|
|
345
|
+
.provide([
|
|
346
|
+
[call(Api.createViberTemplate, { template }), throwError(error)],
|
|
347
|
+
])
|
|
348
|
+
.put({
|
|
349
|
+
type: types.CREATE_VIBER_TEMPLATE_FAILURE,
|
|
350
|
+
error,
|
|
351
|
+
errorMsg: undefined,
|
|
352
|
+
})
|
|
353
|
+
.run();
|
|
354
|
+
});
|
|
94
355
|
});
|
|
95
356
|
|
|
96
357
|
describe('editTemplate Saga', () => {
|
|
@@ -100,18 +361,18 @@ describe('Viber Sagas', () => {
|
|
|
100
361
|
it('handles editing template successfully', () => {
|
|
101
362
|
const fakeResponse = {
|
|
102
363
|
response: { updated: true },
|
|
103
|
-
status: { code: 200 }
|
|
364
|
+
status: { code: 200 },
|
|
104
365
|
};
|
|
105
366
|
|
|
106
367
|
return expectSaga(sagas.editTemplate, { template, callback })
|
|
107
368
|
.provide([
|
|
108
|
-
[call(Api.createViberTemplate, { template }), fakeResponse]
|
|
369
|
+
[call(Api.createViberTemplate, { template }), fakeResponse],
|
|
109
370
|
])
|
|
110
371
|
.put({
|
|
111
372
|
type: types.EDIT_VIBER_TEMPLATE_SUCCESS,
|
|
112
373
|
data: fakeResponse.response,
|
|
113
374
|
statusCode: fakeResponse.status.code,
|
|
114
|
-
errorMsg: undefined
|
|
375
|
+
errorMsg: undefined,
|
|
115
376
|
})
|
|
116
377
|
.run()
|
|
117
378
|
.then(() => {
|
|
@@ -123,7 +384,7 @@ describe('Viber Sagas', () => {
|
|
|
123
384
|
const errorMsg = 'Error in editing template';
|
|
124
385
|
return expectSaga(sagas.editTemplate, { template, callback })
|
|
125
386
|
.provide([
|
|
126
|
-
[call(Api.createViberTemplate, { template }), throwError({ message: errorMsg, status: { code: 400 } })]
|
|
387
|
+
[call(Api.createViberTemplate, { template }), throwError({ message: errorMsg, status: { code: 400 } })],
|
|
127
388
|
])
|
|
128
389
|
.put({
|
|
129
390
|
type: types.EDIT_VIBER_TEMPLATE_FAILURE,
|
|
@@ -135,6 +396,60 @@ describe('Viber Sagas', () => {
|
|
|
135
396
|
expect(callback).toHaveBeenCalledWith(null, undefined);
|
|
136
397
|
});
|
|
137
398
|
});
|
|
399
|
+
|
|
400
|
+
it('handles 4xx API response (treated as failure)', () => {
|
|
401
|
+
const cb = jest.fn();
|
|
402
|
+
const fakeResponse = {
|
|
403
|
+
response: {},
|
|
404
|
+
status: { code: 422 },
|
|
405
|
+
message: 'invalid payload',
|
|
406
|
+
};
|
|
407
|
+
return expectSaga(sagas.editTemplate, { template, callback: cb })
|
|
408
|
+
.provide([
|
|
409
|
+
[call(Api.createViberTemplate, { template }), fakeResponse],
|
|
410
|
+
])
|
|
411
|
+
.put({
|
|
412
|
+
type: types.EDIT_VIBER_TEMPLATE_FAILURE,
|
|
413
|
+
error: 'invalid payload',
|
|
414
|
+
errorMsg: 'invalid payload',
|
|
415
|
+
})
|
|
416
|
+
.run()
|
|
417
|
+
.then(() => {
|
|
418
|
+
expect(cb).toHaveBeenCalledWith(null, 'invalid payload');
|
|
419
|
+
});
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
it('handles success when no callback is supplied', () => {
|
|
423
|
+
const fakeResponse = {
|
|
424
|
+
response: { updated: true },
|
|
425
|
+
status: { code: 200 },
|
|
426
|
+
};
|
|
427
|
+
return expectSaga(sagas.editTemplate, { template })
|
|
428
|
+
.provide([
|
|
429
|
+
[call(Api.createViberTemplate, { template }), fakeResponse],
|
|
430
|
+
])
|
|
431
|
+
.put({
|
|
432
|
+
type: types.EDIT_VIBER_TEMPLATE_SUCCESS,
|
|
433
|
+
data: fakeResponse.response,
|
|
434
|
+
statusCode: 200,
|
|
435
|
+
errorMsg: undefined,
|
|
436
|
+
})
|
|
437
|
+
.run();
|
|
438
|
+
});
|
|
439
|
+
|
|
440
|
+
it('handles failure when no callback is supplied', () => {
|
|
441
|
+
const error = new Error('Edit failed');
|
|
442
|
+
return expectSaga(sagas.editTemplate, { template })
|
|
443
|
+
.provide([
|
|
444
|
+
[call(Api.createViberTemplate, { template }), throwError(error)],
|
|
445
|
+
])
|
|
446
|
+
.put({
|
|
447
|
+
type: types.EDIT_VIBER_TEMPLATE_FAILURE,
|
|
448
|
+
error,
|
|
449
|
+
errorMsg: undefined,
|
|
450
|
+
})
|
|
451
|
+
.run();
|
|
452
|
+
});
|
|
138
453
|
});
|
|
139
454
|
|
|
140
455
|
describe('getTemplateDetails Saga', () => {
|
|
@@ -143,16 +458,16 @@ describe('Viber Sagas', () => {
|
|
|
143
458
|
|
|
144
459
|
it('handles fetching template details successfully', () => {
|
|
145
460
|
const fakeResponse = {
|
|
146
|
-
response: { id
|
|
461
|
+
response: { id, name: 'Detailed Template' },
|
|
147
462
|
};
|
|
148
463
|
|
|
149
464
|
return expectSaga(sagas.getTemplateDetails, { id, callback })
|
|
150
465
|
.provide([
|
|
151
|
-
[call(Api.getTemplateDetails, { id, channel: 'VIBER' }), fakeResponse]
|
|
466
|
+
[call(Api.getTemplateDetails, { id, channel: 'VIBER' }), fakeResponse],
|
|
152
467
|
])
|
|
153
468
|
.put({
|
|
154
469
|
type: types.GET_VIBER_TEMPLATE_DETAILS_SUCCESS,
|
|
155
|
-
data: fakeResponse.response
|
|
470
|
+
data: fakeResponse.response,
|
|
156
471
|
})
|
|
157
472
|
.run()
|
|
158
473
|
.then(() => {
|
|
@@ -165,23 +480,33 @@ describe('Viber Sagas', () => {
|
|
|
165
480
|
|
|
166
481
|
return expectSaga(sagas.getTemplateDetails, { id, callback })
|
|
167
482
|
.provide([
|
|
168
|
-
[call(Api.getTemplateDetails, { id, channel: 'VIBER' }), throwError(error)]
|
|
483
|
+
[call(Api.getTemplateDetails, { id, channel: 'VIBER' }), throwError(error)],
|
|
169
484
|
])
|
|
170
485
|
.put({
|
|
171
486
|
type: types.GET_VIBER_TEMPLATE_DETAILS_FAILURE,
|
|
172
|
-
error
|
|
487
|
+
error,
|
|
173
488
|
})
|
|
174
489
|
.run()
|
|
175
490
|
.then(() => {
|
|
176
491
|
expect(callback).not.toHaveBeenCalledWith();
|
|
177
492
|
});
|
|
178
493
|
});
|
|
179
|
-
});
|
|
180
494
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
return expectSaga(
|
|
495
|
+
it('handles success without a callback', () => {
|
|
496
|
+
const fakeResponse = { response: { id, name: 'No CB' } };
|
|
497
|
+
return expectSaga(sagas.getTemplateDetails, { id })
|
|
498
|
+
.provide([
|
|
499
|
+
[call(Api.getTemplateDetails, { id, channel: 'VIBER' }), fakeResponse],
|
|
500
|
+
])
|
|
501
|
+
.put({
|
|
502
|
+
type: types.GET_VIBER_TEMPLATE_DETAILS_SUCCESS,
|
|
503
|
+
data: fakeResponse.response,
|
|
504
|
+
})
|
|
505
|
+
.run();
|
|
184
506
|
});
|
|
185
507
|
});
|
|
186
508
|
|
|
187
|
-
|
|
509
|
+
describe('v2ViberSagas Combined', () => {
|
|
510
|
+
it('should initialize all Viber-related watcher sagas without error', () => expectSaga(sagas.v2ViberSagas).run());
|
|
511
|
+
});
|
|
512
|
+
});
|
|
@@ -84,6 +84,7 @@ const MemoizedTagList = memo(({
|
|
|
84
84
|
injectedTags,
|
|
85
85
|
selectedOfferDetails,
|
|
86
86
|
eventContextTags,
|
|
87
|
+
waitEventContextTags,
|
|
87
88
|
forwardedTags,
|
|
88
89
|
onTagSelect,
|
|
89
90
|
restrictPersonalization = false,
|
|
@@ -99,6 +100,7 @@ const MemoizedTagList = memo(({
|
|
|
99
100
|
injectedTags={injectedTags}
|
|
100
101
|
selectedOfferDetails={selectedOfferDetails}
|
|
101
102
|
eventContextTags={eventContextTags}
|
|
103
|
+
waitEventContextTags={waitEventContextTags}
|
|
102
104
|
forwardedTags={forwardedTags}
|
|
103
105
|
onTagSelect={onTagSelect}
|
|
104
106
|
restrictPersonalization={restrictPersonalization}
|
|
@@ -116,6 +118,7 @@ const MemoizedTagList = memo(({
|
|
|
116
118
|
&& prevProps.injectedTags === nextProps.injectedTags
|
|
117
119
|
&& prevProps.selectedOfferDetails === nextProps.selectedOfferDetails
|
|
118
120
|
&& prevProps.eventContextTags === nextProps.eventContextTags
|
|
121
|
+
&& prevProps.waitEventContextTags === nextProps.waitEventContextTags
|
|
119
122
|
&& prevProps.forwardedTags === nextProps.forwardedTags
|
|
120
123
|
&& prevProps.onTagSelect === nextProps.onTagSelect
|
|
121
124
|
&& prevProps.restrictPersonalization === nextProps.restrictPersonalization
|
|
@@ -152,6 +155,7 @@ const WebPushCreate = ({
|
|
|
152
155
|
forwardedTags,
|
|
153
156
|
selectedOfferDetails = [],
|
|
154
157
|
eventContextTags = [],
|
|
158
|
+
waitEventContextTags = {},
|
|
155
159
|
templateActions: templateActionsProps,
|
|
156
160
|
Templates,
|
|
157
161
|
restrictPersonalization = false,
|
|
@@ -232,6 +236,7 @@ const WebPushCreate = ({
|
|
|
232
236
|
supportedTags: memoizedSupportedTags,
|
|
233
237
|
injectedTags,
|
|
234
238
|
eventContextTags,
|
|
239
|
+
waitEventContextTags,
|
|
235
240
|
});
|
|
236
241
|
const { tags, handleOnTagsContextChange, validationConfig } = tagState;
|
|
237
242
|
const { weCrmAccounts } = Templates;
|
|
@@ -837,12 +842,13 @@ const WebPushCreate = ({
|
|
|
837
842
|
injectedTags,
|
|
838
843
|
selectedOfferDetails,
|
|
839
844
|
eventContextTags,
|
|
845
|
+
waitEventContextTags,
|
|
840
846
|
forwardedTags,
|
|
841
847
|
restrictPersonalization,
|
|
842
848
|
disabled: restrictPersonalization,
|
|
843
849
|
disableTooltipMsg: restrictPersonalization ? formatMessage(messages.personalizationNotSupportedAnonymous) : undefined,
|
|
844
850
|
}),
|
|
845
|
-
[tags, injectedTags, selectedOfferDetails, eventContextTags, forwardedTags, restrictPersonalization, formatMessage],
|
|
851
|
+
[tags, injectedTags, selectedOfferDetails, eventContextTags, waitEventContextTags, forwardedTags, restrictPersonalization, formatMessage],
|
|
846
852
|
);
|
|
847
853
|
|
|
848
854
|
// Memoized TagList components with optimized props
|
|
@@ -1083,6 +1089,7 @@ WebPushCreate.propTypes = {
|
|
|
1083
1089
|
forwardedTags: PropTypes.object,
|
|
1084
1090
|
selectedOfferDetails: PropTypes.array,
|
|
1085
1091
|
eventContextTags: PropTypes.array,
|
|
1092
|
+
waitEventContextTags: PropTypes.object,
|
|
1086
1093
|
templateActions: PropTypes.object,
|
|
1087
1094
|
restrictPersonalization: PropTypes.bool,
|
|
1088
1095
|
};
|
|
@@ -1111,6 +1118,7 @@ WebPushCreate.defaultProps = {
|
|
|
1111
1118
|
forwardedTags: {},
|
|
1112
1119
|
selectedOfferDetails: [],
|
|
1113
1120
|
eventContextTags: [],
|
|
1121
|
+
waitEventContextTags: {},
|
|
1114
1122
|
templateActions: {},
|
|
1115
1123
|
Templates: {},
|
|
1116
1124
|
restrictPersonalization: false,
|
|
@@ -180,6 +180,7 @@ export const Whatsapp = (props) => {
|
|
|
180
180
|
getFormData,
|
|
181
181
|
selectedOfferDetails,
|
|
182
182
|
eventContextTags,
|
|
183
|
+
waitEventContextTags = {},
|
|
183
184
|
metaDataStatus = "",
|
|
184
185
|
showTestAndPreviewSlidebox: propsShowTestAndPreviewSlidebox,
|
|
185
186
|
handleTestAndPreview: propsHandleTestAndPreview,
|
|
@@ -950,6 +951,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
|
|
|
950
951
|
injectedTags={injectedTags || {}}
|
|
951
952
|
selectedOfferDetails={selectedOfferDetails}
|
|
952
953
|
eventContextTags={eventContextTags}
|
|
954
|
+
waitEventContextTags={waitEventContextTags}
|
|
953
955
|
/>
|
|
954
956
|
)}
|
|
955
957
|
</>
|
|
@@ -1951,6 +1953,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
|
|
|
1951
1953
|
injectedTags={injectedTags || {}}
|
|
1952
1954
|
selectedOfferDetails={selectedOfferDetails}
|
|
1953
1955
|
eventContextTags={eventContextTags}
|
|
1956
|
+
waitEventContextTags={waitEventContextTags}
|
|
1954
1957
|
/>
|
|
1955
1958
|
)
|
|
1956
1959
|
: !isAuthenticationTemplate && (
|
|
@@ -2757,6 +2760,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
|
|
|
2757
2760
|
injectedTags={injectedTags || {}}
|
|
2758
2761
|
selectedOfferDetails={selectedOfferDetails}
|
|
2759
2762
|
eventContextTags={eventContextTags}
|
|
2763
|
+
waitEventContextTags={waitEventContextTags}
|
|
2760
2764
|
/>
|
|
2761
2765
|
)
|
|
2762
2766
|
}
|
|
@@ -2875,6 +2879,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
|
|
|
2875
2879
|
injectedTags={injectedTags || {}}
|
|
2876
2880
|
selectedOfferDetails={selectedOfferDetails}
|
|
2877
2881
|
eventContextTags={eventContextTags}
|
|
2882
|
+
waitEventContextTags={waitEventContextTags}
|
|
2878
2883
|
/>
|
|
2879
2884
|
)}
|
|
2880
2885
|
{isBtnTypeQuickReply && (
|