@capillarytech/creatives-library 9.1.7 → 9.1.8-alpha.sprint-cap-214249.39

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 (41) hide show
  1. package/constants/unified.js +0 -1
  2. package/package.json +1 -1
  3. package/utils/common.js +0 -6
  4. package/utils/createMobilePushPayload.js +50 -33
  5. package/utils/tests/createMobilePushPayload.test.js +113 -8
  6. package/v2Components/CapMpushCTA/index.js +10 -9
  7. package/v2Components/CapMpushCTA/index.scss +29 -3
  8. package/v2Components/CapMpushCTA/tests/index.test.js +89 -0
  9. package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +20 -12
  10. package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +13 -1
  11. package/v2Components/CommonTestAndPreview/constants.js +2 -0
  12. package/v2Components/CommonTestAndPreview/index.js +48 -10
  13. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +81 -5
  14. package/v2Components/CommonTestAndPreview/tests/index.test.js +86 -0
  15. package/v2Components/TemplatePreview/_templatePreview.scss +12 -2
  16. package/v2Components/TemplatePreview/index.js +24 -16
  17. package/v2Components/TemplatePreview/tests/index.test.js +68 -0
  18. package/v2Containers/CreativesContainer/SlideBoxContent.js +4 -6
  19. package/v2Containers/CreativesContainer/index.js +2 -1
  20. package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +43 -0
  21. package/v2Containers/MobilePushNew/components/CtaButtons.js +52 -47
  22. package/v2Containers/MobilePushNew/components/MediaUploaders.js +297 -216
  23. package/v2Containers/MobilePushNew/components/PlatformContentFields.js +158 -125
  24. package/v2Containers/MobilePushNew/components/TapLinkActions.js +76 -0
  25. package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +30 -208
  26. package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +464 -108
  27. package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +106 -35
  28. package/v2Containers/MobilePushNew/constants.js +5 -0
  29. package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +63 -1
  30. package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +52 -0
  31. package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +40 -1
  32. package/v2Containers/MobilePushNew/hooks/useUpload.js +29 -39
  33. package/v2Containers/MobilePushNew/index.js +487 -235
  34. package/v2Containers/MobilePushNew/index.scss +205 -4
  35. package/v2Containers/MobilePushNew/messages.js +106 -6
  36. package/v2Containers/MobilePushNew/tests/index.test.js +469 -1
  37. package/v2Containers/MobilePushNew/tests/utils.test.js +70 -0
  38. package/v2Containers/MobilePushNew/utils.js +56 -0
  39. package/v2Containers/Templates/_templates.scss +10 -2
  40. package/v2Containers/Templates/index.js +83 -81
  41. package/v2Containers/Templates/tests/index.test.js +68 -0
