@capillarytech/creatives-library 9.2.2 → 9.2.4-alpha.feature-rcs-multi-account.51
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/package.json +1 -1
- package/utils/common.js +0 -6
- package/utils/createMobilePushPayload.js +50 -56
- package/utils/tests/createMobilePushPayload.test.js +177 -168
- package/v2Components/CapMpushCTA/index.js +47 -57
- package/v2Components/CapMpushCTA/index.scss +43 -5
- package/v2Components/CapMpushCTA/tests/index.test.js +150 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +11 -8
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +13 -1
- package/v2Components/CommonTestAndPreview/constants.js +2 -0
- package/v2Components/CommonTestAndPreview/index.js +59 -14
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +83 -5
- package/v2Components/CommonTestAndPreview/tests/index.test.js +158 -0
- package/v2Components/MobilePushPreviewV2/_mobilePushPreviewV2.scss +7 -0
- package/v2Components/MobilePushPreviewV2/index.js +22 -9
- package/v2Components/MobilePushPreviewV2/tests/index.test.js +55 -0
- package/v2Components/TemplatePreview/_mobilePushPhone.scss +72 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +18 -2
- package/v2Components/TemplatePreview/index.js +20 -18
- package/v2Components/TemplatePreview/tests/index.test.js +69 -0
- package/v2Components/TestAndPreviewSlidebox/index.js +2 -0
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/Tests/extractContentForPreview.test.js +45 -0
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/extractContentForPreview.js +12 -2
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/DeliverySettingsSection.js +16 -3
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/SenderDetails.js +7 -2
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/deliverySettingsConfig.test.js +44 -0
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/deliverySettingsConfig.js +21 -8
- package/v2Containers/CreativesContainer/SlideBoxContent.js +4 -6
- package/v2Containers/CreativesContainer/index.js +18 -1
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +43 -0
- package/v2Containers/CreativesContainer/tests/index.test.js +66 -0
- package/v2Containers/MobilePushNew/components/CtaButtons.js +52 -47
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +105 -345
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +127 -105
- package/v2Containers/MobilePushNew/components/TapLinkActions.js +76 -0
- package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +30 -208
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +305 -1482
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +165 -59
- package/v2Containers/MobilePushNew/constants.js +12 -0
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +63 -1
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +78 -0
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +40 -1
- package/v2Containers/MobilePushNew/hooks/useUpload.js +42 -46
- package/v2Containers/MobilePushNew/index.js +498 -289
- package/v2Containers/MobilePushNew/index.scss +151 -4
- package/v2Containers/MobilePushNew/messages.js +106 -6
- package/v2Containers/MobilePushNew/tests/index.test.js +483 -1
- package/v2Containers/MobilePushNew/tests/utils.test.js +110 -0
- package/v2Containers/MobilePushNew/utils.js +83 -0
- package/v2Containers/Rcs/accountUtils.js +20 -0
- package/v2Containers/Rcs/index.js +18 -1
- package/v2Containers/Rcs/tests/accountUtils.test.js +24 -0
- package/v2Containers/Rcs/tests/index.test.js +23 -0
- package/v2Containers/Templates/ChannelTypeIllustration.js +12 -0
- package/v2Containers/Templates/_templates.scss +10 -2
- package/v2Containers/Templates/index.js +94 -85
- package/v2Containers/Templates/messages.js +4 -0
- package/v2Containers/Templates/tests/ChannelTypeIllustration.test.js +14 -2
- package/v2Containers/Templates/tests/index.test.js +182 -0
|
@@ -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,
|
|
@@ -227,6 +229,9 @@ const CommonTestAndPreview = (props) => {
|
|
|
227
229
|
} = props;
|
|
228
230
|
|
|
229
231
|
const smsFallbackContent = additionalProps?.smsFallbackContent;
|
|
232
|
+
// RCS multi-account (same as WhatsApp): the template's account sourceAccountIdentifier picks the default domain.
|
|
233
|
+
const rcsSourceAccountIdentifier = additionalProps?.rcsTestPreviewOptions?.sourceAccountIdentifier || '';
|
|
234
|
+
|
|
230
235
|
const smsFallbackTextForTagExtraction = useMemo(
|
|
231
236
|
() => getSmsFallbackTextForTagExtraction(smsFallbackContent),
|
|
232
237
|
[smsFallbackContent],
|
|
@@ -346,7 +351,10 @@ const CommonTestAndPreview = (props) => {
|
|
|
346
351
|
|
|
347
352
|
if (!isRcsDeliveryFullyUnset && !shouldOnlyFillSmsFallbackSender) return;
|
|
348
353
|
|
|
349
|
-
|
|
354
|
+
// Same as WhatsApp: default to the account's domain, else the first domain.
|
|
355
|
+
const firstRcsDomain = (rcsSourceAccountIdentifier
|
|
356
|
+
&& rcsDomainRows.find((domain) => domain?.sourceAccountIdentifier === rcsSourceAccountIdentifier))
|
|
357
|
+
|| rcsDomainRows[0];
|
|
350
358
|
const firstSmsFallbackDomain = smsFallbackDomainRows[0];
|
|
351
359
|
const usableRcsGsmSenders = filterUsableGsmSendersForDomain(
|
|
352
360
|
firstRcsDomain,
|
|
@@ -451,7 +459,7 @@ const CommonTestAndPreview = (props) => {
|
|
|
451
459
|
}
|
|
452
460
|
return next;
|
|
453
461
|
});
|
|
454
|
-
}, [channel, formData?.accountName, senderDetailsByChannel, smsTraiDltEnabled, registeredSenderIds, wecrmAccounts]);
|
|
462
|
+
}, [channel, formData?.accountName, senderDetailsByChannel, rcsSourceAccountIdentifier, smsTraiDltEnabled, registeredSenderIds, wecrmAccounts]);
|
|
455
463
|
|
|
456
464
|
// ============================================
|
|
457
465
|
// MEMOIZED VALUES
|
|
@@ -1884,6 +1892,10 @@ const CommonTestAndPreview = (props) => {
|
|
|
1884
1892
|
'message-title': formDataObj.androidContent.header || '',
|
|
1885
1893
|
'message-editor': formDataObj.androidContent.bodyText || '',
|
|
1886
1894
|
'image': formDataObj.androidContent.bodyImage || '',
|
|
1895
|
+
// bodyVideo also carries GIFs; send only real videos
|
|
1896
|
+
'video': formDataObj.androidContent.bodyGif ? '' : (formDataObj.androidContent.bodyVideo?.videoSrc || ''),
|
|
1897
|
+
// Saved cards, already in the shape Save sent
|
|
1898
|
+
carouselData: formDataObj.androidContent.carouselData || [],
|
|
1887
1899
|
// Extract CTA info from actions if available
|
|
1888
1900
|
...(formDataObj.androidContent.actions?.[0] && {
|
|
1889
1901
|
'cta-deeplink-label': formDataObj.androidContent.actions[0].label,
|
|
@@ -1902,6 +1914,8 @@ const CommonTestAndPreview = (props) => {
|
|
|
1902
1914
|
'message-title2': formDataObj.iosContent.header || '',
|
|
1903
1915
|
'message-editor2': formDataObj.iosContent.bodyText || '',
|
|
1904
1916
|
'image': formDataObj.iosContent.bodyImage || '',
|
|
1917
|
+
'video': formDataObj.iosContent.bodyGif ? '' : (formDataObj.iosContent.bodyVideo?.videoSrc || ''),
|
|
1918
|
+
carouselData: formDataObj.iosContent.carouselData || [],
|
|
1905
1919
|
// Extract CTA info from actions if available
|
|
1906
1920
|
...(formDataObj.iosContent.actions?.[0] && {
|
|
1907
1921
|
'cta-deeplink2-label': formDataObj.iosContent.actions[0].label,
|
|
@@ -2007,11 +2021,35 @@ const CommonTestAndPreview = (props) => {
|
|
|
2007
2021
|
};
|
|
2008
2022
|
};
|
|
2009
2023
|
|
|
2024
|
+
const hasCarousel = (data) => Array.isArray(data.carouselData) && data.carouselData.length > 0;
|
|
2025
|
+
// Carousel, then video, then image; BIG_TEXT when none
|
|
2026
|
+
const getMpushStyle = (data) => {
|
|
2027
|
+
if (hasCarousel(data)) return STYLE_TYPE_MANUAL_CAROUSEL;
|
|
2028
|
+
if (data.video) return STYLE_TYPE_VIDEO;
|
|
2029
|
+
return data.image ? STYLE_TYPE_BIG_PICTURE : STYLE_TYPE_BIG_TEXT;
|
|
2030
|
+
};
|
|
2031
|
+
const getMpushType = (data) => {
|
|
2032
|
+
if (hasCarousel(data)) return MEDIA_TYPE_CAROUSEL;
|
|
2033
|
+
if (data.video) return MEDIA_TYPE_VIDEO;
|
|
2034
|
+
return data.image ? MEDIA_TYPE_IMAGE : MEDIA_TYPE_TEXT;
|
|
2035
|
+
};
|
|
2036
|
+
// Raw URL, as Save sends it (the CDN helper is an image transform)
|
|
2037
|
+
const toMpushVideoMedia = (url) => [{ url, text: '', type: MEDIA_TYPE_VIDEO }];
|
|
2038
|
+
// Only the spec's media list, as campaigns saves it (carouselData is the editor's own format)
|
|
2039
|
+
const addMpushCarousel = (expandableDetails, data) => {
|
|
2040
|
+
Object.assign(expandableDetails, {
|
|
2041
|
+
media: data.carouselData.map((card) => ({
|
|
2042
|
+
url: card?.mediaType?.toUpperCase() === MEDIA_TYPE_VIDEO ? card.videoSrc : card.imageUrl,
|
|
2043
|
+
type: card?.mediaType?.toUpperCase(),
|
|
2044
|
+
text: '',
|
|
2045
|
+
})),
|
|
2046
|
+
});
|
|
2047
|
+
};
|
|
2048
|
+
|
|
2010
2049
|
// Helper function to build expandableDetails for Android
|
|
2011
2050
|
const buildAndroidExpandableDetails = (data) => {
|
|
2012
|
-
// Default style is BIG_TEXT, change to BIG_PICTURE if image exists
|
|
2013
2051
|
const imageLink = data.image;
|
|
2014
|
-
const style =
|
|
2052
|
+
const style = getMpushStyle(data);
|
|
2015
2053
|
|
|
2016
2054
|
const expandableDetails = {
|
|
2017
2055
|
style,
|
|
@@ -2020,7 +2058,11 @@ const CommonTestAndPreview = (props) => {
|
|
|
2020
2058
|
};
|
|
2021
2059
|
|
|
2022
2060
|
// Add image if present (transform to CDN URL if needed)
|
|
2023
|
-
if (
|
|
2061
|
+
if (hasCarousel(data)) {
|
|
2062
|
+
addMpushCarousel(expandableDetails, data);
|
|
2063
|
+
} else if (data.video) {
|
|
2064
|
+
expandableDetails.media = toMpushVideoMedia(data.video);
|
|
2065
|
+
} else if (imageLink) {
|
|
2024
2066
|
expandableDetails.image = getCdnUrl({ url: imageLink, channelName: CHANNEL_NAME_MOBILE_PUSH });
|
|
2025
2067
|
}
|
|
2026
2068
|
|
|
@@ -2099,9 +2141,8 @@ const CommonTestAndPreview = (props) => {
|
|
|
2099
2141
|
|
|
2100
2142
|
// Helper function to build expandableDetails for iOS
|
|
2101
2143
|
const buildIosExpandableDetails = (data) => {
|
|
2102
|
-
// Default style is BIG_TEXT, change to BIG_PICTURE if image exists
|
|
2103
2144
|
const imageLinkIos = data.image;
|
|
2104
|
-
const style =
|
|
2145
|
+
const style = getMpushStyle(data);
|
|
2105
2146
|
|
|
2106
2147
|
const expandableDetails = {
|
|
2107
2148
|
style,
|
|
@@ -2110,7 +2151,11 @@ const CommonTestAndPreview = (props) => {
|
|
|
2110
2151
|
};
|
|
2111
2152
|
|
|
2112
2153
|
// Add image if present (transform to CDN URL if needed)
|
|
2113
|
-
if (
|
|
2154
|
+
if (hasCarousel(data)) {
|
|
2155
|
+
addMpushCarousel(expandableDetails, data);
|
|
2156
|
+
} else if (data.video) {
|
|
2157
|
+
expandableDetails.media = toMpushVideoMedia(data.video);
|
|
2158
|
+
} else if (imageLinkIos) {
|
|
2114
2159
|
expandableDetails.image = getCdnUrl({ url: imageLinkIos, channelName: CHANNEL_NAME_MOBILE_PUSH });
|
|
2115
2160
|
}
|
|
2116
2161
|
|
|
@@ -2183,12 +2228,13 @@ const CommonTestAndPreview = (props) => {
|
|
|
2183
2228
|
// Build Android content
|
|
2184
2229
|
const androidTitle = resolveTagsInText(androidData['message-title'] || '', customValuesObj);
|
|
2185
2230
|
const androidMessage = resolveTagsInText(androidData['message-editor'] || '', customValuesObj);
|
|
2186
|
-
|
|
2231
|
+
// No tap-link form keys when campaigns passes its content: use its saved cta as is
|
|
2232
|
+
const getSavedMpushCta = (savedContent) => savedContent?.cta || null;
|
|
2233
|
+
const androidCta = buildAndroidCta(androidData) || getSavedMpushCta(formDataObj?.androidContent);
|
|
2187
2234
|
const androidExpandableDetails = buildAndroidExpandableDetails(androidData);
|
|
2188
2235
|
const androidCustomProperties = buildCustomProperties(androidData);
|
|
2189
2236
|
|
|
2190
|
-
|
|
2191
|
-
const androidType = androidData.image ? MEDIA_TYPE_IMAGE : MEDIA_TYPE_TEXT;
|
|
2237
|
+
const androidType = getMpushType(androidData);
|
|
2192
2238
|
|
|
2193
2239
|
const androidContent = {
|
|
2194
2240
|
type: androidType,
|
|
@@ -2203,12 +2249,11 @@ const CommonTestAndPreview = (props) => {
|
|
|
2203
2249
|
// Build iOS content
|
|
2204
2250
|
const iosTitle = resolveTagsInText(iosData['message-title2'] || '', customValuesObj);
|
|
2205
2251
|
const iosMessage = resolveTagsInText(iosData['message-editor2'] || '', customValuesObj);
|
|
2206
|
-
const iosCta = buildIosCta(iosData);
|
|
2252
|
+
const iosCta = buildIosCta(iosData) || getSavedMpushCta(formDataObj?.iosContent);
|
|
2207
2253
|
const iosExpandableDetails = buildIosExpandableDetails(iosData);
|
|
2208
2254
|
const iosCustomProperties = buildCustomProperties(iosData);
|
|
2209
2255
|
|
|
2210
|
-
|
|
2211
|
-
const iosType = iosData.image ? MEDIA_TYPE_IMAGE : MEDIA_TYPE_TEXT;
|
|
2256
|
+
const iosType = getMpushType(iosData);
|
|
2212
2257
|
|
|
2213
2258
|
const iosContent = {
|
|
2214
2259
|
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,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
|
},
|
|
@@ -213,6 +213,64 @@ describe('CommonTestAndPreview', () => {
|
|
|
213
213
|
});
|
|
214
214
|
|
|
215
215
|
describe('Delivery settings / sender ID', () => {
|
|
216
|
+
describe('RCS multi-account default sender', () => {
|
|
217
|
+
const rcsDomainA = {
|
|
218
|
+
domainId: 1,
|
|
219
|
+
dgmId: 11,
|
|
220
|
+
domainName: 'RCS A',
|
|
221
|
+
sourceAccountIdentifier: 'acc-A',
|
|
222
|
+
gsmSenders: [{ value: 'RCS_A' }],
|
|
223
|
+
cdmaSenders: [],
|
|
224
|
+
};
|
|
225
|
+
const rcsDomainB = {
|
|
226
|
+
domainId: 2,
|
|
227
|
+
dgmId: 22,
|
|
228
|
+
domainName: 'RCS B',
|
|
229
|
+
sourceAccountIdentifier: 'acc-B',
|
|
230
|
+
gsmSenders: [{ value: 'RCS_B' }],
|
|
231
|
+
cdmaSenders: [],
|
|
232
|
+
};
|
|
233
|
+
const senderDetailsByChannel = { [CHANNELS.RCS]: [rcsDomainA, rcsDomainB] };
|
|
234
|
+
const renderRcs = (rcsTestPreviewOptions) => render(
|
|
235
|
+
<TestWrapper>
|
|
236
|
+
<CommonTestAndPreview
|
|
237
|
+
{...defaultProps}
|
|
238
|
+
channel={CHANNELS.RCS}
|
|
239
|
+
senderDetailsByChannel={senderDetailsByChannel}
|
|
240
|
+
rcsTestPreviewOptions={rcsTestPreviewOptions}
|
|
241
|
+
/>
|
|
242
|
+
</TestWrapper>
|
|
243
|
+
);
|
|
244
|
+
|
|
245
|
+
it('defaults to the template account domain and keeps every RCS domain in the list (same as WhatsApp)', async () => {
|
|
246
|
+
renderRcs({ isLibraryMode: false, sourceAccountIdentifier: 'acc-B' });
|
|
247
|
+
await waitFor(() => {
|
|
248
|
+
expect(lastSendTestMessageProps.deliverySettings).toMatchObject({
|
|
249
|
+
domainId: 2,
|
|
250
|
+
domainGatewayMapId: 22,
|
|
251
|
+
gsmSenderId: '2|RCS_B',
|
|
252
|
+
});
|
|
253
|
+
});
|
|
254
|
+
expect(lastSendTestMessageProps.senderDetailsByChannel).toBe(senderDetailsByChannel);
|
|
255
|
+
});
|
|
256
|
+
|
|
257
|
+
it('defaults to the first RCS domain when no account is given (single-account behaviour)', async () => {
|
|
258
|
+
renderRcs({ isLibraryMode: false });
|
|
259
|
+
await waitFor(() => {
|
|
260
|
+
expect(lastSendTestMessageProps.deliverySettings).toMatchObject({ domainId: 1, gsmSenderId: '1|RCS_A' });
|
|
261
|
+
});
|
|
262
|
+
expect(lastSendTestMessageProps.senderDetailsByChannel).toBe(senderDetailsByChannel);
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
it('defaults to the first RCS domain when the account matches no domain', async () => {
|
|
266
|
+
renderRcs({ isLibraryMode: false, sourceAccountIdentifier: 'acc-unknown' });
|
|
267
|
+
await waitFor(() => {
|
|
268
|
+
expect(lastSendTestMessageProps.deliverySettings).toMatchObject({ domainId: 1, gsmSenderId: '1|RCS_A' });
|
|
269
|
+
});
|
|
270
|
+
expect(lastSendTestMessageProps.senderDetailsByChannel).toBe(senderDetailsByChannel);
|
|
271
|
+
});
|
|
272
|
+
});
|
|
273
|
+
|
|
216
274
|
it('should call getSenderDetailsRequested when show and channel is SMS', async () => {
|
|
217
275
|
render(
|
|
218
276
|
<TestWrapper>
|
|
@@ -602,6 +660,106 @@ describe('CommonTestAndPreview', () => {
|
|
|
602
660
|
});
|
|
603
661
|
});
|
|
604
662
|
|
|
663
|
+
describe('Mobile push video payload - handleSendTestMessage', () => {
|
|
664
|
+
// resetMocks in the jest config wipes the module mock's implementation before each test
|
|
665
|
+
beforeEach(() => {
|
|
666
|
+
// eslint-disable-next-line global-require
|
|
667
|
+
require('../../../utils/cdnTransformation').getCdnUrl.mockImplementation(({ url }) => `cdn_${url}`);
|
|
668
|
+
});
|
|
669
|
+
|
|
670
|
+
const sendAndGetContent = async (props) => {
|
|
671
|
+
render(
|
|
672
|
+
<TestWrapper>
|
|
673
|
+
<CommonTestAndPreview {...defaultProps} channel={CHANNELS.MOBILEPUSH} {...props} />
|
|
674
|
+
</TestWrapper>
|
|
675
|
+
);
|
|
676
|
+
await waitFor(() => expect(lastSendTestMessageProps).toBeTruthy());
|
|
677
|
+
lastSendTestMessageProps.handleSendTestMessage();
|
|
678
|
+
const [payload] = mockActions.createMessageMetaRequested.mock.calls[0];
|
|
679
|
+
return payload.mpushMessageContent;
|
|
680
|
+
};
|
|
681
|
+
|
|
682
|
+
it('sends a VIDEO style with the raw video url from the edit flow form data', async () => {
|
|
683
|
+
const { androidContent, iosContent } = await sendAndGetContent({
|
|
684
|
+
formData: [
|
|
685
|
+
{ 'message-title': 'T', 'message-editor': 'M', image: 'old.jpg', video: 'https://s3/a.mp4' },
|
|
686
|
+
{ 'message-title2': 'T2', 'message-editor2': 'M2', image: 'ios.jpg', video: '' },
|
|
687
|
+
],
|
|
688
|
+
});
|
|
689
|
+
expect(androidContent.type).toBe('VIDEO');
|
|
690
|
+
expect(androidContent.expandableDetails.style).toBe('VIDEO');
|
|
691
|
+
expect(androidContent.expandableDetails.media).toEqual([{ url: 'https://s3/a.mp4', text: '', type: 'VIDEO' }]);
|
|
692
|
+
expect(androidContent.expandableDetails.image).toBeUndefined();
|
|
693
|
+
expect(iosContent.type).toBe('IMAGE');
|
|
694
|
+
expect(iosContent.expandableDetails.style).toBe('BIG_PICTURE');
|
|
695
|
+
expect(iosContent.expandableDetails.image).toBe('cdn_ios.jpg');
|
|
696
|
+
expect(iosContent.expandableDetails.media).toBeUndefined();
|
|
697
|
+
});
|
|
698
|
+
|
|
699
|
+
it('reads bodyVideo from the list (three-dots) content, but not for a GIF', async () => {
|
|
700
|
+
const { androidContent, iosContent } = await sendAndGetContent({
|
|
701
|
+
formData: undefined,
|
|
702
|
+
content: {
|
|
703
|
+
androidContent: { header: 'T', bodyText: 'M', bodyVideo: { videoSrc: 'https://s3/a.mp4' } },
|
|
704
|
+
iosContent: { header: 'T2', bodyText: 'M2', bodyVideo: { videoSrc: 'https://s3/b.gif' }, bodyGif: 'https://s3/b.gif' },
|
|
705
|
+
},
|
|
706
|
+
});
|
|
707
|
+
expect(androidContent.expandableDetails.media).toEqual([{ url: 'https://s3/a.mp4', text: '', type: 'VIDEO' }]);
|
|
708
|
+
expect(androidContent.type).toBe('VIDEO');
|
|
709
|
+
expect(iosContent.type).toBe('TEXT');
|
|
710
|
+
expect(iosContent.expandableDetails.style).toBe('BIG_TEXT');
|
|
711
|
+
expect(iosContent.expandableDetails.media).toBeUndefined();
|
|
712
|
+
});
|
|
713
|
+
|
|
714
|
+
const imageCard = { mediaType: 'image', imageUrl: 'https://s3/1.png', videoSrc: '', buttons: [] };
|
|
715
|
+
const videoCard = { mediaType: 'video', imageUrl: '', videoSrc: 'https://s3/2.mp4', buttons: [] };
|
|
716
|
+
|
|
717
|
+
it('sends only the media list for carousel cards from the edit flow form data', async () => {
|
|
718
|
+
const { androidContent, iosContent } = await sendAndGetContent({
|
|
719
|
+
formData: [
|
|
720
|
+
{ 'message-title': 'T', 'message-editor': 'M', image: '', video: '', carouselData: [imageCard, videoCard] },
|
|
721
|
+
{ 'message-title2': 'T2', 'message-editor2': 'M2', image: '', video: '', carouselData: [] },
|
|
722
|
+
],
|
|
723
|
+
});
|
|
724
|
+
expect(androidContent.type).toBe('CAROUSEL');
|
|
725
|
+
expect(androidContent.expandableDetails.style).toBe('MANUAL_CAROUSEL');
|
|
726
|
+
// carouselData is the editor's format; campaigns saves only media
|
|
727
|
+
expect(androidContent.expandableDetails.carouselData).toBeUndefined();
|
|
728
|
+
expect(androidContent.expandableDetails.media).toEqual([
|
|
729
|
+
{ url: 'https://s3/1.png', type: 'IMAGE', text: '' },
|
|
730
|
+
{ url: 'https://s3/2.mp4', type: 'VIDEO', text: '' },
|
|
731
|
+
]);
|
|
732
|
+
expect(iosContent.type).toBe('TEXT');
|
|
733
|
+
expect(iosContent.expandableDetails.carouselData).toBeUndefined();
|
|
734
|
+
});
|
|
735
|
+
|
|
736
|
+
it('sends saved carousel cards from the list (three-dots) content', async () => {
|
|
737
|
+
const { iosContent } = await sendAndGetContent({
|
|
738
|
+
formData: undefined,
|
|
739
|
+
content: {
|
|
740
|
+
androidContent: { header: 'T', bodyText: 'M' },
|
|
741
|
+
iosContent: { header: 'T2', bodyText: 'M2', carouselData: [videoCard] },
|
|
742
|
+
},
|
|
743
|
+
});
|
|
744
|
+
expect(iosContent.type).toBe('CAROUSEL');
|
|
745
|
+
expect(iosContent.expandableDetails.style).toBe('MANUAL_CAROUSEL');
|
|
746
|
+
expect(iosContent.expandableDetails.media).toEqual([{ url: 'https://s3/2.mp4', type: 'VIDEO', text: '' }]);
|
|
747
|
+
});
|
|
748
|
+
|
|
749
|
+
it('sends the saved tap link from campaigns content, carousel included', async () => {
|
|
750
|
+
const tapCta = { type: 'EXTERNAL_URL', actionLink: 'https://tap.com' };
|
|
751
|
+
const { androidContent, iosContent } = await sendAndGetContent({
|
|
752
|
+
formData: {
|
|
753
|
+
androidContent: { header: 'T', bodyText: 'M', cta: tapCta },
|
|
754
|
+
iosContent: { header: 'T2', bodyText: 'M2', cta: tapCta, carouselData: [imageCard] },
|
|
755
|
+
},
|
|
756
|
+
});
|
|
757
|
+
expect(androidContent.cta).toEqual(tapCta);
|
|
758
|
+
expect(iosContent.type).toBe('CAROUSEL');
|
|
759
|
+
expect(iosContent.cta).toEqual(tapCta);
|
|
760
|
+
});
|
|
761
|
+
});
|
|
762
|
+
|
|
605
763
|
describe('Carousel payload (getCarouselMappedData) - handleSendTestMessage', () => {
|
|
606
764
|
it('should map empty carouselData to empty cards when mediaType is CAROUSEL', async () => {
|
|
607
765
|
const props = {
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
@import '../TemplatePreview/mobilePushPhone';
|
|
2
|
+
|
|
3
|
+
// Saved-template preview (campaigns message summary, creatives template preview).
|
|
4
|
+
// The extra .preview-container outranks TemplatePreview's own `.preview-container #mobilepush-preview` rule.
|
|
5
|
+
.mobile-push-preview-v2 .preview-container #mobilepush-preview.shell-v2 {
|
|
6
|
+
@include mobile-push-phone-shell;
|
|
7
|
+
}
|
|
@@ -7,17 +7,27 @@
|
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
|
|
9
9
|
import React from 'react';
|
|
10
|
-
import { CapTab, CapIcon } from '@capillarytech/cap-ui-library';
|
|
10
|
+
import { CapTab, CapIcon, CapRow } from '@capillarytech/cap-ui-library';
|
|
11
11
|
import { get, isEmpty} from 'lodash';
|
|
12
12
|
import TemplatePreview from '../TemplatePreview';
|
|
13
13
|
import '../PreviewSideBar/_previewsidebar.scss';
|
|
14
|
+
import './_mobilePushPreviewV2.scss';
|
|
14
15
|
import { MOBILE_PUSH } from '../../v2Containers/CreativesContainer/constants';
|
|
15
16
|
import { INAPP } from '../../v2Containers/App/constants';
|
|
16
17
|
import { ANDROID, IOS } from '../../v2Containers/InApp/constants';
|
|
17
18
|
import { getCtaObject } from '../../v2Containers/InApp/utils';
|
|
18
|
-
import {
|
|
19
|
+
import {
|
|
20
|
+
CAROUSEL, IMAGE, MANUAL_CAROUSEL, VIDEO,
|
|
21
|
+
} from '../../v2Containers/MobilePushNew/constants';
|
|
19
22
|
import { DEVICE_TYPES, IPHONE } from './constants';
|
|
20
23
|
|
|
24
|
+
// Saved media item -> carousel card in the shape TemplatePreview renders
|
|
25
|
+
const toCarouselCard = ({ type, url } = {}) => ({
|
|
26
|
+
mediaType: type,
|
|
27
|
+
imageUrl: type === IMAGE ? url : '',
|
|
28
|
+
videoSrc: type === VIDEO ? url : '',
|
|
29
|
+
});
|
|
30
|
+
|
|
21
31
|
class MobilePushPreviewV2 extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
22
32
|
constructor(props) {
|
|
23
33
|
super(props);
|
|
@@ -92,16 +102,18 @@ class MobilePushPreviewV2 extends React.Component { // eslint-disable-line react
|
|
|
92
102
|
const data = device?.toLowerCase() === "android" ? androidContent : iosContent;
|
|
93
103
|
const {
|
|
94
104
|
title = '', message = '', type = '', expandableDetails: {
|
|
95
|
-
ctas = [], image = '', media = [], carouselData = [],
|
|
105
|
+
ctas = [], image = '', media = [], carouselData = [], style = '',
|
|
96
106
|
} = {},
|
|
97
107
|
} = data || {};
|
|
108
|
+
const isCarousel = style === MANUAL_CAROUSEL || type === CAROUSEL;
|
|
98
109
|
|
|
99
110
|
// Handle video/GIF content from expandableDetails.media array (new format)
|
|
100
111
|
let bodyVideo = {};
|
|
101
112
|
let bodyGif = '';
|
|
102
113
|
let bodyImage = image;
|
|
103
114
|
|
|
104
|
-
|
|
115
|
+
// A carousel's media are its cards, not a body video
|
|
116
|
+
if (!isCarousel && media?.length > 0) {
|
|
105
117
|
const mediaItem = media[0];
|
|
106
118
|
const { type: mediaType, url } = mediaItem;
|
|
107
119
|
if (mediaType === VIDEO) {
|
|
@@ -127,7 +139,8 @@ class MobilePushPreviewV2 extends React.Component { // eslint-disable-line react
|
|
|
127
139
|
bodyGif,
|
|
128
140
|
actions: [],
|
|
129
141
|
appName: templateData?.appName,
|
|
130
|
-
carouselData,
|
|
142
|
+
// Campaigns drops carouselData on save, so a saved carousel has its cards only in media
|
|
143
|
+
carouselData: (carouselData?.length || !isCarousel) ? carouselData : (media || []).map(toCarouselCard),
|
|
131
144
|
};
|
|
132
145
|
|
|
133
146
|
// Map CTAs consistently for both Android and iOS
|
|
@@ -190,8 +203,8 @@ class MobilePushPreviewV2 extends React.Component { // eslint-disable-line react
|
|
|
190
203
|
}
|
|
191
204
|
const hasBothAndroidAndIos = hasAndroid && hasIos;
|
|
192
205
|
return (
|
|
193
|
-
<
|
|
194
|
-
<
|
|
206
|
+
<CapRow useLegacy className="mobile-push-preview-v2">
|
|
207
|
+
<CapRow useLegacy className="devices">
|
|
195
208
|
{!isEmpty(templateData)
|
|
196
209
|
&& ( hasBothAndroidAndIos ? (
|
|
197
210
|
<CapTab
|
|
@@ -214,8 +227,8 @@ class MobilePushPreviewV2 extends React.Component { // eslint-disable-line react
|
|
|
214
227
|
(hasAndroid || hasIos) && this.getPreview(hasAndroid ? 'android' : 'ios')
|
|
215
228
|
))
|
|
216
229
|
}
|
|
217
|
-
</
|
|
218
|
-
</
|
|
230
|
+
</CapRow>
|
|
231
|
+
</CapRow>
|
|
219
232
|
);
|
|
220
233
|
}
|
|
221
234
|
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import MobilePushPreviewV2 from '../index';
|
|
2
|
+
|
|
3
|
+
const { setContent } = MobilePushPreviewV2.prototype;
|
|
4
|
+
|
|
5
|
+
// Campaign message as stored: carouselData is dropped on save, cards stay in media
|
|
6
|
+
const savedMessage = {
|
|
7
|
+
androidContent: {
|
|
8
|
+
title: 'Android video',
|
|
9
|
+
message: 'Video body',
|
|
10
|
+
expandableDetails: {
|
|
11
|
+
style: 'VIDEO',
|
|
12
|
+
media: [{ url: 'body.mp4', type: 'VIDEO', text: '' }],
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
iosContent: {
|
|
16
|
+
title: 'IOS carousel',
|
|
17
|
+
message: 'Carousel body',
|
|
18
|
+
expandableDetails: {
|
|
19
|
+
style: 'MANUAL_CAROUSEL',
|
|
20
|
+
media: [
|
|
21
|
+
{ url: 'card1.jpg', type: 'IMAGE', text: '' },
|
|
22
|
+
{ url: 'card2.mp4', type: 'VIDEO', text: '' },
|
|
23
|
+
],
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
describe('MobilePushPreviewV2 setContent', () => {
|
|
29
|
+
it('builds carousel cards from media for a saved carousel', () => {
|
|
30
|
+
const content = setContent(savedMessage, 'iphone', 'MOBILEPUSH');
|
|
31
|
+
expect(content.carouselData).toEqual([
|
|
32
|
+
{ mediaType: 'IMAGE', imageUrl: 'card1.jpg', videoSrc: '' },
|
|
33
|
+
{ mediaType: 'VIDEO', imageUrl: '', videoSrc: 'card2.mp4' },
|
|
34
|
+
]);
|
|
35
|
+
// A video card is not shown as the body video
|
|
36
|
+
expect(content.bodyVideo).toEqual({});
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('keeps carouselData when the template still has it', () => {
|
|
40
|
+
const cards = [{ mediaType: 'IMAGE', imageUrl: 'kept.jpg' }];
|
|
41
|
+
const templateData = {
|
|
42
|
+
iosContent: {
|
|
43
|
+
title: 'T',
|
|
44
|
+
expandableDetails: { style: 'MANUAL_CAROUSEL', carouselData: cards, media: [{ url: 'x.jpg', type: 'IMAGE' }] },
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
expect(setContent(templateData, 'iphone', 'MOBILEPUSH').carouselData).toEqual(cards);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('shows the first media item as the body video when not a carousel', () => {
|
|
51
|
+
const content = setContent(savedMessage, 'android', 'MOBILEPUSH');
|
|
52
|
+
expect(content.bodyVideo).toEqual({ videoSrc: 'body.mp4', videoPreview: 'body.mp4' });
|
|
53
|
+
expect(content.carouselData).toEqual([]);
|
|
54
|
+
});
|
|
55
|
+
});
|