@capillarytech/creatives-library 8.0.159-alpha.1 → 8.0.160
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/package.json +1 -1
- package/v2Components/TestAndPreviewSlidebox/SendTestMessage.js +1 -1
- package/v2Components/TestAndPreviewSlidebox/index.js +140 -104
- package/v2Containers/CreativesContainer/SlideBoxContent.js +0 -2
- package/v2Containers/CreativesContainer/index.js +1 -9
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +599 -1
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +1941 -0
- package/v2Containers/Email/index.js +4 -42
|
@@ -4,6 +4,7 @@ import { shallowWithIntl } from '../../../helpers/intl-enzym-test-helpers';
|
|
|
4
4
|
import { SlideBoxContent } from '../SlideBoxContent';
|
|
5
5
|
import mockdata from '../../mockdata';
|
|
6
6
|
import { templateDetailsImage, templateDetailsVideo, templateDetailsText, templateDetails_ } from '../../Viber/tests/mockData';
|
|
7
|
+
import { CREATE, RICH_MEDIA } from '../../WeChat/Wrapper/constants';
|
|
7
8
|
|
|
8
9
|
const {
|
|
9
10
|
whatsappEditTemplateData,
|
|
@@ -26,14 +27,37 @@ jest.mock('../../../v2Components/FormBuilder', () => ({
|
|
|
26
27
|
describe('Test SlideBoxContent container', () => {
|
|
27
28
|
const onCreateComplete = jest.fn();
|
|
28
29
|
let renderedComponent;
|
|
30
|
+
let originalDate;
|
|
29
31
|
|
|
30
|
-
|
|
32
|
+
beforeAll(() => {
|
|
33
|
+
// Store the original Date
|
|
34
|
+
originalDate = global.Date;
|
|
35
|
+
// Mock Date to always return a fixed timestamp
|
|
36
|
+
const fixedDate = new Date('2024-01-01T00:00:00.000Z');
|
|
37
|
+
global.Date = class extends Date {
|
|
38
|
+
constructor() {
|
|
39
|
+
super();
|
|
40
|
+
return fixedDate;
|
|
41
|
+
}
|
|
42
|
+
getMilliseconds() {
|
|
43
|
+
return 123; // Fixed milliseconds value
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
afterAll(() => {
|
|
49
|
+
// Restore the original Date
|
|
50
|
+
global.Date = originalDate;
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const renderFunction = (channel, mode, templateData, additionalProps = {}) => {
|
|
31
54
|
renderedComponent = shallowWithIntl(
|
|
32
55
|
<SlideBoxContent
|
|
33
56
|
slidBoxContent={mode}
|
|
34
57
|
currentChannel={channel}
|
|
35
58
|
templateData={templateData}
|
|
36
59
|
onCreateComplete={onCreateComplete}
|
|
60
|
+
{...additionalProps}
|
|
37
61
|
/>,
|
|
38
62
|
);
|
|
39
63
|
};
|
|
@@ -102,4 +126,578 @@ describe('Test SlideBoxContent container', () => {
|
|
|
102
126
|
renderFunction('VIBER', 'preview', templateDetailsText);
|
|
103
127
|
expect(renderedComponent).toMatchSnapshot();
|
|
104
128
|
});
|
|
129
|
+
|
|
130
|
+
it('Should render correctly with isTestAndPreviewMode enabled', () => {
|
|
131
|
+
// Test with WhatsApp channel
|
|
132
|
+
renderFunction('WHATSAPP', 'createTemplate', { mode: 'create' }, { isTestAndPreviewMode: true });
|
|
133
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
134
|
+
|
|
135
|
+
// Test with Email channel
|
|
136
|
+
renderFunction('EMAIL', 'createTemplate', { mode: 'create' }, { isTestAndPreviewMode: true });
|
|
137
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
138
|
+
|
|
139
|
+
// Test with preview mode
|
|
140
|
+
renderFunction('VIBER', 'preview', templateDetailsText, { isTestAndPreviewMode: true });
|
|
141
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it('Should render correctly with isTestAndPreviewMode disabled', () => {
|
|
145
|
+
// Test with WhatsApp channel
|
|
146
|
+
renderFunction('WHATSAPP', 'createTemplate', { mode: 'create' }, { isTestAndPreviewMode: false });
|
|
147
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
148
|
+
|
|
149
|
+
// Test with Email channel
|
|
150
|
+
renderFunction('EMAIL', 'createTemplate', { mode: 'create' }, { isTestAndPreviewMode: false });
|
|
151
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
152
|
+
|
|
153
|
+
// Test with preview mode
|
|
154
|
+
renderFunction('VIBER', 'preview', templateDetailsText, { isTestAndPreviewMode: false });
|
|
155
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
it('Should handle isTestAndPreviewMode IIFE implementation correctly', () => {
|
|
159
|
+
// Test the IIFE implementation with true value
|
|
160
|
+
const wrapper = shallowWithIntl(
|
|
161
|
+
<SlideBoxContent
|
|
162
|
+
slidBoxContent="createTemplate"
|
|
163
|
+
currentChannel="WHATSAPP"
|
|
164
|
+
templateData={{ mode: 'create' }}
|
|
165
|
+
onCreateComplete={onCreateComplete}
|
|
166
|
+
isTestAndPreviewMode={(() => {
|
|
167
|
+
return true;
|
|
168
|
+
})()}
|
|
169
|
+
/>
|
|
170
|
+
);
|
|
171
|
+
expect(wrapper).toMatchSnapshot();
|
|
172
|
+
|
|
173
|
+
// Test the IIFE implementation with false value
|
|
174
|
+
const wrapper2 = shallowWithIntl(
|
|
175
|
+
<SlideBoxContent
|
|
176
|
+
slidBoxContent="createTemplate"
|
|
177
|
+
currentChannel="WHATSAPP"
|
|
178
|
+
templateData={{ mode: 'create' }}
|
|
179
|
+
onCreateComplete={onCreateComplete}
|
|
180
|
+
isTestAndPreviewMode={(() => {
|
|
181
|
+
return false;
|
|
182
|
+
})()}
|
|
183
|
+
/>
|
|
184
|
+
);
|
|
185
|
+
expect(wrapper2).toMatchSnapshot();
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
describe('getWechatTemplateType utility function', () => {
|
|
189
|
+
it('Should return RICH_MEDIA when mode is not CREATE and msgcontent is RICH_MEDIA_WECHAT', () => {
|
|
190
|
+
const templateData = {
|
|
191
|
+
definition: {
|
|
192
|
+
msgcontent: 'RICH_MEDIA_WECHAT'
|
|
193
|
+
}
|
|
194
|
+
};
|
|
195
|
+
renderFunction('WECHAT', 'editTemplate', templateData);
|
|
196
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it('Should return MAP_TEMPLATE when mode is not CREATE and msgcontent is not RICH_MEDIA_WECHAT', () => {
|
|
200
|
+
const templateData = {
|
|
201
|
+
definition: {
|
|
202
|
+
msgcontent: 'OTHER'
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
renderFunction('WECHAT', 'editTemplate', templateData);
|
|
206
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
it('Should return weChatTemplateType when mode is CREATE', () => {
|
|
210
|
+
renderFunction('WECHAT', CREATE, null, { weChatTemplateType: RICH_MEDIA });
|
|
211
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
|
|
215
|
+
describe('getLineType utility function', () => {
|
|
216
|
+
it('Should handle LINE channel in create mode with full mode', () => {
|
|
217
|
+
renderFunction('LINE', 'createTemplate', null, { isFullMode: true });
|
|
218
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it('Should handle LINE channel in edit mode with full mode', () => {
|
|
222
|
+
renderFunction('LINE', 'editTemplate', { type: 'LINE' }, { isFullMode: true });
|
|
223
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
it('Should handle LINE channel in non-full mode with template data', () => {
|
|
227
|
+
const templateData = {
|
|
228
|
+
isDefault: true,
|
|
229
|
+
_id: '123',
|
|
230
|
+
versions: {
|
|
231
|
+
base: {
|
|
232
|
+
content: {
|
|
233
|
+
messages: [{ text: 'test' }]
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
};
|
|
238
|
+
renderFunction('LINE', 'editTemplate', templateData, { isFullMode: false });
|
|
239
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
it('Should handle LINE channel in non-full mode with default template', () => {
|
|
243
|
+
const templateData = {
|
|
244
|
+
isDefault: true
|
|
245
|
+
};
|
|
246
|
+
renderFunction('LINE', 'createTemplate', templateData, { isFullMode: false });
|
|
247
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
describe('getViber utility function', () => {
|
|
252
|
+
it('Should handle VIBER channel in create mode', () => {
|
|
253
|
+
renderFunction('VIBER', 'createTemplate', null);
|
|
254
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
it('Should handle VIBER channel in edit mode', () => {
|
|
258
|
+
renderFunction('VIBER', 'editTemplate', { type: 'VIBER' });
|
|
259
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it('Should handle non-VIBER channel', () => {
|
|
263
|
+
renderFunction('SMS', 'createTemplate', null);
|
|
264
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
|
|
268
|
+
describe('Email component isTestAndPreviewMode IIFE', () => {
|
|
269
|
+
const commonEmailProps = {
|
|
270
|
+
editor: 'default',
|
|
271
|
+
cap: {},
|
|
272
|
+
showTemplateName: jest.fn(),
|
|
273
|
+
onValidationFail: jest.fn(),
|
|
274
|
+
moduleType: 'email',
|
|
275
|
+
showLiquidErrorInFooter: false,
|
|
276
|
+
eventContextTags: {},
|
|
277
|
+
isLoyaltyModule: false,
|
|
278
|
+
handleTestAndPreview: jest.fn(),
|
|
279
|
+
handleCloseTestAndPreview: jest.fn()
|
|
280
|
+
};
|
|
281
|
+
|
|
282
|
+
it('Should handle isTestAndPreviewMode IIFE in Email edit mode with ID', () => {
|
|
283
|
+
const emailTemplateData = {
|
|
284
|
+
type: 'EMAIL',
|
|
285
|
+
_id: '123',
|
|
286
|
+
versions: {
|
|
287
|
+
base: {
|
|
288
|
+
content: {}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
};
|
|
292
|
+
|
|
293
|
+
// Test with isTestAndPreviewMode true
|
|
294
|
+
renderFunction('EMAIL', 'editTemplate', emailTemplateData, {
|
|
295
|
+
...commonEmailProps,
|
|
296
|
+
isTestAndPreviewMode: true,
|
|
297
|
+
showTestAndPreviewSlidebox: true
|
|
298
|
+
});
|
|
299
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
300
|
+
|
|
301
|
+
// Test with isTestAndPreviewMode false
|
|
302
|
+
renderFunction('EMAIL', 'editTemplate', emailTemplateData, {
|
|
303
|
+
...commonEmailProps,
|
|
304
|
+
isTestAndPreviewMode: false,
|
|
305
|
+
showTestAndPreviewSlidebox: false
|
|
306
|
+
});
|
|
307
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
308
|
+
});
|
|
309
|
+
|
|
310
|
+
it('Should handle isTestAndPreviewMode IIFE in Email edit mode without ID', () => {
|
|
311
|
+
const emailTemplateData = {
|
|
312
|
+
type: 'EMAIL',
|
|
313
|
+
versions: {
|
|
314
|
+
base: {
|
|
315
|
+
content: {}
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
// Test with isTestAndPreviewMode true
|
|
321
|
+
renderFunction('EMAIL', 'editTemplate', emailTemplateData, {
|
|
322
|
+
...commonEmailProps,
|
|
323
|
+
isTestAndPreviewMode: true,
|
|
324
|
+
showTestAndPreviewSlidebox: true
|
|
325
|
+
});
|
|
326
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
327
|
+
|
|
328
|
+
// Test with isTestAndPreviewMode false
|
|
329
|
+
renderFunction('EMAIL', 'editTemplate', emailTemplateData, {
|
|
330
|
+
...commonEmailProps,
|
|
331
|
+
isTestAndPreviewMode: false,
|
|
332
|
+
showTestAndPreviewSlidebox: false
|
|
333
|
+
});
|
|
334
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
|
|
338
|
+
describe('getChannelPreviewContent utility function for LINE messages type detection', () => {
|
|
339
|
+
it('Should detect text type in LINE messages', () => {
|
|
340
|
+
const templateData = {
|
|
341
|
+
type: 'LINE',
|
|
342
|
+
versions: {
|
|
343
|
+
base: {
|
|
344
|
+
content: {
|
|
345
|
+
messages: [{
|
|
346
|
+
text: 'Hello World'
|
|
347
|
+
}]
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
};
|
|
352
|
+
renderFunction('LINE', 'preview', templateData);
|
|
353
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
354
|
+
});
|
|
355
|
+
|
|
356
|
+
it('Should detect image type in LINE messages', () => {
|
|
357
|
+
const templateData = {
|
|
358
|
+
type: 'LINE',
|
|
359
|
+
versions: {
|
|
360
|
+
base: {
|
|
361
|
+
content: {
|
|
362
|
+
messages: [{
|
|
363
|
+
previewImageUrl: 'image.jpg'
|
|
364
|
+
}]
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
renderFunction('LINE', 'preview', templateData);
|
|
370
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
it('Should detect sticker type in LINE messages', () => {
|
|
374
|
+
const templateData = {
|
|
375
|
+
type: 'LINE',
|
|
376
|
+
versions: {
|
|
377
|
+
base: {
|
|
378
|
+
content: {
|
|
379
|
+
messages: [{
|
|
380
|
+
selectedSticker: {
|
|
381
|
+
stickerUrl: 'sticker.jpg',
|
|
382
|
+
stickerId: '123',
|
|
383
|
+
packageId: '456'
|
|
384
|
+
}
|
|
385
|
+
}]
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
};
|
|
390
|
+
renderFunction('LINE', 'preview', templateData);
|
|
391
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
392
|
+
|
|
393
|
+
// Test with just stickerUrl
|
|
394
|
+
const templateData2 = {
|
|
395
|
+
type: 'LINE',
|
|
396
|
+
versions: {
|
|
397
|
+
base: {
|
|
398
|
+
content: {
|
|
399
|
+
messages: [{
|
|
400
|
+
stickerUrl: 'sticker.jpg'
|
|
401
|
+
}]
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
}
|
|
405
|
+
};
|
|
406
|
+
renderFunction('LINE', 'preview', templateData2);
|
|
407
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
408
|
+
});
|
|
409
|
+
|
|
410
|
+
it('Should detect imagemap type in LINE messages', () => {
|
|
411
|
+
const templateData = {
|
|
412
|
+
type: 'LINE',
|
|
413
|
+
versions: {
|
|
414
|
+
base: {
|
|
415
|
+
content: {
|
|
416
|
+
messages: [{
|
|
417
|
+
baseUrl: 'base.jpg'
|
|
418
|
+
}]
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
};
|
|
423
|
+
renderFunction('LINE', 'preview', templateData);
|
|
424
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
425
|
+
});
|
|
426
|
+
|
|
427
|
+
it('Should detect video type in LINE messages', () => {
|
|
428
|
+
const templateData = {
|
|
429
|
+
type: 'LINE',
|
|
430
|
+
versions: {
|
|
431
|
+
base: {
|
|
432
|
+
content: {
|
|
433
|
+
messages: [{
|
|
434
|
+
video: {
|
|
435
|
+
originalContentUrl: 'video.mp4',
|
|
436
|
+
externalLink: {
|
|
437
|
+
linkUri: 'example.com'
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
}]
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
};
|
|
445
|
+
renderFunction('LINE', 'preview', templateData);
|
|
446
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
447
|
+
});
|
|
448
|
+
|
|
449
|
+
it('Should detect image_carousel type in LINE messages with template', () => {
|
|
450
|
+
const templateData = {
|
|
451
|
+
type: 'LINE',
|
|
452
|
+
versions: {
|
|
453
|
+
base: {
|
|
454
|
+
content: {
|
|
455
|
+
messages: [{
|
|
456
|
+
template: {}
|
|
457
|
+
}]
|
|
458
|
+
}
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
};
|
|
462
|
+
renderFunction('LINE', 'preview', templateData);
|
|
463
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
464
|
+
});
|
|
465
|
+
|
|
466
|
+
it('Should detect image_carousel type in LINE messages with contents', () => {
|
|
467
|
+
const templateData = {
|
|
468
|
+
type: 'LINE',
|
|
469
|
+
versions: {
|
|
470
|
+
base: {
|
|
471
|
+
content: {
|
|
472
|
+
messages: [{
|
|
473
|
+
contents: {}
|
|
474
|
+
}]
|
|
475
|
+
}
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
};
|
|
479
|
+
renderFunction('LINE', 'preview', templateData);
|
|
480
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
481
|
+
});
|
|
482
|
+
});
|
|
483
|
+
|
|
484
|
+
describe('getChannelPreviewContent utility function', () => {
|
|
485
|
+
it('Should handle SMS channel preview content with DLT enabled', () => {
|
|
486
|
+
const templateData = {
|
|
487
|
+
type: 'SMS',
|
|
488
|
+
versions: {
|
|
489
|
+
base: {
|
|
490
|
+
'updated-sms-editor': ['Hello', 'World']
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
renderFunction('SMS', 'preview', templateData, { smsRegister: true, isFullMode: true });
|
|
495
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
496
|
+
});
|
|
497
|
+
|
|
498
|
+
it('Should handle SMS channel preview content without DLT', () => {
|
|
499
|
+
const templateData = {
|
|
500
|
+
type: 'SMS',
|
|
501
|
+
versions: {
|
|
502
|
+
base: {
|
|
503
|
+
'sms-editor': 'Hello World'
|
|
504
|
+
}
|
|
505
|
+
}
|
|
506
|
+
};
|
|
507
|
+
renderFunction('SMS', 'preview', templateData);
|
|
508
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
509
|
+
});
|
|
510
|
+
|
|
511
|
+
it('Should handle LINE channel preview content with flex type', () => {
|
|
512
|
+
const templateData = {
|
|
513
|
+
type: 'LINE',
|
|
514
|
+
versions: {
|
|
515
|
+
base: {
|
|
516
|
+
content: {
|
|
517
|
+
messages: [{
|
|
518
|
+
type: 'flex',
|
|
519
|
+
contents: {
|
|
520
|
+
contents: [{
|
|
521
|
+
hero: { url: 'image.jpg' },
|
|
522
|
+
footer: { contents: [{ action: { label: 'Click' } }] }
|
|
523
|
+
}]
|
|
524
|
+
}
|
|
525
|
+
}]
|
|
526
|
+
}
|
|
527
|
+
}
|
|
528
|
+
}
|
|
529
|
+
};
|
|
530
|
+
renderFunction('LINE', 'preview', templateData);
|
|
531
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
532
|
+
});
|
|
533
|
+
|
|
534
|
+
it('Should handle LINE channel preview content with template type', () => {
|
|
535
|
+
const templateData = {
|
|
536
|
+
type: 'LINE',
|
|
537
|
+
versions: {
|
|
538
|
+
base: {
|
|
539
|
+
content: {
|
|
540
|
+
messages: [{
|
|
541
|
+
template: {
|
|
542
|
+
columns: [{
|
|
543
|
+
imageUrl: 'image.jpg',
|
|
544
|
+
action: { label: 'Click' }
|
|
545
|
+
}]
|
|
546
|
+
}
|
|
547
|
+
}]
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
}
|
|
551
|
+
};
|
|
552
|
+
renderFunction('LINE', 'preview', templateData);
|
|
553
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
554
|
+
});
|
|
555
|
+
|
|
556
|
+
it('Should handle FACEBOOK channel preview content', () => {
|
|
557
|
+
const templateData = {
|
|
558
|
+
type: 'FACEBOOK',
|
|
559
|
+
versions: {
|
|
560
|
+
base: {
|
|
561
|
+
content: {
|
|
562
|
+
FacebookAd: [{
|
|
563
|
+
type: 'image',
|
|
564
|
+
primaryText: 'Hello',
|
|
565
|
+
callToAction: 'Click',
|
|
566
|
+
displayLink: 'example.com',
|
|
567
|
+
imgSrc: 'image.jpg',
|
|
568
|
+
linkDesc: 'Description',
|
|
569
|
+
linkHeadLine: 'Headline',
|
|
570
|
+
subType: 'single',
|
|
571
|
+
webSiteLink: 'example.com'
|
|
572
|
+
}],
|
|
573
|
+
pageOrgUnitId: '123'
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
};
|
|
578
|
+
const campaignSettings = {
|
|
579
|
+
accountSettings: {
|
|
580
|
+
socialAccountSettings: {
|
|
581
|
+
facebookAccountSettings: [{
|
|
582
|
+
accountId: '123',
|
|
583
|
+
employeeAccessToken: 'token',
|
|
584
|
+
orgUnitFacebookPageSettingsMap: {
|
|
585
|
+
'123': {
|
|
586
|
+
pageAccessToken: 'page-token',
|
|
587
|
+
pageId: 'page-123'
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
}]
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
};
|
|
594
|
+
renderFunction('FACEBOOK', 'preview', templateData, { campaignSettings });
|
|
595
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
596
|
+
});
|
|
597
|
+
|
|
598
|
+
it('Should handle VIBER channel preview content with all content types', () => {
|
|
599
|
+
const templateData = {
|
|
600
|
+
type: 'VIBER',
|
|
601
|
+
versions: {
|
|
602
|
+
base: {
|
|
603
|
+
content: {
|
|
604
|
+
content: {
|
|
605
|
+
text: 'Hello World',
|
|
606
|
+
button: {
|
|
607
|
+
text: 'Click Me'
|
|
608
|
+
},
|
|
609
|
+
image: {
|
|
610
|
+
url: 'image.jpg'
|
|
611
|
+
},
|
|
612
|
+
video: {
|
|
613
|
+
url: 'video.mp4',
|
|
614
|
+
thumbnailUrl: 'thumbnail.jpg'
|
|
615
|
+
}
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
};
|
|
621
|
+
renderFunction('VIBER', 'preview', templateData);
|
|
622
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
623
|
+
});
|
|
624
|
+
|
|
625
|
+
it('Should handle VIBER channel preview content with only text', () => {
|
|
626
|
+
const templateData = {
|
|
627
|
+
type: 'VIBER',
|
|
628
|
+
versions: {
|
|
629
|
+
base: {
|
|
630
|
+
content: {
|
|
631
|
+
content: {
|
|
632
|
+
text: 'Hello World'
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
};
|
|
638
|
+
renderFunction('VIBER', 'preview', templateData);
|
|
639
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
640
|
+
});
|
|
641
|
+
|
|
642
|
+
it('Should handle VIBER channel preview content with only image', () => {
|
|
643
|
+
const templateData = {
|
|
644
|
+
type: 'VIBER',
|
|
645
|
+
versions: {
|
|
646
|
+
base: {
|
|
647
|
+
content: {
|
|
648
|
+
content: {
|
|
649
|
+
image: {
|
|
650
|
+
url: 'image.jpg'
|
|
651
|
+
}
|
|
652
|
+
}
|
|
653
|
+
}
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
};
|
|
657
|
+
renderFunction('VIBER', 'preview', templateData);
|
|
658
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
659
|
+
});
|
|
660
|
+
|
|
661
|
+
it('Should handle VIBER channel preview content with only video', () => {
|
|
662
|
+
const templateData = {
|
|
663
|
+
type: 'VIBER',
|
|
664
|
+
versions: {
|
|
665
|
+
base: {
|
|
666
|
+
content: {
|
|
667
|
+
content: {
|
|
668
|
+
video: {
|
|
669
|
+
url: 'video.mp4',
|
|
670
|
+
thumbnailUrl: 'thumbnail.jpg'
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
};
|
|
677
|
+
renderFunction('VIBER', 'preview', templateData);
|
|
678
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
679
|
+
});
|
|
680
|
+
|
|
681
|
+
it('Should handle RCS channel preview content', () => {
|
|
682
|
+
const templateData = {
|
|
683
|
+
type: 'RCS',
|
|
684
|
+
versions: {
|
|
685
|
+
base: {
|
|
686
|
+
content: {
|
|
687
|
+
RCS: {
|
|
688
|
+
cardContent: [{
|
|
689
|
+
description: 'Description',
|
|
690
|
+
media: { mediaUrl: 'image.jpg' },
|
|
691
|
+
title: 'Title',
|
|
692
|
+
suggestions: [{ text: 'Click' }]
|
|
693
|
+
}]
|
|
694
|
+
}
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
};
|
|
699
|
+
renderFunction('RCS', 'preview', templateData);
|
|
700
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
701
|
+
});
|
|
702
|
+
});
|
|
105
703
|
});
|