@capillarytech/creatives-library 8.0.353-alpha.3 → 8.0.353-alpha.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. package/package.json +1 -1
  2. package/v2Components/CommonTestAndPreview/UnifiedPreview/PreviewHeader.js +17 -0
  3. package/v2Components/CommonTestAndPreview/UnifiedPreview/ViberPreviewContent.js +14 -132
  4. package/v2Components/CommonTestAndPreview/UnifiedPreview/WebPushPreviewContent.js +169 -0
  5. package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +70 -163
  6. package/v2Components/CommonTestAndPreview/UnifiedPreview/index.js +44 -5
  7. package/v2Components/CommonTestAndPreview/constants.js +2 -0
  8. package/v2Components/CommonTestAndPreview/index.js +58 -49
  9. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/PreviewHeader.test.js +159 -0
  10. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/ViberPreviewContent.test.js +0 -364
  11. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/WebPushPreviewContent.test.js +522 -0
  12. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/index.test.js +255 -0
  13. package/v2Components/CommonTestAndPreview/tests/constants.test.js +2 -1
  14. package/v2Components/CommonTestAndPreview/tests/index.test.js +194 -0
  15. package/v2Components/TestAndPreviewSlidebox/index.js +2 -2
  16. package/v2Containers/App/constants.js +3 -0
  17. package/v2Containers/App/tests/constants.test.js +61 -0
  18. package/v2Containers/Templates/_templates.scss +0 -77
  19. package/v2Containers/Templates/index.js +70 -77
  20. package/v2Containers/Templates/tests/webpush.test.js +375 -0
  21. package/v2Containers/Viber/constants.js +0 -19
  22. package/v2Containers/Viber/index.js +47 -714
  23. package/v2Containers/Viber/index.scss +0 -148
  24. package/v2Containers/Viber/messages.js +0 -116
  25. package/v2Containers/Viber/tests/index.test.js +0 -80
  26. package/v2Containers/WebPush/Create/index.js +91 -8
  27. package/v2Containers/WebPush/Create/index.scss +7 -0
  28. package/v2Containers/WebPush/Create/tests/getTemplateContent.test.js +338 -0
  29. package/v2Containers/WebPush/Create/tests/testAndPreviewIntegration.test.js +325 -0
@@ -514,4 +514,163 @@ describe('PreviewHeader', () => {
514
514
  consoleSpy.mockRestore();
515
515
  });
516
516
  });
