@capillarytech/creatives-library 9.2.2 → 9.2.4-alpha.feature-rcs-multi-account.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/constants/unified.js +0 -1
- package/package.json +1 -1
- package/utils/common.js +0 -6
- package/utils/createMobilePushPayload.js +50 -56
- package/utils/tests/createMobilePushPayload.test.js +177 -168
- package/v2Components/CapMpushCTA/index.js +47 -57
- package/v2Components/CapMpushCTA/index.scss +43 -5
- package/v2Components/CapMpushCTA/tests/index.test.js +150 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +11 -8
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +13 -1
- package/v2Components/CommonTestAndPreview/constants.js +2 -0
- package/v2Components/CommonTestAndPreview/index.js +59 -14
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +83 -5
- package/v2Components/CommonTestAndPreview/tests/index.test.js +158 -0
- package/v2Components/MobilePushPreviewV2/_mobilePushPreviewV2.scss +7 -0
- package/v2Components/MobilePushPreviewV2/index.js +22 -9
- package/v2Components/MobilePushPreviewV2/tests/index.test.js +55 -0
- package/v2Components/TemplatePreview/_mobilePushPhone.scss +72 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +18 -2
- package/v2Components/TemplatePreview/index.js +20 -18
- package/v2Components/TemplatePreview/tests/index.test.js +69 -0
- package/v2Components/TestAndPreviewSlidebox/index.js +2 -0
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/Tests/extractContentForPreview.test.js +45 -0
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/extractContentForPreview.js +12 -2
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/DeliverySettingsSection.js +16 -3
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/SenderDetails.js +7 -2
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/deliverySettingsConfig.test.js +44 -0
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/deliverySettingsConfig.js +21 -8
- package/v2Containers/CreativesContainer/SlideBoxContent.js +4 -6
- package/v2Containers/CreativesContainer/index.js +18 -1
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +43 -0
- package/v2Containers/CreativesContainer/tests/index.test.js +66 -0
- package/v2Containers/MobilePushNew/components/CtaButtons.js +52 -47
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +105 -345
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +127 -105
- package/v2Containers/MobilePushNew/components/TapLinkActions.js +76 -0
- package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +30 -208
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +305 -1482
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +165 -59
- package/v2Containers/MobilePushNew/constants.js +12 -0
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +63 -1
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +78 -0
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +40 -1
- package/v2Containers/MobilePushNew/hooks/useUpload.js +42 -46
- package/v2Containers/MobilePushNew/index.js +498 -289
- package/v2Containers/MobilePushNew/index.scss +151 -4
- package/v2Containers/MobilePushNew/messages.js +106 -6
- package/v2Containers/MobilePushNew/tests/index.test.js +483 -1
- package/v2Containers/MobilePushNew/tests/utils.test.js +110 -0
- package/v2Containers/MobilePushNew/utils.js +83 -0
- package/v2Containers/Rcs/accountUtils.js +20 -0
- package/v2Containers/Rcs/index.js +18 -1
- package/v2Containers/Rcs/tests/accountUtils.test.js +24 -0
- package/v2Containers/Rcs/tests/index.test.js +23 -0
- package/v2Containers/Templates/ChannelTypeIllustration.js +12 -0
- package/v2Containers/Templates/_templates.scss +10 -2
- package/v2Containers/Templates/index.js +94 -85
- package/v2Containers/Templates/messages.js +4 -0
- package/v2Containers/Templates/tests/ChannelTypeIllustration.test.js +14 -2
- package/v2Containers/Templates/tests/index.test.js +182 -0
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,
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
TEXT,
|
|
12
12
|
} from "../v2Containers/MobilePushNew/constants";
|
|
13
13
|
import messages from '../v2Containers/MobilePushNew/messages';
|
|
14
|
+
import { appendDeepLinkParams } from '../v2Containers/MobilePushNew/utils';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Constructs the payload for Mobile Push, supporting both legacy and rich media as per backend contract.
|
|
@@ -27,6 +28,7 @@ import messages from '../v2Containers/MobilePushNew/messages';
|
|
|
27
28
|
* @param {Object} params.accountData - Account data for the payload
|
|
28
29
|
* @param {boolean} params.sameContent - Whether content is shared between platforms
|
|
29
30
|
* @param {Object} params.options - Additional options
|
|
31
|
+
* @param {string} [params.options.skipPlatform] - ANDROID or IOS: leave out a supported platform the user chose not to configure
|
|
30
32
|
* @param {Object} params.intl - Internationalization object for messages
|
|
31
33
|
*/
|
|
32
34
|
const createMobilePushPayload = ({
|
|
@@ -41,8 +43,8 @@ const createMobilePushPayload = ({
|
|
|
41
43
|
intl,
|
|
42
44
|
}) => {
|
|
43
45
|
// Platform support checks must be at the top
|
|
44
|
-
const isAndroidSupported = accountData?.configs?.android === '1';
|
|
45
|
-
const isIosSupported = accountData?.configs?.ios === '1';
|
|
46
|
+
const isAndroidSupported = accountData?.configs?.android === '1' && options?.skipPlatform !== ANDROID;
|
|
47
|
+
const isIosSupported = accountData?.configs?.ios === '1' && options?.skipPlatform !== IOS;
|
|
46
48
|
|
|
47
49
|
const {
|
|
48
50
|
accountId: accountIdFromAccountData, id, licenseCode: licenseCodeFromAccountData, sourceAccountIdentifier, sourceType: sourceTypeFromAccountData, sourceTypeName,
|
|
@@ -121,6 +123,33 @@ const createMobilePushPayload = ({
|
|
|
121
123
|
return payload;
|
|
122
124
|
};
|
|
123
125
|
|
|
126
|
+
/**
|
|
127
|
+
* Carousel cards as Save sends them (also used by the Test & Preview payload)
|
|
128
|
+
* @param {Array} carouselData - Editor carousel cards
|
|
129
|
+
* @returns {Array} Cards with media only
|
|
130
|
+
*/
|
|
131
|
+
export function buildCarouselCards(carouselData = []) {
|
|
132
|
+
return (carouselData || []).map((card) => {
|
|
133
|
+
const {
|
|
134
|
+
mediaType,
|
|
135
|
+
imageUrl,
|
|
136
|
+
videoSrc,
|
|
137
|
+
videoPreviewImg,
|
|
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
|
+
// No per-card tap: the notification tap is for the whole notification.
|
|
147
|
+
// Dropping old card links also stops them refilling that tap on reopen.
|
|
148
|
+
buttons: [],
|
|
149
|
+
};
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
124
153
|
/**
|
|
125
154
|
* Builds platform-specific content for the payload
|
|
126
155
|
* @param {Object} content - Platform content (Android/iOS)
|
|
@@ -129,7 +158,7 @@ const createMobilePushPayload = ({
|
|
|
129
158
|
* @param {string} platform - Platform (ANDROID/IOS)
|
|
130
159
|
* @returns {Object} Platform-specific content
|
|
131
160
|
*/
|
|
132
|
-
function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview, platform) {
|
|
161
|
+
export function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview, platform) {
|
|
133
162
|
const {
|
|
134
163
|
title = '',
|
|
135
164
|
message = '',
|
|
@@ -148,18 +177,16 @@ function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview, platfo
|
|
|
148
177
|
custom: buildCustomFields(content),
|
|
149
178
|
};
|
|
150
179
|
|
|
151
|
-
// Handle
|
|
180
|
+
// Handle media types
|
|
181
|
+
const style = content?.mediaType || expandableDetails?.style;
|
|
182
|
+
const isCarousel = [CAROUSEL, MANUAL_CAROUSEL, AUTO_CAROUSEL, FILMSTRIP_CAROUSEL].includes(style);
|
|
183
|
+
|
|
184
|
+
// Handle CTA (notification tap, for the whole notification, carousel included)
|
|
152
185
|
if (actionOnClick) {
|
|
153
186
|
let finalDeepLinkValue = deepLinkValue;
|
|
154
187
|
|
|
155
188
|
if (linkType === DEEP_LINK && deepLinkKeysValue?.length > 0) {
|
|
156
|
-
|
|
157
|
-
const urlHasKeys = deepLinkKeysValue?.some((key) => deepLinkValue?.includes(`${key}=${key}`));
|
|
158
|
-
|
|
159
|
-
// Only append keys if they're not already in the URL
|
|
160
|
-
if (!urlHasKeys) {
|
|
161
|
-
finalDeepLinkValue = appendDeepLinkKeysToUrl(deepLinkValue, deepLinkKeysValue);
|
|
162
|
-
}
|
|
189
|
+
finalDeepLinkValue = appendDeepLinkKeysToUrl(deepLinkValue, deepLinkKeysValue);
|
|
163
190
|
}
|
|
164
191
|
|
|
165
192
|
platformContent.cta = {
|
|
@@ -168,9 +195,6 @@ function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview, platfo
|
|
|
168
195
|
};
|
|
169
196
|
}
|
|
170
197
|
|
|
171
|
-
// Handle media types
|
|
172
|
-
const style = content?.mediaType || expandableDetails?.style;
|
|
173
|
-
|
|
174
198
|
// Determine the type field based on media type
|
|
175
199
|
let templateType = TEXT; // Default type for NONE or BIG_TEXT
|
|
176
200
|
|
|
@@ -184,7 +208,8 @@ function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview, platfo
|
|
|
184
208
|
platformContent.expandableDetails.style = VIDEO;
|
|
185
209
|
platformContent.expandableDetails.message = message;
|
|
186
210
|
platformContent.expandableDetails.media = [{
|
|
187
|
-
|
|
211
|
+
// This platform's own video; mpushVideoSrcAndPreview is shared by both tabs
|
|
212
|
+
url: content?.videoSrc || content?.mediaList?.[0]?.url || '',
|
|
188
213
|
text: content?.mediaList?.[0]?.text || '',
|
|
189
214
|
type: VIDEO,
|
|
190
215
|
}];
|
|
@@ -201,50 +226,26 @@ function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview, platfo
|
|
|
201
226
|
type: type.toLowerCase(),
|
|
202
227
|
}];
|
|
203
228
|
} else {
|
|
204
|
-
//
|
|
229
|
+
// No mediaList: use this platform's own GIF
|
|
205
230
|
platformContent.expandableDetails.style = GIF;
|
|
206
231
|
platformContent.expandableDetails.message = message;
|
|
207
232
|
platformContent.expandableDetails.media = [{
|
|
208
|
-
url:
|
|
233
|
+
url: content?.videoSrc || '',
|
|
209
234
|
text: '',
|
|
210
235
|
type: GIF, // Backend expects GIF type for GIFs
|
|
211
236
|
}];
|
|
212
237
|
}
|
|
213
238
|
templateType = GIF;
|
|
214
|
-
} else if (
|
|
239
|
+
} else if (isCarousel) { // Handle CAROUSEL media types
|
|
215
240
|
platformContent.expandableDetails.style = MANUAL_CAROUSEL;
|
|
216
241
|
platformContent.expandableDetails.message = message;
|
|
242
|
+
// A carousel tab hides the Buttons section; buttons added before switching aren't sent
|
|
243
|
+
platformContent.expandableDetails.ctas = [];
|
|
217
244
|
templateType = CAROUSEL;
|
|
218
245
|
|
|
219
246
|
// Handle carouselData
|
|
220
247
|
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
|
-
});
|
|
248
|
+
platformContent.expandableDetails.carouselData = buildCarouselCards(content.carouselData);
|
|
248
249
|
}
|
|
249
250
|
|
|
250
251
|
// Handle mediaList
|
|
@@ -305,21 +306,14 @@ function buildCustomFields(content) {
|
|
|
305
306
|
}
|
|
306
307
|
|
|
307
308
|
/**
|
|
308
|
-
* Appends deep link
|
|
309
|
+
* Appends deep link params to URL
|
|
309
310
|
* @param {string} url - Base URL
|
|
310
|
-
* @param {Array} keys -
|
|
311
|
-
* @returns {string} URL with
|
|
311
|
+
* @param {Array} keys - "key=value" entries (an old entry without "=" means key=key)
|
|
312
|
+
* @returns {string} URL with the params
|
|
312
313
|
*/
|
|
313
314
|
export function appendDeepLinkKeysToUrl(url, keys) {
|
|
314
315
|
if (!url || !keys || !Array.isArray(keys) || keys?.length === 0) return url;
|
|
315
|
-
|
|
316
|
-
const separator = url.includes('?') ? '&' : '?';
|
|
317
|
-
const validKeys = keys.filter((key) => typeof key === 'string' && key?.length > 0);
|
|
318
|
-
if (validKeys?.length === 0) return url;
|
|
319
|
-
|
|
320
|
-
const keyParams = validKeys.map((key) => `${key}=${key}`).join('&');
|
|
321
|
-
|
|
322
|
-
return `${url}${separator}${keyParams}`;
|
|
316
|
+
return appendDeepLinkParams(url, keys);
|
|
323
317
|
}
|
|
324
318
|
|
|
325
319
|
export default createMobilePushPayload;
|
|
@@ -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');
|
|
@@ -413,6 +463,34 @@ describe('createMobilePushPayload', () => {
|
|
|
413
463
|
|
|
414
464
|
// Carousel Handling Tests
|
|
415
465
|
describe('Carousel Handling', () => {
|
|
466
|
+
// Buttons set before switching to carousel stay in the editor but aren't sent; the tap link is sent
|
|
467
|
+
const hiddenCtas = [{ type: 'EXTERNAL_URL', actionText: 'IOS PrimButton', actionLink: 'https://btn.com' }];
|
|
468
|
+
const withHiddenLinks = (mediaType) => ({
|
|
469
|
+
title: 'Title',
|
|
470
|
+
message: 'Message',
|
|
471
|
+
mediaType,
|
|
472
|
+
actionOnClick: true,
|
|
473
|
+
linkType: 'EXTERNAL_LINK',
|
|
474
|
+
externalLinkValue: 'https://tap.com',
|
|
475
|
+
expandableDetails: { ctas: hiddenCtas },
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
it('drops the buttons of a carousel tab but keeps its notification tap', () => {
|
|
479
|
+
const result = callWithIntl({
|
|
480
|
+
templateName: 'Test',
|
|
481
|
+
androidContent: withHiddenLinks('VIDEO'),
|
|
482
|
+
iosContent: withHiddenLinks('CAROUSEL'),
|
|
483
|
+
accountData: mockAccountData,
|
|
484
|
+
});
|
|
485
|
+
const { IOS, ANDROID } = result.versions.base;
|
|
486
|
+
expect(IOS.expandableDetails.ctas).toEqual([]);
|
|
487
|
+
// Notification tap is for the whole notification, carousel included
|
|
488
|
+
expect(IOS.cta).toEqual({ type: 'EXTERNAL_URL', actionLink: 'https://tap.com' });
|
|
489
|
+
// Another tab keeps them
|
|
490
|
+
expect(ANDROID.expandableDetails.ctas).toEqual(hiddenCtas);
|
|
491
|
+
expect(ANDROID.cta).toEqual({ type: 'EXTERNAL_URL', actionLink: 'https://tap.com' });
|
|
492
|
+
});
|
|
493
|
+
|
|
416
494
|
it('should handle CAROUSEL media type with carouselData', () => {
|
|
417
495
|
const result = callWithIntl({
|
|
418
496
|
templateName: 'Test',
|
|
@@ -611,7 +689,7 @@ describe('createMobilePushPayload', () => {
|
|
|
611
689
|
});
|
|
612
690
|
});
|
|
613
691
|
|
|
614
|
-
it('should
|
|
692
|
+
it('should add the missing key when URL contains some keys but not all', () => {
|
|
615
693
|
const result = callWithIntl({
|
|
616
694
|
templateName: 'Test',
|
|
617
695
|
androidContent: {
|
|
@@ -627,8 +705,45 @@ describe('createMobilePushPayload', () => {
|
|
|
627
705
|
});
|
|
628
706
|
expect(result.versions.base.ANDROID.cta).toEqual({
|
|
629
707
|
type: 'DEEP_LINK',
|
|
630
|
-
actionLink: 'app://deep-link?key1=key1',
|
|
708
|
+
actionLink: 'app://deep-link?key1=key1&key2=key2',
|
|
709
|
+
});
|
|
710
|
+
});
|
|
711
|
+
|
|
712
|
+
it('should send the configured key with the typed value', () => {
|
|
713
|
+
const result = callWithIntl({
|
|
714
|
+
templateName: 'Test',
|
|
715
|
+
androidContent: {
|
|
716
|
+
title: 'Title',
|
|
717
|
+
message: 'Message',
|
|
718
|
+
actionOnClick: true,
|
|
719
|
+
linkType: 'DEEP_LINK',
|
|
720
|
+
deepLinkValue: 'https://www.youtube.com/',
|
|
721
|
+
deepLinkKeysValue: ['testing_purpose=androidDeeplink'],
|
|
722
|
+
},
|
|
723
|
+
iosContent: { title: 'Title', message: 'Message' },
|
|
724
|
+
accountData: mockAccountData,
|
|
725
|
+
});
|
|
726
|
+
expect(result.versions.base.ANDROID.cta).toEqual({
|
|
727
|
+
type: 'DEEP_LINK',
|
|
728
|
+
actionLink: 'https://www.youtube.com/?testing_purpose=androidDeeplink',
|
|
729
|
+
});
|
|
730
|
+
});
|
|
731
|
+
|
|
732
|
+
it('should replace a saved value instead of adding the key twice', () => {
|
|
733
|
+
const result = callWithIntl({
|
|
734
|
+
templateName: 'Test',
|
|
735
|
+
androidContent: {
|
|
736
|
+
title: 'Title',
|
|
737
|
+
message: 'Message',
|
|
738
|
+
actionOnClick: true,
|
|
739
|
+
linkType: 'DEEP_LINK',
|
|
740
|
+
deepLinkValue: 'app://home?src=push&id=5',
|
|
741
|
+
deepLinkKeysValue: ['id=7'],
|
|
742
|
+
},
|
|
743
|
+
iosContent: { title: 'Title', message: 'Message' },
|
|
744
|
+
accountData: mockAccountData,
|
|
631
745
|
});
|
|
746
|
+
expect(result.versions.base.ANDROID.cta.actionLink).toBe('app://home?src=push&id=7');
|
|
632
747
|
});
|
|
633
748
|
|
|
634
749
|
it('should handle deep link CTA with empty deepLinkKeysValue', () => {
|
|
@@ -860,13 +975,12 @@ describe('createMobilePushPayload', () => {
|
|
|
860
975
|
title: 'Title',
|
|
861
976
|
message: 'Message',
|
|
862
977
|
mediaType: 'GIF',
|
|
978
|
+
videoSrc: 'test-gif.gif',
|
|
863
979
|
},
|
|
864
980
|
iosContent: { title: 'Title', message: 'Message' },
|
|
865
981
|
accountData: mockAccountData,
|
|
866
|
-
mpushVideoSrcAndPreview: { mpushVideoSrc: 'test-gif.gif' },
|
|
867
982
|
});
|
|
868
|
-
|
|
869
|
-
expect(result.versions.base.ANDROID.expandableDetails.media[0].type).toBe('GIF');
|
|
983
|
+
expect(result.versions.base.ANDROID.expandableDetails.media[0]).toEqual({ url: 'test-gif.gif', text: '', type: 'GIF' });
|
|
870
984
|
});
|
|
871
985
|
|
|
872
986
|
it('should handle options with custom mode', () => {
|
|
@@ -1032,151 +1146,7 @@ describe('createMobilePushPayload', () => {
|
|
|
1032
1146
|
});
|
|
1033
1147
|
|
|
1034
1148
|
describe('Carousel Button Deep Link Keys', () => {
|
|
1035
|
-
it('
|
|
1036
|
-
const result = callWithIntl({
|
|
1037
|
-
templateName: 'Test',
|
|
1038
|
-
androidContent: {
|
|
1039
|
-
title: 'Title',
|
|
1040
|
-
message: 'Message',
|
|
1041
|
-
mediaType: 'CAROUSEL',
|
|
1042
|
-
carouselData: [
|
|
1043
|
-
{
|
|
1044
|
-
mediaType: 'image',
|
|
1045
|
-
imageUrl: 'test.jpg',
|
|
1046
|
-
buttons: [
|
|
1047
|
-
{
|
|
1048
|
-
linkType: 'DEEP_LINK',
|
|
1049
|
-
deepLinkKeys: ['key1', 'key2'],
|
|
1050
|
-
deepLinkValue: 'app://test',
|
|
1051
|
-
},
|
|
1052
|
-
],
|
|
1053
|
-
},
|
|
1054
|
-
],
|
|
1055
|
-
},
|
|
1056
|
-
iosContent: { title: 'Title', message: 'Message' },
|
|
1057
|
-
accountData: mockAccountData,
|
|
1058
|
-
});
|
|
1059
|
-
|
|
1060
|
-
expect(result.versions.base.ANDROID.expandableDetails.carouselData[0].buttons[0].deepLinkValue)
|
|
1061
|
-
.toBe('app://test?key1=key1&key2=key2');
|
|
1062
|
-
});
|
|
1063
|
-
|
|
1064
|
-
it('should handle single deep link key in carousel buttons', () => {
|
|
1065
|
-
const result = callWithIntl({
|
|
1066
|
-
templateName: 'Test',
|
|
1067
|
-
androidContent: {
|
|
1068
|
-
title: 'Title',
|
|
1069
|
-
message: 'Message',
|
|
1070
|
-
mediaType: 'CAROUSEL',
|
|
1071
|
-
carouselData: [
|
|
1072
|
-
{
|
|
1073
|
-
mediaType: 'image',
|
|
1074
|
-
imageUrl: 'test.jpg',
|
|
1075
|
-
buttons: [
|
|
1076
|
-
{
|
|
1077
|
-
linkType: 'DEEP_LINK',
|
|
1078
|
-
deepLinkKeys: 'singleKey',
|
|
1079
|
-
deepLinkValue: 'app://test',
|
|
1080
|
-
},
|
|
1081
|
-
],
|
|
1082
|
-
},
|
|
1083
|
-
],
|
|
1084
|
-
},
|
|
1085
|
-
iosContent: { title: 'Title', message: 'Message' },
|
|
1086
|
-
accountData: mockAccountData,
|
|
1087
|
-
});
|
|
1088
|
-
|
|
1089
|
-
expect(result.versions.base.ANDROID.expandableDetails.carouselData[0].buttons[0].deepLinkValue)
|
|
1090
|
-
.toBe('app://test?singleKey=singleKey');
|
|
1091
|
-
});
|
|
1092
|
-
|
|
1093
|
-
it('should handle URL with existing query parameters', () => {
|
|
1094
|
-
const result = callWithIntl({
|
|
1095
|
-
templateName: 'Test',
|
|
1096
|
-
androidContent: {
|
|
1097
|
-
title: 'Title',
|
|
1098
|
-
message: 'Message',
|
|
1099
|
-
mediaType: 'CAROUSEL',
|
|
1100
|
-
carouselData: [
|
|
1101
|
-
{
|
|
1102
|
-
mediaType: 'image',
|
|
1103
|
-
imageUrl: 'test.jpg',
|
|
1104
|
-
buttons: [
|
|
1105
|
-
{
|
|
1106
|
-
linkType: 'DEEP_LINK',
|
|
1107
|
-
deepLinkKeys: ['key1', 'key2'],
|
|
1108
|
-
deepLinkValue: 'app://test?param=value',
|
|
1109
|
-
},
|
|
1110
|
-
],
|
|
1111
|
-
},
|
|
1112
|
-
],
|
|
1113
|
-
},
|
|
1114
|
-
iosContent: { title: 'Title', message: 'Message' },
|
|
1115
|
-
accountData: mockAccountData,
|
|
1116
|
-
});
|
|
1117
|
-
|
|
1118
|
-
expect(result.versions.base.ANDROID.expandableDetails.carouselData[0].buttons[0].deepLinkValue)
|
|
1119
|
-
.toBe('app://test?param=value&key1=key1&key2=key2');
|
|
1120
|
-
});
|
|
1121
|
-
|
|
1122
|
-
it('should not modify URL when deepLinkKeys is missing', () => {
|
|
1123
|
-
const result = callWithIntl({
|
|
1124
|
-
templateName: 'Test',
|
|
1125
|
-
androidContent: {
|
|
1126
|
-
title: 'Title',
|
|
1127
|
-
message: 'Message',
|
|
1128
|
-
mediaType: 'CAROUSEL',
|
|
1129
|
-
carouselData: [
|
|
1130
|
-
{
|
|
1131
|
-
mediaType: 'image',
|
|
1132
|
-
imageUrl: 'test.jpg',
|
|
1133
|
-
buttons: [
|
|
1134
|
-
{
|
|
1135
|
-
linkType: 'DEEP_LINK',
|
|
1136
|
-
deepLinkValue: 'app://test',
|
|
1137
|
-
},
|
|
1138
|
-
],
|
|
1139
|
-
},
|
|
1140
|
-
],
|
|
1141
|
-
},
|
|
1142
|
-
iosContent: { title: 'Title', message: 'Message' },
|
|
1143
|
-
accountData: mockAccountData,
|
|
1144
|
-
});
|
|
1145
|
-
|
|
1146
|
-
expect(result.versions.base.ANDROID.expandableDetails.carouselData[0].buttons[0].deepLinkValue)
|
|
1147
|
-
.toBe('app://test');
|
|
1148
|
-
});
|
|
1149
|
-
|
|
1150
|
-
it('should not modify URL when deepLinkKeys is empty array', () => {
|
|
1151
|
-
const result = callWithIntl({
|
|
1152
|
-
templateName: 'Test',
|
|
1153
|
-
androidContent: {
|
|
1154
|
-
title: 'Title',
|
|
1155
|
-
message: 'Message',
|
|
1156
|
-
mediaType: 'CAROUSEL',
|
|
1157
|
-
carouselData: [
|
|
1158
|
-
{
|
|
1159
|
-
mediaType: 'image',
|
|
1160
|
-
imageUrl: 'test.jpg',
|
|
1161
|
-
buttons: [
|
|
1162
|
-
{
|
|
1163
|
-
linkType: 'DEEP_LINK',
|
|
1164
|
-
deepLinkKeys: [],
|
|
1165
|
-
deepLinkValue: 'app://test',
|
|
1166
|
-
},
|
|
1167
|
-
],
|
|
1168
|
-
},
|
|
1169
|
-
],
|
|
1170
|
-
},
|
|
1171
|
-
iosContent: { title: 'Title', message: 'Message' },
|
|
1172
|
-
accountData: mockAccountData,
|
|
1173
|
-
});
|
|
1174
|
-
|
|
1175
|
-
expect(result.versions.base.ANDROID.expandableDetails.carouselData[0].buttons[0].deepLinkValue)
|
|
1176
|
-
.toBe('app://test');
|
|
1177
|
-
});
|
|
1178
|
-
|
|
1179
|
-
it('should handle invalid deepLinkKeys values', () => {
|
|
1149
|
+
it('drops old per-card links from carousel cards', () => {
|
|
1180
1150
|
const result = callWithIntl({
|
|
1181
1151
|
templateName: 'Test',
|
|
1182
1152
|
androidContent: {
|
|
@@ -1189,18 +1159,9 @@ describe('createMobilePushPayload', () => {
|
|
|
1189
1159
|
imageUrl: 'test.jpg',
|
|
1190
1160
|
buttons: [
|
|
1191
1161
|
{
|
|
1162
|
+
actionOnClick: true,
|
|
1192
1163
|
linkType: 'DEEP_LINK',
|
|
1193
|
-
deepLinkKeys:
|
|
1194
|
-
deepLinkValue: 'app://test',
|
|
1195
|
-
},
|
|
1196
|
-
{
|
|
1197
|
-
linkType: 'DEEP_LINK',
|
|
1198
|
-
deepLinkKeys: undefined,
|
|
1199
|
-
deepLinkValue: 'app://test',
|
|
1200
|
-
},
|
|
1201
|
-
{
|
|
1202
|
-
linkType: 'DEEP_LINK',
|
|
1203
|
-
deepLinkKeys: {},
|
|
1164
|
+
deepLinkKeys: ['key1=a'],
|
|
1204
1165
|
deepLinkValue: 'app://test',
|
|
1205
1166
|
},
|
|
1206
1167
|
],
|
|
@@ -1211,8 +1172,11 @@ describe('createMobilePushPayload', () => {
|
|
|
1211
1172
|
accountData: mockAccountData,
|
|
1212
1173
|
});
|
|
1213
1174
|
|
|
1214
|
-
result.versions.base.ANDROID.expandableDetails.carouselData[0].
|
|
1215
|
-
|
|
1175
|
+
expect(result.versions.base.ANDROID.expandableDetails.carouselData[0]).toEqual({
|
|
1176
|
+
mediaType: 'image',
|
|
1177
|
+
imageUrl: 'test.jpg',
|
|
1178
|
+
videoSrc: '',
|
|
1179
|
+
buttons: [],
|
|
1216
1180
|
});
|
|
1217
1181
|
});
|
|
1218
1182
|
|
|
@@ -1322,3 +1286,48 @@ describe('createMobilePushPayload', () => {
|
|
|
1322
1286
|
});
|
|
1323
1287
|
});
|
|
1324
1288
|
});
|
|
1289
|
+
|
|
1290
|
+
describe('buildCarouselCards', () => {
|
|
1291
|
+
it.each([
|
|
1292
|
+
['no argument', undefined],
|
|
1293
|
+
['null', null],
|
|
1294
|
+
['an empty array', []],
|
|
1295
|
+
])('returns [] for %s', (_label, input) => {
|
|
1296
|
+
expect(buildCarouselCards(input)).toEqual([]);
|
|
1297
|
+
});
|
|
1298
|
+
|
|
1299
|
+
it('fills defaults for a missing card', () => {
|
|
1300
|
+
expect(buildCarouselCards([null])).toEqual([
|
|
1301
|
+
{ mediaType: 'image', imageUrl: '', videoSrc: '', buttons: [] },
|
|
1302
|
+
]);
|
|
1303
|
+
});
|
|
1304
|
+
|
|
1305
|
+
it('sends no card buttons, even when a card has old links', () => {
|
|
1306
|
+
const [card] = buildCarouselCards([{
|
|
1307
|
+
mediaType: 'image',
|
|
1308
|
+
imageUrl: 'a.jpg',
|
|
1309
|
+
buttons: [
|
|
1310
|
+
{
|
|
1311
|
+
actionOnClick: true, linkType: 'DEEP_LINK', deepLinkValue: 'app://home', deepLinkKeys: ['id=1'],
|
|
1312
|
+
},
|
|
1313
|
+
{
|
|
1314
|
+
actionOnClick: true, linkType: 'EXTERNAL_LINK', externalLinkValue: 'https://a.com', isSaved: true,
|
|
1315
|
+
},
|
|
1316
|
+
null,
|
|
1317
|
+
],
|
|
1318
|
+
}]);
|
|
1319
|
+
expect(card).toEqual({
|
|
1320
|
+
mediaType: 'image', imageUrl: 'a.jpg', videoSrc: '', buttons: [],
|
|
1321
|
+
});
|
|
1322
|
+
});
|
|
1323
|
+
|
|
1324
|
+
it('keeps the video thumbnail only when there is one', () => {
|
|
1325
|
+
const [withThumb, withoutThumb] = buildCarouselCards([
|
|
1326
|
+
{ mediaType: 'video', videoSrc: 'a.mp4', videoPreviewImg: 'a.png' },
|
|
1327
|
+
{ mediaType: 'video', videoSrc: 'b.mp4', videoPreviewImg: '' },
|
|
1328
|
+
]);
|
|
1329
|
+
|
|
1330
|
+
expect(withThumb).toEqual({ mediaType: 'video', imageUrl: '', videoSrc: 'a.mp4', videoPreviewImg: 'a.png', buttons: [] });
|
|
1331
|
+
expect(withoutThumb).toEqual({ mediaType: 'video', imageUrl: '', videoSrc: 'b.mp4', buttons: [] });
|
|
1332
|
+
});
|
|
1333
|
+
});
|