@capillarytech/creatives-library 9.1.7 → 9.1.8-alpha.sprint-cap-214249.38
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/constants/unified.js +0 -1
- package/index.js +0 -13
- package/package.json +1 -1
- package/services/getSchema.js +1 -4
- package/services/tests/getSchema.test.js +2 -2
- package/utils/common.js +0 -6
- package/utils/createMobilePushPayload.js +47 -33
- package/utils/tests/createMobilePushPayload.test.js +102 -8
- package/v2Components/CapMpushCTA/index.js +10 -9
- package/v2Components/CapMpushCTA/index.scss +29 -3
- package/v2Components/CapMpushCTA/tests/index.test.js +89 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +26 -13
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +13 -1
- package/v2Components/CommonTestAndPreview/constants.js +2 -0
- package/v2Components/CommonTestAndPreview/index.js +49 -11
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +79 -5
- package/v2Components/CommonTestAndPreview/tests/index.test.js +86 -0
- package/v2Components/FormBuilder/Functional/tests/mpush.crossFlowParity.test.js +1 -1
- package/v2Components/FormBuilder/Functional/tests/mpush.shellEvents.test.js +1 -1
- package/v2Components/FormBuilder/Functional/tests/mpush.singlePlatform.test.js +1 -1
- package/v2Components/FormBuilder/tests/mpush.characterization.test.js +2 -2
- package/v2Components/TemplatePreview/_templatePreview.scss +12 -2
- package/v2Components/TemplatePreview/index.js +30 -17
- package/v2Components/TemplatePreview/tests/index.test.js +61 -0
- package/v2Containers/Cap/index.js +0 -3
- package/v2Containers/CreativesContainer/SlideBoxContent.js +70 -151
- package/v2Containers/CreativesContainer/index.js +3 -6
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +29 -0
- package/v2Containers/MobilePushNew/components/CtaButtons.js +52 -47
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +207 -192
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +116 -121
- package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +30 -208
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +316 -72
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +45 -16
- package/v2Containers/MobilePushNew/constants.js +5 -0
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +63 -1
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +52 -0
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +38 -1
- package/v2Containers/MobilePushNew/hooks/useUpload.js +29 -39
- package/v2Containers/MobilePushNew/index.js +453 -188
- package/v2Containers/MobilePushNew/index.scss +188 -4
- package/v2Containers/MobilePushNew/messages.js +86 -6
- package/v2Containers/MobilePushNew/tests/index.test.js +450 -1
- package/v2Containers/MobilePushNew/tests/utils.test.js +25 -0
- package/v2Containers/MobilePushNew/utils.js +8 -0
- package/v2Containers/Templates/_templates.scss +10 -2
- package/v2Containers/Templates/index.js +84 -90
- package/v2Containers/Templates/tests/index.test.js +68 -0
- package/v2Components/FormBuilder/Functional/tests/manual.typingPerf.test.js +0 -135
- package/v2Components/FormBuilder/Functional/tests/mpush.ctaFlows.parity.test.js +0 -320
- package/v2Components/FormBuilder/Functional/tests/mpush.editContainer.parity.test.js +0 -148
- package/v2Components/FormBuilder/Functional/tests/mpush.libraryValidity.parity.test.js +0 -152
- package/v2Containers/MobilePush/Create/_mobilePushCreate.scss +0 -70
- package/v2Containers/MobilePush/Create/actions.js +0 -52
- package/v2Containers/MobilePush/Create/constants.js +0 -26
- package/v2Containers/MobilePush/Create/index.js +0 -2149
- package/v2Containers/MobilePush/Create/messages.js +0 -349
- package/v2Containers/MobilePush/Create/reducer.js +0 -72
- package/v2Containers/MobilePush/Create/sagas.js +0 -79
- package/v2Containers/MobilePush/Create/selectors.js +0 -29
- package/v2Containers/MobilePush/Create/test/contentValidity.test.js +0 -154
- package/v2Containers/MobilePush/Create/test/saga.test.js +0 -19
- package/v2Containers/MobilePush/Create/test/stayOpenOnSave.test.js +0 -80
- package/v2Containers/MobilePush/Edit/_mobilePushCreate.scss +0 -65
- package/v2Containers/MobilePush/Edit/actions.js +0 -94
- package/v2Containers/MobilePush/Edit/constants.js +0 -37
- package/v2Containers/MobilePush/Edit/index.js +0 -2407
- package/v2Containers/MobilePush/Edit/messages.js +0 -341
- package/v2Containers/MobilePush/Edit/reducer.js +0 -113
- package/v2Containers/MobilePush/Edit/sagas.js +0 -113
- package/v2Containers/MobilePush/Edit/selectors.js +0 -33
- package/v2Containers/MobilePush/Edit/test/contentValidity.test.js +0 -149
- package/v2Containers/MobilePush/Edit/test/saga.test.js +0 -255
- package/v2Containers/MobilePush/Edit/test/stayOpenOnSave.test.js +0 -60
- package/v2Containers/MobilePush/commonMethods.js +0 -333
- package/v2Containers/MobilePush/eventsMap.js +0 -130
- package/v2Containers/MobilePush/tests/commonMethods.test.js +0 -401
- package/v2Containers/MobilepushWrapper/_mobilepushWrapper.scss +0 -22
- package/v2Containers/MobilepushWrapper/index.js +0 -178
- package/v2Containers/MobilepushWrapper/messages.js +0 -29
- /package/{v2Containers/MobilePush/initialSchema.js → v2Components/FormBuilder/Functional/tests/fixtures/mpushInitialSchema.js} +0 -0
|
@@ -86,14 +86,20 @@ const MobilePushPreviewContent = ({
|
|
|
86
86
|
|
|
87
87
|
// Render MobilePush carousel (based on TemplatePreview renderMobilePushCarousel)
|
|
88
88
|
const renderMobilePushCarousel = (contentData) => {
|
|
89
|
-
|
|
89
|
+
// Only cards with an uploaded image/video
|
|
90
|
+
const cardsWithMedia = (contentData?.carouselData || []).filter((item) => {
|
|
91
|
+
const mediaType = item?.mediaType?.toLowerCase();
|
|
92
|
+
return (mediaType === MEDIA_TYPE_IMAGE.toLowerCase() && (item?.imageUrl || item?.url))
|
|
93
|
+
|| (mediaType === MEDIA_TYPE_VIDEO.toLowerCase() && (item?.videoPreviewImg || item?.videoSrc));
|
|
94
|
+
});
|
|
95
|
+
if (cardsWithMedia.length === 0) {
|
|
90
96
|
return null;
|
|
91
97
|
}
|
|
92
98
|
|
|
93
99
|
return (
|
|
94
100
|
<CapRow type="flex" vertical noWrap className="msg-container-carousel mobile-push-carousel-container">
|
|
95
|
-
<CapRow
|
|
96
|
-
{
|
|
101
|
+
<CapRow type="flex" noWrap className="scroll-container mobile-push-scroll-container">
|
|
102
|
+
{cardsWithMedia.map((item, idx) => (
|
|
97
103
|
<CapColumn
|
|
98
104
|
key={`carousel-card-${idx}`}
|
|
99
105
|
className="mobile-push-carousel-card message-pop align-left message-pop-carousel"
|
|
@@ -105,13 +111,20 @@ const MobilePushPreviewContent = ({
|
|
|
105
111
|
className="carousel-image"
|
|
106
112
|
/>
|
|
107
113
|
)}
|
|
108
|
-
{item?.mediaType?.toLowerCase() === MEDIA_TYPE_VIDEO.toLowerCase() && item?.videoPreviewImg && (
|
|
114
|
+
{item?.mediaType?.toLowerCase() === MEDIA_TYPE_VIDEO.toLowerCase() && (item?.videoPreviewImg || item?.videoSrc) && (
|
|
109
115
|
<CapRow className="video-preview">
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
116
|
+
{item?.videoPreviewImg ? (
|
|
117
|
+
<CapImage
|
|
118
|
+
src={item?.videoPreviewImg || item?.url}
|
|
119
|
+
alt="carousel-video-preview"
|
|
120
|
+
className="carousel-video-preview"
|
|
121
|
+
/>
|
|
122
|
+
) : (
|
|
123
|
+
// No thumbnail from the upload: show the video's first frame
|
|
124
|
+
<video src={item?.videoSrc} className="carousel-video-preview" muted preload="metadata">
|
|
125
|
+
<track kind="captions" />
|
|
126
|
+
</video>
|
|
127
|
+
)}
|
|
115
128
|
<CapRow className="icon-position">
|
|
116
129
|
<CapImage className="video-icon" src={videoPlay} alt="Play" />
|
|
117
130
|
</CapRow>
|
|
@@ -217,15 +230,15 @@ const MobilePushPreviewContent = ({
|
|
|
217
230
|
{/* Action Buttons */}
|
|
218
231
|
{(deviceContent?.actions || []).filter((action) => action?.label || action?.actionText).length > 0
|
|
219
232
|
&& deviceContent?.carouselData?.length === 0 && (
|
|
220
|
-
<CapRow
|
|
221
|
-
{
|
|
233
|
+
<CapRow type="flex" noWrap className="actions">
|
|
234
|
+
{deviceContent.actions.map((action, index) => (
|
|
222
235
|
(action?.label || action?.actionText) && (
|
|
223
236
|
<span
|
|
224
237
|
className="action"
|
|
225
|
-
key={`action-${
|
|
238
|
+
key={`action-${index}`}
|
|
226
239
|
title={action?.url || action?.actionLink || ''}
|
|
227
240
|
>
|
|
228
|
-
{action?.label
|
|
241
|
+
{action?.label || action?.actionText}
|
|
229
242
|
</span>
|
|
230
243
|
)
|
|
231
244
|
))}
|
|
@@ -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
|
-
|
|
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
|
}
|
|
@@ -209,6 +209,8 @@ export const CTA_TYPE_EXTERNAL_URL = 'EXTERNAL_URL';
|
|
|
209
209
|
// ============================================
|
|
210
210
|
export const STYLE_TYPE_BIG_PICTURE = 'BIG_PICTURE';
|
|
211
211
|
export const STYLE_TYPE_BIG_TEXT = 'BIG_TEXT';
|
|
212
|
+
export const STYLE_TYPE_VIDEO = 'VIDEO';
|
|
213
|
+
export const STYLE_TYPE_MANUAL_CAROUSEL = 'MANUAL_CAROUSEL';
|
|
212
214
|
|
|
213
215
|
// ============================================
|
|
214
216
|
// DEVICE TYPE CONSTANTS (for API payloads)
|
|
@@ -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,
|
|
@@ -1844,7 +1846,7 @@ const CommonTestAndPreview = (props) => {
|
|
|
1844
1846
|
|
|
1845
1847
|
case CHANNELS.MOBILEPUSH: {
|
|
1846
1848
|
// MobilePush uses "PUSH" as channel in API
|
|
1847
|
-
//
|
|
1849
|
+
// Mirrors the removed old editor's getTransformedData
|
|
1848
1850
|
//
|
|
1849
1851
|
// Data can come in multiple formats:
|
|
1850
1852
|
// 1. formData[0] and formData[1] (raw formData from old MobilePush Create/Edit)
|
|
@@ -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 =
|
|
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 (
|
|
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 =
|
|
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 (
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js
CHANGED
|
@@ -279,8 +279,8 @@ describe('MobilePushPreviewContent', () => {
|
|
|
279
279
|
</TestWrapper>
|
|
280
280
|
);
|
|
281
281
|
|
|
282
|
-
expect(screen.getByText('
|
|
283
|
-
expect(screen.getByText('
|
|
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('
|
|
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('
|
|
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('
|
|
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,74 @@ describe('MobilePushPreviewContent', () => {
|
|
|
392
394
|
expect(screen.getByText('Carousel Item 2')).toBeTruthy();
|
|
393
395
|
});
|
|
394
396
|
|
|
397
|
+
it('should render only cards with 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(2);
|
|
419
|
+
expect(screen.queryByText('Empty card')).toBeNull();
|
|
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 not render carousel when no card has media', () => {
|
|
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')).toBeFalsy();
|
|
463
|
+
});
|
|
464
|
+
|
|
395
465
|
it('should render carousel with image media type', () => {
|
|
396
466
|
const props = {
|
|
397
467
|
...defaultProps,
|
|
@@ -488,6 +558,8 @@ describe('MobilePushPreviewContent', () => {
|
|
|
488
558
|
bodyText: 'Body',
|
|
489
559
|
carouselData: [
|
|
490
560
|
{
|
|
561
|
+
mediaType: 'IMAGE',
|
|
562
|
+
imageUrl: 'https://image.url',
|
|
491
563
|
header: 'Carousel Header',
|
|
492
564
|
message: 'Message',
|
|
493
565
|
},
|
|
@@ -514,6 +586,8 @@ describe('MobilePushPreviewContent', () => {
|
|
|
514
586
|
bodyText: 'Body',
|
|
515
587
|
carouselData: [
|
|
516
588
|
{
|
|
589
|
+
mediaType: 'IMAGE',
|
|
590
|
+
imageUrl: 'https://image.url',
|
|
517
591
|
title: 'Title',
|
|
518
592
|
bodyText: 'Carousel Body',
|
|
519
593
|
},
|
|
@@ -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 = {
|
|
@@ -16,7 +16,7 @@ import _ from 'lodash';
|
|
|
16
16
|
import { Router } from 'react-router-dom';
|
|
17
17
|
import { render, act } from '../../../../utils/test-utils';
|
|
18
18
|
import history from '../../../../utils/history';
|
|
19
|
-
import { response as mpushSchemaResponse } from '
|
|
19
|
+
import { response as mpushSchemaResponse } from './fixtures/mpushInitialSchema';
|
|
20
20
|
|
|
21
21
|
import ClassicFormBuilder from '../../Classic';
|
|
22
22
|
import FunctionalFormBuilder from '../index';
|
|
@@ -9,7 +9,7 @@ import _ from 'lodash';
|
|
|
9
9
|
import { Router } from 'react-router-dom';
|
|
10
10
|
import { render, act, fireEvent } from '../../../../utils/test-utils';
|
|
11
11
|
import history from '../../../../utils/history';
|
|
12
|
-
import { response as mpushSchemaResponse } from '
|
|
12
|
+
import { response as mpushSchemaResponse } from './fixtures/mpushInitialSchema';
|
|
13
13
|
import FunctionalFormBuilder from '../index';
|
|
14
14
|
|
|
15
15
|
jest.mock('redux-auth-wrapper/history4/redirect', () => ({
|
|
@@ -13,7 +13,7 @@ import { configureStore } from '@capillarytech/vulcan-react-sdk/utils';
|
|
|
13
13
|
import history from '../../../../utils/history';
|
|
14
14
|
import { initialReducer } from '../../../../initialReducer';
|
|
15
15
|
import { render, fireEvent, waitFor } from '../../../../utils/test-utils';
|
|
16
|
-
import { response as mpushSchemaResponse } from '
|
|
16
|
+
import { response as mpushSchemaResponse } from './fixtures/mpushInitialSchema';
|
|
17
17
|
import FunctionalFormBuilder from '../index';
|
|
18
18
|
|
|
19
19
|
jest.mock('redux-auth-wrapper/history4/redirect', () => ({
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* These tests pin the CURRENT behavior of the FormBuilder monolith
|
|
5
5
|
* (app/v2Components/FormBuilder/Classic.js) for the MOBILEPUSH channel, using
|
|
6
|
-
* the real bundled layout schemas (
|
|
6
|
+
* the real bundled layout schemas (Functional/tests/fixtures/mpushInitialSchema.js,
|
|
7
7
|
* textSchema + imageSchema). They are the parity gate for the functional
|
|
8
8
|
* rewrite: the new implementation must keep every assertion here green.
|
|
9
9
|
*
|
|
@@ -28,7 +28,7 @@ import { initialReducer } from '../../../initialReducer';
|
|
|
28
28
|
import {
|
|
29
29
|
render, screen, fireEvent, waitFor, act,
|
|
30
30
|
} from '../../../utils/test-utils';
|
|
31
|
-
import { response as mpushSchemaResponse } from '
|
|
31
|
+
import { response as mpushSchemaResponse } from '../Functional/tests/fixtures/mpushInitialSchema';
|
|
32
32
|
|
|
33
33
|
// Same harness facts as the SMS suite: neutralize the auth-guarded TagList wrapper…
|
|
34
34
|
jest.mock('redux-auth-wrapper/history4/redirect', () => ({
|
|
@@ -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:
|
|
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,20 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
168
168
|
};
|
|
169
169
|
|
|
170
170
|
renderMobilePushCarousel = (content) => {
|
|
171
|
-
|
|
171
|
+
// Only cards with an uploaded image/video
|
|
172
|
+
const cardsWithMedia = (content?.carouselData || []).filter((item) => {
|
|
173
|
+
const mediaType = item?.mediaType?.toLowerCase();
|
|
174
|
+
return (mediaType === IMAGE && (item?.imageUrl || item?.url))
|
|
175
|
+
|| (mediaType === VIDEO && (item?.videoPreviewImg || item?.videoSrc));
|
|
176
|
+
});
|
|
177
|
+
if (cardsWithMedia.length === 0) {
|
|
172
178
|
return null;
|
|
173
179
|
}
|
|
174
180
|
|
|
175
181
|
return (
|
|
176
182
|
<CapRow type="flex" vertical noWrap className="msg-container-carousel mobile-push-carousel-container">
|
|
177
|
-
<CapRow className="scroll-container mobile-push-scroll-container">
|
|
178
|
-
{
|
|
183
|
+
<CapRow type="flex" noWrap className="scroll-container mobile-push-scroll-container">
|
|
184
|
+
{cardsWithMedia.map((item, idx) => (
|
|
179
185
|
<CapColumn
|
|
180
186
|
key={`carousel-card-${idx}`}
|
|
181
187
|
className="mobile-push-carousel-card message-pop align-left message-pop-carousel"
|
|
@@ -187,13 +193,20 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
187
193
|
className="carousel-image"
|
|
188
194
|
/>
|
|
189
195
|
)}
|
|
190
|
-
{item?.mediaType?.toLowerCase() === VIDEO && item?.videoPreviewImg && (
|
|
196
|
+
{item?.mediaType?.toLowerCase() === VIDEO && (item?.videoPreviewImg || item?.videoSrc) && (
|
|
191
197
|
<CapRow className="video-preview">
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
198
|
+
{item?.videoPreviewImg ? (
|
|
199
|
+
<CapImage
|
|
200
|
+
src={item?.videoPreviewImg || item?.url}
|
|
201
|
+
alt="carousel-video-preview"
|
|
202
|
+
className="carousel-video-preview"
|
|
203
|
+
/>
|
|
204
|
+
) : (
|
|
205
|
+
// No thumbnail from the upload: show the video's first frame
|
|
206
|
+
<video src={item?.videoSrc} className="carousel-video-preview" muted preload="metadata">
|
|
207
|
+
<track kind="captions" />
|
|
208
|
+
</video>
|
|
209
|
+
)}
|
|
197
210
|
<CapRow className="icon-position">
|
|
198
211
|
<CapImage className="video-icon" src={videoPlay} />
|
|
199
212
|
</CapRow>
|
|
@@ -907,17 +920,17 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
907
920
|
)}
|
|
908
921
|
{(content?.actions || []).filter((action) => action?.label)
|
|
909
922
|
.length && content?.carouselData?.length === 0 ? (
|
|
910
|
-
<CapRow className="actions">
|
|
923
|
+
<CapRow type="flex" noWrap className="actions">
|
|
911
924
|
{_.map(
|
|
912
925
|
content?.actions || [],
|
|
913
|
-
(action) =>
|
|
926
|
+
(action, index) =>
|
|
914
927
|
!!action?.label && (
|
|
915
928
|
<span
|
|
916
929
|
className="action"
|
|
917
|
-
key={`action-${
|
|
930
|
+
key={`action-${index}`}
|
|
918
931
|
title={action?.url || ''}
|
|
919
932
|
>
|
|
920
|
-
{action?.label
|
|
933
|
+
{action?.label}
|
|
921
934
|
</span>
|
|
922
935
|
)
|
|
923
936
|
)}
|
|
@@ -971,17 +984,17 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
971
984
|
)}
|
|
972
985
|
{(content?.actions || []).filter((action) => action?.label)
|
|
973
986
|
.length && content?.carouselData?.length === 0 ? (
|
|
974
|
-
<CapRow className="actions">
|
|
987
|
+
<CapRow type="flex" noWrap className="actions">
|
|
975
988
|
{_.map(
|
|
976
989
|
content?.actions || [],
|
|
977
|
-
(action) =>
|
|
990
|
+
(action, index) =>
|
|
978
991
|
!!action?.label && (
|
|
979
992
|
<span
|
|
980
993
|
className="action"
|
|
981
|
-
key={`action-${
|
|
994
|
+
key={`action-${index}`}
|
|
982
995
|
title={action?.url || ''}
|
|
983
996
|
>
|
|
984
|
-
{action?.label
|
|
997
|
+
{action?.label}
|
|
985
998
|
</span>
|
|
986
999
|
)
|
|
987
1000
|
)}
|