@@ -72,6 +72,8 @@ import {
72
72
  CTA_TYPE_EXTERNAL_URL,
73
73
  STYLE_TYPE_BIG_PICTURE,
74
74
  STYLE_TYPE_BIG_TEXT,
75
+ STYLE_TYPE_VIDEO,
76
+ STYLE_TYPE_MANUAL_CAROUSEL,
75
77
  DEVICE_TYPE_ANDROID,
76
78
  DEVICE_TYPE_IOS,
77
79
  BUTTON_TYPE_NONE,
@@ -1863,6 +1865,10 @@ const CommonTestAndPreview = (props) => {
1863
1865
  'message-title': formDataObj.androidContent.header || '',
1864
1866
  'message-editor': formDataObj.androidContent.bodyText || '',
1865
1867
  'image': formDataObj.androidContent.bodyImage || '',
1868
+ // bodyVideo also carries GIFs; send only real videos
1869
+ 'video': formDataObj.androidContent.bodyGif ? '' : (formDataObj.androidContent.bodyVideo?.videoSrc || ''),
1870
+ // Saved cards, already in the shape Save sent
1871
+ carouselData: formDataObj.androidContent.carouselData || [],
1866
1872
  // Extract CTA info from actions if available
1867
1873
  ...(formDataObj.androidContent.actions?.[0] && {
1868
1874
  'cta-deeplink-label': formDataObj.androidContent.actions[0].label,
@@ -1881,6 +1887,8 @@ const CommonTestAndPreview = (props) => {
1881
1887
  'message-title2': formDataObj.iosContent.header || '',
1882
1888
  'message-editor2': formDataObj.iosContent.bodyText || '',
1883
1889
  'image': formDataObj.iosContent.bodyImage || '',
1890
+ 'video': formDataObj.iosContent.bodyGif ? '' : (formDataObj.iosContent.bodyVideo?.videoSrc || ''),
1891
+ carouselData: formDataObj.iosContent.carouselData || [],
1884
1892
  // Extract CTA info from actions if available
1885
1893
  ...(formDataObj.iosContent.actions?.[0] && {
1886
1894
  'cta-deeplink2-label': formDataObj.iosContent.actions[0].label,
@@ -1986,11 +1994,36 @@ const CommonTestAndPreview = (props) => {
1986
1994
  };
1987
1995
  };
1988
1996
 
1997
+ const hasCarousel = (data) => Array.isArray(data.carouselData) && data.carouselData.length > 0;
1998
+ // Carousel, then video, then image; BIG_TEXT when none
1999
+ const getMpushStyle = (data) => {
2000
+ if (hasCarousel(data)) return STYLE_TYPE_MANUAL_CAROUSEL;
2001
+ if (data.video) return STYLE_TYPE_VIDEO;
2002
+ return data.image ? STYLE_TYPE_BIG_PICTURE : STYLE_TYPE_BIG_TEXT;
2003
+ };
2004
+ const getMpushType = (data) => {
2005
+ if (hasCarousel(data)) return MEDIA_TYPE_CAROUSEL;
2006
+ if (data.video) return MEDIA_TYPE_VIDEO;
2007
+ return data.image ? MEDIA_TYPE_IMAGE : MEDIA_TYPE_TEXT;
2008
+ };
2009
+ // Raw URL, as Save sends it (the CDN helper is an image transform)
2010
+ const toMpushVideoMedia = (url) => [{ url, text: '', type: MEDIA_TYPE_VIDEO }];
2011
+ // Cards plus the spec's media list, as CreativesContainer getMobilePushCarouselData sends to campaigns
2012
+ const addMpushCarousel = (expandableDetails, data) => {
2013
+ Object.assign(expandableDetails, {
2014
+ carouselData: data.carouselData,
2015
+ media: data.carouselData.map((card) => ({
2016
+ url: card?.mediaType?.toUpperCase() === MEDIA_TYPE_VIDEO ? card.videoSrc : card.imageUrl,
2017
+ type: card?.mediaType?.toUpperCase(),
2018
+ text: '',
2019
+ })),
2020
+ });
2021
+ };
2022
+
1989
2023
  // Helper function to build expandableDetails for Android
1990
2024
  const buildAndroidExpandableDetails = (data) => {
1991
- // Default style is BIG_TEXT, change to BIG_PICTURE if image exists
1992
2025
  const imageLink = data.image;
1993
- const style = imageLink ? STYLE_TYPE_BIG_PICTURE : STYLE_TYPE_BIG_TEXT;
2026
+ const style = getMpushStyle(data);
1994
2027
 
1995
2028
  const expandableDetails = {
1996
2029
  style,
@@ -1999,7 +2032,11 @@ const CommonTestAndPreview = (props) => {
1999
2032
  };
2000
2033
 
2001
2034
  // Add image if present (transform to CDN URL if needed)
2002
- if (imageLink) {
2035
+ if (hasCarousel(data)) {
2036
+ addMpushCarousel(expandableDetails, data);
2037
+ } else if (data.video) {
2038
+ expandableDetails.media = toMpushVideoMedia(data.video);
2039
+ } else if (imageLink) {
2003
2040
  expandableDetails.image = getCdnUrl({ url: imageLink, channelName: CHANNEL_NAME_MOBILE_PUSH });
2004
2041
  }
2005
2042
 
@@ -2078,9 +2115,8 @@ const CommonTestAndPreview = (props) => {
2078
2115
 
2079
2116
  // Helper function to build expandableDetails for iOS
2080
2117
  const buildIosExpandableDetails = (data) => {
2081
- // Default style is BIG_TEXT, change to BIG_PICTURE if image exists
2082
2118
  const imageLinkIos = data.image;
2083
- const style = imageLinkIos ? STYLE_TYPE_BIG_PICTURE : STYLE_TYPE_BIG_TEXT;
2119
+ const style = getMpushStyle(data);
2084
2120
 
2085
2121
  const expandableDetails = {
2086
2122
  style,
@@ -2089,7 +2125,11 @@ const CommonTestAndPreview = (props) => {
2089
2125
  };
2090
2126
 
2091
2127
  // Add image if present (transform to CDN URL if needed)
2092
- if (imageLinkIos) {
2128
+ if (hasCarousel(data)) {
2129
+ addMpushCarousel(expandableDetails, data);
2130
+ } else if (data.video) {
2131
+ expandableDetails.media = toMpushVideoMedia(data.video);
2132
+ } else if (imageLinkIos) {
2093
2133
  expandableDetails.image = getCdnUrl({ url: imageLinkIos, channelName: CHANNEL_NAME_MOBILE_PUSH });
2094
2134
  }
2095
2135
 
@@ -2166,8 +2206,7 @@ const CommonTestAndPreview = (props) => {
2166
2206
  const androidExpandableDetails = buildAndroidExpandableDetails(androidData);
2167
2207
  const androidCustomProperties = buildCustomProperties(androidData);
2168
2208
 
2169
- // Determine type based on image presence
2170
- const androidType = androidData.image ? MEDIA_TYPE_IMAGE : MEDIA_TYPE_TEXT;
2209
+ const androidType = getMpushType(androidData);
2171
2210
 
2172
2211
  const androidContent = {
2173
2212
  type: androidType,
@@ -2186,8 +2225,7 @@ const CommonTestAndPreview = (props) => {
2186
2225
  const iosExpandableDetails = buildIosExpandableDetails(iosData);
2187
2226
  const iosCustomProperties = buildCustomProperties(iosData);
2188
2227
 
2189
- // Determine type based on image presence
2190
- const iosType = iosData.image ? MEDIA_TYPE_IMAGE : MEDIA_TYPE_TEXT;
2228
+ const iosType = getMpushType(iosData);
2191
2229
 
2192
2230
  const iosContent = {
2193
2231
  type: iosType,
@@ -279,8 +279,8 @@ describe('MobilePushPreviewContent', () => {
279
279
  </TestWrapper>
280
280
  );
281
281
 
282
- expect(screen.getByText('ACTION 1')).toBeTruthy();
283
- expect(screen.getByText('ACTION 2')).toBeTruthy();
282
+ expect(screen.getByText('Action 1')).toBeTruthy();
283
+ expect(screen.getByText('Action 2')).toBeTruthy();
284
284
  });
285
285
 
286
286
  it('should use actionText as fallback for label', () => {
@@ -304,7 +304,7 @@ describe('MobilePushPreviewContent', () => {
304
304
  </TestWrapper>
305
305
  );
306
306
 
307
- expect(screen.getByText('ACTION TEXT')).toBeTruthy();
307
+ expect(screen.getByText('Action Text')).toBeTruthy();
308
308
  });
309
309
 
310
310
  it('should not render actions when carouselData is present', () => {
@@ -330,7 +330,7 @@ describe('MobilePushPreviewContent', () => {
330
330
  </TestWrapper>
331
331
  );
332
332
 
333
- expect(screen.queryByText('ACTION 1')).toBeNull();
333
+ expect(screen.queryByText('Action 1')).toBeNull();
334
334
  });
335
335
 
336
336
  it('should filter out actions without label or actionText', () => {
@@ -354,7 +354,7 @@ describe('MobilePushPreviewContent', () => {
354
354
  <ComponentToRender {...props} />
355
355
  </TestWrapper>
356
356
  );
357
- expect(screen.getByText('ACTION 1')).toBeTruthy();
357
+ expect(screen.getByText('Action 1')).toBeTruthy();
358
358
  });
359
359
  });
360
360
 
@@ -368,11 +368,13 @@ describe('MobilePushPreviewContent', () => {
368
368
  bodyText: 'Body',
369
369
  carouselData: [
370
370
  {
371
+ mediaType: 'IMAGE',
371
372
  title: 'Carousel Item 1',
372
373
  message: 'Message 1',
373
374
  imageUrl: 'https://image1.url',
374
375
  },
375
376
  {
377
+ mediaType: 'IMAGE',
376
378
  title: 'Carousel Item 2',
377
379
  message: 'Message 2',
378
380
  imageUrl: 'https://image2.url',
@@ -392,6 +394,76 @@ describe('MobilePushPreviewContent', () => {
392
394
  expect(screen.getByText('Carousel Item 2')).toBeTruthy();
393
395
  });
394
396
 
397
+ it('should render every card, with or without media, in a horizontal row', () => {
398
+ const props = {
399
+ ...defaultProps,
400
+ content: {
401
+ androidContent: {
402
+ header: 'Header',
403
+ carouselData: [
404
+ { mediaType: 'IMAGE', imageUrl: 'https://a.url', title: 'Card 1' },
405
+ { mediaType: 'IMAGE', title: 'Empty card' },
406
+ { mediaType: 'VIDEO', videoPreviewImg: 'https://b.url', title: 'Card 3' },
407
+ ],
408
+ },
409
+ },
410
+ };
411
+
412
+ const { container } = render(
413
+ <TestWrapper>
414
+ <ComponentToRender {...props} />
415
+ </TestWrapper>
416
+ );
417
+
418
+ expect(container.querySelectorAll('.mobile-push-carousel-card')).toHaveLength(3);
419
+ expect(screen.getByText('Empty card')).toBeInTheDocument();
420
+ const scrollRow = container.querySelector('.scroll-container');
421
+ expect(scrollRow.className).not.toMatch(/ant-row-legacy|cap-row-vertical/);
422
+ });
423
+
424
+ it('should render a video card with no thumbnail as the video itself', () => {
425
+ const props = {
426
+ ...defaultProps,
427
+ content: {
428
+ androidContent: {
429
+ header: 'Header',
430
+ carouselData: [{ mediaType: 'video', videoSrc: 'https://v.mp4', title: 'Video card' }],
431
+ },
432
+ },
433
+ };
434
+
435
+ const { container } = render(
436
+ <TestWrapper>
437
+ <ComponentToRender {...props} />
438
+ </TestWrapper>
439
+ );
440
+
441
+ expect(container.querySelectorAll('.mobile-push-carousel-card')).toHaveLength(1);
442
+ expect(container.querySelector('video.carousel-video-preview')).toHaveAttribute('src', 'https://v.mp4');
443
+ });
444
+
445
+ it('should render an empty card while no media is uploaded', () => {
446
+ const props = {
447
+ ...defaultProps,
448
+ content: {
449
+ androidContent: {
450
+ header: 'Header',
451
+ carouselData: [{ mediaType: 'IMAGE', title: 'Empty card' }],
452
+ },
453
+ },
454
+ };
455
+
456
+ const { container } = render(
457
+ <TestWrapper>
458
+ <ComponentToRender {...props} />
459
+ </TestWrapper>
460
+ );
461
+
462
+ expect(container.querySelector('.mobile-push-carousel-container')).toBeTruthy();
463
+ expect(container.querySelectorAll('.mobile-push-carousel-card')).toHaveLength(1);
464
+ expect(container.querySelector('.carousel-image')).toBeNull();
465
+ });
466
+
395
467
  it('should render carousel with image media type', () => {
396
468
  const props = {
397
469
  ...defaultProps,
@@ -488,6 +560,8 @@ describe('MobilePushPreviewContent', () => {
488
560
  bodyText: 'Body',
489
561
  carouselData: [
490
562
  {
563
+ mediaType: 'IMAGE',
564
+ imageUrl: 'https://image.url',
491
565
  header: 'Carousel Header',
492
566
  message: 'Message',
493
567
  },
@@ -514,6 +588,8 @@ describe('MobilePushPreviewContent', () => {
514
588
  bodyText: 'Body',
515
589
  carouselData: [
516
590
  {
591
+ mediaType: 'IMAGE',
592
+ imageUrl: 'https://image.url',
517
593
  title: 'Title',
518
594
  bodyText: 'Carousel Body',
519
595
  },
@@ -602,6 +602,92 @@ describe('CommonTestAndPreview', () => {
602
602
  });
603
603
  });
604
604
 
605
+ describe('Mobile push video payload - handleSendTestMessage', () => {
606
+ // resetMocks in the jest config wipes the module mock's implementation before each test
607
+ beforeEach(() => {
608
+ // eslint-disable-next-line global-require
609
+ require('../../../utils/cdnTransformation').getCdnUrl.mockImplementation(({ url }) => `cdn_${url}`);
610
+ });
611
+
612
+ const sendAndGetContent = async (props) => {
613
+ render(
614
+ <TestWrapper>
615
+ <CommonTestAndPreview {...defaultProps} channel={CHANNELS.MOBILEPUSH} {...props} />
616
+ </TestWrapper>
617
+ );
618
+ await waitFor(() => expect(lastSendTestMessageProps).toBeTruthy());
619
+ lastSendTestMessageProps.handleSendTestMessage();
620
+ const [payload] = mockActions.createMessageMetaRequested.mock.calls[0];
621
+ return payload.mpushMessageContent;
622
+ };
623
+
624
+ it('sends a VIDEO style with the raw video url from the edit flow form data', async () => {
625
+ const { androidContent, iosContent } = await sendAndGetContent({
626
+ formData: [
627
+ { 'message-title': 'T', 'message-editor': 'M', image: 'old.jpg', video: 'https://s3/a.mp4' },
628
+ { 'message-title2': 'T2', 'message-editor2': 'M2', image: 'ios.jpg', video: '' },
629
+ ],
630
+ });
631
+ expect(androidContent.type).toBe('VIDEO');
632
+ expect(androidContent.expandableDetails.style).toBe('VIDEO');
633
+ expect(androidContent.expandableDetails.media).toEqual([{ url: 'https://s3/a.mp4', text: '', type: 'VIDEO' }]);
634
+ expect(androidContent.expandableDetails.image).toBeUndefined();
635
+ expect(iosContent.type).toBe('IMAGE');
636
+ expect(iosContent.expandableDetails.style).toBe('BIG_PICTURE');
637
+ expect(iosContent.expandableDetails.image).toBe('cdn_ios.jpg');
638
+ expect(iosContent.expandableDetails.media).toBeUndefined();
639
+ });
640
+
641
+ it('reads bodyVideo from the list (three-dots) content, but not for a GIF', async () => {
642
+ const { androidContent, iosContent } = await sendAndGetContent({
643
+ formData: undefined,
644
+ content: {
645
+ androidContent: { header: 'T', bodyText: 'M', bodyVideo: { videoSrc: 'https://s3/a.mp4' } },
646
+ iosContent: { header: 'T2', bodyText: 'M2', bodyVideo: { videoSrc: 'https://s3/b.gif' }, bodyGif: 'https://s3/b.gif' },
647
+ },
648
+ });
649
+ expect(androidContent.expandableDetails.media).toEqual([{ url: 'https://s3/a.mp4', text: '', type: 'VIDEO' }]);
650
+ expect(androidContent.type).toBe('VIDEO');
651
+ expect(iosContent.type).toBe('TEXT');
652
+ expect(iosContent.expandableDetails.style).toBe('BIG_TEXT');
653
+ expect(iosContent.expandableDetails.media).toBeUndefined();
654
+ });
655
+
656
+ const imageCard = { mediaType: 'image', imageUrl: 'https://s3/1.png', videoSrc: '', buttons: [] };
657
+ const videoCard = { mediaType: 'video', imageUrl: '', videoSrc: 'https://s3/2.mp4', buttons: [] };
658
+
659
+ it('sends carousel cards and the media list from the edit flow form data', async () => {
660
+ const { androidContent, iosContent } = await sendAndGetContent({
661
+ formData: [
662
+ { 'message-title': 'T', 'message-editor': 'M', image: '', video: '', carouselData: [imageCard, videoCard] },
663
+ { 'message-title2': 'T2', 'message-editor2': 'M2', image: '', video: '', carouselData: [] },
664
+ ],
665
+ });
666
+ expect(androidContent.type).toBe('CAROUSEL');
667
+ expect(androidContent.expandableDetails.style).toBe('MANUAL_CAROUSEL');
668
+ expect(androidContent.expandableDetails.carouselData).toEqual([imageCard, videoCard]);
669
+ expect(androidContent.expandableDetails.media).toEqual([
670
+ { url: 'https://s3/1.png', type: 'IMAGE', text: '' },
671
+ { url: 'https://s3/2.mp4', type: 'VIDEO', text: '' },
672
+ ]);
673
+ expect(iosContent.type).toBe('TEXT');
674
+ expect(iosContent.expandableDetails.carouselData).toBeUndefined();
675
+ });
676
+
677
+ it('sends saved carousel cards from the list (three-dots) content', async () => {
678
+ const { iosContent } = await sendAndGetContent({
679
+ formData: undefined,
680
+ content: {
681
+ androidContent: { header: 'T', bodyText: 'M' },
682
+ iosContent: { header: 'T2', bodyText: 'M2', carouselData: [videoCard] },
683
+ },
684
+ });
685
+ expect(iosContent.type).toBe('CAROUSEL');
686
+ expect(iosContent.expandableDetails.style).toBe('MANUAL_CAROUSEL');
687
+ expect(iosContent.expandableDetails.media).toEqual([{ url: 'https://s3/2.mp4', type: 'VIDEO', text: '' }]);
688
+ });
689
+ });
690
+
605
691
  describe('Carousel payload (getCarouselMappedData) - handleSendTestMessage', () => {
606
692
  it('should map empty carouselData to empty cards when mediaType is CAROUSEL', async () => {
607
693
  const props = {
@@ -745,13 +745,23 @@
745
745
  justify-content: space-between;
746
746
  flex-direction: row;
747
747
  gap: $CAP_SPACE_08;
748
+ width: 100%;
749
+ // One button: centred. Two: equal halves, each centred, split by a divider.
748
750
  .action{
751
+ flex: 1 1 0;
752
+ min-width: 0;
753
+ text-align: center;
754
+ white-space: nowrap;
755
+ overflow: hidden;
756
+ text-overflow: ellipsis;
749
757
  font-size: $FONT_SIZE_S;
750
758
  font-weight: 600;
751
- color: #1970DA;
759
+ color: $FONT_COLOR_01;
752
760
  height: 1.25rem;
753
- text-transform: uppercase;
754
761
  cursor: pointer;
762
+ & + .action {
763
+ border-left: 1px solid $CAP_G07;
764
+ }
755
765
  &:hover {
756
766
  text-decoration: underline;
757
767
  }
@@ -168,14 +168,15 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
168
168
  };
169
169
 
170
170
  renderMobilePushCarousel = (content) => {
171
+ // Every card shows, even before its media is uploaded (an empty card keeps its place)
171
172
  if (!content?.carouselData || content?.carouselData?.length === 0) {
172
173
  return null;
173
174
  }
174
175
 
175
176
  return (
176
177
  <CapRow type="flex" vertical noWrap className="msg-container-carousel mobile-push-carousel-container">
177
- <CapRow className="scroll-container mobile-push-scroll-container">
178
- {content?.carouselData?.map((item, idx) => (
178
+ <CapRow type="flex" noWrap className="scroll-container mobile-push-scroll-container">
179
+ {content.carouselData.map((item, idx) => (
179
180
  <CapColumn
180
181
  key={`carousel-card-${idx}`}
181
182
  className="mobile-push-carousel-card message-pop align-left message-pop-carousel"
@@ -187,13 +188,20 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
187
188
  className="carousel-image"
188
189
  />
189
190
  )}
190
- {item?.mediaType?.toLowerCase() === VIDEO && item?.videoPreviewImg && (
191
+ {item?.mediaType?.toLowerCase() === VIDEO && (item?.videoPreviewImg || item?.videoSrc) && (
191
192
  <CapRow className="video-preview">
192
- <CapImage
193
- src={item?.videoPreviewImg || item?.url}
194
- alt="carousel-video-preview"
195
- className="carousel-video-preview"
196
- />
193
+ {item?.videoPreviewImg ? (
194
+ <CapImage
195
+ src={item?.videoPreviewImg || item?.url}
196
+ alt="carousel-video-preview"
197
+ className="carousel-video-preview"
198
+ />
199
+ ) : (
200
+ // No thumbnail from the upload: show the video's first frame
201
+ <video src={item?.videoSrc} className="carousel-video-preview" muted preload="metadata">
202
+ <track kind="captions" />
203
+ </video>
204
+ )}
197
205
  <CapRow className="icon-position">
198
206
  <CapImage className="video-icon" src={videoPlay} />
199
207
  </CapRow>
@@ -907,17 +915,17 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
907
915
  )}
908
916
  {(content?.actions || []).filter((action) => action?.label)
909
917
  .length && content?.carouselData?.length === 0 ? (
910
- <CapRow className="actions">
918
+ <CapRow type="flex" noWrap className="actions">
911
919
  {_.map(
912
920
  content?.actions || [],
913
- (action) =>
921
+ (action, index) =>
914
922
  !!action?.label && (
915
923
  <span
916
924
  className="action"
917
- key={`action-${action?.label}`}
925
+ key={`action-${index}`}
918
926
  title={action?.url || ''}
919
927
  >
920
- {action?.label?.toUpperCase()}
928
+ {action?.label}
921
929
  </span>
922
930
  )
923
931
  )}
@@ -971,17 +979,17 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
971
979
  )}
972
980
  {(content?.actions || []).filter((action) => action?.label)
973
981
  .length && content?.carouselData?.length === 0 ? (
974
- <CapRow className="actions">
982
+ <CapRow type="flex" noWrap className="actions">
975
983
  {_.map(
976
984
  content?.actions || [],
977
- (action) =>
985
+ (action, index) =>
978
986
  !!action?.label && (
979
987
  <span
980
988
  className="action"
981
- key={`action-${action?.label}`}
989
+ key={`action-${index}`}
982
990
  title={action?.url || ''}
983
991
  >
984
- {action?.label?.toUpperCase()}
992
+ {action?.label}
985
993
  </span>
986
994
  )
987
995
  )}
@@ -73,6 +73,74 @@ describe('Test Templates container', () => {
73
73
  expect(renderedComponent).toMatchSnapshot();
74
74
  });
75
75
 
76
+ describe('Mobile push action buttons', () => {
77
+ const renderMobilePush = (device, actions) => {
78
+ renderedComponent = shallowWithIntl(
79
+ <TemplatePreview
80
+ channel="MOBILEPUSH"
81
+ device={device}
82
+ content={{ header: 'Title', bodyText: 'Body', actions, carouselData: [] }}
83
+ />,
84
+ );
85
+ return renderedComponent.find('.actions');
86
+ };
87
+
88
+ it.each(['android', 'ios'])('renders labels as typed on one flex row with index keys (%s)', (device) => {
89
+ const row = renderMobilePush(device, [
90
+ { label: 'Shop', url: 'https://a.com' },
91
+ { label: 'Shop' },
92
+ { label: '' },
93
+ ]);
94
+ const buttons = row.find('.action');
95
+
96
+ expect(row.props()).toEqual(expect.objectContaining({ type: 'flex', noWrap: true }));
97
+ expect(buttons).toHaveLength(2);
98
+ expect(buttons.map((button) => button.key())).toEqual(['action-0', 'action-1']);
99
+ expect(buttons.map((button) => button.text())).toEqual(['Shop', 'Shop']);
100
+ expect(buttons.at(0).prop('title')).toBe('https://a.com');
101
+ });
102
+
103
+ const renderCarousel = (device, carouselData) => {
104
+ renderedComponent = shallowWithIntl(
105
+ <TemplatePreview
106
+ channel="MOBILEPUSH"
107
+ device={device}
108
+ content={{ header: 'Title', carouselData }}
109
+ />,
110
+ );
111
+ };
112
+
113
+ it.each(['android', 'ios'])('shows every card, with or without media, in one horizontal row (%s)', (device) => {
114
+ renderCarousel(device, [
115
+ { mediaType: 'IMAGE', imageUrl: 'https://a.url' },
116
+ { mediaType: 'IMAGE' },
117
+ { mediaType: 'VIDEO', videoPreviewImg: 'https://b.url' },
118
+ ]);
119
+ const scrollRow = renderedComponent.find('.scroll-container');
120
+
121
+ expect(scrollRow.props()).toEqual(expect.objectContaining({ type: 'flex', noWrap: true }));
122
+ expect(renderedComponent.find('.mobile-push-carousel-card')).toHaveLength(3);
123
+ });
124
+
125
+ it.each(['android', 'ios'])('shows a video card with no thumbnail as the video itself (%s)', (device) => {
126
+ renderCarousel(device, [{ mediaType: 'video', videoSrc: 'https://v.mp4' }]);
127
+ expect(renderedComponent.find('.mobile-push-carousel-card')).toHaveLength(1);
128
+ expect(renderedComponent.find('video.carousel-video-preview').prop('src')).toBe('https://v.mp4');
129
+ });
130
+
131
+ it.each(['android', 'ios'])('shows an empty card while no media is uploaded (%s)', (device) => {
132
+ renderCarousel(device, [{ mediaType: 'IMAGE' }]);
133
+ expect(renderedComponent.find('.mobile-push-carousel-container')).toHaveLength(1);
134
+ expect(renderedComponent.find('.mobile-push-carousel-card')).toHaveLength(1);
135
+ expect(renderedComponent.find('.carousel-image')).toHaveLength(0);
136
+ });
137
+
138
+ it.each(['android', 'ios'])('shows no carousel when there are no cards (%s)', (device) => {
139
+ renderCarousel(device, []);
140
+ expect(renderedComponent.find('.mobile-push-carousel-container')).toHaveLength(0);
141
+ });
142
+ });
143
+
76
144
  describe('RCS carousel preview branches', () => {
77
145
  const buildRcsContent = (cards) => ({
78
146
  rcsPreviewContent: {
@@ -846,9 +846,7 @@ export function SlideBoxContent(props) {
846
846
  })()
847
847
  )}
848
848
  {isEditMPush && (
849
- (isFullMode && !commonUtil.hasNewMobilePushFeatureEnabled()) ||
850
- (!isFullMode && isLoyaltyModule) ||
851
- (!isFullMode && !isLoyaltyModule && !commonUtil.hasNewMobilePushFeatureEnabled()) ? (
849
+ !isFullMode && isLoyaltyModule ? (
852
850
  <MobliPushEdit
853
851
  getFormLibraryData={getFormData}
854
852
  setIsLoadingContent={setIsLoadingContent}
@@ -910,6 +908,8 @@ export function SlideBoxContent(props) {
910
908
  waitEventContextTags={waitEventContextTags}
911
909
  showLiquidErrorInFooter={showLiquidErrorInFooter}
912
910
  handleClose={handleClose}
911
+ showTestAndPreviewSlidebox={showTestAndPreviewSlidebox}
912
+ handleCloseTestAndPreview={handleCloseTestAndPreview}
913
913
  restrictPersonalization={restrictPersonalization}
914
914
  isAnonymousType={isAnonymousType}
915
915
  onPersonalizationTokensChange={onPersonalizationTokensChange}
@@ -918,9 +918,7 @@ export function SlideBoxContent(props) {
918
918
  )
919
919
  )}
920
920
  {isCreateMPush && (
921
- (isFullMode && !commonUtil.hasNewMobilePushFeatureEnabled()) ||
922
- (!isFullMode && isLoyaltyModule) ||
923
- (!isFullMode && !isLoyaltyModule && !commonUtil.hasNewMobilePushFeatureEnabled()) ? (
921
+ !isFullMode && isLoyaltyModule ? (
924
922
  <MobilepushWrapper
925
923
  key="creatives-mobilepush-wrapper"
926
924
  date={new Date().getMilliseconds()}
@@ -1042,7 +1042,8 @@ export class Creatives extends React.Component {
1042
1042
  newExpandableDetails.message = expandableDetails.message || '';
1043
1043
  newExpandableDetails.ctas = expandableDetails.ctas || [];
1044
1044
  newExpandableDetails.media = expandableDetails.carouselData.map((carousel) => ({
1045
- url: carousel.imageUrl,
1045
+ // Video cards keep their url in videoSrc
1046
+ url: carousel?.mediaType?.toUpperCase() === VIDEO ? carousel.videoSrc : carousel.imageUrl,
1046
1047
  type: carousel?.mediaType?.toUpperCase(),
1047
1048
  text: '',
1048
1049
  }));
@@ -4,6 +4,9 @@ import { SlideBoxContent } from '../SlideBoxContent';
4
4
  import mockdata from '../../mockdata';
5
5
  import { templateDetailsImage, templateDetailsVideo, templateDetailsText, templateDetails_ } from '../../Viber/tests/mockData';
6
6
  import { CREATE, RICH_MEDIA } from '../../WeChat/Wrapper/constants';
7
+ import MobilePushNew from '../../MobilePushNew';
8
+ import MobilepushWrapper from '../../MobilepushWrapper';
9
+ import MobliPushEdit from '../../MobilePush/Edit';
7
10
 
8
11
  const {
9
12
  whatsappEditTemplateData,
@@ -1015,4 +1018,44 @@ describe('Test SlideBoxContent container', () => {
1015
1018
  });
1016
1019
 
1017
1020
  });
1021
+
1022
+ describe('Mobile push editor choice', () => {
1023
+ const editTemplateData = { _id: 'mp-1', type: 'MOBILEPUSH' };
1024
+
1025
+ it.each([
1026
+ ['full mode', { isFullMode: true }],
1027
+ ['embedded outside Loyalty', { isFullMode: false, isLoyaltyModule: false }],
1028
+ ])('opens the new editor for create and edit in %s', (_, modeProps) => {
1029
+ renderFunction('MOBILEPUSH', 'createTemplate', { mode: 'create' }, modeProps);
1030
+ expect(renderedComponent.find(MobilePushNew).exists()).toBe(true);
1031
+ expect(renderedComponent.find(MobilepushWrapper).exists()).toBe(false);
1032
+
1033
+ renderFunction('MOBILEPUSH', 'editTemplate', editTemplateData, modeProps);
1034
+ expect(renderedComponent.find(MobilePushNew).exists()).toBe(true);
1035
+ expect(renderedComponent.find(MobliPushEdit).exists()).toBe(false);
1036
+ });
1037
+
1038
+ it('passes the footer Test & Preview state to the new editor in edit', () => {
1039
+ const handleCloseTestAndPreview = jest.fn();
1040
+ renderFunction('MOBILEPUSH', 'editTemplate', editTemplateData, {
1041
+ isFullMode: true,
1042
+ showTestAndPreviewSlidebox: true,
1043
+ handleCloseTestAndPreview,
1044
+ });
1045
+ const editor = renderedComponent.find(MobilePushNew);
1046
+ expect(editor.prop('showTestAndPreviewSlidebox')).toBe(true);
1047
+ expect(editor.prop('handleCloseTestAndPreview')).toBe(handleCloseTestAndPreview);
1048
+ });
1049
+
1050
+ it('keeps the old editor when embedded in Loyalty', () => {
1051
+ const loyaltyProps = { isFullMode: false, isLoyaltyModule: true };
1052
+ renderFunction('MOBILEPUSH', 'createTemplate', { mode: 'create' }, loyaltyProps);
1053
+ expect(renderedComponent.find(MobilepushWrapper).exists()).toBe(true);
1054
+ expect(renderedComponent.find(MobilePushNew).exists()).toBe(false);
1055
+
1056
+ renderFunction('MOBILEPUSH', 'editTemplate', editTemplateData, loyaltyProps);
1057
+ expect(renderedComponent.find(MobliPushEdit).exists()).toBe(true);
1058
+ expect(renderedComponent.find(MobilePushNew).exists()).toBe(false);
1059
+ });
1060
+ });
1018
1061
  });