@capillarytech/creatives-library 8.0.358 → 8.0.359-alpha.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/index.html +0 -1
- package/package.json +1 -1
- package/utils/cdnTransformation.js +3 -75
- package/utils/tests/cdnTransformation.test.js +0 -127
- package/v2Components/CommonTestAndPreview/UnifiedPreview/PreviewHeader.js +0 -16
- package/v2Components/CommonTestAndPreview/UnifiedPreview/ViberPreviewContent.js +132 -14
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +163 -54
- package/v2Components/CommonTestAndPreview/UnifiedPreview/index.js +6 -52
- package/v2Components/CommonTestAndPreview/constants.js +0 -2
- package/v2Components/CommonTestAndPreview/index.js +231 -77
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/PreviewHeader.test.js +0 -163
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/ViberPreviewContent.test.js +364 -0
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/index.test.js +0 -255
- package/v2Components/CommonTestAndPreview/tests/constants.test.js +1 -2
- package/v2Components/CommonTestAndPreview/tests/index.test.js +0 -194
- package/v2Components/FormBuilder/index.js +52 -162
- package/v2Components/TestAndPreviewSlidebox/index.js +2 -2
- package/v2Containers/App/constants.js +0 -3
- package/v2Containers/CreativesContainer/index.js +24 -60
- package/v2Containers/Templates/_templates.scss +77 -0
- package/v2Containers/Templates/index.js +92 -82
- package/v2Containers/Templates/sagas.js +1 -6
- package/v2Containers/Templates/tests/sagas.test.js +6 -23
- package/v2Containers/Viber/constants.js +19 -0
- package/v2Containers/Viber/index.js +714 -47
- package/v2Containers/Viber/index.scss +148 -0
- package/v2Containers/Viber/messages.js +116 -0
- package/v2Containers/Viber/tests/index.test.js +80 -0
- package/v2Containers/WebPush/Create/index.js +8 -91
- package/v2Containers/WebPush/Create/index.scss +0 -7
- package/v2Components/CommonTestAndPreview/UnifiedPreview/WebPushPreviewContent.js +0 -169
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/WebPushPreviewContent.test.js +0 -522
- package/v2Containers/App/tests/constants.test.js +0 -61
- package/v2Containers/Templates/tests/webpush.test.js +0 -375
- package/v2Containers/WebPush/Create/tests/getTemplateContent.test.js +0 -348
- package/v2Containers/WebPush/Create/tests/testAndPreviewIntegration.test.js +0 -325
|
@@ -200,6 +200,370 @@ describe('ViberPreviewContent', () => {
|
|
|
200
200
|
|
|
201
201
|
expect(screen.getByText('Click Here')).toBeTruthy();
|
|
202
202
|
});
|
|
203
|
+
|
|
204
|
+
it('should not render button when buttonText has only whitespace', () => {
|
|
205
|
+
const props = {
|
|
206
|
+
...defaultProps,
|
|
207
|
+
content: {
|
|
208
|
+
viberPreviewContent: {
|
|
209
|
+
messageContent: 'Message',
|
|
210
|
+
buttonText: ' ',
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
const { container } = render(
|
|
216
|
+
<TestWrapper>
|
|
217
|
+
<ComponentToRender {...props} />
|
|
218
|
+
</TestWrapper>
|
|
219
|
+
);
|
|
220
|
+
|
|
221
|
+
expect(container.querySelector('.viber-button-base')).toBeFalsy();
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
describe('Carousel Content', () => {
|
|
226
|
+
it('should render no content when carousel is selected but cards are empty', () => {
|
|
227
|
+
const props = {
|
|
228
|
+
...defaultProps,
|
|
229
|
+
content: {
|
|
230
|
+
viberPreviewContent: {
|
|
231
|
+
type: 'CAROUSEL',
|
|
232
|
+
cards: [
|
|
233
|
+
{
|
|
234
|
+
text: '',
|
|
235
|
+
mediaUrl: '',
|
|
236
|
+
buttons: [
|
|
237
|
+
{ title: '', action: '' },
|
|
238
|
+
],
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
text: ' ',
|
|
242
|
+
mediaUrl: ' ',
|
|
243
|
+
buttons: [
|
|
244
|
+
{ title: ' ', action: 'https://example.com/2' },
|
|
245
|
+
],
|
|
246
|
+
},
|
|
247
|
+
],
|
|
248
|
+
},
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
render(
|
|
253
|
+
<TestWrapper>
|
|
254
|
+
<ComponentToRender {...props} />
|
|
255
|
+
</TestWrapper>
|
|
256
|
+
);
|
|
257
|
+
|
|
258
|
+
expect(screen.getByText('No content available')).toBeTruthy();
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
it('should render carousel cards when type is CAROUSEL', () => {
|
|
262
|
+
const props = {
|
|
263
|
+
...defaultProps,
|
|
264
|
+
content: {
|
|
265
|
+
viberPreviewContent: {
|
|
266
|
+
type: 'CAROUSEL',
|
|
267
|
+
cards: [
|
|
268
|
+
{
|
|
269
|
+
text: 'Card 1 text',
|
|
270
|
+
mediaUrl: 'https://image.url/card1.jpg',
|
|
271
|
+
buttons: [
|
|
272
|
+
{ title: 'Button 1', action: 'https://example.com/1' },
|
|
273
|
+
],
|
|
274
|
+
},
|
|
275
|
+
{
|
|
276
|
+
text: 'Card 2 text',
|
|
277
|
+
mediaUrl: 'https://image.url/card2.jpg',
|
|
278
|
+
buttons: [
|
|
279
|
+
{ title: 'Button 2', action: 'https://example.com/2' },
|
|
280
|
+
],
|
|
281
|
+
},
|
|
282
|
+
],
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
};
|
|
286
|
+
|
|
287
|
+
render(
|
|
288
|
+
<TestWrapper>
|
|
289
|
+
<ComponentToRender {...props} />
|
|
290
|
+
</TestWrapper>
|
|
291
|
+
);
|
|
292
|
+
|
|
293
|
+
expect(screen.getByText('Card 1 text')).toBeTruthy();
|
|
294
|
+
expect(screen.getByText('Card 2 text')).toBeTruthy();
|
|
295
|
+
expect(screen.getByText('Button 1')).toBeTruthy();
|
|
296
|
+
expect(screen.getByText('Button 2')).toBeTruthy();
|
|
297
|
+
});
|
|
298
|
+
|
|
299
|
+
it('should not render empty carousel button placeholder', () => {
|
|
300
|
+
const props = {
|
|
301
|
+
...defaultProps,
|
|
302
|
+
content: {
|
|
303
|
+
viberPreviewContent: {
|
|
304
|
+
type: 'CAROUSEL',
|
|
305
|
+
cards: [
|
|
306
|
+
{
|
|
307
|
+
text: 'Card 1 text',
|
|
308
|
+
mediaUrl: 'https://image.url/card1.jpg',
|
|
309
|
+
buttons: [
|
|
310
|
+
{ title: '', action: 'https://example.com/1' },
|
|
311
|
+
{ title: ' ', action: 'https://example.com/2' },
|
|
312
|
+
],
|
|
313
|
+
},
|
|
314
|
+
],
|
|
315
|
+
},
|
|
316
|
+
},
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
const { container } = render(
|
|
320
|
+
<TestWrapper>
|
|
321
|
+
<ComponentToRender {...props} />
|
|
322
|
+
</TestWrapper>
|
|
323
|
+
);
|
|
324
|
+
|
|
325
|
+
expect(container.querySelector('.viber-carousel-preview-button')).toBeNull();
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
it('should show carousel shell when showCarouselEditorPreview is true even if cards are empty', () => {
|
|
329
|
+
const props = {
|
|
330
|
+
...defaultProps,
|
|
331
|
+
content: {
|
|
332
|
+
viberPreviewContent: {
|
|
333
|
+
type: 'CAROUSEL',
|
|
334
|
+
showCarouselEditorPreview: true,
|
|
335
|
+
cards: [
|
|
336
|
+
{ text: '', mediaUrl: '', buttons: [{ title: '', action: '' }] },
|
|
337
|
+
{ text: '', mediaUrl: '', buttons: [{ title: '', action: '' }] },
|
|
338
|
+
],
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
const { container } = render(
|
|
344
|
+
<TestWrapper>
|
|
345
|
+
<ComponentToRender {...props} />
|
|
346
|
+
</TestWrapper>
|
|
347
|
+
);
|
|
348
|
+
|
|
349
|
+
expect(screen.queryByText('No content available')).toBeNull();
|
|
350
|
+
expect(container.querySelector('.viber-carousel-preview-scroll')).toBeTruthy();
|
|
351
|
+
expect(container.querySelector('.viber-carousel-message-box-placeholder')).toBeTruthy();
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
it('should render carousel message text in message box when type is CAROUSEL', () => {
|
|
355
|
+
const props = {
|
|
356
|
+
...defaultProps,
|
|
357
|
+
content: {
|
|
358
|
+
viberPreviewContent: {
|
|
359
|
+
type: 'CAROUSEL',
|
|
360
|
+
messageContent: 'Carousel intro copy',
|
|
361
|
+
cards: [
|
|
362
|
+
{
|
|
363
|
+
text: 'Card text',
|
|
364
|
+
mediaUrl: 'https://image.url/c.jpg',
|
|
365
|
+
buttons: [{ title: 'Go', action: 'https://example.com' }],
|
|
366
|
+
},
|
|
367
|
+
],
|
|
368
|
+
},
|
|
369
|
+
},
|
|
370
|
+
};
|
|
371
|
+
|
|
372
|
+
const { container } = render(
|
|
373
|
+
<TestWrapper>
|
|
374
|
+
<ComponentToRender {...props} />
|
|
375
|
+
</TestWrapper>
|
|
376
|
+
);
|
|
377
|
+
|
|
378
|
+
expect(container.querySelector('.viber-carousel-message-box-text')).toHaveTextContent('Carousel intro copy');
|
|
379
|
+
expect(screen.queryByText('Carousel intro copy')).toBeTruthy();
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
it('should hide account icon when carousel is shown', () => {
|
|
383
|
+
const props = {
|
|
384
|
+
...defaultProps,
|
|
385
|
+
content: {
|
|
386
|
+
viberPreviewContent: {
|
|
387
|
+
type: 'CAROUSEL',
|
|
388
|
+
cards: [
|
|
389
|
+
{
|
|
390
|
+
text: 'Carousel card line',
|
|
391
|
+
mediaUrl: '',
|
|
392
|
+
buttons: [{ title: 'Open link', action: 'https://x.com' }],
|
|
393
|
+
},
|
|
394
|
+
],
|
|
395
|
+
},
|
|
396
|
+
},
|
|
397
|
+
};
|
|
398
|
+
|
|
399
|
+
const { container } = render(
|
|
400
|
+
<TestWrapper>
|
|
401
|
+
<ComponentToRender {...props} />
|
|
402
|
+
</TestWrapper>
|
|
403
|
+
);
|
|
404
|
+
|
|
405
|
+
expect(container.querySelector('.viber-account-icon')).toBeNull();
|
|
406
|
+
});
|
|
407
|
+
|
|
408
|
+
it('should use image placeholder when carousel card mediaUrl is whitespace only', () => {
|
|
409
|
+
const props = {
|
|
410
|
+
...defaultProps,
|
|
411
|
+
content: {
|
|
412
|
+
viberPreviewContent: {
|
|
413
|
+
type: 'CAROUSEL',
|
|
414
|
+
cards: [
|
|
415
|
+
{
|
|
416
|
+
text: 'Only text',
|
|
417
|
+
mediaUrl: ' ',
|
|
418
|
+
buttons: [{ title: 'Btn', action: 'https://example.com' }],
|
|
419
|
+
},
|
|
420
|
+
],
|
|
421
|
+
},
|
|
422
|
+
},
|
|
423
|
+
};
|
|
424
|
+
|
|
425
|
+
const { container } = render(
|
|
426
|
+
<TestWrapper>
|
|
427
|
+
<ComponentToRender {...props} />
|
|
428
|
+
</TestWrapper>
|
|
429
|
+
);
|
|
430
|
+
|
|
431
|
+
expect(container.querySelector('.viber-carousel-preview-image-placeholder')).toBeTruthy();
|
|
432
|
+
expect(container.querySelector('.viber-carousel-preview-image')).toBeNull();
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
it('should render at most two carousel buttons per card', () => {
|
|
436
|
+
const props = {
|
|
437
|
+
...defaultProps,
|
|
438
|
+
content: {
|
|
439
|
+
viberPreviewContent: {
|
|
440
|
+
type: 'CAROUSEL',
|
|
441
|
+
cards: [
|
|
442
|
+
{
|
|
443
|
+
text: 'Card',
|
|
444
|
+
mediaUrl: 'https://image.url/c.jpg',
|
|
445
|
+
buttons: [
|
|
446
|
+
{ title: 'One', action: 'https://a.com' },
|
|
447
|
+
{ title: 'Two', action: 'https://b.com' },
|
|
448
|
+
{ title: 'Three', action: 'https://c.com' },
|
|
449
|
+
],
|
|
450
|
+
},
|
|
451
|
+
],
|
|
452
|
+
},
|
|
453
|
+
},
|
|
454
|
+
};
|
|
455
|
+
|
|
456
|
+
const { container } = render(
|
|
457
|
+
<TestWrapper>
|
|
458
|
+
<ComponentToRender {...props} />
|
|
459
|
+
</TestWrapper>
|
|
460
|
+
);
|
|
461
|
+
|
|
462
|
+
expect(container.querySelectorAll('.viber-carousel-preview-button')).toHaveLength(2);
|
|
463
|
+
expect(screen.getByText('One')).toBeTruthy();
|
|
464
|
+
expect(screen.getByText('Two')).toBeTruthy();
|
|
465
|
+
expect(screen.queryByText('Three')).toBeNull();
|
|
466
|
+
});
|
|
467
|
+
|
|
468
|
+
it('should apply secondary class to second carousel button', () => {
|
|
469
|
+
const props = {
|
|
470
|
+
...defaultProps,
|
|
471
|
+
content: {
|
|
472
|
+
viberPreviewContent: {
|
|
473
|
+
type: 'CAROUSEL',
|
|
474
|
+
cards: [
|
|
475
|
+
{
|
|
476
|
+
text: 'Card',
|
|
477
|
+
mediaUrl: 'https://image.url/c.jpg',
|
|
478
|
+
buttons: [
|
|
479
|
+
{ title: 'Primary', action: 'https://a.com' },
|
|
480
|
+
{ title: 'Secondary', action: 'https://b.com' },
|
|
481
|
+
],
|
|
482
|
+
},
|
|
483
|
+
],
|
|
484
|
+
},
|
|
485
|
+
},
|
|
486
|
+
};
|
|
487
|
+
|
|
488
|
+
const { container } = render(
|
|
489
|
+
<TestWrapper>
|
|
490
|
+
<ComponentToRender {...props} />
|
|
491
|
+
</TestWrapper>
|
|
492
|
+
);
|
|
493
|
+
|
|
494
|
+
const buttons = container.querySelectorAll('.viber-carousel-preview-button');
|
|
495
|
+
expect(buttons[0].className).toContain('viber-carousel-preview-button');
|
|
496
|
+
expect(buttons[0].className).not.toContain('viber-carousel-preview-button-secondary');
|
|
497
|
+
expect(buttons[1].className).toContain('viber-carousel-preview-button-secondary');
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
it('should show carousel when only a button title is present on a card', () => {
|
|
501
|
+
const props = {
|
|
502
|
+
...defaultProps,
|
|
503
|
+
content: {
|
|
504
|
+
viberPreviewContent: {
|
|
505
|
+
type: 'CAROUSEL',
|
|
506
|
+
cards: [
|
|
507
|
+
{
|
|
508
|
+
text: '',
|
|
509
|
+
mediaUrl: '',
|
|
510
|
+
buttons: [{ title: 'Tap me', action: 'https://example.com' }],
|
|
511
|
+
},
|
|
512
|
+
],
|
|
513
|
+
},
|
|
514
|
+
},
|
|
515
|
+
};
|
|
516
|
+
|
|
517
|
+
render(
|
|
518
|
+
<TestWrapper>
|
|
519
|
+
<ComponentToRender {...props} />
|
|
520
|
+
</TestWrapper>
|
|
521
|
+
);
|
|
522
|
+
|
|
523
|
+
expect(screen.getByText('Tap me')).toBeTruthy();
|
|
524
|
+
expect(screen.queryByText('No content available')).toBeNull();
|
|
525
|
+
});
|
|
526
|
+
|
|
527
|
+
it('should show one placeholder card when editor preview and cards array is empty', () => {
|
|
528
|
+
const props = {
|
|
529
|
+
...defaultProps,
|
|
530
|
+
content: {
|
|
531
|
+
viberPreviewContent: {
|
|
532
|
+
type: 'CAROUSEL',
|
|
533
|
+
showCarouselEditorPreview: true,
|
|
534
|
+
cards: [],
|
|
535
|
+
},
|
|
536
|
+
},
|
|
537
|
+
};
|
|
538
|
+
|
|
539
|
+
const { container } = render(
|
|
540
|
+
<TestWrapper>
|
|
541
|
+
<ComponentToRender {...props} />
|
|
542
|
+
</TestWrapper>
|
|
543
|
+
);
|
|
544
|
+
|
|
545
|
+
expect(container.querySelectorAll('.viber-carousel-preview-card')).toHaveLength(1);
|
|
546
|
+
});
|
|
547
|
+
|
|
548
|
+
it('should show no content when CAROUSEL has empty cards and no editor preview flag', () => {
|
|
549
|
+
const props = {
|
|
550
|
+
...defaultProps,
|
|
551
|
+
content: {
|
|
552
|
+
viberPreviewContent: {
|
|
553
|
+
type: 'CAROUSEL',
|
|
554
|
+
cards: [],
|
|
555
|
+
},
|
|
556
|
+
},
|
|
557
|
+
};
|
|
558
|
+
|
|
559
|
+
render(
|
|
560
|
+
<TestWrapper>
|
|
561
|
+
<ComponentToRender {...props} />
|
|
562
|
+
</TestWrapper>
|
|
563
|
+
);
|
|
564
|
+
|
|
565
|
+
expect(screen.getByText('No content available')).toBeTruthy();
|
|
566
|
+
});
|
|
203
567
|
});
|
|
204
568
|
|
|
205
569
|
describe('Account and Brand Name', () => {
|
|
@@ -119,21 +119,6 @@ jest.mock('../../UnifiedPreview/ZaloPreviewContent', () => ({
|
|
|
119
119
|
),
|
|
120
120
|
}));
|
|
121
121
|
|
|
122
|
-
jest.mock('../../UnifiedPreview/WebPushPreviewContent', () => ({
|
|
123
|
-
__esModule: true,
|
|
124
|
-
default: (props) => (
|
|
125
|
-
<div data-testid="webpush-preview">
|
|
126
|
-
<div data-testid="webpush-title">{props.notificationTitle}</div>
|
|
127
|
-
<div data-testid="webpush-body">{props.notificationBody}</div>
|
|
128
|
-
<div data-testid="webpush-image">{props.imageSrc}</div>
|
|
129
|
-
<div data-testid="webpush-icon">{props.brandIconSrc}</div>
|
|
130
|
-
<div data-testid="webpush-url">{props.url}</div>
|
|
131
|
-
<div data-testid="webpush-buttons">{JSON.stringify(props.buttons)}</div>
|
|
132
|
-
<div data-testid="webpush-fullscreen">{props.isFullscreenOpen ? 'true' : 'false'}</div>
|
|
133
|
-
</div>
|
|
134
|
-
),
|
|
135
|
-
}));
|
|
136
|
-
|
|
137
122
|
jest.mock('../../UnifiedPreview/PreviewHeader', () => ({
|
|
138
123
|
__esModule: true,
|
|
139
124
|
default: (props) => (
|
|
@@ -991,244 +976,4 @@ describe('UnifiedPreview', () => {
|
|
|
991
976
|
consoleSpy.mockRestore();
|
|
992
977
|
});
|
|
993
978
|
});
|
|
994
|
-
|
|
995
|
-
describe('Channel Routing - WEBPUSH', () => {
|
|
996
|
-
it('should render WebPushPreviewContent for WEBPUSH channel with object content', () => {
|
|
997
|
-
const content = {
|
|
998
|
-
content: {
|
|
999
|
-
title: 'Hello World',
|
|
1000
|
-
message: 'This is a notification',
|
|
1001
|
-
iconImageUrl: 'https://example.com/icon.png',
|
|
1002
|
-
cta: { actionLink: 'https://example.com' },
|
|
1003
|
-
expandableDetails: {
|
|
1004
|
-
media: [{ url: 'https://example.com/image.jpg' }],
|
|
1005
|
-
ctas: [{ title: 'Click me', actionLink: 'https://example.com/btn', type: 'EXTERNAL_URL' }],
|
|
1006
|
-
},
|
|
1007
|
-
},
|
|
1008
|
-
};
|
|
1009
|
-
const props = { ...defaultProps, channel: CHANNELS.WEBPUSH, content };
|
|
1010
|
-
|
|
1011
|
-
render(
|
|
1012
|
-
<TestWrapper>
|
|
1013
|
-
<ComponentToRender {...props} />
|
|
1014
|
-
</TestWrapper>
|
|
1015
|
-
);
|
|
1016
|
-
|
|
1017
|
-
expect(screen.getByTestId('webpush-preview')).toBeTruthy();
|
|
1018
|
-
expect(screen.getByTestId('webpush-title')).toHaveTextContent('Hello World');
|
|
1019
|
-
expect(screen.getByTestId('webpush-body')).toHaveTextContent('This is a notification');
|
|
1020
|
-
expect(screen.getByTestId('webpush-icon')).toHaveTextContent('https://example.com/icon.png');
|
|
1021
|
-
expect(screen.getByTestId('webpush-url')).toHaveTextContent('https://example.com');
|
|
1022
|
-
});
|
|
1023
|
-
|
|
1024
|
-
it('should render WebPushPreviewContent for WEBPUSH channel with JSON string content', () => {
|
|
1025
|
-
const contentObj = {
|
|
1026
|
-
content: {
|
|
1027
|
-
title: 'Push Title',
|
|
1028
|
-
message: 'Push message body',
|
|
1029
|
-
iconImageUrl: 'https://example.com/brand.png',
|
|
1030
|
-
},
|
|
1031
|
-
};
|
|
1032
|
-
const props = {
|
|
1033
|
-
...defaultProps,
|
|
1034
|
-
channel: CHANNELS.WEBPUSH,
|
|
1035
|
-
content: JSON.stringify(contentObj),
|
|
1036
|
-
};
|
|
1037
|
-
|
|
1038
|
-
render(
|
|
1039
|
-
<TestWrapper>
|
|
1040
|
-
<ComponentToRender {...props} />
|
|
1041
|
-
</TestWrapper>
|
|
1042
|
-
);
|
|
1043
|
-
|
|
1044
|
-
expect(screen.getByTestId('webpush-preview')).toBeTruthy();
|
|
1045
|
-
expect(screen.getByTestId('webpush-title')).toHaveTextContent('Push Title');
|
|
1046
|
-
expect(screen.getByTestId('webpush-body')).toHaveTextContent('Push message body');
|
|
1047
|
-
expect(screen.getByTestId('webpush-icon')).toHaveTextContent('https://example.com/brand.png');
|
|
1048
|
-
});
|
|
1049
|
-
|
|
1050
|
-
it('should fallback to empty object when JSON parse fails', () => {
|
|
1051
|
-
const props = {
|
|
1052
|
-
...defaultProps,
|
|
1053
|
-
channel: CHANNELS.WEBPUSH,
|
|
1054
|
-
content: 'INVALID_JSON{{{{',
|
|
1055
|
-
};
|
|
1056
|
-
|
|
1057
|
-
render(
|
|
1058
|
-
<TestWrapper>
|
|
1059
|
-
<ComponentToRender {...props} />
|
|
1060
|
-
</TestWrapper>
|
|
1061
|
-
);
|
|
1062
|
-
|
|
1063
|
-
expect(screen.getByTestId('webpush-preview')).toBeTruthy();
|
|
1064
|
-
expect(screen.getByTestId('webpush-title')).toHaveTextContent('');
|
|
1065
|
-
expect(screen.getByTestId('webpush-body')).toHaveTextContent('');
|
|
1066
|
-
});
|
|
1067
|
-
|
|
1068
|
-
it('should fallback to empty object when content is null', () => {
|
|
1069
|
-
const props = { ...defaultProps, channel: CHANNELS.WEBPUSH, content: null };
|
|
1070
|
-
|
|
1071
|
-
render(
|
|
1072
|
-
<TestWrapper>
|
|
1073
|
-
<ComponentToRender {...props} />
|
|
1074
|
-
</TestWrapper>
|
|
1075
|
-
);
|
|
1076
|
-
|
|
1077
|
-
expect(screen.getByTestId('webpush-preview')).toBeTruthy();
|
|
1078
|
-
expect(screen.getByTestId('webpush-title')).toHaveTextContent('');
|
|
1079
|
-
});
|
|
1080
|
-
|
|
1081
|
-
it('should extract imageSrc from expandableDetails.media[0].url', () => {
|
|
1082
|
-
const content = {
|
|
1083
|
-
content: {
|
|
1084
|
-
title: 'T',
|
|
1085
|
-
message: 'M',
|
|
1086
|
-
expandableDetails: {
|
|
1087
|
-
media: [{ url: 'https://example.com/media.jpg' }],
|
|
1088
|
-
ctas: [],
|
|
1089
|
-
},
|
|
1090
|
-
},
|
|
1091
|
-
};
|
|
1092
|
-
const props = { ...defaultProps, channel: CHANNELS.WEBPUSH, content };
|
|
1093
|
-
|
|
1094
|
-
render(
|
|
1095
|
-
<TestWrapper>
|
|
1096
|
-
<ComponentToRender {...props} />
|
|
1097
|
-
</TestWrapper>
|
|
1098
|
-
);
|
|
1099
|
-
|
|
1100
|
-
expect(screen.getByTestId('webpush-image')).toHaveTextContent('https://example.com/media.jpg');
|
|
1101
|
-
});
|
|
1102
|
-
|
|
1103
|
-
it('should pass empty imageSrc when media array is empty', () => {
|
|
1104
|
-
const content = {
|
|
1105
|
-
content: {
|
|
1106
|
-
title: 'T',
|
|
1107
|
-
message: 'M',
|
|
1108
|
-
expandableDetails: { media: [], ctas: [] },
|
|
1109
|
-
},
|
|
1110
|
-
};
|
|
1111
|
-
const props = { ...defaultProps, channel: CHANNELS.WEBPUSH, content };
|
|
1112
|
-
|
|
1113
|
-
render(
|
|
1114
|
-
<TestWrapper>
|
|
1115
|
-
<ComponentToRender {...props} />
|
|
1116
|
-
</TestWrapper>
|
|
1117
|
-
);
|
|
1118
|
-
|
|
1119
|
-
expect(screen.getByTestId('webpush-image')).toHaveTextContent('');
|
|
1120
|
-
});
|
|
1121
|
-
|
|
1122
|
-
it('should map CTA buttons from expandableDetails.ctas', () => {
|
|
1123
|
-
const content = {
|
|
1124
|
-
content: {
|
|
1125
|
-
title: 'T',
|
|
1126
|
-
message: 'M',
|
|
1127
|
-
expandableDetails: {
|
|
1128
|
-
media: [],
|
|
1129
|
-
ctas: [
|
|
1130
|
-
{ title: 'Btn1', actionLink: 'https://a.com', type: 'EXTERNAL_URL' },
|
|
1131
|
-
{ title: 'Btn2', actionLink: 'https://b.com', type: 'SITE_URL' },
|
|
1132
|
-
],
|
|
1133
|
-
},
|
|
1134
|
-
},
|
|
1135
|
-
};
|
|
1136
|
-
const props = { ...defaultProps, channel: CHANNELS.WEBPUSH, content };
|
|
1137
|
-
|
|
1138
|
-
render(
|
|
1139
|
-
<TestWrapper>
|
|
1140
|
-
<ComponentToRender {...props} />
|
|
1141
|
-
</TestWrapper>
|
|
1142
|
-
);
|
|
1143
|
-
|
|
1144
|
-
const buttons = JSON.parse(screen.getByTestId('webpush-buttons').textContent);
|
|
1145
|
-
expect(buttons).toHaveLength(2);
|
|
1146
|
-
expect(buttons[0]).toEqual({ text: 'Btn1', url: 'https://a.com', type: 'EXTERNAL_URL' });
|
|
1147
|
-
expect(buttons[1]).toEqual({ text: 'Btn2', url: 'https://b.com', type: 'SITE_URL' });
|
|
1148
|
-
});
|
|
1149
|
-
|
|
1150
|
-
it('should pass empty buttons array when no ctas', () => {
|
|
1151
|
-
const content = { content: { title: 'T', message: 'M' } };
|
|
1152
|
-
const props = { ...defaultProps, channel: CHANNELS.WEBPUSH, content };
|
|
1153
|
-
|
|
1154
|
-
render(
|
|
1155
|
-
<TestWrapper>
|
|
1156
|
-
<ComponentToRender {...props} />
|
|
1157
|
-
</TestWrapper>
|
|
1158
|
-
);
|
|
1159
|
-
|
|
1160
|
-
const buttons = JSON.parse(screen.getByTestId('webpush-buttons').textContent);
|
|
1161
|
-
expect(buttons).toEqual([]);
|
|
1162
|
-
});
|
|
1163
|
-
|
|
1164
|
-
it('should NOT show device toggle for WEBPUSH channel', () => {
|
|
1165
|
-
const props = {
|
|
1166
|
-
...defaultProps,
|
|
1167
|
-
channel: CHANNELS.WEBPUSH,
|
|
1168
|
-
showDeviceToggle: true,
|
|
1169
|
-
showHeader: true,
|
|
1170
|
-
selectedCustomer: { name: 'Alice' },
|
|
1171
|
-
};
|
|
1172
|
-
|
|
1173
|
-
render(
|
|
1174
|
-
<TestWrapper>
|
|
1175
|
-
<ComponentToRender {...props} />
|
|
1176
|
-
</TestWrapper>
|
|
1177
|
-
);
|
|
1178
|
-
|
|
1179
|
-
// PreviewHeader is mocked - verify it receives showDeviceToggle=false for WEBPUSH
|
|
1180
|
-
const header = screen.getByTestId('preview-header');
|
|
1181
|
-
expect(header).toBeTruthy();
|
|
1182
|
-
});
|
|
1183
|
-
|
|
1184
|
-
it('should include WEBPUSH in supported channels list', () => {
|
|
1185
|
-
const props = { ...defaultProps, channel: CHANNELS.WEBPUSH, content: {} };
|
|
1186
|
-
|
|
1187
|
-
render(
|
|
1188
|
-
<TestWrapper>
|
|
1189
|
-
<ComponentToRender {...props} />
|
|
1190
|
-
</TestWrapper>
|
|
1191
|
-
);
|
|
1192
|
-
|
|
1193
|
-
// WEBPUSH should render WebPushPreviewContent, not the unsupported placeholder
|
|
1194
|
-
expect(screen.getByTestId('webpush-preview')).toBeTruthy();
|
|
1195
|
-
expect(screen.queryByText(/Coming Soon/)).toBeNull();
|
|
1196
|
-
});
|
|
1197
|
-
|
|
1198
|
-
it('should pass isUpdating to WebPushPreviewContent in loading state', () => {
|
|
1199
|
-
const props = {
|
|
1200
|
-
...defaultProps,
|
|
1201
|
-
channel: CHANNELS.WEBPUSH,
|
|
1202
|
-
content: { content: { title: 'T', message: 'M' } },
|
|
1203
|
-
isUpdating: true,
|
|
1204
|
-
};
|
|
1205
|
-
|
|
1206
|
-
render(
|
|
1207
|
-
<TestWrapper>
|
|
1208
|
-
<ComponentToRender {...props} />
|
|
1209
|
-
</TestWrapper>
|
|
1210
|
-
);
|
|
1211
|
-
|
|
1212
|
-
// When isUpdating, component shows loading spinner, not WebPushPreviewContent
|
|
1213
|
-
expect(screen.queryByTestId('webpush-preview')).toBeNull();
|
|
1214
|
-
});
|
|
1215
|
-
|
|
1216
|
-
it('should pass error to WebPushPreviewContent in error state', () => {
|
|
1217
|
-
const props = {
|
|
1218
|
-
...defaultProps,
|
|
1219
|
-
channel: CHANNELS.WEBPUSH,
|
|
1220
|
-
content: { content: { title: 'T', message: 'M' } },
|
|
1221
|
-
error: 'Network error',
|
|
1222
|
-
};
|
|
1223
|
-
|
|
1224
|
-
render(
|
|
1225
|
-
<TestWrapper>
|
|
1226
|
-
<ComponentToRender {...props} />
|
|
1227
|
-
</TestWrapper>
|
|
1228
|
-
);
|
|
1229
|
-
|
|
1230
|
-
// When error, component shows error state, not WebPushPreviewContent
|
|
1231
|
-
expect(screen.queryByTestId('webpush-preview')).toBeNull();
|
|
1232
|
-
});
|
|
1233
|
-
});
|
|
1234
979
|
});
|
|
@@ -179,11 +179,10 @@ describe('CommonTestAndPreview Constants', () => {
|
|
|
179
179
|
expect(CHANNELS.MOBILEPUSH).toBe('MOBILEPUSH');
|
|
180
180
|
expect(CHANNELS.VIBER).toBe('VIBER');
|
|
181
181
|
expect(CHANNELS.ZALO).toBe('ZALO');
|
|
182
|
-
expect(CHANNELS.WEBPUSH).toBe('WEBPUSH');
|
|
183
182
|
});
|
|
184
183
|
|
|
185
184
|
it('should have all required channel keys', () => {
|
|
186
|
-
const expectedChannels = ['EMAIL', 'SMS', 'RCS', 'WHATSAPP', 'INAPP', 'MOBILEPUSH', 'VIBER', 'ZALO'
|
|
185
|
+
const expectedChannels = ['EMAIL', 'SMS', 'RCS', 'WHATSAPP', 'INAPP', 'MOBILEPUSH', 'VIBER', 'ZALO'];
|
|
187
186
|
expect(Object.keys(CHANNELS)).toEqual(expect.arrayContaining(expectedChannels));
|
|
188
187
|
expect(Object.keys(CHANNELS).length).toBe(expectedChannels.length);
|
|
189
188
|
});
|