@capillarytech/creatives-library 9.2.2 → 9.2.3
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 +51 -12
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +83 -5
- package/v2Components/CommonTestAndPreview/tests/index.test.js +100 -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/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/Tests/extractContentForPreview.test.js +45 -0
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/extractContentForPreview.js +12 -2
- package/v2Containers/CreativesContainer/SlideBoxContent.js +4 -6
- package/v2Containers/CreativesContainer/index.js +2 -1
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +43 -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/Templates/_templates.scss +10 -2
- package/v2Containers/Templates/index.js +86 -81
- package/v2Containers/Templates/tests/index.test.js +81 -0
|
@@ -1,4 +1,79 @@
|
|
|
1
1
|
import { isUrl } from "../Line/Container/Wrapper/utils";
|
|
2
|
+
import { VIDEO } from "./constants";
|
|
3
|
+
|
|
4
|
+
// Deep link option for a saved value; falls back to matching without query params
|
|
5
|
+
export const findSelectedDeepLink = (links, value) => {
|
|
6
|
+
if (!links || !value) return undefined;
|
|
7
|
+
const exactMatch = links.find((link) => link?.value === value);
|
|
8
|
+
if (exactMatch || !value.includes('?')) return exactMatch;
|
|
9
|
+
const baseDeepLinkValue = value.split('?')[0];
|
|
10
|
+
return links.find((link) => link?.value === baseDeepLinkValue);
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// Deep link params are kept as "key=value" entries, e.g. "testing_purpose=androidDeeplink"
|
|
14
|
+
const toEntryArray = (entries) => {
|
|
15
|
+
if (Array.isArray(entries)) return entries;
|
|
16
|
+
return entries ? [entries] : [];
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
// Splits at the first "=". Old entries saved as just the key mean key=key
|
|
20
|
+
export const splitDeepLinkParam = (entry) => {
|
|
21
|
+
const text = String(entry ?? '');
|
|
22
|
+
const index = text.indexOf('=');
|
|
23
|
+
return index === -1 ? [text, text] : [text.slice(0, index), text.slice(index + 1)];
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const getDeepLinkParamValue = (entries, key) => {
|
|
27
|
+
const match = toEntryArray(entries).find((entry) => splitDeepLinkParam(entry)[0] === key);
|
|
28
|
+
return match === undefined ? '' : splitDeepLinkParam(match)[1];
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
// New entries after typing `value` for `key`, in configured-key order; empty values are dropped
|
|
32
|
+
export const setDeepLinkParamValue = (entries, configuredKeys, key, value) => toEntryArray(configuredKeys)
|
|
33
|
+
.map((configuredKey) => [configuredKey, configuredKey === key ? value : getDeepLinkParamValue(entries, configuredKey)])
|
|
34
|
+
.filter(([, paramValue]) => paramValue !== '' && paramValue !== undefined && paramValue !== null)
|
|
35
|
+
.map(([paramKey, paramValue]) => `${paramKey}=${paramValue}`);
|
|
36
|
+
|
|
37
|
+
export const hasAllDeepLinkParams = (entries, configuredKeys) => toEntryArray(configuredKeys)
|
|
38
|
+
.every((key) => getDeepLinkParamValue(entries, key).trim() !== '');
|
|
39
|
+
|
|
40
|
+
// Every "key=value" in the URL's query, raw (not decoded) so tags like {{x}} round-trip
|
|
41
|
+
export const extractDeepLinkParams = (url) => {
|
|
42
|
+
if (typeof url !== 'string' || !url.includes('?')) return [];
|
|
43
|
+
return url.slice(url.indexOf('?') + 1).split('&').filter((param) => param.indexOf('=') > 0);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
// Adds the entries to the URL; a key already in the URL is replaced, not repeated
|
|
47
|
+
export const appendDeepLinkParams = (url, entries) => {
|
|
48
|
+
if (!url) return url;
|
|
49
|
+
const pairs = toEntryArray(entries)
|
|
50
|
+
.filter((entry) => typeof entry === 'string' && entry.length > 0)
|
|
51
|
+
.map(splitDeepLinkParam)
|
|
52
|
+
.filter(([key]) => key.length > 0);
|
|
53
|
+
if (pairs.length === 0) return url;
|
|
54
|
+
const keys = new Set(pairs.map(([key]) => key));
|
|
55
|
+
const queryIndex = url.indexOf('?');
|
|
56
|
+
const base = queryIndex === -1 ? url : url.slice(0, queryIndex);
|
|
57
|
+
const kept = queryIndex === -1 ? [] : url.slice(queryIndex + 1).split('&')
|
|
58
|
+
.filter((param) => param && !keys.has(splitDeepLinkParam(param)[0]));
|
|
59
|
+
const params = [...kept, ...pairs.map(([key, value]) => `${key}=${value}`)];
|
|
60
|
+
return `${base}?${params.join('&')}`;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export const CAROUSEL_CARD_ISSUE = {
|
|
64
|
+
MEDIA: 'media',
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* What a carousel card still needs before it can be saved. The notification tap is for the whole
|
|
69
|
+
* notification, so a card only needs its media.
|
|
70
|
+
* @param {Object} card - Editor carousel card
|
|
71
|
+
* @returns {string|null} - A CAROUSEL_CARD_ISSUE value, or null when the card is complete
|
|
72
|
+
*/
|
|
73
|
+
export const getCarouselCardIssue = (card) => {
|
|
74
|
+
const isMediaMissing = card?.mediaType === VIDEO.toLowerCase() ? !card?.videoSrc : !card?.imageUrl;
|
|
75
|
+
return isMediaMissing ? CAROUSEL_CARD_ISSUE.MEDIA : null;
|
|
76
|
+
};
|
|
2
77
|
|
|
3
78
|
/**
|
|
4
79
|
* Validate deep link format - supports custom schemes, HTTP/HTTPS, and relative paths
|
|
@@ -119,3 +194,11 @@ export const computeIsContentEmpty = ({
|
|
|
119
194
|
const isIosMissing = isPlatformFieldsMissing(isIosSupported, iosContent);
|
|
120
195
|
return (!isAndroidSupported || isAndroidMissing) && (!isIosSupported || isIosMissing);
|
|
121
196
|
};
|
|
197
|
+
|
|
198
|
+
// Android and iOS title + message joined, for the create GA event
|
|
199
|
+
export const getContent = (obj) => {
|
|
200
|
+
const base = obj?.versions?.base || {};
|
|
201
|
+
const android = base.ANDROID || {};
|
|
202
|
+
const ios = base.IOS || {};
|
|
203
|
+
return `${android.title || ''} ${android.message || ''} ${ios.title || ''} ${ios.message || ''}`;
|
|
204
|
+
};
|
|
@@ -495,15 +495,23 @@
|
|
|
495
495
|
padding: $CAP_SPACE_08;
|
|
496
496
|
text-align: center;
|
|
497
497
|
display: flex;
|
|
498
|
-
flex-direction: column;
|
|
499
498
|
align-items: center;
|
|
500
499
|
justify-content: center;
|
|
501
500
|
gap: $CAP_SPACE_08;
|
|
501
|
+
// Same as the editor previews: one button centred, two as halves split by a divider
|
|
502
502
|
.action{
|
|
503
|
+
flex: 1 1 0;
|
|
504
|
+
min-width: 0;
|
|
505
|
+
white-space: nowrap;
|
|
506
|
+
overflow: hidden;
|
|
507
|
+
text-overflow: ellipsis;
|
|
503
508
|
font-size: $FONT_SIZE_S;
|
|
504
509
|
font-weight: 600;
|
|
505
|
-
color:
|
|
510
|
+
color: $FONT_COLOR_01;
|
|
506
511
|
height: 1.25rem;
|
|
512
|
+
& + .action {
|
|
513
|
+
border-left: 1px solid $CAP_G07;
|
|
514
|
+
}
|
|
507
515
|
}
|
|
508
516
|
}
|
|
509
517
|
}
|
|
@@ -164,7 +164,7 @@ import { makeSelectRcs } from '../Rcs/selectors';
|
|
|
164
164
|
import { getRcsStatusType } from '../Rcs/utils';
|
|
165
165
|
import { makeSelectWebPush } from '../WebPush/selectors';
|
|
166
166
|
import { v2MobilePushSagas } from '../MobilePushNew/sagas';
|
|
167
|
-
import { AUTO_CAROUSEL, BIG_PICTURE, FILMSTRIP_CAROUSEL, MANUAL_CAROUSEL } from '../MobilePushNew/constants';
|
|
167
|
+
import { AUTO_CAROUSEL, BIG_PICTURE, FILMSTRIP_CAROUSEL, MANUAL_CAROUSEL, VIDEO as MPUSH_VIDEO } from '../MobilePushNew/constants';
|
|
168
168
|
import CapPageSpinner from '../../v2Components/CapPageSpinner';
|
|
169
169
|
import webPushSagas from '../WebPush/sagas';
|
|
170
170
|
import { DLT_LEGACY_VAR_REGEX } from '../SmsTrai/Edit/dltVarTypes';
|
|
@@ -1426,14 +1426,21 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1426
1426
|
|
|
1427
1427
|
const expandableDetailsAndroid = androidContent.expandableDetails || {};
|
|
1428
1428
|
const expandableDetailsIos = iosContent.expandableDetails || {};
|
|
1429
|
+
// Saved media[0] is { url, type, videoPreviewUrl }; the preview reads { videoSrc, videoPreview }
|
|
1430
|
+
const toPreviewVideo = (media) => {
|
|
1431
|
+
const { type, url, videoPreviewUrl } = media?.[0] || {};
|
|
1432
|
+
return type === MPUSH_VIDEO && url ? { videoSrc: url, videoPreview: videoPreviewUrl || '' } : {};
|
|
1433
|
+
};
|
|
1429
1434
|
// Extract Android content
|
|
1430
1435
|
const androidPreview = {
|
|
1431
1436
|
header: androidContent.title || '',
|
|
1432
1437
|
bodyText: androidContent.message || '',
|
|
1433
1438
|
bodyImage: expandableDetailsAndroid.image || '',
|
|
1434
|
-
bodyVideo: expandableDetailsAndroid.media
|
|
1439
|
+
bodyVideo: toPreviewVideo(expandableDetailsAndroid.media),
|
|
1435
1440
|
bodyGif: '',
|
|
1436
1441
|
actions: expandableDetailsAndroid.ctas || [],
|
|
1442
|
+
// Notification tap, read by the test send
|
|
1443
|
+
cta: androidContent.cta,
|
|
1437
1444
|
carouselData: expandableDetailsAndroid.carouselData || [],
|
|
1438
1445
|
};
|
|
1439
1446
|
|
|
@@ -1442,9 +1449,10 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1442
1449
|
header: iosContent.title || '',
|
|
1443
1450
|
bodyText: iosContent.message || '',
|
|
1444
1451
|
bodyImage: expandableDetailsIos.image || '',
|
|
1445
|
-
bodyVideo: expandableDetailsIos.media
|
|
1452
|
+
bodyVideo: toPreviewVideo(expandableDetailsIos.media),
|
|
1446
1453
|
bodyGif: '',
|
|
1447
1454
|
actions: expandableDetailsIos.ctas || [],
|
|
1455
|
+
cta: iosContent.cta,
|
|
1448
1456
|
carouselData: expandableDetailsIos.carouselData || [],
|
|
1449
1457
|
};
|
|
1450
1458
|
|
|
@@ -2405,94 +2413,91 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2405
2413
|
}
|
|
2406
2414
|
break;
|
|
2407
2415
|
}
|
|
2408
|
-
case MOBILE_PUSH:
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
2421
|
-
|
|
2422
|
-
|
|
2423
|
-
|
|
2424
|
-
<div className="app-header-left">
|
|
2425
|
-
<span className="app-icon">{""}</span>
|
|
2426
|
-
<CapLabel type="label4">{title}</CapLabel>
|
|
2427
|
-
</div>
|
|
2416
|
+
case MOBILE_PUSH: {
|
|
2417
|
+
const mpushData = get(template, 'versions.base', template);
|
|
2418
|
+
const androidData = get(mpushData, 'ANDROID') || get(mpushData, 'androidContent');
|
|
2419
|
+
const iosData = get(mpushData, 'IOS') || get(mpushData, 'iosContent');
|
|
2420
|
+
let mpushListingData = androidData;
|
|
2421
|
+
if (isEmpty(androidData) || !androidData?.title) {
|
|
2422
|
+
mpushListingData = iosData;
|
|
2423
|
+
};
|
|
2424
|
+
const { title, message, expandableDetails: { style = '', image, carouselData = [], ctas = [], media = [] } = {} } = mpushListingData || {};
|
|
2425
|
+
const {url = ''} = media?.[0] || {};
|
|
2426
|
+
templateData.content = (
|
|
2427
|
+
<div className='mobilepush-container'>
|
|
2428
|
+
<div className="app-header">
|
|
2429
|
+
<div className="app-header-left">
|
|
2430
|
+
<span className="app-icon">{""}</span>
|
|
2431
|
+
<CapLabel type="label4">{title}</CapLabel>
|
|
2428
2432
|
</div>
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2433
|
+
</div>
|
|
2434
|
+
<CapLabel className="mobilepush-message" type="label1">{message}</CapLabel>
|
|
2435
|
+
{style === BIG_PICTURE && (
|
|
2436
|
+
<CapImage src={image} className="mobilepush-image mobilepush-image-padding" />
|
|
2437
|
+
)}
|
|
2438
|
+
{style === VIDEO && (
|
|
2439
|
+
<div className="video-preview">
|
|
2440
|
+
<video aria-label="Template video preview" controls={false} tabIndex="0">
|
|
2441
|
+
<source src={url} type="video/mp4" />
|
|
2442
|
+
</video>
|
|
2443
|
+
<div className="icon-position">
|
|
2444
|
+
<CapImage className="video-icon" src={videoPlay} />
|
|
2441
2445
|
</div>
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2446
|
+
</div>
|
|
2447
|
+
)}
|
|
2448
|
+
{[MANUAL_CAROUSEL, AUTO_CAROUSEL, FILMSTRIP_CAROUSEL].includes(style) && (
|
|
2449
|
+
<div className="scroll-container">
|
|
2450
|
+
{carouselData?.map((data, index) => {
|
|
2451
|
+
return (
|
|
2452
|
+
<div
|
|
2453
|
+
key={`carousel-${index + 1}`}
|
|
2454
|
+
className="whatsapp-carousel-container"
|
|
2455
|
+
role="group"
|
|
2456
|
+
>
|
|
2457
|
+
<div className="whatsapp-carousel-card">
|
|
2458
|
+
{data?.mediaType === IMAGE.toLowerCase() && (
|
|
2459
|
+
<CapImage
|
|
2460
|
+
src={data?.imageUrl ? data?.imageUrl : data?.url ? data?.url : whatsappImageEmptyPreview}
|
|
2461
|
+
className="whatsapp-image"
|
|
2462
|
+
/>
|
|
2463
|
+
)}
|
|
2464
|
+
{data?.mediaType === VIDEO.toLowerCase() && (
|
|
2465
|
+
<div className="video-preview">
|
|
2454
2466
|
<CapImage
|
|
2455
|
-
src={data?.
|
|
2467
|
+
src={data?.videoPreviewImg ? data?.videoPreviewImg : data?.url ? data?.url : whatsappVideoEmptyPreview}
|
|
2456
2468
|
className="whatsapp-image"
|
|
2457
2469
|
/>
|
|
2458
|
-
|
|
2459
|
-
{data?.mediaType === VIDEO.toLowerCase() && (
|
|
2460
|
-
<div className="video-preview">
|
|
2470
|
+
<div className="icon-position">
|
|
2461
2471
|
<CapImage
|
|
2462
|
-
|
|
2463
|
-
|
|
2472
|
+
className="video-icon"
|
|
2473
|
+
src={videoPlay}
|
|
2464
2474
|
/>
|
|
2465
|
-
<div className="icon-position">
|
|
2466
|
-
<CapImage
|
|
2467
|
-
className="video-icon"
|
|
2468
|
-
src={videoPlay}
|
|
2469
|
-
/>
|
|
2470
|
-
</div>
|
|
2471
2475
|
</div>
|
|
2472
|
-
|
|
2473
|
-
|
|
2474
|
-
|
|
2475
|
-
|
|
2476
|
-
|
|
2477
|
-
|
|
2478
|
-
)}
|
|
2479
|
-
{ctas.length > 0 && (
|
|
2480
|
-
<div className="actions">
|
|
2481
|
-
{ctas.map((cta) => (
|
|
2482
|
-
<span
|
|
2483
|
-
className="action"
|
|
2484
|
-
key={`action-${cta?.actionText}`}
|
|
2485
|
-
>
|
|
2486
|
-
{cta?.actionText && cta?.actionText.toUpperCase()}
|
|
2487
|
-
</span>
|
|
2488
|
-
))}
|
|
2489
|
-
</div>
|
|
2490
|
-
)}
|
|
2476
|
+
</div>
|
|
2477
|
+
)}
|
|
2478
|
+
</div>
|
|
2479
|
+
</div>
|
|
2480
|
+
)
|
|
2481
|
+
})}
|
|
2491
2482
|
</div>
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2483
|
+
)}
|
|
2484
|
+
{ctas.length > 0 && (
|
|
2485
|
+
<CapRow type="flex" align="middle" justify="center" className="actions">
|
|
2486
|
+
{ctas.map((cta, index) => (
|
|
2487
|
+
<CapLabel.CapLabelInline
|
|
2488
|
+
className="action"
|
|
2489
|
+
key={`action-${index}`}
|
|
2490
|
+
>
|
|
2491
|
+
{cta?.actionText}
|
|
2492
|
+
</CapLabel.CapLabelInline>
|
|
2493
|
+
))}
|
|
2494
|
+
</CapRow>
|
|
2495
|
+
)}
|
|
2496
|
+
</div>
|
|
2497
|
+
);
|
|
2498
|
+
templateData.isNewMobilePush = true;
|
|
2495
2499
|
break;
|
|
2500
|
+
}
|
|
2496
2501
|
case INAPP: {
|
|
2497
2502
|
// Pass the full template object to CapCustomCard so getInAppContent can extract the data
|
|
2498
2503
|
// Similar to how MOBILE_PUSH passes the full template when new feature is enabled
|
|
@@ -498,4 +498,85 @@ describe('Test Templates container', () => {
|
|
|
498
498
|
expect(renderedComponent.instance().getCreativesParams()).not.toHaveProperty('openTestAndPreview');
|
|
499
499
|
});
|
|
500
500
|
});
|
|
501
|
+
|
|
502
|
+
describe('Mobile push grid tile buttons', () => {
|
|
503
|
+
it('renders button labels as typed with index keys, so duplicate labels do not clash', () => {
|
|
504
|
+
RenderFunctionFor('whatsapp', true);
|
|
505
|
+
|
|
506
|
+
const cardDataList = renderedComponent.instance().getTemplateDataForGrid({
|
|
507
|
+
templates: [{
|
|
508
|
+
_id: 'mpush_1',
|
|
509
|
+
name: 'Push Template',
|
|
510
|
+
versions: {
|
|
511
|
+
base: {
|
|
512
|
+
ANDROID: {
|
|
513
|
+
title: 'Title',
|
|
514
|
+
message: 'Body',
|
|
515
|
+
expandableDetails: { ctas: [{ actionText: 'Shop' }, { actionText: 'Shop' }] },
|
|
516
|
+
},
|
|
517
|
+
},
|
|
518
|
+
},
|
|
519
|
+
}],
|
|
520
|
+
handlers: { handlePreviewClick: jest.fn(), handleEditClick: jest.fn() },
|
|
521
|
+
filterContent: null,
|
|
522
|
+
channel: 'mobilepush',
|
|
523
|
+
isLoading: false,
|
|
524
|
+
isInitialLoading: false,
|
|
525
|
+
loadingTip: '',
|
|
526
|
+
previewTemplateId: null,
|
|
527
|
+
});
|
|
528
|
+
|
|
529
|
+
const buttons = findByClassName(cardDataList, 'mobilepush-container').props.children
|
|
530
|
+
.find((child) => child?.props?.className === 'actions').props.children;
|
|
531
|
+
expect(buttons.map((button) => button.key)).toEqual(['action-0', 'action-1']);
|
|
532
|
+
expect(buttons.map((button) => button.props.children)).toEqual(['Shop', 'Shop']);
|
|
533
|
+
});
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
describe('Mobile push Test & Preview content from the list', () => {
|
|
537
|
+
it('maps each saved video to the { videoSrc, videoPreview } shape the preview reads', () => {
|
|
538
|
+
RenderFunctionFor('whatsapp', true);
|
|
539
|
+
|
|
540
|
+
const result = renderedComponent.instance().extractTemplateContentForPreview({
|
|
541
|
+
versions: {
|
|
542
|
+
base: {
|
|
543
|
+
ANDROID: {
|
|
544
|
+
title: 'A',
|
|
545
|
+
expandableDetails: { media: [{ url: 'https://a.mp4', type: 'VIDEO', videoPreviewUrl: 'https://a.jpg' }] },
|
|
546
|
+
},
|
|
547
|
+
IOS: {
|
|
548
|
+
title: 'I',
|
|
549
|
+
expandableDetails: { media: [{ url: 'https://i.mp4', type: 'VIDEO' }] },
|
|
550
|
+
},
|
|
551
|
+
},
|
|
552
|
+
},
|
|
553
|
+
}, 'MOBILEPUSH');
|
|
554
|
+
|
|
555
|
+
expect(result.androidContent.bodyVideo).toEqual({ videoSrc: 'https://a.mp4', videoPreview: 'https://a.jpg' });
|
|
556
|
+
expect(result.iosContent.bodyVideo).toEqual({ videoSrc: 'https://i.mp4', videoPreview: '' });
|
|
557
|
+
});
|
|
558
|
+
|
|
559
|
+
it('gives no video for a text template', () => {
|
|
560
|
+
RenderFunctionFor('whatsapp', true);
|
|
561
|
+
|
|
562
|
+
const result = renderedComponent.instance().extractTemplateContentForPreview({
|
|
563
|
+
versions: { base: { ANDROID: { title: 'A', expandableDetails: { style: 'BIG_TEXT' } } } },
|
|
564
|
+
}, 'MOBILEPUSH');
|
|
565
|
+
|
|
566
|
+
expect(result.androidContent.bodyVideo).toEqual({});
|
|
567
|
+
});
|
|
568
|
+
|
|
569
|
+
it('passes each saved notification tap (cta) for the test send', () => {
|
|
570
|
+
RenderFunctionFor('whatsapp', true);
|
|
571
|
+
const androidCta = { type: 'DEEP_LINK', actionLink: 'app://home' };
|
|
572
|
+
const iosCta = { type: 'EXTERNAL_URL', actionLink: 'https://x.com' };
|
|
573
|
+
|
|
574
|
+
const result = renderedComponent.instance().extractTemplateContentForPreview({
|
|
575
|
+
versions: { base: { ANDROID: { title: 'A', cta: androidCta }, IOS: { title: 'I', cta: iosCta } } },
|
|
576
|
+
}, 'MOBILEPUSH');
|
|
577
|
+
|
|
578
|
+
expect(result.androidContent.cta).toEqual(androidCta);
|
|
579
|
+
expect(result.iosContent.cta).toEqual(iosCta);
|
|
580
|
+
});
|
|
581
|
+
});
|
|
501
582
|
});
|