@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
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { fromJS } from 'immutable';
|
|
2
|
+
import viberReducer from '../reducer';
|
|
3
|
+
import * as types from '../constants';
|
|
4
|
+
import { ASSET_STATUS } from '../../../utils/assetStatusConstants';
|
|
5
|
+
|
|
6
|
+
const initialState = fromJS({
|
|
7
|
+
uploadedAssetData: {},
|
|
8
|
+
createTemplateInProgress: false,
|
|
9
|
+
assetProcessing: {},
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
describe('viberReducer', () => {
|
|
13
|
+
it('returns initial state for unknown action', () => {
|
|
14
|
+
expect(viberReducer(undefined, { type: '@@INIT' })).toEqual(initialState);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
describe('CREATE_VIBER_TEMPLATE_*', () => {
|
|
18
|
+
it('handles CREATE_VIBER_TEMPLATE_REQUEST', () => {
|
|
19
|
+
const next = viberReducer(initialState, {
|
|
20
|
+
type: types.CREATE_VIBER_TEMPLATE_REQUEST,
|
|
21
|
+
});
|
|
22
|
+
expect(next.get('createTemplateInProgress')).toBe(true);
|
|
23
|
+
expect(next.get('createTemplateError')).toBe(false);
|
|
24
|
+
expect(next.get('createTemplateErrorMessage')).toEqual(fromJS(''));
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('handles CREATE_VIBER_TEMPLATE_SUCCESS with status > 300', () => {
|
|
28
|
+
const next = viberReducer(initialState, {
|
|
29
|
+
type: types.CREATE_VIBER_TEMPLATE_SUCCESS,
|
|
30
|
+
data: { id: 'x' },
|
|
31
|
+
statusCode: 400,
|
|
32
|
+
errorMsg: 'oops',
|
|
33
|
+
});
|
|
34
|
+
expect(next.get('createTemplateInProgress')).toBe(false);
|
|
35
|
+
expect(next.get('response')).toEqual({ id: 'x' });
|
|
36
|
+
expect(next.get('createTemplateError')).toBe(true);
|
|
37
|
+
expect(next.get('createTemplateErrorMessage')).toEqual(fromJS('oops'));
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('handles CREATE_VIBER_TEMPLATE_SUCCESS with status <= 300', () => {
|
|
41
|
+
const next = viberReducer(initialState, {
|
|
42
|
+
type: types.CREATE_VIBER_TEMPLATE_SUCCESS,
|
|
43
|
+
data: { id: 'x' },
|
|
44
|
+
statusCode: 200,
|
|
45
|
+
errorMsg: '',
|
|
46
|
+
});
|
|
47
|
+
expect(next.get('createTemplateError')).toBe(false);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('handles CREATE_VIBER_TEMPLATE_FAILURE', () => {
|
|
51
|
+
const next = viberReducer(initialState, {
|
|
52
|
+
type: types.CREATE_VIBER_TEMPLATE_FAILURE,
|
|
53
|
+
errorMsg: 'bad',
|
|
54
|
+
});
|
|
55
|
+
expect(next.get('createTemplateInProgress')).toBe(false);
|
|
56
|
+
expect(next.get('createTemplateError')).toBe(true);
|
|
57
|
+
expect(next.get('createTemplateErrorMessage')).toEqual(fromJS('bad'));
|
|
58
|
+
});
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
describe('UPLOAD_VIBER_ASSET_*', () => {
|
|
62
|
+
it('handles UPLOAD_VIBER_ASSET_REQUEST', () => {
|
|
63
|
+
const next = viberReducer(initialState, {
|
|
64
|
+
type: types.UPLOAD_VIBER_ASSET_REQUEST,
|
|
65
|
+
});
|
|
66
|
+
expect(next.get('uploadAssetSuccess')).toBe(false);
|
|
67
|
+
expect(next.get('assetUploading')).toBe(true);
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
it('handles UPLOAD_VIBER_ASSET_SUCCESS and wraps data with fromJS (finding 2)', () => {
|
|
71
|
+
const payload = { url: 'https://cdn/x.png', meta: { size: 100 } };
|
|
72
|
+
const next = viberReducer(initialState, {
|
|
73
|
+
type: types.UPLOAD_VIBER_ASSET_SUCCESS,
|
|
74
|
+
data: payload,
|
|
75
|
+
statusCode: 200,
|
|
76
|
+
});
|
|
77
|
+
expect(next.get('assetUploading')).toBe(false);
|
|
78
|
+
expect(next.get('uploadAssetSuccess')).toBe(true);
|
|
79
|
+
// must be wrapped in Immutable (same as asyncUploadCases.handleCompleted)
|
|
80
|
+
const stored = next.get('uploadedAssetData');
|
|
81
|
+
expect(stored).toEqual(fromJS(payload));
|
|
82
|
+
// verify it's actually an Immutable Map, not a plain JS object
|
|
83
|
+
expect(stored.toJS).toBeDefined();
|
|
84
|
+
expect(typeof stored.toJS).toBe('function');
|
|
85
|
+
expect(stored.get('url')).toBe(payload.url);
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('handles UPLOAD_VIBER_ASSET_SUCCESS with templateType key wrapped in fromJS', () => {
|
|
89
|
+
const payload = { url: 'https://cdn/y.mp4' };
|
|
90
|
+
const next = viberReducer(initialState, {
|
|
91
|
+
type: types.UPLOAD_VIBER_ASSET_SUCCESS,
|
|
92
|
+
data: payload,
|
|
93
|
+
statusCode: 200,
|
|
94
|
+
templateType: 3,
|
|
95
|
+
});
|
|
96
|
+
const stored = next.get('uploadedAssetData3');
|
|
97
|
+
expect(stored).toEqual(fromJS(payload));
|
|
98
|
+
expect(stored.get('url')).toBe(payload.url);
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
it('UPLOAD_VIBER_ASSET_SUCCESS sets uploadAssetSuccess false when status >= 300', () => {
|
|
102
|
+
const next = viberReducer(initialState, {
|
|
103
|
+
type: types.UPLOAD_VIBER_ASSET_SUCCESS,
|
|
104
|
+
data: {},
|
|
105
|
+
statusCode: 500,
|
|
106
|
+
});
|
|
107
|
+
expect(next.get('uploadAssetSuccess')).toBe(false);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('UPLOAD_VIBER_ASSET_SUCCESS sync and async produce same shape', () => {
|
|
111
|
+
const asset = { url: 'https://cdn/same.png' };
|
|
112
|
+
const sync = viberReducer(initialState, {
|
|
113
|
+
type: types.UPLOAD_VIBER_ASSET_SUCCESS,
|
|
114
|
+
data: asset,
|
|
115
|
+
statusCode: 200,
|
|
116
|
+
});
|
|
117
|
+
const async_ = viberReducer(initialState, {
|
|
118
|
+
type: types.UPLOAD_VIBER_ASSET_COMPLETED,
|
|
119
|
+
payload: { assetId: 'a1', asset },
|
|
120
|
+
});
|
|
121
|
+
// Both paths should store uploadedAssetData as Immutable fromJS(asset)
|
|
122
|
+
expect(sync.get('uploadedAssetData')).toEqual(async_.get('uploadedAssetData'));
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it('handles UPLOAD_VIBER_ASSET_FAILURE', () => {
|
|
126
|
+
const next = viberReducer(initialState, {
|
|
127
|
+
type: types.UPLOAD_VIBER_ASSET_FAILURE,
|
|
128
|
+
});
|
|
129
|
+
expect(next.get('uploadAssetSuccess')).toBe(false);
|
|
130
|
+
expect(next.get('assetUploading')).toBe(false);
|
|
131
|
+
});
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
describe('async polling cases', () => {
|
|
135
|
+
it('handles UPLOAD_VIBER_ASSET_PROCESSING', () => {
|
|
136
|
+
const next = viberReducer(initialState, {
|
|
137
|
+
type: types.UPLOAD_VIBER_ASSET_PROCESSING,
|
|
138
|
+
payload: { assetId: 'a1', asset: { id: 'a1' } },
|
|
139
|
+
});
|
|
140
|
+
expect(next.get('assetUploading')).toBe(true);
|
|
141
|
+
expect(next.get('uploadAssetSuccess')).toBe(false);
|
|
142
|
+
expect(next.getIn(['assetProcessing', 'a1', 'status'])).toBe(ASSET_STATUS.PROCESSING);
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
it('handles UPLOAD_VIBER_ASSET_COMPLETED', () => {
|
|
146
|
+
const next = viberReducer(initialState, {
|
|
147
|
+
type: types.UPLOAD_VIBER_ASSET_COMPLETED,
|
|
148
|
+
payload: { assetId: 'a1', asset: { url: 'https://cdn/x.png' } },
|
|
149
|
+
});
|
|
150
|
+
expect(next.get('assetUploading')).toBe(false);
|
|
151
|
+
expect(next.get('uploadAssetSuccess')).toBe(true);
|
|
152
|
+
expect(next.getIn(['assetProcessing', 'a1', 'status'])).toBe(ASSET_STATUS.COMPLETED);
|
|
153
|
+
expect(next.get('uploadedAssetData')).toEqual(fromJS({ url: 'https://cdn/x.png' }));
|
|
154
|
+
});
|
|
155
|
+
|
|
156
|
+
it('handles UPLOAD_VIBER_ASSET_FAILED', () => {
|
|
157
|
+
const next = viberReducer(initialState, {
|
|
158
|
+
type: types.UPLOAD_VIBER_ASSET_FAILED,
|
|
159
|
+
payload: { assetId: 'a1', error: 'boom' },
|
|
160
|
+
});
|
|
161
|
+
expect(next.get('assetUploading')).toBe(false);
|
|
162
|
+
expect(next.get('uploadAssetSuccess')).toBe(false);
|
|
163
|
+
expect(next.getIn(['assetProcessing', 'a1', 'status'])).toBe(ASSET_STATUS.FAILED);
|
|
164
|
+
expect(next.getIn(['assetProcessing', 'a1', 'error'])).toBe('boom');
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it('handles UPLOAD_VIBER_ASSET_TIMEOUT', () => {
|
|
168
|
+
const next = viberReducer(initialState, {
|
|
169
|
+
type: types.UPLOAD_VIBER_ASSET_TIMEOUT,
|
|
170
|
+
payload: { assetId: 'a1', message: 'timed out' },
|
|
171
|
+
});
|
|
172
|
+
expect(next.get('assetUploading')).toBe(false);
|
|
173
|
+
expect(next.getIn(['assetProcessing', 'a1', 'status'])).toBe(ASSET_STATUS.TIMEOUT);
|
|
174
|
+
expect(next.getIn(['assetProcessing', 'a1', 'error'])).toBe('timed out');
|
|
175
|
+
});
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
describe('CLEAR_VIBER_ASSET (finding 3)', () => {
|
|
179
|
+
const dirtyState = initialState
|
|
180
|
+
.set('assetUploading', true)
|
|
181
|
+
.set('uploadAssetSuccess', true)
|
|
182
|
+
.set('uploadedAssetData', fromJS({ url: 'x' }))
|
|
183
|
+
.set('uploadedAssetData2', fromJS({ url: 'y' }))
|
|
184
|
+
.setIn(['assetProcessing', 'a1'], fromJS({ status: 'processing' }));
|
|
185
|
+
|
|
186
|
+
it('clears default uploadedAssetData and resets upload flags', () => {
|
|
187
|
+
const next = viberReducer(dirtyState, { type: types.CLEAR_VIBER_ASSET });
|
|
188
|
+
expect(next.has('uploadedAssetData')).toBe(false);
|
|
189
|
+
expect(next.get('assetProcessing')).toEqual(fromJS({}));
|
|
190
|
+
expect(next.get('assetUploading')).toBe(false);
|
|
191
|
+
expect(next.get('uploadAssetSuccess')).toBe(false);
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
it('clears templateType-specific uploadedAssetData and resets upload flags', () => {
|
|
195
|
+
const next = viberReducer(dirtyState, {
|
|
196
|
+
type: types.CLEAR_VIBER_ASSET,
|
|
197
|
+
templateType: 2,
|
|
198
|
+
});
|
|
199
|
+
expect(next.has('uploadedAssetData2')).toBe(false);
|
|
200
|
+
// default key untouched by specific clear
|
|
201
|
+
expect(next.has('uploadedAssetData')).toBe(true);
|
|
202
|
+
expect(next.get('assetProcessing')).toEqual(fromJS({}));
|
|
203
|
+
expect(next.get('assetUploading')).toBe(false);
|
|
204
|
+
expect(next.get('uploadAssetSuccess')).toBe(false);
|
|
205
|
+
});
|
|
206
|
+
});
|
|
207
|
+
|
|
208
|
+
describe('CLEAR_VIBER_DATA (finding 3 mirror)', () => {
|
|
209
|
+
it('clears assetProcessing, assetUploading, uploadAssetSuccess', () => {
|
|
210
|
+
const dirtyState = initialState
|
|
211
|
+
.set('assetUploading', true)
|
|
212
|
+
.set('uploadAssetSuccess', true)
|
|
213
|
+
.set('metaEntities', fromJS({ some: 'data' }))
|
|
214
|
+
.set('templateDetails', fromJS({ id: 'x' }))
|
|
215
|
+
.setIn(['assetProcessing', 'a1'], fromJS({ status: 'processing' }));
|
|
216
|
+
const next = viberReducer(dirtyState, { type: types.CLEAR_VIBER_DATA });
|
|
217
|
+
expect(next.has('uploadedAssetData')).toBe(false);
|
|
218
|
+
expect(next.has('metaEntities')).toBe(false);
|
|
219
|
+
expect(next.has('templateDetails')).toBe(false);
|
|
220
|
+
expect(next.get('assetProcessing')).toEqual(fromJS({}));
|
|
221
|
+
expect(next.get('assetUploading')).toBe(false);
|
|
222
|
+
expect(next.get('uploadAssetSuccess')).toBe(false);
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
describe('EDIT_VIBER_TEMPLATE_*', () => {
|
|
227
|
+
it('handles EDIT_VIBER_TEMPLATE_REQUEST', () => {
|
|
228
|
+
const next = viberReducer(initialState, {
|
|
229
|
+
type: types.EDIT_VIBER_TEMPLATE_REQUEST,
|
|
230
|
+
});
|
|
231
|
+
expect(next.get('editTemplateInProgress')).toBe(true);
|
|
232
|
+
expect(next.get('editTemplateError')).toBe(false);
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
it('handles EDIT_VIBER_TEMPLATE_SUCCESS', () => {
|
|
236
|
+
const next = viberReducer(initialState, {
|
|
237
|
+
type: types.EDIT_VIBER_TEMPLATE_SUCCESS,
|
|
238
|
+
data: { id: 'e' },
|
|
239
|
+
statusCode: 200,
|
|
240
|
+
errorMsg: '',
|
|
241
|
+
});
|
|
242
|
+
expect(next.get('editTemplateInProgress')).toBe(false);
|
|
243
|
+
expect(next.get('editResponse')).toEqual({ id: 'e' });
|
|
244
|
+
expect(next.get('editTemplateError')).toBe(false);
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
it('handles EDIT_VIBER_TEMPLATE_SUCCESS error status', () => {
|
|
248
|
+
const next = viberReducer(initialState, {
|
|
249
|
+
type: types.EDIT_VIBER_TEMPLATE_SUCCESS,
|
|
250
|
+
data: {},
|
|
251
|
+
statusCode: 500,
|
|
252
|
+
errorMsg: 'err',
|
|
253
|
+
});
|
|
254
|
+
expect(next.get('editTemplateError')).toBe(true);
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
it('handles EDIT_VIBER_TEMPLATE_FAILURE', () => {
|
|
258
|
+
const next = viberReducer(initialState, {
|
|
259
|
+
type: types.EDIT_VIBER_TEMPLATE_FAILURE,
|
|
260
|
+
errorMsg: 'nope',
|
|
261
|
+
});
|
|
262
|
+
expect(next.get('editTemplateError')).toBe(true);
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
|
|
266
|
+
describe('GET/CLEAR branches', () => {
|
|
267
|
+
it('handles GET_VIBER_TEMPLATE_DETAILS_REQUEST', () => {
|
|
268
|
+
const next = viberReducer(initialState, {
|
|
269
|
+
type: types.GET_VIBER_TEMPLATE_DETAILS_REQUEST,
|
|
270
|
+
});
|
|
271
|
+
expect(next.get('getTemplateDetailsInProgress')).toBe(true);
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
it('handles GET_VIBER_TEMPLATE_DETAILS_SUCCESS', () => {
|
|
275
|
+
const next = viberReducer(initialState, {
|
|
276
|
+
type: types.GET_VIBER_TEMPLATE_DETAILS_SUCCESS,
|
|
277
|
+
data: { id: 'd' },
|
|
278
|
+
});
|
|
279
|
+
expect(next.get('getTemplateDetailsInProgress')).toBe(false);
|
|
280
|
+
expect(next.get('templateDetails')).toEqual({ id: 'd' });
|
|
281
|
+
});
|
|
282
|
+
|
|
283
|
+
it('handles GET_VIBER_TEMPLATE_DETAILS_FAILURE / CLEAR_VIBER_EDIT_RESPONSE_REQUEST', () => {
|
|
284
|
+
const next = viberReducer(initialState, {
|
|
285
|
+
type: types.CLEAR_VIBER_EDIT_RESPONSE_REQUEST,
|
|
286
|
+
});
|
|
287
|
+
expect(next.get('editResponse')).toEqual({});
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
it('handles CLEAR_VIBER_CREATE_RESPONSE_REQUEST', () => {
|
|
291
|
+
const next = viberReducer(initialState, {
|
|
292
|
+
type: types.CLEAR_VIBER_CREATE_RESPONSE_REQUEST,
|
|
293
|
+
});
|
|
294
|
+
expect(next.get('response')).toEqual({});
|
|
295
|
+
});
|
|
296
|
+
});
|
|
297
|
+
});
|