517
+
518
+ describe('WEBPUSH channel - Fullscreen expander', () => {
519
+ it('should render expander icon for WEBPUSH channel', () => {
520
+ const setIsFullscreenOpen = jest.fn();
521
+ const props = {
522
+ ...defaultProps,
523
+ channel: CHANNELS.WEBPUSH,
524
+ setIsFullscreenOpen,
525
+ };
526
+
527
+ const { container } = render(
528
+ <TestWrapper>
529
+ <PreviewHeader {...props} />
530
+ </TestWrapper>
531
+ );
532
+
533
+ // expander icon should be present for WEBPUSH
534
+ const expanderIcon = container.querySelector('[class*="expander"], [aria-label*="expander"], .anticon');
535
+ expect(expanderIcon).toBeTruthy();
536
+ });
537
+
538
+ it('should NOT render expander icon for non-WEBPUSH channels', () => {
539
+ const setIsFullscreenOpen = jest.fn();
540
+ const props = {
541
+ ...defaultProps,
542
+ channel: CHANNELS.EMAIL,
543
+ setIsFullscreenOpen,
544
+ showDeviceToggle: false,
545
+ };
546
+
547
+ const { container } = render(
548
+ <TestWrapper>
549
+ <PreviewHeader {...props} />
550
+ </TestWrapper>
551
+ );
552
+
553
+ // No expander icon for EMAIL channel (only device toggle icons may appear)
554
+ const expanderIcon = container.querySelector('[class*="expander"]');
555
+ expect(expanderIcon).toBeNull();
556
+ });
557
+
558
+ it('should call setIsFullscreenOpen(true) when expander icon is clicked', () => {
559
+ const setIsFullscreenOpen = jest.fn();
560
+ const props = {
561
+ ...defaultProps,
562
+ channel: CHANNELS.WEBPUSH,
563
+ setIsFullscreenOpen,
564
+ };
565
+
566
+ const { container } = render(
567
+ <TestWrapper>
568
+ <PreviewHeader {...props} />
569
+ </TestWrapper>
570
+ );
571
+
572
+ const expanderIcon = container.querySelector('[class*="expander"]') ||
573
+ container.querySelector('.anticon');
574
+ if (expanderIcon) {
575
+ fireEvent.click(expanderIcon);
576
+ expect(setIsFullscreenOpen).toHaveBeenCalledWith(true);
577
+ }
578
+ });
579
+
580
+ it('should render expander icon with ACTIVE class when device is MOBILE', () => {
581
+ const setIsFullscreenOpen = jest.fn();
582
+ const props = {
583
+ ...defaultProps,
584
+ channel: CHANNELS.WEBPUSH,
585
+ device: MOBILE,
586
+ setIsFullscreenOpen,
587
+ };
588
+
589
+ const { container } = render(
590
+ <TestWrapper>
591
+ <PreviewHeader {...props} />
592
+ </TestWrapper>
593
+ );
594
+
595
+ // MOBILE device should give ACTIVE class to expander
596
+ const activeEl = container.querySelector('.active');
597
+ expect(activeEl).toBeTruthy();
598
+ });
599
+
600
+ it('should render expander icon without ACTIVE class when device is DESKTOP', () => {
601
+ const setIsFullscreenOpen = jest.fn();
602
+ const props = {
603
+ ...defaultProps,
604
+ channel: CHANNELS.WEBPUSH,
605
+ device: DESKTOP,
606
+ setIsFullscreenOpen,
607
+ };
608
+
609
+ const { container } = render(
610
+ <TestWrapper>
611
+ <PreviewHeader {...props} />
612
+ </TestWrapper>
613
+ );
614
+
615
+ // DESKTOP device should NOT give ACTIVE class to expander
616
+ const activeEl = container.querySelector('.active');
617
+ expect(activeEl).toBeNull();
618
+ });
619
+
620
+ it('should render expander icon alongside device content for WEBPUSH', () => {
621
+ // Note: suppression of showDeviceToggle for WEBPUSH is done in UnifiedPreview (parent),
622
+ // not in PreviewHeader itself. PreviewHeader only adds the expander icon for WEBPUSH.
623
+ const setIsFullscreenOpen = jest.fn();
624
+ const props = {
625
+ ...defaultProps,
626
+ channel: CHANNELS.WEBPUSH,
627
+ setIsFullscreenOpen,
628
+ showDeviceToggle: false,
629
+ };
630
+
631
+ const { container } = render(
632
+ <TestWrapper>
633
+ <PreviewHeader {...props} />
634
+ </TestWrapper>
635
+ );
636
+
637
+ // expander icon should be present for WEBPUSH
638
+ const expanderIcon = container.querySelector('[class*="expander"]') ||
639
+ container.querySelector('.anticon');
640
+ expect(expanderIcon).toBeTruthy();
641
+ });
642
+
643
+ it('should accept isFullscreenOpen and setIsFullscreenOpen as props', () => {
644
+ const setIsFullscreenOpen = jest.fn();
645
+ const props = {
646
+ ...defaultProps,
647
+ channel: CHANNELS.WEBPUSH,
648
+ isFullscreenOpen: false,
649
+ setIsFullscreenOpen,
650
+ };
651
+
652
+ expect(() =>
653
+ render(
654
+ <TestWrapper>
655
+ <PreviewHeader {...props} />
656
+ </TestWrapper>
657
+ )
658
+ ).not.toThrow();
659
+ });
660
+
661
+ it('should use default setIsFullscreenOpen when not provided', () => {
662
+ const props = {
663
+ ...defaultProps,
664
+ channel: CHANNELS.WEBPUSH,
665
+ };
666
+
667
+ expect(() =>
668
+ render(
669
+ <TestWrapper>
670
+ <PreviewHeader {...props} />
671
+ </TestWrapper>
672
+ )
673
+ ).not.toThrow();
674
+ });
675
+ });
517
676
  });
@@ -200,370 +200,6 @@ 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
- });
567
203
  });
568
204
 
569
205
  describe('Account and Brand Name', () => {