@capillarytech/creatives-library 9.1.7 → 9.1.8-alpha.sprint-cap-214249.39
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 -33
- package/utils/tests/createMobilePushPayload.test.js +113 -8
- package/v2Components/CapMpushCTA/index.js +10 -9
- package/v2Components/CapMpushCTA/index.scss +29 -3
- package/v2Components/CapMpushCTA/tests/index.test.js +89 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +20 -12
- 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 +81 -5
- package/v2Components/CommonTestAndPreview/tests/index.test.js +86 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +12 -2
- package/v2Components/TemplatePreview/index.js +24 -16
- package/v2Components/TemplatePreview/tests/index.test.js +68 -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 +297 -216
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +158 -125
- 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 +464 -108
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +106 -35
- package/v2Containers/MobilePushNew/constants.js +5 -0
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +63 -1
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +52 -0
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +40 -1
- package/v2Containers/MobilePushNew/hooks/useUpload.js +29 -39
- package/v2Containers/MobilePushNew/index.js +487 -235
- package/v2Containers/MobilePushNew/index.scss +205 -4
- package/v2Containers/MobilePushNew/messages.js +106 -6
- package/v2Containers/MobilePushNew/tests/index.test.js +469 -1
- package/v2Containers/MobilePushNew/tests/utils.test.js +70 -0
- package/v2Containers/MobilePushNew/utils.js +56 -0
- package/v2Containers/Templates/_templates.scss +10 -2
- package/v2Containers/Templates/index.js +83 -81
- package/v2Containers/Templates/tests/index.test.js +68 -0
package/constants/unified.js
CHANGED
|
@@ -46,7 +46,6 @@ export const HOSPITALITY_BASED_SCOPE = 'HOSPITALITY_BASED_SCOPE';
|
|
|
46
46
|
export const REGISTRATION_CUSTOM_FIELD = 'Registration custom fields';
|
|
47
47
|
export const GIFT_CARDS = 'GIFT_CARDS';
|
|
48
48
|
export const PROMO_ENGINE = 'PROMO_ENGINE';
|
|
49
|
-
export const ENABLE_NEW_MPUSH = 'ENABLE_NEW_MPUSH';
|
|
50
49
|
export const ENABLE_NEW_EDITOR_FLOW_INAPP = 'ENABLE_NEW_EDITOR_FLOW_INAPP';
|
|
51
50
|
// Per-channel flags for the FormBuilder V3 migration. Each routes its channel to
|
|
52
51
|
// the new functional FormBuilder; later channels get their own flags (…_EMAIL).
|
package/package.json
CHANGED
package/utils/common.js
CHANGED
|
@@ -24,7 +24,6 @@ import {
|
|
|
24
24
|
ENABLE_WECHAT,
|
|
25
25
|
ENABLE_WEBPUSH,
|
|
26
26
|
SUPPORT_CK_EDITOR,
|
|
27
|
-
ENABLE_NEW_MPUSH,
|
|
28
27
|
ENABLE_NEW_EDITOR_FLOW_INAPP,
|
|
29
28
|
ENABLE_NEW_FORMBUILDER_SMS,
|
|
30
29
|
ENABLE_NEW_FORMBUILDER_MPUSH,
|
|
@@ -144,11 +143,6 @@ export const isEmailUnsubscribeTagOptional = Auth.hasFeatureAccess.bind(
|
|
|
144
143
|
EMAIL_UNSUBSCRIBE_TAG_MANDATORY,
|
|
145
144
|
);
|
|
146
145
|
|
|
147
|
-
export const hasNewMobilePushFeatureEnabled = Auth.hasFeatureAccess.bind(
|
|
148
|
-
null,
|
|
149
|
-
ENABLE_NEW_MPUSH,
|
|
150
|
-
);
|
|
151
|
-
|
|
152
146
|
export const hasNewEditorFlowInAppEnabled = Auth.hasFeatureAccess.bind(
|
|
153
147
|
null,
|
|
154
148
|
ENABLE_NEW_EDITOR_FLOW_INAPP,
|
|
@@ -27,6 +27,7 @@ import messages from '../v2Containers/MobilePushNew/messages';
|
|
|
27
27
|
* @param {Object} params.accountData - Account data for the payload
|
|
28
28
|
* @param {boolean} params.sameContent - Whether content is shared between platforms
|
|
29
29
|
* @param {Object} params.options - Additional options
|
|
30
|
+
* @param {string} [params.options.skipPlatform] - ANDROID or IOS: leave out a supported platform the user chose not to configure
|
|
30
31
|
* @param {Object} params.intl - Internationalization object for messages
|
|
31
32
|
*/
|
|
32
33
|
const createMobilePushPayload = ({
|
|
@@ -41,8 +42,8 @@ const createMobilePushPayload = ({
|
|
|
41
42
|
intl,
|
|
42
43
|
}) => {
|
|
43
44
|
// Platform support checks must be at the top
|
|
44
|
-
const isAndroidSupported = accountData?.configs?.android === '1';
|
|
45
|
-
const isIosSupported = accountData?.configs?.ios === '1';
|
|
45
|
+
const isAndroidSupported = accountData?.configs?.android === '1' && options?.skipPlatform !== ANDROID;
|
|
46
|
+
const isIosSupported = accountData?.configs?.ios === '1' && options?.skipPlatform !== IOS;
|
|
46
47
|
|
|
47
48
|
const {
|
|
48
49
|
accountId: accountIdFromAccountData, id, licenseCode: licenseCodeFromAccountData, sourceAccountIdentifier, sourceType: sourceTypeFromAccountData, sourceTypeName,
|
|
@@ -121,6 +122,47 @@ const createMobilePushPayload = ({
|
|
|
121
122
|
return payload;
|
|
122
123
|
};
|
|
123
124
|
|
|
125
|
+
/**
|
|
126
|
+
* Carousel cards as Save sends them (also used by the Test & Preview payload)
|
|
127
|
+
* @param {Array} carouselData - Editor carousel cards
|
|
128
|
+
* @returns {Array} Cards with deep link keys appended to button links
|
|
129
|
+
*/
|
|
130
|
+
export function buildCarouselCards(carouselData = []) {
|
|
131
|
+
return (carouselData || []).map((card) => {
|
|
132
|
+
const {
|
|
133
|
+
mediaType,
|
|
134
|
+
imageUrl,
|
|
135
|
+
videoSrc,
|
|
136
|
+
videoPreviewImg,
|
|
137
|
+
buttons,
|
|
138
|
+
} = card || {};
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
mediaType: mediaType || IMAGE.toLowerCase(),
|
|
142
|
+
imageUrl: imageUrl || '',
|
|
143
|
+
videoSrc: videoSrc || '',
|
|
144
|
+
// Thumbnail, so the phone preview can show the video card when editing
|
|
145
|
+
...(videoPreviewImg && { videoPreviewImg }),
|
|
146
|
+
buttons: buttons ? buttons.map((button) => {
|
|
147
|
+
if (!button) return button;
|
|
148
|
+
// isSaved is the editor's own Save state; it doesn't go to the backend
|
|
149
|
+
const { isSaved, ...buttonData } = button;
|
|
150
|
+
const { linkType: buttonLinkType, deepLinkKeys, deepLinkValue: buttonDeepLinkValue } = buttonData;
|
|
151
|
+
if (buttonLinkType === DEEP_LINK && deepLinkKeys && buttonDeepLinkValue) {
|
|
152
|
+
const deepLinkKeysArray = Array.isArray(deepLinkKeys) ? deepLinkKeys : [deepLinkKeys];
|
|
153
|
+
const updatedDeepLinkValue = appendDeepLinkKeysToUrl(buttonDeepLinkValue, deepLinkKeysArray);
|
|
154
|
+
|
|
155
|
+
return {
|
|
156
|
+
...buttonData,
|
|
157
|
+
deepLinkValue: updatedDeepLinkValue,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
return buttonData;
|
|
161
|
+
}) : [],
|
|
162
|
+
};
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
|
|
124
166
|
/**
|
|
125
167
|
* Builds platform-specific content for the payload
|
|
126
168
|
* @param {Object} content - Platform content (Android/iOS)
|
|
@@ -129,7 +171,7 @@ const createMobilePushPayload = ({
|
|
|
129
171
|
* @param {string} platform - Platform (ANDROID/IOS)
|
|
130
172
|
* @returns {Object} Platform-specific content
|
|
131
173
|
*/
|
|
132
|
-
function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview, platform) {
|
|
174
|
+
export function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview, platform) {
|
|
133
175
|
const {
|
|
134
176
|
title = '',
|
|
135
177
|
message = '',
|
|
@@ -184,7 +226,8 @@ function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview, platfo
|
|
|
184
226
|
platformContent.expandableDetails.style = VIDEO;
|
|
185
227
|
platformContent.expandableDetails.message = message;
|
|
186
228
|
platformContent.expandableDetails.media = [{
|
|
187
|
-
|
|
229
|
+
// This platform's own video; mpushVideoSrcAndPreview is shared by both tabs
|
|
230
|
+
url: content?.videoSrc || content?.mediaList?.[0]?.url || '',
|
|
188
231
|
text: content?.mediaList?.[0]?.text || '',
|
|
189
232
|
type: VIDEO,
|
|
190
233
|
}];
|
|
@@ -201,11 +244,11 @@ function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview, platfo
|
|
|
201
244
|
type: type.toLowerCase(),
|
|
202
245
|
}];
|
|
203
246
|
} else {
|
|
204
|
-
//
|
|
247
|
+
// No mediaList: use this platform's own GIF
|
|
205
248
|
platformContent.expandableDetails.style = GIF;
|
|
206
249
|
platformContent.expandableDetails.message = message;
|
|
207
250
|
platformContent.expandableDetails.media = [{
|
|
208
|
-
url:
|
|
251
|
+
url: content?.videoSrc || '',
|
|
209
252
|
text: '',
|
|
210
253
|
type: GIF, // Backend expects GIF type for GIFs
|
|
211
254
|
}];
|
|
@@ -218,33 +261,7 @@ function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview, platfo
|
|
|
218
261
|
|
|
219
262
|
// Handle carouselData
|
|
220
263
|
if (content?.carouselData?.length > 0) {
|
|
221
|
-
platformContent.expandableDetails.carouselData = content.carouselData
|
|
222
|
-
const {
|
|
223
|
-
mediaType,
|
|
224
|
-
imageUrl,
|
|
225
|
-
videoSrc,
|
|
226
|
-
buttons,
|
|
227
|
-
} = card || {};
|
|
228
|
-
|
|
229
|
-
return {
|
|
230
|
-
mediaType: mediaType || IMAGE.toLowerCase(),
|
|
231
|
-
imageUrl: imageUrl || '',
|
|
232
|
-
videoSrc: videoSrc || '',
|
|
233
|
-
buttons: buttons ? buttons.map((button) => {
|
|
234
|
-
const { linkType: buttonLinkType, deepLinkKeys, deepLinkValue: buttonDeepLinkValue } = button || {};
|
|
235
|
-
if (buttonLinkType === DEEP_LINK && deepLinkKeys && buttonDeepLinkValue) {
|
|
236
|
-
const deepLinkKeysArray = Array.isArray(deepLinkKeys) ? deepLinkKeys : [deepLinkKeys];
|
|
237
|
-
const updatedDeepLinkValue = appendDeepLinkKeysToUrl(buttonDeepLinkValue, deepLinkKeysArray);
|
|
238
|
-
|
|
239
|
-
return {
|
|
240
|
-
...button,
|
|
241
|
-
deepLinkValue: updatedDeepLinkValue,
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
return button;
|
|
245
|
-
}) : [],
|
|
246
|
-
};
|
|
247
|
-
});
|
|
264
|
+
platformContent.expandableDetails.carouselData = buildCarouselCards(content.carouselData);
|
|
248
265
|
}
|
|
249
266
|
|
|
250
267
|
// Handle mediaList
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IntlProvider } from 'react-intl';
|
|
2
|
-
import createMobilePushPayload from '../createMobilePushPayload';
|
|
2
|
+
import createMobilePushPayload, { buildCarouselCards } from '../createMobilePushPayload';
|
|
3
3
|
import messages from '../../v2Containers/MobilePushNew/messages';
|
|
4
4
|
|
|
5
5
|
// Create a mock intl object
|
|
@@ -48,6 +48,7 @@ jest.mock('../createMobilePushPayload', () => {
|
|
|
48
48
|
__esModule: true,
|
|
49
49
|
default: mockCreateMobilePushPayload,
|
|
50
50
|
appendDeepLinkKeysToUrl: originalModule.appendDeepLinkKeysToUrl,
|
|
51
|
+
buildCarouselCards: originalModule.buildCarouselCards,
|
|
51
52
|
};
|
|
52
53
|
});
|
|
53
54
|
|
|
@@ -261,6 +262,21 @@ describe('createMobilePushPayload', () => {
|
|
|
261
262
|
accountData: unsupportedAccountData,
|
|
262
263
|
})).not.toThrow();
|
|
263
264
|
});
|
|
265
|
+
|
|
266
|
+
it.each([
|
|
267
|
+
['IOS', 'ANDROID', { androidContent: { title: 'Title', message: 'Message' }, iosContent: { title: '', message: '' } }],
|
|
268
|
+
['ANDROID', 'IOS', { androidContent: { title: '', message: '' }, iosContent: { title: 'Title', message: 'Message' } }],
|
|
269
|
+
])('leaves out a supported platform passed as skipPlatform (%s)', (skipPlatform, keptPlatform, content) => {
|
|
270
|
+
const result = callWithIntl({
|
|
271
|
+
templateName: 'Test',
|
|
272
|
+
...content,
|
|
273
|
+
accountData: mockAccountData,
|
|
274
|
+
options: { skipPlatform },
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
expect(result.versions.base[skipPlatform]).toBeUndefined();
|
|
278
|
+
expect(result.versions.base[keptPlatform]).toBeDefined();
|
|
279
|
+
});
|
|
264
280
|
});
|
|
265
281
|
|
|
266
282
|
// Account Data Validation Tests
|
|
@@ -335,33 +351,67 @@ describe('createMobilePushPayload', () => {
|
|
|
335
351
|
expect(result.versions.base.ANDROID.expandableDetails.image).toBe('test-image.jpg');
|
|
336
352
|
});
|
|
337
353
|
|
|
338
|
-
it('should handle VIDEO media type with
|
|
354
|
+
it('should handle VIDEO media type with the platform videoSrc', () => {
|
|
339
355
|
const result = callWithIntl({
|
|
340
356
|
templateName: 'Test',
|
|
341
357
|
androidContent: {
|
|
342
358
|
title: 'Title',
|
|
343
359
|
message: 'Message',
|
|
344
360
|
mediaType: 'VIDEO',
|
|
361
|
+
videoSrc: 'test-video.mp4',
|
|
345
362
|
},
|
|
346
363
|
iosContent: { title: 'Title', message: 'Message' },
|
|
347
364
|
accountData: mockAccountData,
|
|
348
|
-
|
|
365
|
+
// The shared slot is ignored; it can hold the other tab's video
|
|
366
|
+
mpushVideoSrcAndPreview: { mpushVideoSrc: 'other-tab.mp4' },
|
|
349
367
|
});
|
|
350
368
|
expect(result.versions.base.ANDROID.expandableDetails.media[0].url).toBe('test-video.mp4');
|
|
351
369
|
expect(result.versions.base.ANDROID.expandableDetails.media[0].type).toBe('VIDEO');
|
|
352
370
|
});
|
|
353
371
|
|
|
354
|
-
it('should
|
|
372
|
+
it('should fall back to mediaList for a VIDEO with no videoSrc', () => {
|
|
373
|
+
const result = callWithIntl({
|
|
374
|
+
templateName: 'Test',
|
|
375
|
+
androidContent: {
|
|
376
|
+
title: 'Title',
|
|
377
|
+
message: 'Message',
|
|
378
|
+
mediaType: 'VIDEO',
|
|
379
|
+
mediaList: [{ url: 'saved.mp4', text: 'Saved' }],
|
|
380
|
+
},
|
|
381
|
+
iosContent: { title: 'Title', message: 'Message' },
|
|
382
|
+
accountData: mockAccountData,
|
|
383
|
+
});
|
|
384
|
+
expect(result.versions.base.ANDROID.expandableDetails.media[0]).toEqual({ url: 'saved.mp4', text: 'Saved', type: 'VIDEO' });
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
it('saves each platform its own video', () => {
|
|
388
|
+
const result = callWithIntl({
|
|
389
|
+
templateName: 'Test',
|
|
390
|
+
androidContent: {
|
|
391
|
+
title: 'Title', message: 'Message', mediaType: 'VIDEO', videoSrc: 'a.mp4',
|
|
392
|
+
},
|
|
393
|
+
iosContent: {
|
|
394
|
+
title: 'Title', message: 'Message', mediaType: 'VIDEO', videoSrc: 'b.mp4',
|
|
395
|
+
},
|
|
396
|
+
accountData: mockAccountData,
|
|
397
|
+
mpushVideoSrcAndPreview: { mpushVideoSrc: 'b.mp4' },
|
|
398
|
+
});
|
|
399
|
+
expect(result.versions.base.ANDROID.expandableDetails.media[0].url).toBe('a.mp4');
|
|
400
|
+
expect(result.versions.base.IOS.expandableDetails.media[0].url).toBe('b.mp4');
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
it('should handle GIF media type with the platform videoSrc', () => {
|
|
355
404
|
const result = callWithIntl({
|
|
356
405
|
templateName: 'Test',
|
|
357
406
|
androidContent: {
|
|
358
407
|
title: 'Title',
|
|
359
408
|
message: 'Message',
|
|
360
409
|
mediaType: 'GIF',
|
|
410
|
+
videoSrc: 'test-gif.gif',
|
|
361
411
|
},
|
|
362
412
|
iosContent: { title: 'Title', message: 'Message' },
|
|
363
413
|
accountData: mockAccountData,
|
|
364
|
-
mpushVideoSrcAndPreview: { mpushVideoSrc: '
|
|
414
|
+
mpushVideoSrcAndPreview: { mpushVideoSrc: 'other-tab.gif' },
|
|
365
415
|
});
|
|
366
416
|
expect(result.versions.base.ANDROID.expandableDetails.media[0].url).toBe('test-gif.gif');
|
|
367
417
|
expect(result.versions.base.ANDROID.expandableDetails.media[0].type).toBe('GIF');
|
|
@@ -860,13 +910,12 @@ describe('createMobilePushPayload', () => {
|
|
|
860
910
|
title: 'Title',
|
|
861
911
|
message: 'Message',
|
|
862
912
|
mediaType: 'GIF',
|
|
913
|
+
videoSrc: 'test-gif.gif',
|
|
863
914
|
},
|
|
864
915
|
iosContent: { title: 'Title', message: 'Message' },
|
|
865
916
|
accountData: mockAccountData,
|
|
866
|
-
mpushVideoSrcAndPreview: { mpushVideoSrc: 'test-gif.gif' },
|
|
867
917
|
});
|
|
868
|
-
|
|
869
|
-
expect(result.versions.base.ANDROID.expandableDetails.media[0].type).toBe('GIF');
|
|
918
|
+
expect(result.versions.base.ANDROID.expandableDetails.media[0]).toEqual({ url: 'test-gif.gif', text: '', type: 'GIF' });
|
|
870
919
|
});
|
|
871
920
|
|
|
872
921
|
it('should handle options with custom mode', () => {
|
|
@@ -1322,3 +1371,59 @@ describe('createMobilePushPayload', () => {
|
|
|
1322
1371
|
});
|
|
1323
1372
|
});
|
|
1324
1373
|
});
|
|
1374
|
+
|
|
1375
|
+
describe('buildCarouselCards', () => {
|
|
1376
|
+
it.each([
|
|
1377
|
+
['no argument', undefined],
|
|
1378
|
+
['null', null],
|
|
1379
|
+
['an empty array', []],
|
|
1380
|
+
])('returns [] for %s', (_label, input) => {
|
|
1381
|
+
expect(buildCarouselCards(input)).toEqual([]);
|
|
1382
|
+
});
|
|
1383
|
+
|
|
1384
|
+
it('fills defaults for a missing card', () => {
|
|
1385
|
+
expect(buildCarouselCards([null])).toEqual([
|
|
1386
|
+
{ mediaType: 'image', imageUrl: '', videoSrc: '', buttons: [] },
|
|
1387
|
+
]);
|
|
1388
|
+
});
|
|
1389
|
+
|
|
1390
|
+
it('leaves the editor-only isSaved flag out of card buttons', () => {
|
|
1391
|
+
const [card] = buildCarouselCards([{
|
|
1392
|
+
mediaType: 'image',
|
|
1393
|
+
imageUrl: 'a.jpg',
|
|
1394
|
+
buttons: [{
|
|
1395
|
+
actionOnClick: true, linkType: 'EXTERNAL_LINK', externalLinkValue: 'https://a.com', isSaved: true,
|
|
1396
|
+
}],
|
|
1397
|
+
}]);
|
|
1398
|
+
expect(card.buttons[0]).toEqual({ actionOnClick: true, linkType: 'EXTERNAL_LINK', externalLinkValue: 'https://a.com' });
|
|
1399
|
+
});
|
|
1400
|
+
|
|
1401
|
+
it('keeps the video thumbnail only when there is one', () => {
|
|
1402
|
+
const [withThumb, withoutThumb] = buildCarouselCards([
|
|
1403
|
+
{ mediaType: 'video', videoSrc: 'a.mp4', videoPreviewImg: 'a.png' },
|
|
1404
|
+
{ mediaType: 'video', videoSrc: 'b.mp4', videoPreviewImg: '' },
|
|
1405
|
+
]);
|
|
1406
|
+
|
|
1407
|
+
expect(withThumb).toEqual({ mediaType: 'video', imageUrl: '', videoSrc: 'a.mp4', videoPreviewImg: 'a.png', buttons: [] });
|
|
1408
|
+
expect(withoutThumb).toEqual({ mediaType: 'video', imageUrl: '', videoSrc: 'b.mp4', buttons: [] });
|
|
1409
|
+
});
|
|
1410
|
+
|
|
1411
|
+
it('appends deep link keys and leaves other buttons as they are', () => {
|
|
1412
|
+
const externalButton = { linkType: 'EXTERNAL_LINK', externalLinkValue: 'https://x.com' };
|
|
1413
|
+
const [card] = buildCarouselCards([{
|
|
1414
|
+
mediaType: 'image',
|
|
1415
|
+
imageUrl: 'a.jpg',
|
|
1416
|
+
buttons: [
|
|
1417
|
+
{ linkType: 'DEEP_LINK', deepLinkValue: 'app://home', deepLinkKeys: 'id' },
|
|
1418
|
+
externalButton,
|
|
1419
|
+
null,
|
|
1420
|
+
],
|
|
1421
|
+
}]);
|
|
1422
|
+
|
|
1423
|
+
expect(card.buttons).toEqual([
|
|
1424
|
+
{ linkType: 'DEEP_LINK', deepLinkValue: 'app://home?id=id', deepLinkKeys: 'id' },
|
|
1425
|
+
externalButton,
|
|
1426
|
+
null,
|
|
1427
|
+
]);
|
|
1428
|
+
});
|
|
1429
|
+
});
|
|
@@ -235,9 +235,10 @@ export const CapMpushCTA = (props) => {
|
|
|
235
235
|
type="flex"
|
|
236
236
|
>
|
|
237
237
|
<CapColumn>
|
|
238
|
-
<CapRow className="mpush-cta-row">
|
|
238
|
+
<CapRow type="flex" align="middle" className="mpush-cta-row">
|
|
239
239
|
<CapColumn>
|
|
240
|
-
|
|
240
|
+
{/* Not "launch": its SVG mask id collides with other launch icons and renders a square */}
|
|
241
|
+
<CapIcon size="s" type="open-in-new" />
|
|
241
242
|
</CapColumn>
|
|
242
243
|
<CapColumn className="btn-text">
|
|
243
244
|
<CapLabel type="label2" className="mpush-saved-cta-button-text">
|
|
@@ -251,13 +252,11 @@ export const CapMpushCTA = (props) => {
|
|
|
251
252
|
<CapTag className="cta-type-label">{formatMessage(messages.urlDeepLink)}</CapTag>
|
|
252
253
|
: <CapTag className="cta-type-label">{formatMessage(messages.urlExternalLink)}</CapTag>}
|
|
253
254
|
</CapColumn>
|
|
254
|
-
<CapColumn>
|
|
255
|
-
{urlType === DEEP_LINK ? selectedDeepLink?.label :
|
|
256
|
-
</CapColumn>
|
|
257
|
-
<CapColumn>
|
|
255
|
+
<CapColumn className="mpush-saved-cta-link" title={cta?.url}>
|
|
256
|
+
{urlType === DEEP_LINK ? selectedDeepLink?.label : cta?.url}
|
|
258
257
|
</CapColumn>
|
|
259
258
|
<CapColumn>
|
|
260
|
-
<CapRow className="cta-action-grp">
|
|
259
|
+
<CapRow type="flex" align="middle" className="cta-action-grp">
|
|
261
260
|
<CapColumn
|
|
262
261
|
className="mpush-saved-cta-edit-icon"
|
|
263
262
|
onClick={() => isSavedCta(index, false)}
|
|
@@ -320,6 +319,8 @@ export const CapMpushCTA = (props) => {
|
|
|
320
319
|
</CapRow>
|
|
321
320
|
)}
|
|
322
321
|
{urlType === EXTERNAL_URL && (
|
|
322
|
+
// Wrapper lets the stylesheet size the label row to match "Type of link"
|
|
323
|
+
<div className="mpush-cta-external-link-field">
|
|
323
324
|
<CapTagListWithInput
|
|
324
325
|
inputId="mpush-cta-external-link"
|
|
325
326
|
inputValue={localUrlValues[index] || ''}
|
|
@@ -329,8 +330,7 @@ export const CapMpushCTA = (props) => {
|
|
|
329
330
|
inputMaxLength={URL_MAX_LENGTH}
|
|
330
331
|
inputErrorMessage={urlError}
|
|
331
332
|
headingText={formatMessage(messages.urlExternalLink)}
|
|
332
|
-
headingStyle={{
|
|
333
|
-
containerStyle={{ width: '70%', marginTop: '-0.625rem' }}
|
|
333
|
+
headingStyle={{ whiteSpace: 'nowrap' }}
|
|
334
334
|
moduleFilterEnabled={location?.query?.type !== "embedded"}
|
|
335
335
|
onTagSelect={onButtonTagSelect}
|
|
336
336
|
onContextChange={handleOnTagsContextChange}
|
|
@@ -340,6 +340,7 @@ export const CapMpushCTA = (props) => {
|
|
|
340
340
|
selectedOfferDetails={selectedOfferDetails}
|
|
341
341
|
inputProps={{ 'data-index': index }}
|
|
342
342
|
/>
|
|
343
|
+
</div>
|
|
343
344
|
)}
|
|
344
345
|
</CapColumn>
|
|
345
346
|
{urlType === DEEP_LINK && ctaDeepLinkValue && deepLinkKeysFromSelectionArray.length > 0 && (
|
|
@@ -31,6 +31,18 @@
|
|
|
31
31
|
margin-top: $CAP_SPACE_12;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
// External link column: its label row (heading + "Add label") gets the height of the
|
|
35
|
+
// "Type of link" label plus its 8px gap, so the input lines up with the dropdown
|
|
36
|
+
.mpush-cta-external-link-field {
|
|
37
|
+
width: 70%;
|
|
38
|
+
|
|
39
|
+
> .ant-col > .ant-row:first-child {
|
|
40
|
+
height: 1.449rem; // CapHeading h4 line height
|
|
41
|
+
margin-bottom: $CAP_SPACE_08;
|
|
42
|
+
justify-content: space-between;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
34
46
|
.mpush-cta-save-delete-btn {
|
|
35
47
|
margin-top: $CAP_SPACE_16;
|
|
36
48
|
|
|
@@ -55,13 +67,27 @@
|
|
|
55
67
|
padding: $CAP_SPACE_08 $CAP_SPACE_12;
|
|
56
68
|
border-radius: $CAP_SPACE_04;
|
|
57
69
|
height: $CAP_SPACE_40;
|
|
70
|
+
gap: $CAP_SPACE_12;
|
|
58
71
|
|
|
59
72
|
.mpush-saved-cta-button-text {
|
|
60
73
|
font-weight: 500;
|
|
61
74
|
}
|
|
62
75
|
|
|
63
|
-
|
|
64
|
-
|
|
76
|
+
// Inline icons sit on the text baseline (a few px high); as blocks they centre with the text
|
|
77
|
+
.cap-icon-v2 {
|
|
78
|
+
display: flex;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// URL fills the space up to the icons and ends in "..." when too long.
|
|
82
|
+
// contain: inline-size stops a long URL from widening the whole form.
|
|
83
|
+
.mpush-saved-cta-link {
|
|
84
|
+
flex: 1;
|
|
85
|
+
min-width: 0;
|
|
86
|
+
contain: inline-size;
|
|
87
|
+
white-space: nowrap;
|
|
88
|
+
overflow: hidden;
|
|
89
|
+
text-overflow: ellipsis;
|
|
90
|
+
color: $CAP_G04;
|
|
65
91
|
}
|
|
66
92
|
}
|
|
67
93
|
.cta-label {
|
|
@@ -89,5 +115,5 @@
|
|
|
89
115
|
padding-left: 1rem;
|
|
90
116
|
}
|
|
91
117
|
.btn-text {
|
|
92
|
-
margin-left: $
|
|
118
|
+
margin-left: $CAP_SPACE_08;
|
|
93
119
|
}
|
|
@@ -0,0 +1,89 @@
|
|
|
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
|
+
});
|
|
@@ -86,14 +86,15 @@ const MobilePushPreviewContent = ({
|
|
|
86
86
|
|
|
87
87
|
// Render MobilePush carousel (based on TemplatePreview renderMobilePushCarousel)
|
|
88
88
|
const renderMobilePushCarousel = (contentData) => {
|
|
89
|
+
// Every card shows, even before its media is uploaded (an empty card keeps its place)
|
|
89
90
|
if (!contentData?.carouselData || contentData?.carouselData?.length === 0) {
|
|
90
91
|
return null;
|
|
91
92
|
}
|
|
92
93
|
|
|
93
94
|
return (
|
|
94
95
|
<CapRow type="flex" vertical noWrap className="msg-container-carousel mobile-push-carousel-container">
|
|
95
|
-
<CapRow
|
|
96
|
-
{contentData
|
|
96
|
+
<CapRow type="flex" noWrap className="scroll-container mobile-push-scroll-container">
|
|
97
|
+
{contentData.carouselData.map((item, idx) => (
|
|
97
98
|
<CapColumn
|
|
98
99
|
key={`carousel-card-${idx}`}
|
|
99
100
|
className="mobile-push-carousel-card message-pop align-left message-pop-carousel"
|
|
@@ -105,13 +106,20 @@ const MobilePushPreviewContent = ({
|
|
|
105
106
|
className="carousel-image"
|
|
106
107
|
/>
|
|
107
108
|
)}
|
|
108
|
-
{item?.mediaType?.toLowerCase() === MEDIA_TYPE_VIDEO.toLowerCase() && item?.videoPreviewImg && (
|
|
109
|
+
{item?.mediaType?.toLowerCase() === MEDIA_TYPE_VIDEO.toLowerCase() && (item?.videoPreviewImg || item?.videoSrc) && (
|
|
109
110
|
<CapRow className="video-preview">
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
{item?.videoPreviewImg ? (
|
|
112
|
+
<CapImage
|
|
113
|
+
src={item?.videoPreviewImg || item?.url}
|
|
114
|
+
alt="carousel-video-preview"
|
|
115
|
+
className="carousel-video-preview"
|
|
116
|
+
/>
|
|
117
|
+
) : (
|
|
118
|
+
// No thumbnail from the upload: show the video's first frame
|
|
119
|
+
<video src={item?.videoSrc} className="carousel-video-preview" muted preload="metadata">
|
|
120
|
+
<track kind="captions" />
|
|
121
|
+
</video>
|
|
122
|
+
)}
|
|
115
123
|
<CapRow className="icon-position">
|
|
116
124
|
<CapImage className="video-icon" src={videoPlay} alt="Play" />
|
|
117
125
|
</CapRow>
|
|
@@ -217,15 +225,15 @@ const MobilePushPreviewContent = ({
|
|
|
217
225
|
{/* Action Buttons */}
|
|
218
226
|
{(deviceContent?.actions || []).filter((action) => action?.label || action?.actionText).length > 0
|
|
219
227
|
&& deviceContent?.carouselData?.length === 0 && (
|
|
220
|
-
<CapRow
|
|
221
|
-
{
|
|
228
|
+
<CapRow type="flex" noWrap className="actions">
|
|
229
|
+
{deviceContent.actions.map((action, index) => (
|
|
222
230
|
(action?.label || action?.actionText) && (
|
|
223
231
|
<span
|
|
224
232
|
className="action"
|
|
225
|
-
key={`action-${
|
|
233
|
+
key={`action-${index}`}
|
|
226
234
|
title={action?.url || action?.actionLink || ''}
|
|
227
235
|
>
|
|
228
|
-
{action?.label
|
|
236
|
+
{action?.label || action?.actionText}
|
|
229
237
|
</span>
|
|
230
238
|
)
|
|
231
239
|
))}
|
|
@@ -2307,9 +2307,21 @@
|
|
|
2307
2307
|
flex-direction: row;
|
|
2308
2308
|
gap: $CAP_SPACE_08;
|
|
2309
2309
|
|
|
2310
|
+
// One button: centred. Two: equal halves, each centred, split by a divider.
|
|
2310
2311
|
.action {
|
|
2311
2312
|
font-size: $FONT_SIZE_S;
|
|
2312
|
-
|
|
2313
|
+
font-weight: 600;
|
|
2314
|
+
color: $FONT_COLOR_01;
|
|
2315
|
+
flex: 1 1 0;
|
|
2316
|
+
min-width: 0;
|
|
2317
|
+
text-align: center;
|
|
2318
|
+
white-space: nowrap;
|
|
2319
|
+
overflow: hidden;
|
|
2320
|
+
text-overflow: ellipsis;
|
|
2321
|
+
|
|
2322
|
+
& + .action {
|
|
2323
|
+
border-left: 1px solid $CAP_G07;
|
|
2324
|
+
}
|
|
2313
2325
|
}
|
|
2314
2326
|
}
|
|
2315
2327
|
}
|
|
@@ -209,6 +209,8 @@ export const CTA_TYPE_EXTERNAL_URL = 'EXTERNAL_URL';
|
|
|
209
209
|
// ============================================
|
|
210
210
|
export const STYLE_TYPE_BIG_PICTURE = 'BIG_PICTURE';
|
|
211
211
|
export const STYLE_TYPE_BIG_TEXT = 'BIG_TEXT';
|
|
212
|
+
export const STYLE_TYPE_VIDEO = 'VIDEO';
|
|
213
|
+
export const STYLE_TYPE_MANUAL_CAROUSEL = 'MANUAL_CAROUSEL';
|
|
212
214
|
|
|
213
215
|
// ============================================
|
|
214
216
|
// DEVICE TYPE CONSTANTS (for API payloads)
|