@capillarytech/creatives-library 9.2.0 → 9.2.1-alpha.sprint-cap-214249.42

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 +56 -51
  5. package/utils/tests/createMobilePushPayload.test.js +162 -10
  6. package/v2Components/CapMpushCTA/index.js +47 -57
  7. package/v2Components/CapMpushCTA/index.scss +43 -5
  8. package/v2Components/CapMpushCTA/tests/index.test.js +150 -0
  9. package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +11 -8
  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 +83 -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 +14 -12
  17. package/v2Components/TemplatePreview/tests/index.test.js +69 -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 +314 -222
  23. package/v2Containers/MobilePushNew/components/PlatformContentFields.js +161 -130
  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 +484 -123
  27. package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +152 -46
  28. package/v2Containers/MobilePushNew/constants.js +12 -0
  29. package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +63 -1
  30. package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +78 -0
  31. package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +40 -1
  32. package/v2Containers/MobilePushNew/hooks/useUpload.js +42 -46
  33. package/v2Containers/MobilePushNew/index.js +503 -273
  34. package/v2Containers/MobilePushNew/index.scss +215 -4
  35. package/v2Containers/MobilePushNew/messages.js +106 -6
  36. package/v2Containers/MobilePushNew/tests/index.test.js +482 -1
  37. package/v2Containers/MobilePushNew/tests/utils.test.js +122 -0
  38. package/v2Containers/MobilePushNew/utils.js +107 -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
@@ -9,6 +9,8 @@
9
9
  display: flex;
10
10
  flex-direction: row;
11
11
  justify-content: space-between;
12
+ // MobilePushNew's .mpush-cta-buttons padding is for the Buttons section, not this link row
13
+ padding-bottom: 0;
12
14
 
13
15
  .mpush-render-btn-length {
14
16
  margin-top: $CAP_SPACE_12;
@@ -31,6 +33,18 @@
31
33
  margin-top: $CAP_SPACE_12;
32
34
  }
33
35
 
36
+ // External link column: its label row (heading + "Add label") gets the height of the
37
+ // "Type of link" label plus its 8px gap, so the input lines up with the dropdown
38
+ .mpush-cta-external-link-field {
39
+ width: 70%;
40
+
41
+ > .ant-col > .ant-row:first-child {
42
+ height: 1.449rem; // CapHeading h4 line height
43
+ margin-bottom: $CAP_SPACE_08;
44
+ justify-content: space-between;
45
+ }
46
+ }
47
+
34
48
  .mpush-cta-save-delete-btn {
35
49
  margin-top: $CAP_SPACE_16;
36
50
 
@@ -42,8 +56,18 @@
42
56
  }
43
57
  }
44
58
 
45
- .cta-deep-link-keys-value {
46
- margin: $CAP_SPACE_08 0;
59
+ // Same spacing as the Notification tap keys: label + input per key
60
+ .mpush-cta-deep-link-keys {
61
+ margin-top: $CAP_SPACE_16;
62
+
63
+ .mpush-deep-link-key {
64
+ margin-top: $CAP_SPACE_12;
65
+ }
66
+
67
+ .cta-deep-link-keys-value {
68
+ display: block;
69
+ margin: 0 0 $CAP_SPACE_08;
70
+ }
47
71
  }
48
72
 
49
73
  }
@@ -55,13 +79,27 @@
55
79
  padding: $CAP_SPACE_08 $CAP_SPACE_12;
56
80
  border-radius: $CAP_SPACE_04;
57
81
  height: $CAP_SPACE_40;
82
+ gap: $CAP_SPACE_12;
58
83
 
59
84
  .mpush-saved-cta-button-text {
60
85
  font-weight: 500;
61
86
  }
62
87
 
