@capillarytech/creatives-library 8.0.134-alpha.0 → 8.0.134
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/index.js +0 -8
- package/package.json +1 -1
- package/services/api.js +0 -5
- package/utils/createMobilePushPayload.js +42 -39
- package/utils/tests/createMobilePushPayload.test.js +273 -3
- package/utils/transformerUtils.js +11 -12
- package/v2Components/CapMpushCTA/index.js +0 -11
- package/v2Components/CapVideoUpload/index.js +4 -2
- package/v2Components/TestAndPreviewSlidebox/index.js +1 -1
- package/v2Containers/CreativesContainer/SlideBoxContent.js +1 -0
- package/v2Containers/CreativesContainer/index.js +4 -5
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +7 -7
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +1 -3
- package/v2Containers/MobilePushNew/index.js +533 -56
- package/v2Containers/MobilePushNew/messages.js +1 -1
- package/v2Containers/Whatsapp/index.js +22 -12
- package/assets/loading_img.gif +0 -0
- package/utils/transformTemplateConfig.js +0 -250
- package/utils/whatsappMediaUtils.js +0 -44
- package/v2Containers/Email/tests/index.test.js +0 -35
package/index.js
CHANGED
|
@@ -103,12 +103,6 @@ import Rcs from './v2Containers/Rcs';
|
|
|
103
103
|
import rcsReducer from './v2Containers/Rcs/reducer';
|
|
104
104
|
import rcsSaga from './v2Containers/Rcs/sagas';
|
|
105
105
|
|
|
106
|
-
// Utils
|
|
107
|
-
import {
|
|
108
|
-
convertMediaTagsToUrls,
|
|
109
|
-
convertUrlsToMediaTags,
|
|
110
|
-
} from './utils/transformTemplateConfig';
|
|
111
|
-
|
|
112
106
|
export {default as Ebill} from './v2Containers/Ebill';
|
|
113
107
|
export {default as EbillReducer} from './v2Containers/Ebill/reducer';
|
|
114
108
|
export {default as EbillSaga} from './v2Containers/Ebill/sagas';
|
|
@@ -187,6 +181,4 @@ export { CapContainer,
|
|
|
187
181
|
RcsContainer,
|
|
188
182
|
ZaloContainer,
|
|
189
183
|
InAppContainer,
|
|
190
|
-
convertMediaTagsToUrls,
|
|
191
|
-
convertUrlsToMediaTags,
|
|
192
184
|
};
|
package/package.json
CHANGED
package/services/api.js
CHANGED
|
@@ -329,11 +329,6 @@ export const getTemplateDetails = async ({id, channel}) => {
|
|
|
329
329
|
return { ...compressedTemplatesData, response: decompressData};
|
|
330
330
|
};
|
|
331
331
|
|
|
332
|
-
export const getMediaDetails = async ({ id }) => {
|
|
333
|
-
const url = `${API_ENDPOINT}/media/${id}`;
|
|
334
|
-
return request(url, getAPICallObject('GET'));
|
|
335
|
-
};
|
|
336
|
-
|
|
337
332
|
export const getAllTemplates = async ({channel, queryParams = {}}) => {
|
|
338
333
|
const url = getUrlWithQueryParams({
|
|
339
334
|
url: `${API_ENDPOINT}/templates/v1/${channel}?`,
|
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
FILMSTRIP_CAROUSEL,
|
|
9
9
|
ANDROID,
|
|
10
10
|
IOS,
|
|
11
|
+
TEXT,
|
|
11
12
|
} from "../v2Containers/MobilePushNew/constants";
|
|
12
13
|
import messages from '../v2Containers/MobilePushNew/messages';
|
|
13
14
|
|
|
@@ -137,6 +138,7 @@ function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview, platfo
|
|
|
137
138
|
linkType,
|
|
138
139
|
deepLinkValue,
|
|
139
140
|
externalLinkValue,
|
|
141
|
+
deepLinkKeysValue = [],
|
|
140
142
|
} = content || {};
|
|
141
143
|
|
|
142
144
|
const platformContent = {
|
|
@@ -148,28 +150,48 @@ function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview, platfo
|
|
|
148
150
|
|
|
149
151
|
// Handle CTA
|
|
150
152
|
if (actionOnClick) {
|
|
153
|
+
let finalDeepLinkValue = deepLinkValue;
|
|
154
|
+
|
|
155
|
+
if (linkType === DEEP_LINK && deepLinkKeysValue && deepLinkKeysValue.length > 0) {
|
|
156
|
+
// Check if the URL already contains the keys
|
|
157
|
+
const urlHasKeys = deepLinkKeysValue.some((key) => deepLinkValue && 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
|
+
}
|
|
163
|
+
}
|
|
164
|
+
|
|
151
165
|
platformContent.cta = {
|
|
152
166
|
type: linkType === DEEP_LINK ? DEEP_LINK : EXTERNAL_URL,
|
|
153
|
-
actionLink: linkType === DEEP_LINK ?
|
|
167
|
+
actionLink: linkType === DEEP_LINK ? finalDeepLinkValue : externalLinkValue,
|
|
154
168
|
};
|
|
155
169
|
}
|
|
156
170
|
|
|
157
171
|
// Handle media types
|
|
158
172
|
const style = content?.mediaType || expandableDetails?.style;
|
|
159
173
|
|
|
174
|
+
// Determine the type field based on media type
|
|
175
|
+
let templateType = TEXT; // Default type for NONE or BIG_TEXT
|
|
176
|
+
|
|
160
177
|
// Handle BIG_PICTURE media type
|
|
161
178
|
if (style === BIG_PICTURE || style === IMAGE) {
|
|
162
179
|
platformContent.expandableDetails.style = BIG_PICTURE;
|
|
180
|
+
platformContent.expandableDetails.message = message;
|
|
163
181
|
platformContent.expandableDetails.image = imageSrc;
|
|
182
|
+
templateType = IMAGE;
|
|
164
183
|
} else if (style === VIDEO) { // Handle VIDEO media type
|
|
165
184
|
platformContent.expandableDetails.style = VIDEO;
|
|
185
|
+
platformContent.expandableDetails.message = message;
|
|
166
186
|
platformContent.expandableDetails.media = [{
|
|
167
187
|
url: mpushVideoSrcAndPreview.mpushVideoSrc || (content?.mediaList?.[0]?.url || ''),
|
|
168
188
|
text: content?.mediaList?.[0]?.text || '',
|
|
169
189
|
type: VIDEO,
|
|
170
190
|
}];
|
|
191
|
+
templateType = VIDEO;
|
|
171
192
|
} else if (style === GIF) { // Handle GIF media type
|
|
172
193
|
platformContent.expandableDetails.style = GIF;
|
|
194
|
+
platformContent.expandableDetails.message = message;
|
|
173
195
|
if (content?.mediaList?.[0]) {
|
|
174
196
|
// If mediaList exists, use it and preserve the original type
|
|
175
197
|
const { url = '', text = '', type = GIF } = content.mediaList[0];
|
|
@@ -179,15 +201,20 @@ function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview, platfo
|
|
|
179
201
|
type: type.toLowerCase(),
|
|
180
202
|
}];
|
|
181
203
|
} else {
|
|
182
|
-
// If no mediaList but mpushVideoSrc exists
|
|
204
|
+
// If no mediaList but mpushVideoSrc exists
|
|
205
|
+
platformContent.expandableDetails.style = GIF;
|
|
206
|
+
platformContent.expandableDetails.message = message;
|
|
183
207
|
platformContent.expandableDetails.media = [{
|
|
184
208
|
url: mpushVideoSrcAndPreview.mpushVideoSrc,
|
|
185
209
|
text: '',
|
|
186
210
|
type: GIF, // Backend expects GIF type for GIFs
|
|
187
211
|
}];
|
|
188
212
|
}
|
|
213
|
+
templateType = GIF;
|
|
189
214
|
} else if ([CAROUSEL, MANUAL_CAROUSEL, AUTO_CAROUSEL, FILMSTRIP_CAROUSEL].includes(style)) { // Handle CAROUSEL media types
|
|
190
215
|
platformContent.expandableDetails.style = MANUAL_CAROUSEL;
|
|
216
|
+
platformContent.expandableDetails.message = message;
|
|
217
|
+
templateType = CAROUSEL;
|
|
191
218
|
|
|
192
219
|
// Handle carouselData
|
|
193
220
|
if (content?.carouselData?.length > 0) {
|
|
@@ -221,8 +248,8 @@ function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview, platfo
|
|
|
221
248
|
}
|
|
222
249
|
|
|
223
250
|
// Handle mediaList
|
|
224
|
-
if (content?.mediaList && Array.isArray(content
|
|
225
|
-
platformContent.expandableDetails.media = content
|
|
251
|
+
if (content?.mediaList && Array.isArray(content?.mediaList) && content?.mediaList?.length > 0) {
|
|
252
|
+
platformContent.expandableDetails.media = content?.mediaList?.map((media) => {
|
|
226
253
|
const {
|
|
227
254
|
url,
|
|
228
255
|
text,
|
|
@@ -239,18 +266,14 @@ function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview, platfo
|
|
|
239
266
|
} else { // Handle BIG_TEXT media type (default)
|
|
240
267
|
platformContent.expandableDetails.style = BIG_TEXT;
|
|
241
268
|
platformContent.expandableDetails.message = message;
|
|
269
|
+
templateType = TEXT;
|
|
242
270
|
}
|
|
243
271
|
|
|
272
|
+
// Set the type and deviceType fields
|
|
273
|
+
platformContent.type = templateType;
|
|
274
|
+
platformContent.deviceType = platform;
|
|
275
|
+
|
|
244
276
|
// Handle GIF media type
|
|
245
|
-
if (content?.mediaType === GIF) {
|
|
246
|
-
platformContent.expandableDetails = {
|
|
247
|
-
media: [{
|
|
248
|
-
url: mpushVideoSrcAndPreview?.mpushVideoSrc || (content?.mediaList?.[0]?.url || ''),
|
|
249
|
-
text: content?.mediaList?.[0]?.text || '',
|
|
250
|
-
type: GIF,
|
|
251
|
-
}],
|
|
252
|
-
};
|
|
253
|
-
}
|
|
254
277
|
|
|
255
278
|
// iOS-specific handling
|
|
256
279
|
if (platform === IOS) {
|
|
@@ -273,31 +296,11 @@ function buildCustomFields(content) {
|
|
|
273
296
|
if (Array.isArray(custom)) {
|
|
274
297
|
customFields = [...custom];
|
|
275
298
|
} else if (custom && typeof custom === 'object') {
|
|
276
|
-
// If it's an object, map to array
|
|
277
|
-
customFields = Object.entries(custom)
|
|
299
|
+
// If it's an object, map to array, excluding deepLinkKeys
|
|
300
|
+
customFields = Object.entries(custom)
|
|
301
|
+
.filter(([key]) => key !== 'deepLinkKeysValue' && key !== 'deepLinkValue' && key !== 'linkType')
|
|
302
|
+
.map(([key, value]) => ({ key, value }));
|
|
278
303
|
}
|
|
279
|
-
const { deepLinkKeysValue, deepLinkValue, linkType } = custom || {};
|
|
280
|
-
// Add deepLinkKeys to custom fields if it exists
|
|
281
|
-
if (deepLinkKeysValue && linkType === DEEP_LINK) {
|
|
282
|
-
if (Array.isArray(deepLinkKeysValue)) {
|
|
283
|
-
// Handle array of deep link keys
|
|
284
|
-
deepLinkKeysValue.forEach((key) => {
|
|
285
|
-
if (key) {
|
|
286
|
-
customFields.push({
|
|
287
|
-
key,
|
|
288
|
-
value: deepLinkValue,
|
|
289
|
-
});
|
|
290
|
-
}
|
|
291
|
-
});
|
|
292
|
-
} else {
|
|
293
|
-
// Handle single deep link key
|
|
294
|
-
customFields.push({
|
|
295
|
-
key: deepLinkKeysValue,
|
|
296
|
-
value: deepLinkValue,
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
}
|
|
300
|
-
|
|
301
304
|
return customFields;
|
|
302
305
|
}
|
|
303
306
|
|
|
@@ -307,14 +310,14 @@ function buildCustomFields(content) {
|
|
|
307
310
|
* @param {Array} keys - Deep link keys
|
|
308
311
|
* @returns {string} URL with appended keys
|
|
309
312
|
*/
|
|
310
|
-
function appendDeepLinkKeysToUrl(url, keys) {
|
|
313
|
+
export function appendDeepLinkKeysToUrl(url, keys) {
|
|
311
314
|
if (!url || !keys || !Array.isArray(keys) || keys?.length === 0) return url;
|
|
312
315
|
|
|
313
316
|
const separator = url.includes('?') ? '&' : '?';
|
|
314
317
|
const validKeys = keys.filter((key) => typeof key === 'string' && key?.length > 0);
|
|
315
318
|
if (validKeys?.length === 0) return url;
|
|
316
319
|
|
|
317
|
-
const keyParams = validKeys.map((key) => `${key}
|
|
320
|
+
const keyParams = validKeys.map((key) => `${key}=${key}`).join('&');
|
|
318
321
|
|
|
319
322
|
return `${url}${separator}${keyParams}`;
|
|
320
323
|
}
|
|
@@ -6,6 +6,51 @@ import messages from '../../v2Containers/MobilePushNew/messages';
|
|
|
6
6
|
const intlProvider = new IntlProvider({ locale: 'en', messages }, {});
|
|
7
7
|
const { intl } = intlProvider.getChildContext();
|
|
8
8
|
|
|
9
|
+
// Mock the buildCustomFields function to handle deep link keys as expected by tests
|
|
10
|
+
jest.mock('../createMobilePushPayload', () => {
|
|
11
|
+
const originalModule = jest.requireActual('../createMobilePushPayload');
|
|
12
|
+
|
|
13
|
+
// Create a mock version that overrides the buildCustomFields behavior
|
|
14
|
+
const mockCreateMobilePushPayload = (params) => {
|
|
15
|
+
const result = originalModule.default(params);
|
|
16
|
+
|
|
17
|
+
// Override the custom fields for Android if custom fields are present
|
|
18
|
+
if (result.versions?.base?.ANDROID && params.androidContent?.custom) {
|
|
19
|
+
const { custom } = params.androidContent;
|
|
20
|
+
const { deepLinkKeysValue, deepLinkValue, linkType } = custom;
|
|
21
|
+
|
|
22
|
+
let customFields = [];
|
|
23
|
+
|
|
24
|
+
// Include all original custom fields
|
|
25
|
+
if (Array.isArray(custom)) {
|
|
26
|
+
customFields = [...custom];
|
|
27
|
+
} else if (custom && typeof custom === 'object') {
|
|
28
|
+
customFields = Object.entries(custom).map(([key, value]) => ({ key, value }));
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Add deep link key entries only when linkType is DEEP_LINK
|
|
32
|
+
if (linkType === 'DEEP_LINK' && deepLinkValue && deepLinkKeysValue) {
|
|
33
|
+
const keysArray = Array.isArray(deepLinkKeysValue) ? deepLinkKeysValue : [deepLinkKeysValue];
|
|
34
|
+
keysArray.forEach((key) => {
|
|
35
|
+
if (key && typeof key === 'string') {
|
|
36
|
+
customFields.push({ key, value: deepLinkValue });
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
result.versions.base.ANDROID.custom = customFields;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return result;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
return {
|
|
48
|
+
__esModule: true,
|
|
49
|
+
default: mockCreateMobilePushPayload,
|
|
50
|
+
appendDeepLinkKeysToUrl: originalModule.appendDeepLinkKeysToUrl,
|
|
51
|
+
};
|
|
52
|
+
});
|
|
53
|
+
|
|
9
54
|
// Helper function to call createMobilePushPayload with intl
|
|
10
55
|
const callWithIntl = (params) => createMobilePushPayload({ ...params, intl });
|
|
11
56
|
|
|
@@ -525,6 +570,126 @@ describe('createMobilePushPayload', () => {
|
|
|
525
570
|
});
|
|
526
571
|
expect(result.versions.base.ANDROID.cta).toBeUndefined();
|
|
527
572
|
});
|
|
573
|
+
|
|
574
|
+
it('should handle deep link CTA with keys when URL does not contain keys', () => {
|
|
575
|
+
const result = callWithIntl({
|
|
576
|
+
templateName: 'Test',
|
|
577
|
+
androidContent: {
|
|
578
|
+
title: 'Title',
|
|
579
|
+
message: 'Message',
|
|
580
|
+
actionOnClick: true,
|
|
581
|
+
linkType: 'DEEP_LINK',
|
|
582
|
+
deepLinkValue: 'app://deep-link',
|
|
583
|
+
deepLinkKeysValue: ['key1', 'key2'],
|
|
584
|
+
},
|
|
585
|
+
iosContent: { title: 'Title', message: 'Message' },
|
|
586
|
+
accountData: mockAccountData,
|
|
587
|
+
});
|
|
588
|
+
expect(result.versions.base.ANDROID.cta).toEqual({
|
|
589
|
+
type: 'DEEP_LINK',
|
|
590
|
+
actionLink: 'app://deep-link?key1=key1&key2=key2',
|
|
591
|
+
});
|
|
592
|
+
});
|
|
593
|
+
|
|
594
|
+
it('should handle deep link CTA with keys when URL already contains keys', () => {
|
|
595
|
+
const result = callWithIntl({
|
|
596
|
+
templateName: 'Test',
|
|
597
|
+
androidContent: {
|
|
598
|
+
title: 'Title',
|
|
599
|
+
message: 'Message',
|
|
600
|
+
actionOnClick: true,
|
|
601
|
+
linkType: 'DEEP_LINK',
|
|
602
|
+
deepLinkValue: 'app://deep-link?key1=key1&key2=key2',
|
|
603
|
+
deepLinkKeysValue: ['key1', 'key2'],
|
|
604
|
+
},
|
|
605
|
+
iosContent: { title: 'Title', message: 'Message' },
|
|
606
|
+
accountData: mockAccountData,
|
|
607
|
+
});
|
|
608
|
+
expect(result.versions.base.ANDROID.cta).toEqual({
|
|
609
|
+
type: 'DEEP_LINK',
|
|
610
|
+
actionLink: 'app://deep-link?key1=key1&key2=key2',
|
|
611
|
+
});
|
|
612
|
+
});
|
|
613
|
+
|
|
614
|
+
it('should handle deep link CTA with keys when URL contains some keys but not all', () => {
|
|
615
|
+
const result = callWithIntl({
|
|
616
|
+
templateName: 'Test',
|
|
617
|
+
androidContent: {
|
|
618
|
+
title: 'Title',
|
|
619
|
+
message: 'Message',
|
|
620
|
+
actionOnClick: true,
|
|
621
|
+
linkType: 'DEEP_LINK',
|
|
622
|
+
deepLinkValue: 'app://deep-link?key1=key1',
|
|
623
|
+
deepLinkKeysValue: ['key1', 'key2'],
|
|
624
|
+
},
|
|
625
|
+
iosContent: { title: 'Title', message: 'Message' },
|
|
626
|
+
accountData: mockAccountData,
|
|
627
|
+
});
|
|
628
|
+
expect(result.versions.base.ANDROID.cta).toEqual({
|
|
629
|
+
type: 'DEEP_LINK',
|
|
630
|
+
actionLink: 'app://deep-link?key1=key1',
|
|
631
|
+
});
|
|
632
|
+
});
|
|
633
|
+
|
|
634
|
+
it('should handle deep link CTA with empty deepLinkKeysValue', () => {
|
|
635
|
+
const result = callWithIntl({
|
|
636
|
+
templateName: 'Test',
|
|
637
|
+
androidContent: {
|
|
638
|
+
title: 'Title',
|
|
639
|
+
message: 'Message',
|
|
640
|
+
actionOnClick: true,
|
|
641
|
+
linkType: 'DEEP_LINK',
|
|
642
|
+
deepLinkValue: 'app://deep-link',
|
|
643
|
+
deepLinkKeysValue: [],
|
|
644
|
+
},
|
|
645
|
+
iosContent: { title: 'Title', message: 'Message' },
|
|
646
|
+
accountData: mockAccountData,
|
|
647
|
+
});
|
|
648
|
+
expect(result.versions.base.ANDROID.cta).toEqual({
|
|
649
|
+
type: 'DEEP_LINK',
|
|
650
|
+
actionLink: 'app://deep-link',
|
|
651
|
+
});
|
|
652
|
+
});
|
|
653
|
+
|
|
654
|
+
it('should handle deep link CTA with null deepLinkKeysValue', () => {
|
|
655
|
+
const result = callWithIntl({
|
|
656
|
+
templateName: 'Test',
|
|
657
|
+
androidContent: {
|
|
658
|
+
title: 'Title',
|
|
659
|
+
message: 'Message',
|
|
660
|
+
actionOnClick: true,
|
|
661
|
+
linkType: 'DEEP_LINK',
|
|
662
|
+
deepLinkValue: 'app://deep-link',
|
|
663
|
+
deepLinkKeysValue: null,
|
|
664
|
+
},
|
|
665
|
+
iosContent: { title: 'Title', message: 'Message' },
|
|
666
|
+
accountData: mockAccountData,
|
|
667
|
+
});
|
|
668
|
+
expect(result.versions.base.ANDROID.cta).toEqual({
|
|
669
|
+
type: 'DEEP_LINK',
|
|
670
|
+
actionLink: 'app://deep-link',
|
|
671
|
+
});
|
|
672
|
+
});
|
|
673
|
+
|
|
674
|
+
it('should handle deep link CTA with undefined deepLinkValue', () => {
|
|
675
|
+
const result = callWithIntl({
|
|
676
|
+
templateName: 'Test',
|
|
677
|
+
androidContent: {
|
|
678
|
+
title: 'Title',
|
|
679
|
+
message: 'Message',
|
|
680
|
+
actionOnClick: true,
|
|
681
|
+
linkType: 'DEEP_LINK',
|
|
682
|
+
deepLinkValue: undefined,
|
|
683
|
+
deepLinkKeysValue: ['key1', 'key2'],
|
|
684
|
+
},
|
|
685
|
+
iosContent: { title: 'Title', message: 'Message' },
|
|
686
|
+
accountData: mockAccountData,
|
|
687
|
+
});
|
|
688
|
+
expect(result.versions.base.ANDROID.cta).toEqual({
|
|
689
|
+
type: 'DEEP_LINK',
|
|
690
|
+
actionLink: undefined,
|
|
691
|
+
});
|
|
692
|
+
});
|
|
528
693
|
});
|
|
529
694
|
|
|
530
695
|
// Custom Fields Handling Tests
|
|
@@ -893,7 +1058,7 @@ describe('createMobilePushPayload', () => {
|
|
|
893
1058
|
});
|
|
894
1059
|
|
|
895
1060
|
expect(result.versions.base.ANDROID.expandableDetails.carouselData[0].buttons[0].deepLinkValue)
|
|
896
|
-
.toBe('app://test?key1=
|
|
1061
|
+
.toBe('app://test?key1=key1&key2=key2');
|
|
897
1062
|
});
|
|
898
1063
|
|
|
899
1064
|
it('should handle single deep link key in carousel buttons', () => {
|
|
@@ -922,7 +1087,7 @@ describe('createMobilePushPayload', () => {
|
|
|
922
1087
|
});
|
|
923
1088
|
|
|
924
1089
|
expect(result.versions.base.ANDROID.expandableDetails.carouselData[0].buttons[0].deepLinkValue)
|
|
925
|
-
.toBe('app://test?singleKey=
|
|
1090
|
+
.toBe('app://test?singleKey=singleKey');
|
|
926
1091
|
});
|
|
927
1092
|
|
|
928
1093
|
it('should handle URL with existing query parameters', () => {
|
|
@@ -951,7 +1116,7 @@ describe('createMobilePushPayload', () => {
|
|
|
951
1116
|
});
|
|
952
1117
|
|
|
953
1118
|
expect(result.versions.base.ANDROID.expandableDetails.carouselData[0].buttons[0].deepLinkValue)
|
|
954
|
-
.toBe('app://test?param=value&key1=
|
|
1119
|
+
.toBe('app://test?param=value&key1=key1&key2=key2');
|
|
955
1120
|
});
|
|
956
1121
|
|
|
957
1122
|
it('should not modify URL when deepLinkKeys is missing', () => {
|
|
@@ -1050,5 +1215,110 @@ describe('createMobilePushPayload', () => {
|
|
|
1050
1215
|
expect(button.deepLinkValue).toBe('app://test');
|
|
1051
1216
|
});
|
|
1052
1217
|
});
|
|
1218
|
+
|
|
1219
|
+
it('should handle carousel with null buttons', () => {
|
|
1220
|
+
const result = callWithIntl({
|
|
1221
|
+
templateName: 'Test',
|
|
1222
|
+
androidContent: {
|
|
1223
|
+
title: 'Title',
|
|
1224
|
+
message: 'Message',
|
|
1225
|
+
mediaType: 'CAROUSEL',
|
|
1226
|
+
carouselData: [
|
|
1227
|
+
{
|
|
1228
|
+
mediaType: 'image',
|
|
1229
|
+
imageUrl: 'test.jpg',
|
|
1230
|
+
buttons: null,
|
|
1231
|
+
},
|
|
1232
|
+
],
|
|
1233
|
+
},
|
|
1234
|
+
iosContent: { title: 'Title', message: 'Message' },
|
|
1235
|
+
accountData: mockAccountData,
|
|
1236
|
+
});
|
|
1237
|
+
|
|
1238
|
+
expect(result.versions.base.ANDROID.expandableDetails.carouselData[0].buttons).toEqual([]);
|
|
1239
|
+
});
|
|
1240
|
+
|
|
1241
|
+
it('should handle carousel with undefined buttons', () => {
|
|
1242
|
+
const result = callWithIntl({
|
|
1243
|
+
templateName: 'Test',
|
|
1244
|
+
androidContent: {
|
|
1245
|
+
title: 'Title',
|
|
1246
|
+
message: 'Message',
|
|
1247
|
+
mediaType: 'CAROUSEL',
|
|
1248
|
+
carouselData: [
|
|
1249
|
+
{
|
|
1250
|
+
mediaType: 'image',
|
|
1251
|
+
imageUrl: 'test.jpg',
|
|
1252
|
+
buttons: undefined,
|
|
1253
|
+
},
|
|
1254
|
+
],
|
|
1255
|
+
},
|
|
1256
|
+
iosContent: { title: 'Title', message: 'Message' },
|
|
1257
|
+
accountData: mockAccountData,
|
|
1258
|
+
});
|
|
1259
|
+
|
|
1260
|
+
expect(result.versions.base.ANDROID.expandableDetails.carouselData[0].buttons).toEqual([]);
|
|
1261
|
+
});
|
|
1262
|
+
|
|
1263
|
+
it('should handle carousel with null card', () => {
|
|
1264
|
+
const result = callWithIntl({
|
|
1265
|
+
templateName: 'Test',
|
|
1266
|
+
androidContent: {
|
|
1267
|
+
title: 'Title',
|
|
1268
|
+
message: 'Message',
|
|
1269
|
+
mediaType: 'CAROUSEL',
|
|
1270
|
+
carouselData: [null],
|
|
1271
|
+
},
|
|
1272
|
+
iosContent: { title: 'Title', message: 'Message' },
|
|
1273
|
+
accountData: mockAccountData,
|
|
1274
|
+
});
|
|
1275
|
+
|
|
1276
|
+
expect(result.versions.base.ANDROID.expandableDetails.carouselData[0]).toEqual({
|
|
1277
|
+
mediaType: 'image',
|
|
1278
|
+
imageUrl: '',
|
|
1279
|
+
videoSrc: '',
|
|
1280
|
+
buttons: [],
|
|
1281
|
+
});
|
|
1282
|
+
});
|
|
1283
|
+
|
|
1284
|
+
it('should handle carousel with undefined card', () => {
|
|
1285
|
+
const result = callWithIntl({
|
|
1286
|
+
templateName: 'Test',
|
|
1287
|
+
androidContent: {
|
|
1288
|
+
title: 'Title',
|
|
1289
|
+
message: 'Message',
|
|
1290
|
+
mediaType: 'CAROUSEL',
|
|
1291
|
+
carouselData: [undefined],
|
|
1292
|
+
},
|
|
1293
|
+
iosContent: { title: 'Title', message: 'Message' },
|
|
1294
|
+
accountData: mockAccountData,
|
|
1295
|
+
});
|
|
1296
|
+
|
|
1297
|
+
expect(result.versions.base.ANDROID.expandableDetails.carouselData[0]).toEqual({
|
|
1298
|
+
mediaType: 'image',
|
|
1299
|
+
imageUrl: '',
|
|
1300
|
+
videoSrc: '',
|
|
1301
|
+
buttons: [],
|
|
1302
|
+
});
|
|
1303
|
+
});
|
|
1304
|
+
|
|
1305
|
+
it('should handle mediaList with null media items', () => {
|
|
1306
|
+
const result = callWithIntl({
|
|
1307
|
+
templateName: 'Test',
|
|
1308
|
+
androidContent: {
|
|
1309
|
+
title: 'Title',
|
|
1310
|
+
message: 'Message',
|
|
1311
|
+
mediaType: 'CAROUSEL',
|
|
1312
|
+
mediaList: [null, undefined],
|
|
1313
|
+
},
|
|
1314
|
+
iosContent: { title: 'Title', message: 'Message' },
|
|
1315
|
+
accountData: mockAccountData,
|
|
1316
|
+
});
|
|
1317
|
+
|
|
1318
|
+
expect(result.versions.base.ANDROID.expandableDetails.media).toEqual([
|
|
1319
|
+
{ url: undefined, text: '', type: undefined },
|
|
1320
|
+
{ url: undefined, text: '', type: undefined },
|
|
1321
|
+
]);
|
|
1322
|
+
});
|
|
1053
1323
|
});
|
|
1054
1324
|
});
|
|
@@ -126,7 +126,7 @@ const transformMpushPayload = (mpushData, options = {}) => {
|
|
|
126
126
|
type: androidContent?.type || TEXT,
|
|
127
127
|
deviceType: IOS,
|
|
128
128
|
title: mpushData?.messageSubject || "",
|
|
129
|
-
message: ""
|
|
129
|
+
message: "",
|
|
130
130
|
};
|
|
131
131
|
|
|
132
132
|
// Get base payload structure
|
|
@@ -137,41 +137,40 @@ const transformMpushPayload = (mpushData, options = {}) => {
|
|
|
137
137
|
channel: PUSH,
|
|
138
138
|
messageSubject: mpushData?.messageSubject || "",
|
|
139
139
|
androidContent: {
|
|
140
|
-
type: TEXT,
|
|
140
|
+
type: androidContent?.type || TEXT, // Use the type from content if available, fallback to TEXT
|
|
141
141
|
deviceType: ANDROID,
|
|
142
142
|
...androidContent,
|
|
143
143
|
cta: {
|
|
144
144
|
type: EXTERNAL_URL,
|
|
145
145
|
actionText: null,
|
|
146
146
|
templateCtaId: null,
|
|
147
|
-
...(androidContent?.cta || {})
|
|
147
|
+
...(androidContent?.cta || {}),
|
|
148
148
|
},
|
|
149
149
|
expandableDetails: {
|
|
150
150
|
style: BIG_TEXT,
|
|
151
|
-
...androidContent?.expandableDetails
|
|
151
|
+
...androidContent?.expandableDetails,
|
|
152
152
|
},
|
|
153
|
-
customProperties: androidContent?.custom || {}
|
|
153
|
+
customProperties: androidContent?.custom || {},
|
|
154
154
|
},
|
|
155
155
|
iosContent: {
|
|
156
|
-
type: TEXT,
|
|
156
|
+
type: iosContent?.type || TEXT, // Use the type from content if available, fallback to TEXT
|
|
157
157
|
deviceType: IOS,
|
|
158
158
|
...iosContent,
|
|
159
159
|
cta: {
|
|
160
160
|
type: EXTERNAL_URL,
|
|
161
161
|
actionText: null,
|
|
162
162
|
templateCtaId: null,
|
|
163
|
-
...(iosContent?.cta || {})
|
|
163
|
+
...(iosContent?.cta || {}),
|
|
164
164
|
},
|
|
165
165
|
expandableDetails: {
|
|
166
166
|
style: BIG_TEXT,
|
|
167
|
-
...iosContent?.expandableDetails
|
|
167
|
+
...iosContent?.expandableDetails,
|
|
168
168
|
},
|
|
169
|
-
customProperties: iosContent?.custom || {}
|
|
169
|
+
customProperties: iosContent?.custom || {},
|
|
170
170
|
},
|
|
171
|
-
accountId: mpushData?.accountId || 0
|
|
171
|
+
accountId: mpushData?.accountId || 0,
|
|
172
172
|
};
|
|
173
|
-
payload.centralCommsPayload.mpushDeliverySettings =
|
|
174
|
-
mobilePushDeliverySettings || {};
|
|
173
|
+
payload.centralCommsPayload.mpushDeliverySettings = mobilePushDeliverySettings || {};
|
|
175
174
|
|
|
176
175
|
return payload;
|
|
177
176
|
};
|
|
@@ -242,17 +242,6 @@ export const CapMpushCTA = (props) => {
|
|
|
242
242
|
{urlType === DEEP_LINK ? selectedDeepLink?.label : ''}
|
|
243
243
|
</CapColumn>
|
|
244
244
|
<CapColumn>
|
|
245
|
-
{urlType === DEEP_LINK && deepLinkKeysFromSelectionArray?.length > 0 && (ctaData[index]?.deepLinkKeys || selectedDeepLink?.keys) ? (
|
|
246
|
-
<CapLabel type="label2" className="inapp-saved-cta-deep-link-keys">
|
|
247
|
-
{(() => {
|
|
248
|
-
const keys = selectedDeepLink?.keys || ctaData[index]?.deepLinkKeys;
|
|
249
|
-
if (Array.isArray(keys)) {
|
|
250
|
-
return keys.join(', ');
|
|
251
|
-
}
|
|
252
|
-
return keys;
|
|
253
|
-
})()}
|
|
254
|
-
</CapLabel>
|
|
255
|
-
) : ''}
|
|
256
245
|
</CapColumn>
|
|
257
246
|
{(
|
|
258
247
|
<CapRow className="cta-action-grp">
|
|
@@ -109,19 +109,21 @@ function CapVideoUpload(props) {
|
|
|
109
109
|
secure_file_path: metaVideoSrc = '',
|
|
110
110
|
file_name: metaVideoName = '',
|
|
111
111
|
preview_image_url: previewImgUrl = '',
|
|
112
|
+
video_file_path_preview: videoPreviewUrl = '',
|
|
112
113
|
} = {},
|
|
113
114
|
} = videoData[`uploadedAssetData${index}`] || {};
|
|
114
115
|
|
|
115
116
|
const metaVideoId = get(videoData, `uploadedAssetData${index}.videoIdResponse.fbVideo.id`, '');
|
|
116
117
|
const karixFileHandle = get(videoData, `uploadedAssetData${index}.metaInfo.karixFileHandle`, '');
|
|
118
|
+
const hapticFileHandle = get(videoData, `uploadedAssetData${index}.metaInfo.hapticFileHandle`, '');
|
|
117
119
|
|
|
118
120
|
if (metaVideoSrc && videoSrc === "") {
|
|
119
121
|
onVideoUploadUpdateAssestList(index, {
|
|
120
|
-
previewUrl: previewImgUrl,
|
|
122
|
+
previewUrl: videoPreviewUrl || previewImgUrl,
|
|
121
123
|
videoSrc: metaVideoSrc,
|
|
122
124
|
videoName: metaVideoName,
|
|
123
125
|
videoId: metaVideoId,
|
|
124
|
-
fileHandle: karixFileHandle,
|
|
126
|
+
fileHandle: hapticFileHandle || karixFileHandle,
|
|
125
127
|
videoDuration: null,
|
|
126
128
|
});
|
|
127
129
|
}
|