@capillarytech/creatives-library 9.2.1 → 9.2.2-alpha.sprint-cap-214249.44
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
|
@@ -20,7 +20,9 @@ import {
|
|
|
20
20
|
isUrl,
|
|
21
21
|
isValidText,
|
|
22
22
|
} from "../../v2Containers/Line/Container/Wrapper/utils";
|
|
23
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
isDeepLink, getDeepLinkParamValue, setDeepLinkParamValue, hasAllDeepLinkParams,
|
|
25
|
+
} from "../../v2Containers/MobilePushNew/utils";
|
|
24
26
|
import {
|
|
25
27
|
BTN_MAX_LENGTH,
|
|
26
28
|
DEEP_LINK,
|
|
@@ -52,8 +54,9 @@ export const CapMpushCTA = (props) => {
|
|
|
52
54
|
const [urlError, setUrlError] = useState(false);
|
|
53
55
|
const [buttonError, setButtonError] = useState(false);
|
|
54
56
|
const [deepLinkKeysError, setDeepLinkKeysError] = useState(false);
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
+
// Read from ctaData so a copy from the other tab shows here too
|
|
58
|
+
const ctaDeepLinkValue = ctaData[0]?.url || "";
|
|
59
|
+
const ctaDeepLinkKeysValue = ctaData[0]?.deepLinkKeys || [];
|
|
57
60
|
const [localUrlValues, setLocalUrlValues] = useState({});
|
|
58
61
|
// Track which URLs have been manually cleared to prevent restoration
|
|
59
62
|
const clearedUrlsRef = useRef(new Set());
|
|
@@ -133,21 +136,16 @@ export const CapMpushCTA = (props) => {
|
|
|
133
136
|
// Mark this URL as manually cleared to prevent restoration
|
|
134
137
|
clearedUrlsRef.current.add(index);
|
|
135
138
|
|
|
136
|
-
// Clear the URL field when switching between link types
|
|
137
|
-
updateHelper('url', '', index);
|
|
138
|
-
|
|
139
139
|
// Immediately clear the local URL state for this button
|
|
140
140
|
setLocalUrlValues(prev => ({
|
|
141
141
|
...prev,
|
|
142
142
|
[index]: ''
|
|
143
143
|
}));
|
|
144
144
|
|
|
145
|
-
// Also clear the local deep link state
|
|
146
|
-
setCtaDeepLinkValue('');
|
|
147
145
|
// Clear any URL errors
|
|
148
146
|
setUrlError(false);
|
|
149
|
-
//
|
|
150
|
-
|
|
147
|
+
// One update: clear the URL and set the new type
|
|
148
|
+
updateHandler({ ...cloneDeep(ctaData[index]), url: '', urlType: value }, index);
|
|
151
149
|
};
|
|
152
150
|
|
|
153
151
|
const onUrlChange = ({ target }) => {
|
|
@@ -175,7 +173,6 @@ export const CapMpushCTA = (props) => {
|
|
|
175
173
|
};
|
|
176
174
|
|
|
177
175
|
const onDeepLinkSelect = (value, index) => {
|
|
178
|
-
setCtaDeepLinkValue(value);
|
|
179
176
|
let errorMessage = false;
|
|
180
177
|
if (!isDeepLink(value)) {
|
|
181
178
|
errorMessage = formatMessage(messages.ctaWebsiteUrlErrorMessage);
|
|
@@ -184,13 +181,10 @@ export const CapMpushCTA = (props) => {
|
|
|
184
181
|
updateHelper('url', value, index);
|
|
185
182
|
};
|
|
186
183
|
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
const
|
|
190
|
-
|
|
191
|
-
const keysArray = value?.split(',')?.map((key) => key?.trim())?.filter((key) => key?.length > 0);
|
|
192
|
-
setCtaDeepLinkKeysValue(keysArray);
|
|
193
|
-
setDeepLinkKeysError(keysArray.length === 0);
|
|
184
|
+
// Stores "key=value" for the configured key being typed into
|
|
185
|
+
const onDeepLinkKeysChange = (index, key, value) => {
|
|
186
|
+
const keysArray = setDeepLinkParamValue(deepLinkKeysArray, deepLinkKeysFromSelectionArray, key, value);
|
|
187
|
+
setDeepLinkKeysError(!hasAllDeepLinkParams(keysArray, deepLinkKeysFromSelectionArray));
|
|
194
188
|
updateHelper('deepLinkKeys', keysArray, index);
|
|
195
189
|
};
|
|
196
190
|
|
|
@@ -200,7 +194,7 @@ export const CapMpushCTA = (props) => {
|
|
|
200
194
|
return true;
|
|
201
195
|
} else if (urlType === DEEP_LINK && (ctaDeepLinkValue === "" || urlError)) {
|
|
202
196
|
return true;
|
|
203
|
-
} else if (urlType === DEEP_LINK && ctaDeepLinkValue && deepLinkKeysFromSelectionArray?.length > 0 && (!
|
|
197
|
+
} else if (urlType === DEEP_LINK && ctaDeepLinkValue && deepLinkKeysFromSelectionArray?.length > 0 && (!hasAllDeepLinkParams(deepLinkKeysArray, deepLinkKeysFromSelectionArray) || deepLinkKeysError)) {
|
|
204
198
|
return true;
|
|
205
199
|
} else if (urlType === EXTERNAL_URL && (url === "" || urlError)) {
|
|
206
200
|
return true;
|
|
@@ -235,9 +229,10 @@ export const CapMpushCTA = (props) => {
|
|
|
235
229
|
type="flex"
|
|
236
230
|
>
|
|
237
231
|
<CapColumn>
|
|
238
|
-
<CapRow className="mpush-cta-row">
|
|
232
|
+
<CapRow type="flex" align="middle" className="mpush-cta-row">
|
|
239
233
|
<CapColumn>
|
|
240
|
-
|
|
234
|
+
{/* Not "launch": its SVG mask id collides with other launch icons and renders a square */}
|
|
235
|
+
<CapIcon size="s" type="open-in-new" />
|
|
241
236
|
</CapColumn>
|
|
242
237
|
<CapColumn className="btn-text">
|
|
243
238
|
<CapLabel type="label2" className="mpush-saved-cta-button-text">
|
|
@@ -251,13 +246,11 @@ export const CapMpushCTA = (props) => {
|
|
|
251
246
|
<CapTag className="cta-type-label">{formatMessage(messages.urlDeepLink)}</CapTag>
|
|
252
247
|
: <CapTag className="cta-type-label">{formatMessage(messages.urlExternalLink)}</CapTag>}
|
|
253
248
|
</CapColumn>
|
|
254
|
-
<CapColumn>
|
|
255
|
-
{urlType === DEEP_LINK ? selectedDeepLink?.label :
|
|
256
|
-
</CapColumn>
|
|
257
|
-
<CapColumn>
|
|
249
|
+
<CapColumn className="mpush-saved-cta-link" title={cta?.url}>
|
|
250
|
+
{urlType === DEEP_LINK ? selectedDeepLink?.label : cta?.url}
|
|
258
251
|
</CapColumn>
|
|
259
252
|
<CapColumn>
|
|
260
|
-
<CapRow className="cta-action-grp">
|
|
253
|
+
<CapRow type="flex" align="middle" className="cta-action-grp">
|
|
261
254
|
<CapColumn
|
|
262
255
|
className="mpush-saved-cta-edit-icon"
|
|
263
256
|
onClick={() => isSavedCta(index, false)}
|
|
@@ -317,9 +310,35 @@ export const CapMpushCTA = (props) => {
|
|
|
317
310
|
onChange={(value) => onDeepLinkSelect(value, index)}
|
|
318
311
|
value={ctaDeepLinkValue}
|
|
319
312
|
/>
|
|
313
|
+
{/* Keys under the Deep link dropdown, as in Notification tap */}
|
|
314
|
+
{ctaDeepLinkValue && deepLinkKeysFromSelectionArray.length > 0 && (
|
|
315
|
+
<CapRow useLegacy className="mpush-cta-deep-link-keys">
|
|
316
|
+
<CapHeading type="h4">
|
|
317
|
+
{formatMessage(messages.deepLinkKeys)}
|
|
318
|
+
</CapHeading>
|
|
319
|
+
{deepLinkKeysFromSelectionArray.map((key, keyIndex) => (
|
|
320
|
+
<CapRow useLegacy key={key} className="mpush-deep-link-key">
|
|
321
|
+
<CapLabel type="label2" className="cta-deep-link-keys-value">
|
|
322
|
+
{key}
|
|
323
|
+
</CapLabel>
|
|
324
|
+
<CapInput
|
|
325
|
+
id={keyIndex === 0 ? "mpush-deep-link-keys" : `mpush-deep-link-keys-${keyIndex}`}
|
|
326
|
+
className="mpush-deep-link-keys"
|
|
327
|
+
onChange={({ target: { value } }) => onDeepLinkKeysChange(index, key, value)}
|
|
328
|
+
placeholder={formatMessage(messages.deepLinkKeysPlaceholder, { key })}
|
|
329
|
+
value={getDeepLinkParamValue(deepLinkKeysArray, key)}
|
|
330
|
+
data-index={index}
|
|
331
|
+
errorMessage={deepLinkKeysError && keyIndex === deepLinkKeysFromSelectionArray.length - 1 ? formatMessage(messages.deepLinkKeysRequired) : ""}
|
|
332
|
+
/>
|
|
333
|
+
</CapRow>
|
|
334
|
+
))}
|
|
335
|
+
</CapRow>
|
|
336
|
+
)}
|
|
320
337
|
</CapRow>
|
|
321
338
|
)}
|
|
322
339
|
{urlType === EXTERNAL_URL && (
|
|
340
|
+
// Wrapper lets the stylesheet size the label row to match "Type of link"
|
|
341
|
+
<CapRow className="mpush-cta-external-link-field">
|
|
323
342
|
<CapTagListWithInput
|
|
324
343
|
inputId="mpush-cta-external-link"
|
|
325
344
|
inputValue={localUrlValues[index] || ''}
|
|
@@ -329,8 +348,7 @@ export const CapMpushCTA = (props) => {
|
|
|
329
348
|
inputMaxLength={URL_MAX_LENGTH}
|
|
330
349
|
inputErrorMessage={urlError}
|
|
331
350
|
headingText={formatMessage(messages.urlExternalLink)}
|
|
332
|
-
headingStyle={{
|
|
333
|
-
containerStyle={{ width: '70%', marginTop: '-0.625rem' }}
|
|
351
|
+
headingStyle={{ whiteSpace: 'nowrap' }}
|
|
334
352
|
moduleFilterEnabled={location?.query?.type !== "embedded"}
|
|
335
353
|
onTagSelect={onButtonTagSelect}
|
|
336
354
|
onContextChange={handleOnTagsContextChange}
|
|
@@ -340,37 +358,9 @@ export const CapMpushCTA = (props) => {
|
|
|
340
358
|
selectedOfferDetails={selectedOfferDetails}
|
|
341
359
|
inputProps={{ 'data-index': index }}
|
|
342
360
|
/>
|
|
361
|
+
</CapRow>
|
|
343
362
|
)}
|
|
344
363
|
</CapColumn>
|
|
345
|
-
{urlType === DEEP_LINK && ctaDeepLinkValue && deepLinkKeysFromSelectionArray.length > 0 && (
|
|
346
|
-
<CapColumn>
|
|
347
|
-
<CapRow useLegacy style={{ marginTop: '10px' }}>
|
|
348
|
-
<CapHeading type="h4">
|
|
349
|
-
{formatMessage(messages.deepLinkKeys)}
|
|
350
|
-
</CapHeading>
|
|
351
|
-
<CapLabel type="label2" className="cta-deep-link-keys-value">
|
|
352
|
-
{(() => {
|
|
353
|
-
if (deepLinkKeysFromSelectionArray.length > 0) {
|
|
354
|
-
return deepLinkKeysFromSelectionArray.join(', ');
|
|
355
|
-
}
|
|
356
|
-
if (deepLinkKeysArray.length > 0) {
|
|
357
|
-
return deepLinkKeysArray.join(', ');
|
|
358
|
-
}
|
|
359
|
-
})()}
|
|
360
|
-
</CapLabel>
|
|
361
|
-
<CapInput
|
|
362
|
-
id="mpush-deep-link-keys"
|
|
363
|
-
className="mpush-deep-link-keys"
|
|
364
|
-
onChange={onDeepLinkKeysChange}
|
|
365
|
-
placeholder={formatMessage(messages.deepLinkKeysPlaceholder, { key: deepLinkKeysFromSelectionArray.join(', ') })}
|
|
366
|
-
value={Array.isArray(ctaDeepLinkKeysValue) ? ctaDeepLinkKeysValue.join(', ') : (ctaDeepLinkKeysValue || '')}
|
|
367
|
-
size="large"
|
|
368
|
-
data-index={index}
|
|
369
|
-
errorMessage={deepLinkKeysError ? formatMessage(messages.deepLinkKeysRequired) : ""}
|
|
370
|
-
/>
|
|
371
|
-
</CapRow>
|
|
372
|
-
</CapColumn>
|
|
373
|
-
)}
|
|
374
364
|
<CapColumn>
|
|
375
365
|
<CapRow useLegacy className="mpush-cta-save-delete-btn">
|
|
376
366
|
<CapTooltip
|
|
@@ -9,6 +9,8 @@
|
|
|
9
9
|
display: flex;
|
|
10
10
|
flex-direction: row;
|
|
11
11
|
justify-content: space-between;
|
|
12
|
+
// MobilePushNew's .mpush-cta-buttons padding is for the Buttons section, not this link row
|
|
13
|
+
padding-bottom: 0;
|
|
12
14
|
|
|
13
15
|
.mpush-render-btn-length {
|
|
14
16
|
margin-top: $CAP_SPACE_12;
|
|
@@ -31,6 +33,18 @@
|
|
|
31
33
|
margin-top: $CAP_SPACE_12;
|
|
32
34
|
}
|
|
33
35
|
|
|
36
|
+
// External link column: its label row (heading + "Add label") gets the height of the
|
|
37
|
+
// "Type of link" label plus its 8px gap, so the input lines up with the dropdown
|
|
38
|
+
.mpush-cta-external-link-field {
|
|
39
|
+
width: 70%;
|
|
40
|
+
|
|
41
|
+
> .ant-col > .ant-row:first-child {
|
|
42
|
+
height: 1.449rem; // CapHeading h4 line height
|
|
43
|
+
margin-bottom: $CAP_SPACE_08;
|
|
44
|
+
justify-content: space-between;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
34
48
|
.mpush-cta-save-delete-btn {
|
|
35
49
|
margin-top: $CAP_SPACE_16;
|
|
36
50
|
|
|
@@ -42,8 +56,18 @@
|
|
|
42
56
|
}
|
|
43
57
|
}
|
|
44
58
|
|
|
45
|
-
|
|
46
|
-
|
|
59
|
+
// Same spacing as the Notification tap keys: label + input per key
|
|
60
|
+
.mpush-cta-deep-link-keys {
|
|
61
|
+
margin-top: $CAP_SPACE_16;
|
|
62
|
+
|
|
63
|
+
.mpush-deep-link-key {
|
|
64
|
+
margin-top: $CAP_SPACE_12;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.cta-deep-link-keys-value {
|
|
68
|
+
display: block;
|
|
69
|
+
margin: 0 0 $CAP_SPACE_08;
|
|
70
|
+
}
|
|
47
71
|
}
|
|
48
72
|
|
|
49
73
|
}
|
|
@@ -55,13 +79,27 @@
|
|
|
55
79
|
padding: $CAP_SPACE_08 $CAP_SPACE_12;
|
|
56
80
|
border-radius: $CAP_SPACE_04;
|
|
57
81
|
height: $CAP_SPACE_40;
|
|
82
|
+
gap: $CAP_SPACE_12;
|
|
58
83
|
|
|
59
84
|
.mpush-saved-cta-button-text {
|
|
60
85
|
font-weight: 500;
|
|
61
86
|
}
|
|
62
87
|
|
|
63
|
-
|
|
64
|
-
|
|
88
|
+
// Inline icons sit on the text baseline (a few px high); as blocks they centre with the text
|
|
89
|
+
.cap-icon-v2 {
|
|
90
|
+
display: flex;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// URL fills the space up to the icons and ends in "..." when too long.
|
|
94
|
+
// contain: inline-size stops a long URL from widening the whole form.
|
|
95
|
+
.mpush-saved-cta-link {
|
|
96
|
+
flex: 1;
|
|
97
|
+
min-width: 0;
|
|
98
|
+
contain: inline-size;
|
|
99
|
+
white-space: nowrap;
|
|
100
|
+
overflow: hidden;
|
|
101
|
+
text-overflow: ellipsis;
|
|
102
|
+
color: $CAP_G04;
|
|
65
103
|
}
|
|
66
104
|
}
|
|
67
105
|
.cta-label {
|
|
@@ -89,5 +127,5 @@
|
|
|
89
127
|
padding-left: 1rem;
|
|
90
128
|
}
|
|
91
129
|
.btn-text {
|
|
92
|
-
margin-left: $
|
|
130
|
+
margin-left: $CAP_SPACE_08;
|
|
93
131
|
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shallow } from 'enzyme';
|
|
3
|
+
import CapIcon from '@capillarytech/cap-ui-library/CapIcon';
|
|
4
|
+
import { CapMpushCTA } from '../index';
|
|
5
|
+
import CapTagListWithInput from '../../CapTagListWithInput';
|
|
6
|
+
import { DEEP_LINK, EXTERNAL_URL } from '../constants';
|
|
7
|
+
import { PRIMARY } from '../../../v2Containers/MobilePushNew/constants';
|
|
8
|
+
|
|
9
|
+
jest.mock('../../../v2Containers/TagList', () => () => null);
|
|
10
|
+
jest.mock('../../CapTagListWithInput', () => () => null);
|
|
11
|
+
|
|
12
|
+
const intl = { formatMessage: (msg) => msg?.defaultMessage || '' };
|
|
13
|
+
|
|
14
|
+
const renderCta = (cta, extraProps = {}) => shallow(
|
|
15
|
+
<CapMpushCTA
|
|
16
|
+
intl={intl}
|
|
17
|
+
ctaData={[{ index: 0, text: 'Shop', ...cta }]}
|
|
18
|
+
buttonType={PRIMARY}
|
|
19
|
+
updateHandler={jest.fn()}
|
|
20
|
+
deleteHandler={jest.fn()}
|
|
21
|
+
deepLink={[{ value: 'app://home', label: 'Home' }]}
|
|
22
|
+
location={{ query: {} }}
|
|
23
|
+
{...extraProps}
|
|
24
|
+
/>,
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
describe('CapMpushCTA', () => {
|
|
28
|
+
describe('saved button card', () => {
|
|
29
|
+
it('uses the mask-free "open-in-new" icon, not "launch"', () => {
|
|
30
|
+
const wrapper = renderCta({ urlType: EXTERNAL_URL, url: 'https://google.com', isSaved: true });
|
|
31
|
+
const iconTypes = wrapper.find(CapIcon).map((icon) => icon.prop('type'));
|
|
32
|
+
|
|
33
|
+
expect(iconTypes).toContain('open-in-new');
|
|
34
|
+
expect(iconTypes).not.toContain('launch');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('shows the external URL in the link column with the URL as tooltip', () => {
|
|
38
|
+
const wrapper = renderCta({ urlType: EXTERNAL_URL, url: 'https://google.com', isSaved: true });
|
|
39
|
+
const link = wrapper.find('.mpush-saved-cta-link');
|
|
40
|
+
|
|
41
|
+
expect(link.prop('children')).toBe('https://google.com');
|
|
42
|
+
expect(link.prop('title')).toBe('https://google.com');
|
|
43
|
+
expect(wrapper.find('.cta-type-label').prop('children')).toBe('External link');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('shows the selected deep link label in the link column', () => {
|
|
47
|
+
const wrapper = renderCta({ urlType: DEEP_LINK, url: 'app://home', isSaved: true });
|
|
48
|
+
|
|
49
|
+
expect(wrapper.find('.mpush-saved-cta-link').prop('children')).toBe('Home');
|
|
50
|
+
expect(wrapper.find('.cta-type-label').prop('children')).toBe('Deep link');
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('lays out the card rows horizontally with vertically centred items', () => {
|
|
54
|
+
const wrapper = renderCta({ urlType: EXTERNAL_URL, url: 'https://google.com', isSaved: true });
|
|
55
|
+
|
|
56
|
+
expect(wrapper.find('.mpush-cta-row').props()).toEqual(expect.objectContaining({ type: 'flex', align: 'middle' }));
|
|
57
|
+
expect(wrapper.find('.cta-action-grp').props()).toEqual(expect.objectContaining({ type: 'flex', align: 'middle' }));
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('reopens the button for editing and deletes it from the card icons', () => {
|
|
61
|
+
const updateHandler = jest.fn();
|
|
62
|
+
const deleteHandler = jest.fn();
|
|
63
|
+
const wrapper = renderCta(
|
|
64
|
+
{ urlType: EXTERNAL_URL, url: 'https://google.com', isSaved: true },
|
|
65
|
+
{ updateHandler, deleteHandler },
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
wrapper.find('.mpush-saved-cta-edit-icon').simulate('click');
|
|
69
|
+
expect(updateHandler).toHaveBeenCalledWith(expect.objectContaining({ isSaved: false }), 0);
|
|
70
|
+
|
|
71
|
+
wrapper.find('.cta-del-icon').simulate('click');
|
|
72
|
+
expect(deleteHandler).toHaveBeenCalledWith(0);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('keeps the "External link" heading on one line in the edit form', () => {
|
|
77
|
+
const wrapper = renderCta({ urlType: EXTERNAL_URL, url: '', isSaved: false });
|
|
78
|
+
|
|
79
|
+
expect(wrapper.find(CapTagListWithInput).prop('headingStyle')).toEqual(
|
|
80
|
+
expect.objectContaining({ whiteSpace: 'nowrap' }),
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('wraps the External link field so its label row lines up with "Type of link"', () => {
|
|
85
|
+
const wrapper = renderCta({ urlType: EXTERNAL_URL, url: '', isSaved: false });
|
|
86
|
+
|
|
87
|
+
expect(wrapper.find('.mpush-cta-external-link-field').find(CapTagListWithInput).exists()).toBe(true);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe('deep link keys', () => {
|
|
91
|
+
const offerLink = [{ value: 'app://offer', label: 'Offer', keys: ['offerId', 'src'] }];
|
|
92
|
+
|
|
93
|
+
it('shows one input per configured key with its saved value', () => {
|
|
94
|
+
const wrapper = renderCta(
|
|
95
|
+
{ urlType: DEEP_LINK, url: 'app://offer', isSaved: false, deepLinkKeys: ['offerId=5'] },
|
|
96
|
+
{ deepLink: offerLink },
|
|
97
|
+
);
|
|
98
|
+
|
|
99
|
+
expect(wrapper.find({ id: 'mpush-deep-link-keys' }).prop('value')).toBe('5');
|
|
100
|
+
expect(wrapper.find({ id: 'mpush-deep-link-keys-1' }).prop('value')).toBe('');
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it('stores the configured key with the typed value', () => {
|
|
104
|
+
const updateHandler = jest.fn();
|
|
105
|
+
const wrapper = renderCta(
|
|
106
|
+
{ urlType: DEEP_LINK, url: 'app://offer', isSaved: false, deepLinkKeys: ['offerId=5'] },
|
|
107
|
+
{ deepLink: offerLink, updateHandler },
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
wrapper.find({ id: 'mpush-deep-link-keys-1' }).simulate('change', { target: { value: 'push' } });
|
|
111
|
+
expect(updateHandler).toHaveBeenCalledWith(
|
|
112
|
+
expect.objectContaining({ deepLinkKeys: ['offerId=5', 'src=push'] }),
|
|
113
|
+
0,
|
|
114
|
+
);
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
it('shows a deep link copied in from the other tab after the form is open', () => {
|
|
118
|
+
const wrapper = renderCta(
|
|
119
|
+
{ urlType: DEEP_LINK, url: '', isSaved: false },
|
|
120
|
+
{ deepLink: offerLink },
|
|
121
|
+
);
|
|
122
|
+
expect(wrapper.find({ id: 'mpush-deep-link-type' }).prop('value')).toBe('');
|
|
123
|
+
|
|
124
|
+
wrapper.setProps({
|
|
125
|
+
ctaData: [{
|
|
126
|
+
index: 0, text: 'Shop', urlType: DEEP_LINK, url: 'app://offer', isSaved: false, deepLinkKeys: ['offerId=5'],
|
|
127
|
+
}],
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
expect(wrapper.find({ id: 'mpush-deep-link-type' }).prop('value')).toBe('app://offer');
|
|
131
|
+
expect(wrapper.find({ id: 'mpush-deep-link-keys' }).prop('value')).toBe('5');
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
it('clears the url and sets the new type in one update on type change', () => {
|
|
136
|
+
const updateHandler = jest.fn();
|
|
137
|
+
const wrapper = renderCta(
|
|
138
|
+
{ urlType: DEEP_LINK, url: 'app://home', isSaved: false },
|
|
139
|
+
{ updateHandler },
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
wrapper.find({ id: 'mpush-cta-type' }).simulate('change', EXTERNAL_URL);
|
|
143
|
+
|
|
144
|
+
expect(updateHandler).toHaveBeenCalledTimes(1);
|
|
145
|
+
expect(updateHandler).toHaveBeenCalledWith(
|
|
146
|
+
expect.objectContaining({ url: '', urlType: EXTERNAL_URL }),
|
|
147
|
+
0,
|
|
148
|
+
);
|
|
149
|
+
});
|
|
150
|
+
});
|
|
@@ -23,6 +23,7 @@ const iPhonePushMessagePhone = require('../../TemplatePreview/assets/images/iOS_
|
|
|
23
23
|
|
|
24
24
|
// Import video play icon for carousel
|
|
25
25
|
const videoPlay = require('../../../assets/videoPlay.svg');
|
|
26
|
+
const videoEmptyPreview = require('../../TemplatePreview/assets/images/empty_video_preview.svg');
|
|
26
27
|
|
|
27
28
|
const MobilePushPreviewContent = ({
|
|
28
29
|
content,
|
|
@@ -86,14 +87,15 @@ const MobilePushPreviewContent = ({
|
|
|
86
87
|
|
|
87
88
|
// Render MobilePush carousel (based on TemplatePreview renderMobilePushCarousel)
|
|
88
89
|
const renderMobilePushCarousel = (contentData) => {
|
|
90
|
+
// Every card shows, even before its media is uploaded (an empty card keeps its place)
|
|
89
91
|
if (!contentData?.carouselData || contentData?.carouselData?.length === 0) {
|
|
90
92
|
return null;
|
|
91
93
|
}
|
|
92
94
|
|
|
93
95
|
return (
|
|
94
96
|
<CapRow type="flex" vertical noWrap className="msg-container-carousel mobile-push-carousel-container">
|
|
95
|
-
<CapRow
|
|
96
|
-
{contentData
|
|
97
|
+
<CapRow type="flex" noWrap className="scroll-container mobile-push-scroll-container">
|
|
98
|
+
{contentData.carouselData.map((item, idx) => (
|
|
97
99
|
<CapColumn
|
|
98
100
|
key={`carousel-card-${idx}`}
|
|
99
101
|
className="mobile-push-carousel-card message-pop align-left message-pop-carousel"
|
|
@@ -105,10 +107,11 @@ const MobilePushPreviewContent = ({
|
|
|
105
107
|
className="carousel-image"
|
|
106
108
|
/>
|
|
107
109
|
)}
|
|
108
|
-
{item?.mediaType?.toLowerCase() === MEDIA_TYPE_VIDEO.toLowerCase() && item?.videoPreviewImg && (
|
|
110
|
+
{item?.mediaType?.toLowerCase() === MEDIA_TYPE_VIDEO.toLowerCase() && (item?.videoPreviewImg || item?.videoSrc) && (
|
|
109
111
|
<CapRow className="video-preview">
|
|
112
|
+
{/* No thumbnail from the upload: same placeholder as WhatsApp/RCS */}
|
|
110
113
|
<CapImage
|
|
111
|
-
src={item?.videoPreviewImg ||
|
|
114
|
+
src={item?.videoPreviewImg || videoEmptyPreview}
|
|
112
115
|
alt="carousel-video-preview"
|
|
113
116
|
className="carousel-video-preview"
|
|
114
117
|
/>
|
|
@@ -217,15 +220,15 @@ const MobilePushPreviewContent = ({
|
|
|
217
220
|
{/* Action Buttons */}
|
|
218
221
|
{(deviceContent?.actions || []).filter((action) => action?.label || action?.actionText).length > 0
|
|
219
222
|
&& deviceContent?.carouselData?.length === 0 && (
|
|
220
|
-
<CapRow
|
|
221
|
-
{
|
|
223
|
+
<CapRow type="flex" noWrap className="actions">
|
|
224
|
+
{deviceContent.actions.map((action, index) => (
|
|
222
225
|
(action?.label || action?.actionText) && (
|
|
223
226
|
<span
|
|
224
227
|
className="action"
|
|
225
|
-
key={`action-${
|
|
228
|
+
key={`action-${index}`}
|
|
226
229
|
title={action?.url || action?.actionLink || ''}
|
|
227
230
|
>
|
|
228
|
-
{action?.label
|
|
231
|
+
{action?.label || action?.actionText}
|
|
229
232
|
</span>
|
|
230
233
|
)
|
|
231
234
|
))}
|
|
@@ -2307,9 +2307,21 @@
|
|
|
2307
2307
|
flex-direction: row;
|
|
2308
2308
|
gap: $CAP_SPACE_08;
|
|
2309
2309
|
|
|
2310
|
+
// One button: centred. Two: equal halves, each centred, split by a divider.
|
|
2310
2311
|
.action {
|
|
2311
2312
|
font-size: $FONT_SIZE_S;
|
|
2312
|
-
|
|
2313
|
+
font-weight: 600;
|
|
2314
|
+
color: $FONT_COLOR_01;
|
|
2315
|
+
flex: 1 1 0;
|
|
2316
|
+
min-width: 0;
|
|
2317
|
+
text-align: center;
|
|
2318
|
+
white-space: nowrap;
|
|
2319
|
+
overflow: hidden;
|
|
2320
|
+
text-overflow: ellipsis;
|
|
2321
|
+
|
|
2322
|
+
& + .action {
|
|
2323
|
+
border-left: 1px solid $CAP_G07;
|
|
2324
|
+
}
|
|
2313
2325
|
}
|
|
2314
2326
|
}
|
|
2315
2327
|
}
|
|
@@ -212,6 +212,8 @@ export const CTA_TYPE_EXTERNAL_URL = 'EXTERNAL_URL';
|
|
|
212
212
|
// ============================================
|
|
213
213
|
export const STYLE_TYPE_BIG_PICTURE = 'BIG_PICTURE';
|
|
214
214
|
export const STYLE_TYPE_BIG_TEXT = 'BIG_TEXT';
|
|
215
|
+
export const STYLE_TYPE_VIDEO = 'VIDEO';
|
|
216
|
+
export const STYLE_TYPE_MANUAL_CAROUSEL = 'MANUAL_CAROUSEL';
|
|
215
217
|
|
|
216
218
|
// ============================================
|
|
217
219
|
// DEVICE TYPE CONSTANTS (for API payloads)
|
|
@@ -75,6 +75,8 @@ import {
|
|
|
75
75
|
CTA_TYPE_EXTERNAL_URL,
|
|
76
76
|
STYLE_TYPE_BIG_PICTURE,
|
|
77
77
|
STYLE_TYPE_BIG_TEXT,
|
|
78
|
+
STYLE_TYPE_VIDEO,
|
|
79
|
+
STYLE_TYPE_MANUAL_CAROUSEL,
|
|
78
80
|
DEVICE_TYPE_ANDROID,
|
|
79
81
|
DEVICE_TYPE_IOS,
|
|
80
82
|
BUTTON_TYPE_NONE,
|
|
@@ -1884,6 +1886,10 @@ const CommonTestAndPreview = (props) => {
|
|
|
1884
1886
|
'message-title': formDataObj.androidContent.header || '',
|
|
1885
1887
|
'message-editor': formDataObj.androidContent.bodyText || '',
|
|
1886
1888
|
'image': formDataObj.androidContent.bodyImage || '',
|
|
1889
|
+
// bodyVideo also carries GIFs; send only real videos
|
|
1890
|
+
'video': formDataObj.androidContent.bodyGif ? '' : (formDataObj.androidContent.bodyVideo?.videoSrc || ''),
|
|
1891
|
+
// Saved cards, already in the shape Save sent
|
|
1892
|
+
carouselData: formDataObj.androidContent.carouselData || [],
|
|
1887
1893
|
// Extract CTA info from actions if available
|
|
1888
1894
|
...(formDataObj.androidContent.actions?.[0] && {
|
|
1889
1895
|
'cta-deeplink-label': formDataObj.androidContent.actions[0].label,
|
|
@@ -1902,6 +1908,8 @@ const CommonTestAndPreview = (props) => {
|
|
|
1902
1908
|
'message-title2': formDataObj.iosContent.header || '',
|
|
1903
1909
|
'message-editor2': formDataObj.iosContent.bodyText || '',
|
|
1904
1910
|
'image': formDataObj.iosContent.bodyImage || '',
|
|
1911
|
+
'video': formDataObj.iosContent.bodyGif ? '' : (formDataObj.iosContent.bodyVideo?.videoSrc || ''),
|
|
1912
|
+
carouselData: formDataObj.iosContent.carouselData || [],
|
|
1905
1913
|
// Extract CTA info from actions if available
|
|
1906
1914
|
...(formDataObj.iosContent.actions?.[0] && {
|
|
1907
1915
|
'cta-deeplink2-label': formDataObj.iosContent.actions[0].label,
|
|
@@ -2007,11 +2015,35 @@ const CommonTestAndPreview = (props) => {
|
|
|
2007
2015
|
};
|
|
2008
2016
|
};
|
|
2009
2017
|
|
|
2018
|
+
const hasCarousel = (data) => Array.isArray(data.carouselData) && data.carouselData.length > 0;
|
|
2019
|
+
// Carousel, then video, then image; BIG_TEXT when none
|
|
2020
|
+
const getMpushStyle = (data) => {
|
|
2021
|
+
if (hasCarousel(data)) return STYLE_TYPE_MANUAL_CAROUSEL;
|
|
2022
|
+
if (data.video) return STYLE_TYPE_VIDEO;
|
|
2023
|
+
return data.image ? STYLE_TYPE_BIG_PICTURE : STYLE_TYPE_BIG_TEXT;
|
|
2024
|
+
};
|
|
2025
|
+
const getMpushType = (data) => {
|
|
2026
|
+
if (hasCarousel(data)) return MEDIA_TYPE_CAROUSEL;
|
|
2027
|
+
if (data.video) return MEDIA_TYPE_VIDEO;
|
|
2028
|
+
return data.image ? MEDIA_TYPE_IMAGE : MEDIA_TYPE_TEXT;
|
|
2029
|
+
};
|
|
2030
|
+
// Raw URL, as Save sends it (the CDN helper is an image transform)
|
|
2031
|
+
const toMpushVideoMedia = (url) => [{ url, text: '', type: MEDIA_TYPE_VIDEO }];
|
|
2032
|
+
// Only the spec's media list, as campaigns saves it (carouselData is the editor's own format)
|
|
2033
|
+
const addMpushCarousel = (expandableDetails, data) => {
|
|
2034
|
+
Object.assign(expandableDetails, {
|
|
2035
|
+
media: data.carouselData.map((card) => ({
|
|
2036
|
+
url: card?.mediaType?.toUpperCase() === MEDIA_TYPE_VIDEO ? card.videoSrc : card.imageUrl,
|
|
2037
|
+
type: card?.mediaType?.toUpperCase(),
|
|
2038
|
+
text: '',
|
|
2039
|
+
})),
|
|
2040
|
+
});
|
|
2041
|
+
};
|
|
2042
|
+
|
|
2010
2043
|
// Helper function to build expandableDetails for Android
|
|
2011
2044
|
const buildAndroidExpandableDetails = (data) => {
|
|
2012
|
-
// Default style is BIG_TEXT, change to BIG_PICTURE if image exists
|
|
2013
2045
|
const imageLink = data.image;
|
|
2014
|
-
const style =
|
|
2046
|
+
const style = getMpushStyle(data);
|
|
2015
2047
|
|
|
2016
2048
|
const expandableDetails = {
|
|
2017
2049
|
style,
|
|
@@ -2020,7 +2052,11 @@ const CommonTestAndPreview = (props) => {
|
|
|
2020
2052
|
};
|
|
2021
2053
|
|
|
2022
2054
|
// Add image if present (transform to CDN URL if needed)
|
|
2023
|
-
if (
|
|
2055
|
+
if (hasCarousel(data)) {
|
|
2056
|
+
addMpushCarousel(expandableDetails, data);
|
|
2057
|
+
} else if (data.video) {
|
|
2058
|
+
expandableDetails.media = toMpushVideoMedia(data.video);
|
|
2059
|
+
} else if (imageLink) {
|
|
2024
2060
|
expandableDetails.image = getCdnUrl({ url: imageLink, channelName: CHANNEL_NAME_MOBILE_PUSH });
|
|
2025
2061
|
}
|
|
2026
2062
|
|
|
@@ -2099,9 +2135,8 @@ const CommonTestAndPreview = (props) => {
|
|
|
2099
2135
|
|
|
2100
2136
|
// Helper function to build expandableDetails for iOS
|
|
2101
2137
|
const buildIosExpandableDetails = (data) => {
|
|
2102
|
-
// Default style is BIG_TEXT, change to BIG_PICTURE if image exists
|
|
2103
2138
|
const imageLinkIos = data.image;
|
|
2104
|
-
const style =
|
|
2139
|
+
const style = getMpushStyle(data);
|
|
2105
2140
|
|
|
2106
2141
|
const expandableDetails = {
|
|
2107
2142
|
style,
|
|
@@ -2110,7 +2145,11 @@ const CommonTestAndPreview = (props) => {
|
|
|
2110
2145
|
};
|
|
2111
2146
|
|
|
2112
2147
|
// Add image if present (transform to CDN URL if needed)
|
|
2113
|
-
if (
|
|
2148
|
+
if (hasCarousel(data)) {
|
|
2149
|
+
addMpushCarousel(expandableDetails, data);
|
|
2150
|
+
} else if (data.video) {
|
|
2151
|
+
expandableDetails.media = toMpushVideoMedia(data.video);
|
|
2152
|
+
} else if (imageLinkIos) {
|
|
2114
2153
|
expandableDetails.image = getCdnUrl({ url: imageLinkIos, channelName: CHANNEL_NAME_MOBILE_PUSH });
|
|
2115
2154
|
}
|
|
2116
2155
|
|
|
@@ -2183,12 +2222,13 @@ const CommonTestAndPreview = (props) => {
|
|
|
2183
2222
|
// Build Android content
|
|
2184
2223
|
const androidTitle = resolveTagsInText(androidData['message-title'] || '', customValuesObj);
|
|
2185
2224
|
const androidMessage = resolveTagsInText(androidData['message-editor'] || '', customValuesObj);
|
|
2186
|
-
|
|
2225
|
+
// No tap-link form keys when campaigns passes its content: use its saved cta as is
|
|
2226
|
+
const getSavedMpushCta = (savedContent) => savedContent?.cta || null;
|
|
2227
|
+
const androidCta = buildAndroidCta(androidData) || getSavedMpushCta(formDataObj?.androidContent);
|
|
2187
2228
|
const androidExpandableDetails = buildAndroidExpandableDetails(androidData);
|
|
2188
2229
|
const androidCustomProperties = buildCustomProperties(androidData);
|
|
2189
2230
|
|
|
2190
|
-
|
|
2191
|
-
const androidType = androidData.image ? MEDIA_TYPE_IMAGE : MEDIA_TYPE_TEXT;
|
|
2231
|
+
const androidType = getMpushType(androidData);
|
|
2192
2232
|
|
|
2193
2233
|
const androidContent = {
|
|
2194
2234
|
type: androidType,
|
|
@@ -2203,12 +2243,11 @@ const CommonTestAndPreview = (props) => {
|
|
|
2203
2243
|
// Build iOS content
|
|
2204
2244
|
const iosTitle = resolveTagsInText(iosData['message-title2'] || '', customValuesObj);
|
|
2205
2245
|
const iosMessage = resolveTagsInText(iosData['message-editor2'] || '', customValuesObj);
|
|
2206
|
-
const iosCta = buildIosCta(iosData);
|
|
2246
|
+
const iosCta = buildIosCta(iosData) || getSavedMpushCta(formDataObj?.iosContent);
|
|
2207
2247
|
const iosExpandableDetails = buildIosExpandableDetails(iosData);
|
|
2208
2248
|
const iosCustomProperties = buildCustomProperties(iosData);
|
|
2209
2249
|
|
|
2210
|
-
|
|
2211
|
-
const iosType = iosData.image ? MEDIA_TYPE_IMAGE : MEDIA_TYPE_TEXT;
|
|
2250
|
+
const iosType = getMpushType(iosData);
|
|
2212
2251
|
|
|
2213
2252
|
const iosContent = {
|
|
2214
2253
|
type: iosType,
|