63
- .mpush-saved-cta-edit-icon {
64
- margin-left: 4.286rem;
88
+ // Inline icons sit on the text baseline (a few px high); as blocks they centre with the text
89
+ .cap-icon-v2 {
90
+ display: flex;
91
+ }
92
+
93
+ // URL fills the space up to the icons and ends in "..." when too long.
94
+ // contain: inline-size stops a long URL from widening the whole form.
95
+ .mpush-saved-cta-link {
96
+ flex: 1;
97
+ min-width: 0;
98
+ contain: inline-size;
99
+ white-space: nowrap;
100
+ overflow: hidden;
101
+ text-overflow: ellipsis;
102
+ color: $CAP_G04;
65
103
  }
66
104
  }
67
105
  .cta-label {
@@ -89,5 +127,5 @@
89
127
  padding-left: 1rem;
90
128
  }
91
129
  .btn-text {
92
- margin-left: $CAP_SPACE_24;
130
+ margin-left: $CAP_SPACE_08;
93
131
  }
@@ -0,0 +1,150 @@
1
+ import React from 'react';
2
+ import { shallow } from 'enzyme';
3
+ import CapIcon from '@capillarytech/cap-ui-library/CapIcon';
4
+ import { CapMpushCTA } from '../index';
5
+ import CapTagListWithInput from '../../CapTagListWithInput';
6
+ import { DEEP_LINK, EXTERNAL_URL } from '../constants';
7
+ import { PRIMARY } from '../../../v2Containers/MobilePushNew/constants';
8
+
9
+ jest.mock('../../../v2Containers/TagList', () => () => null);
10
+ jest.mock('../../CapTagListWithInput', () => () => null);
11
+
12
+ const intl = { formatMessage: (msg) => msg?.defaultMessage || '' };
13
+
14
+ const renderCta = (cta, extraProps = {}) => shallow(
15
+ <CapMpushCTA
16
+ intl={intl}
17
+ ctaData={[{ index: 0, text: 'Shop', ...cta }]}
18
+ buttonType={PRIMARY}
19
+ updateHandler={jest.fn()}
20
+ deleteHandler={jest.fn()}
21
+ deepLink={[{ value: 'app://home', label: 'Home' }]}
22
+ location={{ query: {} }}
23
+ {...extraProps}
24
+ />,
25
+ );
26
+
27
+ describe('CapMpushCTA', () => {
28
+ describe('saved button card', () => {
29
+ it('uses the mask-free "open-in-new" icon, not "launch"', () => {
30
+ const wrapper = renderCta({ urlType: EXTERNAL_URL, url: 'https://google.com', isSaved: true });
31
+ const iconTypes = wrapper.find(CapIcon).map((icon) => icon.prop('type'));
32
+
33
+ expect(iconTypes).toContain('open-in-new');
34
+ expect(iconTypes).not.toContain('launch');
35
+ });
36
+
37
+ it('shows the external URL in the link column with the URL as tooltip', () => {
38
+ const wrapper = renderCta({ urlType: EXTERNAL_URL, url: 'https://google.com', isSaved: true });
39
+ const link = wrapper.find('.mpush-saved-cta-link');
40
+
41
+ expect(link.prop('children')).toBe('https://google.com');
42
+ expect(link.prop('title')).toBe('https://google.com');
43
+ expect(wrapper.find('.cta-type-label').prop('children')).toBe('External link');
44
+ });
45
+
46
+ it('shows the selected deep link label in the link column', () => {
47
+ const wrapper = renderCta({ urlType: DEEP_LINK, url: 'app://home', isSaved: true });
48
+
49
+ expect(wrapper.find('.mpush-saved-cta-link').prop('children')).toBe('Home');
50
+ expect(wrapper.find('.cta-type-label').prop('children')).toBe('Deep link');
51
+ });
52
+
53
+ it('lays out the card rows horizontally with vertically centred items', () => {
54
+ const wrapper = renderCta({ urlType: EXTERNAL_URL, url: 'https://google.com', isSaved: true });
55
+
56
+ expect(wrapper.find('.mpush-cta-row').props()).toEqual(expect.objectContaining({ type: 'flex', align: 'middle' }));
57
+ expect(wrapper.find('.cta-action-grp').props()).toEqual(expect.objectContaining({ type: 'flex', align: 'middle' }));
58
+ });
59
+
60
+ it('reopens the button for editing and deletes it from the card icons', () => {
61
+ const updateHandler = jest.fn();
62
+ const deleteHandler = jest.fn();
63
+ const wrapper = renderCta(
64
+ { urlType: EXTERNAL_URL, url: 'https://google.com', isSaved: true },
65
+ { updateHandler, deleteHandler },
66
+ );
67
+
68
+ wrapper.find('.mpush-saved-cta-edit-icon').simulate('click');
69
+ expect(updateHandler).toHaveBeenCalledWith(expect.objectContaining({ isSaved: false }), 0);
70
+
71
+ wrapper.find('.cta-del-icon').simulate('click');
72
+ expect(deleteHandler).toHaveBeenCalledWith(0);
73
+ });
74
+ });
75
+
76
+ it('keeps the "External link" heading on one line in the edit form', () => {
77
+ const wrapper = renderCta({ urlType: EXTERNAL_URL, url: '', isSaved: false });
78
+
79
+ expect(wrapper.find(CapTagListWithInput).prop('headingStyle')).toEqual(
80
+ expect.objectContaining({ whiteSpace: 'nowrap' }),
81
+ );
82
+ });
83
+
84
+ it('wraps the External link field so its label row lines up with "Type of link"', () => {
85
+ const wrapper = renderCta({ urlType: EXTERNAL_URL, url: '', isSaved: false });
86
+
87
+ expect(wrapper.find('.mpush-cta-external-link-field').find(CapTagListWithInput).exists()).toBe(true);
88
+ });
89
+
90
+ describe('deep link keys', () => {
91
+ const offerLink = [{ value: 'app://offer', label: 'Offer', keys: ['offerId', 'src'] }];
92
+
93
+ it('shows one input per configured key with its saved value', () => {
94
+ const wrapper = renderCta(
95
+ { urlType: DEEP_LINK, url: 'app://offer', isSaved: false, deepLinkKeys: ['offerId=5'] },
96
+ { deepLink: offerLink },
97
+ );
98
+
99
+ expect(wrapper.find({ id: 'mpush-deep-link-keys' }).prop('value')).toBe('5');
100
+ expect(wrapper.find({ id: 'mpush-deep-link-keys-1' }).prop('value')).toBe('');
101
+ });
102
+
103
+ it('stores the configured key with the typed value', () => {
104
+ const updateHandler = jest.fn();
105
+ const wrapper = renderCta(
106
+ { urlType: DEEP_LINK, url: 'app://offer', isSaved: false, deepLinkKeys: ['offerId=5'] },
107
+ { deepLink: offerLink, updateHandler },
108
+ );
109
+
110
+ wrapper.find({ id: 'mpush-deep-link-keys-1' }).simulate('change', { target: { value: 'push' } });
111
+ expect(updateHandler).toHaveBeenCalledWith(
112
+ expect.objectContaining({ deepLinkKeys: ['offerId=5', 'src=push'] }),
113
+ 0,
114
+ );
115
+ });
116
+
117
+ it('shows a deep link copied in from the other tab after the form is open', () => {
118
+ const wrapper = renderCta(
119
+ { urlType: DEEP_LINK, url: '', isSaved: false },
120
+ { deepLink: offerLink },
121
+ );
122
+ expect(wrapper.find({ id: 'mpush-deep-link-type' }).prop('value')).toBe('');
123
+
124
+ wrapper.setProps({
125
+ ctaData: [{
126
+ index: 0, text: 'Shop', urlType: DEEP_LINK, url: 'app://offer', isSaved: false, deepLinkKeys: ['offerId=5'],
127
+ }],
128
+ });
129
+
130
+ expect(wrapper.find({ id: 'mpush-deep-link-type' }).prop('value')).toBe('app://offer');
131
+ expect(wrapper.find({ id: 'mpush-deep-link-keys' }).prop('value')).toBe('5');
132
+ });
133
+ });
134
+
135
+ it('clears the url and sets the new type in one update on type change', () => {
136
+ const updateHandler = jest.fn();
137
+ const wrapper = renderCta(
138
+ { urlType: DEEP_LINK, url: 'app://home', isSaved: false },
139
+ { updateHandler },
140
+ );
141
+
142
+ wrapper.find({ id: 'mpush-cta-type' }).simulate('change', EXTERNAL_URL);
143
+
144
+ expect(updateHandler).toHaveBeenCalledTimes(1);
145
+ expect(updateHandler).toHaveBeenCalledWith(
146
+ expect.objectContaining({ url: '', urlType: EXTERNAL_URL }),
147
+ 0,
148
+ );
149
+ });
150
+ });
@@ -23,6 +23,7 @@ const iPhonePushMessagePhone = require('../../TemplatePreview/assets/images/iOS_
23
23
 
24
24
  // Import video play icon for carousel
25
25
  const videoPlay = require('../../../assets/videoPlay.svg');
26
+ const videoEmptyPreview = require('../../TemplatePreview/assets/images/empty_video_preview.svg');
26
27
 
27
28
  const MobilePushPreviewContent = ({
28
29
  content,
@@ -86,14 +87,15 @@ const MobilePushPreviewContent = ({
86
87
 
87
88
  // Render MobilePush carousel (based on TemplatePreview renderMobilePushCarousel)
88
89
  const renderMobilePushCarousel = (contentData) => {
90
+ // Every card shows, even before its media is uploaded (an empty card keeps its place)
89
91
  if (!contentData?.carouselData || contentData?.carouselData?.length === 0) {
90
92
  return null;
91
93
  }
92
94
 
93
95
  return (
94
96
  <CapRow type="flex" vertical noWrap className="msg-container-carousel mobile-push-carousel-container">
95
- <CapRow useLegacy className="scroll-container mobile-push-scroll-container">
96
- {contentData?.carouselData?.map((item, idx) => (
97
+ <CapRow type="flex" noWrap className="scroll-container mobile-push-scroll-container">
98
+ {contentData.carouselData.map((item, idx) => (
97
99
  <CapColumn
98
100
  key={`carousel-card-${idx}`}
99
101
  className="mobile-push-carousel-card message-pop align-left message-pop-carousel"
@@ -105,10 +107,11 @@ const MobilePushPreviewContent = ({
105
107
  className="carousel-image"
106
108
  />
107
109
  )}
108
- {item?.mediaType?.toLowerCase() === MEDIA_TYPE_VIDEO.toLowerCase() && item?.videoPreviewImg && (
110
+ {item?.mediaType?.toLowerCase() === MEDIA_TYPE_VIDEO.toLowerCase() && (item?.videoPreviewImg || item?.videoSrc) && (
109
111
  <CapRow className="video-preview">
112
+ {/* No thumbnail from the upload: same placeholder as WhatsApp/RCS */}
110
113
  <CapImage
111
- src={item?.videoPreviewImg || item?.url}
114
+ src={item?.videoPreviewImg || videoEmptyPreview}
112
115
  alt="carousel-video-preview"
113
116
  className="carousel-video-preview"
114
117
  />
@@ -217,15 +220,15 @@ const MobilePushPreviewContent = ({
217
220
  {/* Action Buttons */}
218
221
  {(deviceContent?.actions || []).filter((action) => action?.label || action?.actionText).length > 0
219
222
  && deviceContent?.carouselData?.length === 0 && (
220
- <CapRow useLegacy className="actions">
221
- {(deviceContent?.actions || []).map((action) => (
223
+ <CapRow type="flex" noWrap className="actions">
224
+ {deviceContent.actions.map((action, index) => (
222
225
  (action?.label || action?.actionText) && (
223
226
  <span
224
227
  className="action"
225
- key={`action-${action?.label || action?.actionText}`}
228
+ key={`action-${index}`}
226
229
  title={action?.url || action?.actionLink || ''}
227
230
  >
228
- {action?.label?.toUpperCase() || action?.actionText?.toUpperCase()}
231
+ {action?.label || action?.actionText}
229
232
  </span>
230
233
  )
231
234
  ))}
@@ -2307,9 +2307,21 @@
2307
2307
  flex-direction: row;
2308
2308
  gap: $CAP_SPACE_08;
2309
2309
 
2310
+ // One button: centred. Two: equal halves, each centred, split by a divider.
2310
2311
  .action {
2311
2312
  font-size: $FONT_SIZE_S;
2312
- // Additional action button styles from TemplatePreview
2313
+ font-weight: 600;
2314
+ color: $FONT_COLOR_01;
2315
+ flex: 1 1 0;
2316
+ min-width: 0;
2317
+ text-align: center;
2318
+ white-space: nowrap;
2319
+ overflow: hidden;
2320
+ text-overflow: ellipsis;
2321
+
2322
+ & + .action {
2323
+ border-left: 1px solid $CAP_G07;
2324
+ }
2313
2325
  }
2314
2326
  }
2315
2327
  }
@@ -212,6 +212,8 @@ export const CTA_TYPE_EXTERNAL_URL = 'EXTERNAL_URL';
212
212
  // ============================================
213
213
  export const STYLE_TYPE_BIG_PICTURE = 'BIG_PICTURE';
214
214
  export const STYLE_TYPE_BIG_TEXT = 'BIG_TEXT';
215
+ export const STYLE_TYPE_VIDEO = 'VIDEO';
216
+ export const STYLE_TYPE_MANUAL_CAROUSEL = 'MANUAL_CAROUSEL';
215
217
 
216
218
  // ============================================
217
219
  // DEVICE TYPE CONSTANTS (for API payloads)
@@ -75,6 +75,8 @@ import {
75
75
  CTA_TYPE_EXTERNAL_URL,
76
76
  STYLE_TYPE_BIG_PICTURE,
77
77
  STYLE_TYPE_BIG_TEXT,
78
+ STYLE_TYPE_VIDEO,
79
+ STYLE_TYPE_MANUAL_CAROUSEL,
78
80
  DEVICE_TYPE_ANDROID,
79
81
  DEVICE_TYPE_IOS,
80
82
  BUTTON_TYPE_NONE,
@@ -1884,6 +1886,10 @@ const CommonTestAndPreview = (props) => {
1884
1886
  'message-title': formDataObj.androidContent.header || '',
1885
1887
  'message-editor': formDataObj.androidContent.bodyText || '',
1886
1888
  'image': formDataObj.androidContent.bodyImage || '',
1889
+ // bodyVideo also carries GIFs; send only real videos
1890
+ 'video': formDataObj.androidContent.bodyGif ? '' : (formDataObj.androidContent.bodyVideo?.videoSrc || ''),
1891
+ // Saved cards, already in the shape Save sent
1892
+ carouselData: formDataObj.androidContent.carouselData || [],
1887
1893
  // Extract CTA info from actions if available
1888
1894
  ...(formDataObj.androidContent.actions?.[0] && {
1889
1895
  'cta-deeplink-label': formDataObj.androidContent.actions[0].label,
@@ -1902,6 +1908,8 @@ const CommonTestAndPreview = (props) => {
1902
1908
  'message-title2': formDataObj.iosContent.header || '',
1903
1909
  'message-editor2': formDataObj.iosContent.bodyText || '',
1904
1910
  'image': formDataObj.iosContent.bodyImage || '',
1911
+ 'video': formDataObj.iosContent.bodyGif ? '' : (formDataObj.iosContent.bodyVideo?.videoSrc || ''),
1912
+ carouselData: formDataObj.iosContent.carouselData || [],
1905
1913
  // Extract CTA info from actions if available
1906
1914
  ...(formDataObj.iosContent.actions?.[0] && {
1907
1915
  'cta-deeplink2-label': formDataObj.iosContent.actions[0].label,
@@ -2007,11 +2015,36 @@ const CommonTestAndPreview = (props) => {
2007
2015
  };
2008
2016
  };
2009
2017
 
2018
+ const hasCarousel = (data) => Array.isArray(data.carouselData) && data.carouselData.length > 0;
2019
+ // Carousel, then video, then image; BIG_TEXT when none
2020
+ const getMpushStyle = (data) => {
2021
+ if (hasCarousel(data)) return STYLE_TYPE_MANUAL_CAROUSEL;
2022
+ if (data.video) return STYLE_TYPE_VIDEO;
2023
+ return data.image ? STYLE_TYPE_BIG_PICTURE : STYLE_TYPE_BIG_TEXT;
2024
+ };
2025
+ const getMpushType = (data) => {
2026
+ if (hasCarousel(data)) return MEDIA_TYPE_CAROUSEL;
2027
+ if (data.video) return MEDIA_TYPE_VIDEO;
2028
+ return data.image ? MEDIA_TYPE_IMAGE : MEDIA_TYPE_TEXT;
2029
+ };
2030
+ // Raw URL, as Save sends it (the CDN helper is an image transform)
2031
+ const toMpushVideoMedia = (url) => [{ url, text: '', type: MEDIA_TYPE_VIDEO }];
2032
+ // Cards plus the spec's media list, as CreativesContainer getMobilePushCarouselData sends to campaigns
2033
+ const addMpushCarousel = (expandableDetails, data) => {
2034
+ Object.assign(expandableDetails, {
2035
+ carouselData: data.carouselData,
2036
+ media: data.carouselData.map((card) => ({
2037
+ url: card?.mediaType?.toUpperCase() === MEDIA_TYPE_VIDEO ? card.videoSrc : card.imageUrl,
2038
+ type: card?.mediaType?.toUpperCase(),
2039
+ text: '',
2040
+ })),
2041
+ });
2042
+ };
2043
+
2010
2044
  // Helper function to build expandableDetails for Android
2011
2045
  const buildAndroidExpandableDetails = (data) => {
2012
- // Default style is BIG_TEXT, change to BIG_PICTURE if image exists
2013
2046
  const imageLink = data.image;
2014
- const style = imageLink ? STYLE_TYPE_BIG_PICTURE : STYLE_TYPE_BIG_TEXT;
2047
+ const style = getMpushStyle(data);
2015
2048
 
2016
2049
  const expandableDetails = {
2017
2050
  style,
@@ -2020,7 +2053,11 @@ const CommonTestAndPreview = (props) => {
2020
2053
  };
2021
2054
 
2022
2055
  // Add image if present (transform to CDN URL if needed)
2023
- if (imageLink) {
2056
+ if (hasCarousel(data)) {
2057
+ addMpushCarousel(expandableDetails, data);
2058
+ } else if (data.video) {
2059
+ expandableDetails.media = toMpushVideoMedia(data.video);
2060
+ } else if (imageLink) {
2024
2061
  expandableDetails.image = getCdnUrl({ url: imageLink, channelName: CHANNEL_NAME_MOBILE_PUSH });
2025
2062
  }
2026
2063
 
@@ -2099,9 +2136,8 @@ const CommonTestAndPreview = (props) => {
2099
2136
 
2100
2137
  // Helper function to build expandableDetails for iOS
2101
2138
  const buildIosExpandableDetails = (data) => {
2102
- // Default style is BIG_TEXT, change to BIG_PICTURE if image exists
2103
2139
  const imageLinkIos = data.image;
2104
- const style = imageLinkIos ? STYLE_TYPE_BIG_PICTURE : STYLE_TYPE_BIG_TEXT;
2140
+ const style = getMpushStyle(data);
2105
2141
 
2106
2142
  const expandableDetails = {
2107
2143
  style,
@@ -2110,7 +2146,11 @@ const CommonTestAndPreview = (props) => {
2110
2146
  };
2111
2147
 
2112
2148
  // Add image if present (transform to CDN URL if needed)
2113
- if (imageLinkIos) {
2149
+ if (hasCarousel(data)) {
2150
+ addMpushCarousel(expandableDetails, data);
2151
+ } else if (data.video) {
2152
+ expandableDetails.media = toMpushVideoMedia(data.video);
2153
+ } else if (imageLinkIos) {
2114
2154
  expandableDetails.image = getCdnUrl({ url: imageLinkIos, channelName: CHANNEL_NAME_MOBILE_PUSH });
2115
2155
  }
2116
2156
 
@@ -2187,8 +2227,7 @@ const CommonTestAndPreview = (props) => {
2187
2227
  const androidExpandableDetails = buildAndroidExpandableDetails(androidData);
2188
2228
  const androidCustomProperties = buildCustomProperties(androidData);
2189
2229
 
2190
- // Determine type based on image presence
2191
- const androidType = androidData.image ? MEDIA_TYPE_IMAGE : MEDIA_TYPE_TEXT;
2230
+ const androidType = getMpushType(androidData);
2192
2231
 
2193
2232
  const androidContent = {
2194
2233
  type: androidType,
@@ -2207,8 +2246,7 @@ const CommonTestAndPreview = (props) => {
2207
2246
  const iosExpandableDetails = buildIosExpandableDetails(iosData);
2208
2247
  const iosCustomProperties = buildCustomProperties(iosData);
2209
2248
 
2210
- // Determine type based on image presence
2211
- const iosType = iosData.image ? MEDIA_TYPE_IMAGE : MEDIA_TYPE_TEXT;
2249
+ const iosType = getMpushType(iosData);
2212
2250
 
2213
2251
  const iosContent = {
2214
2252
  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,78 @@ 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 placeholder', () => {
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')).toBeNull();
443
+ // svg imports resolve to the file stub in tests
444
+ expect(container.querySelector('img.carousel-video-preview')).toHaveAttribute('src', 'test-file-stub');
445
+ });
446
+
447
+ it('should render an empty card while no media is uploaded', () => {
448
+ const props = {
449
+ ...defaultProps,
450
+ content: {
451
+ androidContent: {
452
+ header: 'Header',
453
+ carouselData: [{ mediaType: 'IMAGE', title: 'Empty card' }],
454
+ },
455
+ },
456
+ };
457
+
458
+ const { container } = render(
459
+ <TestWrapper>
460
+ <ComponentToRender {...props} />
461
+ </TestWrapper>
462
+ );
463
+
464
+ expect(container.querySelector('.mobile-push-carousel-container')).toBeTruthy();
465
+ expect(container.querySelectorAll('.mobile-push-carousel-card')).toHaveLength(1);
466
+ expect(container.querySelector('.carousel-image')).toBeNull();
467
+ });
468
+
395
469
  it('should render carousel with image media type', () => {
396
470
  const props = {
397
471
  ...defaultProps,
@@ -488,6 +562,8 @@ describe('MobilePushPreviewContent', () => {
488
562
  bodyText: 'Body',
489
563
  carouselData: [
490
564
  {
565
+ mediaType: 'IMAGE',
566
+ imageUrl: 'https://image.url',
491
567
  header: 'Carousel Header',
492
568
  message: 'Message',
493
569
  },
@@ -514,6 +590,8 @@ describe('MobilePushPreviewContent', () => {
514
590
  bodyText: 'Body',
515
591
  carouselData: [
516
592
  {
593
+ mediaType: 'IMAGE',
594
+ imageUrl: 'https://image.url',
517
595
  title: 'Title',
518
596
  bodyText: 'Carousel Body',
519
597
  },