@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.
- package/constants/unified.js +0 -1
- package/package.json +1 -1
- package/utils/common.js +0 -6
- package/utils/createMobilePushPayload.js +56 -51
- package/utils/tests/createMobilePushPayload.test.js +162 -10
- 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 +48 -10
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +83 -5
- package/v2Components/CommonTestAndPreview/tests/index.test.js +86 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +12 -2
- package/v2Components/TemplatePreview/index.js +14 -12
- package/v2Components/TemplatePreview/tests/index.test.js +69 -0
- 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 +314 -222
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +161 -130
- 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 +484 -123
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +152 -46
- 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 +503 -273
- package/v2Containers/MobilePushNew/index.scss +215 -4
- package/v2Containers/MobilePushNew/messages.js +106 -6
- package/v2Containers/MobilePushNew/tests/index.test.js +482 -1
- package/v2Containers/MobilePushNew/tests/utils.test.js +122 -0
- package/v2Containers/MobilePushNew/utils.js +107 -0
- package/v2Containers/Templates/_templates.scss +10 -2
- package/v2Containers/Templates/index.js +83 -81
- package/v2Containers/Templates/tests/index.test.js +68 -0
|
@@ -1,4 +1,103 @@
|
|
|
1
1
|
import { isUrl } from "../Line/Container/Wrapper/utils";
|
|
2
|
+
import { EXTERNAL_LINK, 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
|
+
DEEP_LINK: 'deepLink',
|
|
66
|
+
DEEP_LINK_KEYS: 'deepLinkKeys',
|
|
67
|
+
EXTERNAL_LINK: 'externalLink',
|
|
68
|
+
UNSAVED_LINK: 'unsavedLink',
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* What a carousel card still needs before it can be saved. Link issues come first so the
|
|
73
|
+
* card can show them while its media is still being added.
|
|
74
|
+
* @param {Object} card - Editor carousel card
|
|
75
|
+
* @param {Array} deepLinks - Deep link options ({ value, keys })
|
|
76
|
+
* @returns {string|null} - A CAROUSEL_CARD_ISSUE value, or null when the card is complete
|
|
77
|
+
*/
|
|
78
|
+
export const getCarouselCardIssue = (card, deepLinks) => {
|
|
79
|
+
const buttons = card?.buttons || [];
|
|
80
|
+
for (let i = 0; i < buttons.length; i += 1) {
|
|
81
|
+
const button = buttons[i];
|
|
82
|
+
if (button?.actionOnClick) {
|
|
83
|
+
if (button.linkType === EXTERNAL_LINK) {
|
|
84
|
+
if (!button.externalLinkValue?.trim()) return CAROUSEL_CARD_ISSUE.EXTERNAL_LINK;
|
|
85
|
+
} else if (!button.deepLinkValue) {
|
|
86
|
+
return CAROUSEL_CARD_ISSUE.DEEP_LINK;
|
|
87
|
+
} else {
|
|
88
|
+
const keysFromSelection = findSelectedDeepLink(deepLinks, button.deepLinkValue)?.keys;
|
|
89
|
+
const hasKeys = Array.isArray(keysFromSelection) ? keysFromSelection.length > 0 : !!keysFromSelection;
|
|
90
|
+
if (hasKeys && !hasAllDeepLinkParams(button.deepLinkKeys, keysFromSelection)) {
|
|
91
|
+
return CAROUSEL_CARD_ISSUE.DEEP_LINK_KEYS;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
// Filled in but its Save not clicked yet (links loaded from a saved template have no flag)
|
|
95
|
+
if (button.isSaved === false) return CAROUSEL_CARD_ISSUE.UNSAVED_LINK;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
const isMediaMissing = card?.mediaType === VIDEO.toLowerCase() ? !card?.videoSrc : !card?.imageUrl;
|
|
99
|
+
return isMediaMissing ? CAROUSEL_CARD_ISSUE.MEDIA : null;
|
|
100
|
+
};
|
|
2
101
|
|
|
3
102
|
/**
|
|
4
103
|
* Validate deep link format - supports custom schemes, HTTP/HTTPS, and relative paths
|
|
@@ -119,3 +218,11 @@ export const computeIsContentEmpty = ({
|
|
|
119
218
|
const isIosMissing = isPlatformFieldsMissing(isIosSupported, iosContent);
|
|
120
219
|
return (!isAndroidSupported || isAndroidMissing) && (!isIosSupported || isIosMissing);
|
|
121
220
|
};
|
|
221
|
+
|
|
222
|
+
// Android and iOS title + message joined, for the create GA event
|
|
223
|
+
export const getContent = (obj) => {
|
|
224
|
+
const base = obj?.versions?.base || {};
|
|
225
|
+
const android = base.ANDROID || {};
|
|
226
|
+
const ios = base.IOS || {};
|
|
227
|
+
return `${android.title || ''} ${android.message || ''} ${ios.title || ''} ${ios.message || ''}`;
|
|
228
|
+
};
|
|
@@ -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,12 +1426,17 @@ 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 || [],
|
|
1437
1442
|
carouselData: expandableDetailsAndroid.carouselData || [],
|
|
@@ -1442,7 +1447,7 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
1442
1447
|
header: iosContent.title || '',
|
|
1443
1448
|
bodyText: iosContent.message || '',
|
|
1444
1449
|
bodyImage: expandableDetailsIos.image || '',
|
|
1445
|
-
bodyVideo: expandableDetailsIos.media
|
|
1450
|
+
bodyVideo: toPreviewVideo(expandableDetailsIos.media),
|
|
1446
1451
|
bodyGif: '',
|
|
1447
1452
|
actions: expandableDetailsIos.ctas || [],
|
|
1448
1453
|
carouselData: expandableDetailsIos.carouselData || [],
|
|
@@ -2405,94 +2410,91 @@ export class Templates extends React.Component { // eslint-disable-line react/pr
|
|
|
2405
2410
|
}
|
|
2406
2411
|
break;
|
|
2407
2412
|
}
|
|
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>
|
|
2413
|
+
case MOBILE_PUSH: {
|
|
2414
|
+
const mpushData = get(template, 'versions.base', template);
|
|
2415
|
+
const androidData = get(mpushData, 'ANDROID') || get(mpushData, 'androidContent');
|
|
2416
|
+
const iosData = get(mpushData, 'IOS') || get(mpushData, 'iosContent');
|
|
2417
|
+
let mpushListingData = androidData;
|
|
2418
|
+
if (isEmpty(androidData) || !androidData?.title) {
|
|
2419
|
+
mpushListingData = iosData;
|
|
2420
|
+
};
|
|
2421
|
+
const { title, message, expandableDetails: { style = '', image, carouselData = [], ctas = [], media = [] } = {} } = mpushListingData || {};
|
|
2422
|
+
const {url = ''} = media?.[0] || {};
|
|
2423
|
+
templateData.content = (
|
|
2424
|
+
<div className='mobilepush-container'>
|
|
2425
|
+
<div className="app-header">
|
|
2426
|
+
<div className="app-header-left">
|
|
2427
|
+
<span className="app-icon">{""}</span>
|
|
2428
|
+
<CapLabel type="label4">{title}</CapLabel>
|
|
2428
2429
|
</div>
|
|
2429
|
-
|
|
2430
|
-
|
|
2431
|
-
|
|
2432
|
-
|
|
2433
|
-
|
|
2434
|
-
|
|
2435
|
-
|
|
2436
|
-
|
|
2437
|
-
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
|
|
2430
|
+
</div>
|
|
2431
|
+
<CapLabel className="mobilepush-message" type="label1">{message}</CapLabel>
|
|
2432
|
+
{style === BIG_PICTURE && (
|
|
2433
|
+
<CapImage src={image} className="mobilepush-image mobilepush-image-padding" />
|
|
2434
|
+
)}
|
|
2435
|
+
{style === VIDEO && (
|
|
2436
|
+
<div className="video-preview">
|
|
2437
|
+
<video aria-label="Template video preview" controls={false} tabIndex="0">
|
|
2438
|
+
<source src={url} type="video/mp4" />
|
|
2439
|
+
</video>
|
|
2440
|
+
<div className="icon-position">
|
|
2441
|
+
<CapImage className="video-icon" src={videoPlay} />
|
|
2441
2442
|
</div>
|
|
2442
|
-
|
|
2443
|
-
|
|
2444
|
-
|
|
2445
|
-
|
|
2446
|
-
|
|
2447
|
-
|
|
2448
|
-
|
|
2449
|
-
|
|
2450
|
-
|
|
2451
|
-
|
|
2452
|
-
|
|
2453
|
-
|
|
2443
|
+
</div>
|
|
2444
|
+
)}
|
|
2445
|
+
{[MANUAL_CAROUSEL, AUTO_CAROUSEL, FILMSTRIP_CAROUSEL].includes(style) && (
|
|
2446
|
+
<div className="scroll-container">
|
|
2447
|
+
{carouselData?.map((data, index) => {
|
|
2448
|
+
return (
|
|
2449
|
+
<div
|
|
2450
|
+
key={`carousel-${index + 1}`}
|
|
2451
|
+
className="whatsapp-carousel-container"
|
|
2452
|
+
role="group"
|
|
2453
|
+
>
|
|
2454
|
+
<div className="whatsapp-carousel-card">
|
|
2455
|
+
{data?.mediaType === IMAGE.toLowerCase() && (
|
|
2456
|
+
<CapImage
|
|
2457
|
+
src={data?.imageUrl ? data?.imageUrl : data?.url ? data?.url : whatsappImageEmptyPreview}
|
|
2458
|
+
className="whatsapp-image"
|
|
2459
|
+
/>
|
|
2460
|
+
)}
|
|
2461
|
+
{data?.mediaType === VIDEO.toLowerCase() && (
|
|
2462
|
+
<div className="video-preview">
|
|
2454
2463
|
<CapImage
|
|
2455
|
-
src={data?.
|
|
2464
|
+
src={data?.videoPreviewImg ? data?.videoPreviewImg : data?.url ? data?.url : whatsappVideoEmptyPreview}
|
|
2456
2465
|
className="whatsapp-image"
|
|
2457
2466
|
/>
|
|
2458
|
-
|
|
2459
|
-
{data?.mediaType === VIDEO.toLowerCase() && (
|
|
2460
|
-
<div className="video-preview">
|
|
2467
|
+
<div className="icon-position">
|
|
2461
2468
|
<CapImage
|
|
2462
|
-
|
|
2463
|
-
|
|
2469
|
+
className="video-icon"
|
|
2470
|
+
src={videoPlay}
|
|
2464
2471
|
/>
|
|
2465
|
-
<div className="icon-position">
|
|
2466
|
-
<CapImage
|
|
2467
|
-
className="video-icon"
|
|
2468
|
-
src={videoPlay}
|
|
2469
|
-
/>
|
|
2470
|
-
</div>
|
|
2471
2472
|
</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
|
-
)}
|
|
2473
|
+
</div>
|
|
2474
|
+
)}
|
|
2475
|
+
</div>
|
|
2476
|
+
</div>
|
|
2477
|
+
)
|
|
2478
|
+
})}
|
|
2491
2479
|
</div>
|
|
2492
|
-
|
|
2493
|
-
|
|
2494
|
-
|
|
2480
|
+
)}
|
|
2481
|
+
{ctas.length > 0 && (
|
|
2482
|
+
<CapRow type="flex" align="middle" justify="center" className="actions">
|
|
2483
|
+
{ctas.map((cta, index) => (
|
|
2484
|
+
<CapLabel.CapLabelInline
|
|
2485
|
+
className="action"
|
|
2486
|
+
key={`action-${index}`}
|
|
2487
|
+
>
|
|
2488
|
+
{cta?.actionText}
|
|
2489
|
+
</CapLabel.CapLabelInline>
|
|
2490
|
+
))}
|
|
2491
|
+
</CapRow>
|
|
2492
|
+
)}
|
|
2493
|
+
</div>
|
|
2494
|
+
);
|
|
2495
|
+
templateData.isNewMobilePush = true;
|
|
2495
2496
|
break;
|
|
2497
|
+
}
|
|
2496
2498
|
case INAPP: {
|
|
2497
2499
|
// Pass the full template object to CapCustomCard so getInAppContent can extract the data
|
|
2498
2500
|
// Similar to how MOBILE_PUSH passes the full template when new feature is enabled
|
|
@@ -498,4 +498,72 @@ 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
|
+
});
|
|
501
569
|
});
|