@capillarytech/creatives-library 8.0.133-alpha.1 → 8.0.133
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/package.json
CHANGED
|
@@ -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
|
|
@@ -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
|
});
|
|
@@ -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
|
}
|
|
@@ -318,6 +318,7 @@ export const Whatsapp = (props) => {
|
|
|
318
318
|
videoUrl = '',
|
|
319
319
|
documentUrl = '',
|
|
320
320
|
karixFileHandle = '',
|
|
321
|
+
hapticFileHandle = '',
|
|
321
322
|
buttonType: btnType = WHATSAPP_BUTTON_TYPES.NONE,
|
|
322
323
|
buttons = [],
|
|
323
324
|
videoPreviewImg = '',
|
|
@@ -338,14 +339,23 @@ export const Whatsapp = (props) => {
|
|
|
338
339
|
});
|
|
339
340
|
setWhatsappDocSource(documentUrl);
|
|
340
341
|
setWhatsappDocParams(whatsappDocParams);
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
342
|
+
if (host === HOST_HAPTIC) {
|
|
343
|
+
updateAssetList(transformToVendorFormat({
|
|
344
|
+
...assetList,
|
|
345
|
+
previewUrl: videoPreviewImg,
|
|
346
|
+
videoSrc: videoUrl,
|
|
347
|
+
fileHandle: hapticFileHandle,
|
|
348
|
+
}, VENDOR_TYPES.HAPTIC));
|
|
349
|
+
} else {
|
|
350
|
+
updateAssetList({
|
|
351
|
+
...assetList,
|
|
352
|
+
previewUrl: videoPreviewImg,
|
|
353
|
+
videoSrc: videoUrl,
|
|
354
|
+
fileHandle: karixFileHandle,
|
|
355
|
+
});
|
|
356
|
+
}
|
|
347
357
|
if (isHaptic) {
|
|
348
|
-
setHapticFileHandle(
|
|
358
|
+
setHapticFileHandle(hapticFileHandle);
|
|
349
359
|
} else {
|
|
350
360
|
setKarixFileHandle(karixFileHandle);
|
|
351
361
|
}
|
|
@@ -1125,8 +1135,8 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
|
|
|
1125
1135
|
};
|
|
1126
1136
|
|
|
1127
1137
|
// Handle vendor-specific updates
|
|
1128
|
-
const handleVideoUploadUpdate = (index, data
|
|
1129
|
-
if (host === HOST_HAPTIC
|
|
1138
|
+
const handleVideoUploadUpdate = (index, data) => {
|
|
1139
|
+
if (host === HOST_HAPTIC) {
|
|
1130
1140
|
// Transform back to HAPTIC format
|
|
1131
1141
|
const hapticData = transformToVendorFormat(data, VENDOR_TYPES.HAPTIC);
|
|
1132
1142
|
setUpdateWhatsappVideoSrc(index, hapticData);
|
|
@@ -1143,11 +1153,11 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
|
|
|
1143
1153
|
handleCarouselValueChange(parseInt(activeIndex, 10), [{fieldName: "videoSrc", value: videoSrc}, {fieldName: "videoPreviewImg", value: previewUrl}, {fieldName: "assetList", value: data}, {fieldName: "karixFileHandle", value: fileHandle}]);
|
|
1144
1154
|
} else {
|
|
1145
1155
|
setWhatsappVideoSrcAndPreview({
|
|
1146
|
-
whatsappVideoSrc: videoSrc,
|
|
1147
|
-
whatsappVideoPreviewImg: previewUrl,
|
|
1156
|
+
whatsappVideoSrc: host === HOST_HAPTIC ? data?.metaInfo?.secure_file_path : videoSrc,
|
|
1157
|
+
whatsappVideoPreviewImg: host === HOST_HAPTIC ? data?.previewUrl : previewUrl,
|
|
1148
1158
|
});
|
|
1149
1159
|
if (isHaptic) {
|
|
1150
|
-
setHapticFileHandle(fileHandle);
|
|
1160
|
+
setHapticFileHandle(data?.metaInfo?.hapticFileHandle || fileHandle);
|
|
1151
1161
|
} else {
|
|
1152
1162
|
setKarixFileHandle(fileHandle);
|
|
1153
1163
|
}
|