@capillarytech/creatives-library 8.0.298 → 8.0.299-alpha.0
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 +1 -0
- package/package.json +1 -1
- package/services/api.js +17 -0
- package/services/tests/api.test.js +85 -0
- package/utils/common.js +12 -5
- package/utils/commonUtils.js +10 -0
- package/utils/tests/commonUtil.test.js +169 -0
- package/v2Components/CapDeviceContent/index.js +10 -7
- package/v2Components/CommonTestAndPreview/AddTestCustomer.js +42 -0
- package/v2Components/CommonTestAndPreview/CustomerCreationModal.js +284 -0
- package/v2Components/CommonTestAndPreview/ExistingCustomerModal.js +72 -0
- package/v2Components/CommonTestAndPreview/SendTestMessage.js +78 -49
- package/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +189 -4
- package/v2Components/CommonTestAndPreview/actions.js +10 -0
- package/v2Components/CommonTestAndPreview/constants.js +18 -1
- package/v2Components/CommonTestAndPreview/index.js +259 -14
- package/v2Components/CommonTestAndPreview/messages.js +94 -0
- package/v2Components/CommonTestAndPreview/reducer.js +10 -0
- package/v2Components/CommonTestAndPreview/tests/AddTestCustomer.test.js +66 -0
- package/v2Components/CommonTestAndPreview/tests/CommonTestAndPreview.addTestCustomer.test.js +653 -0
- package/v2Components/CommonTestAndPreview/tests/CustomerCreationModal.test.js +316 -0
- package/v2Components/CommonTestAndPreview/tests/ExistingCustomerModal.test.js +114 -0
- package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +53 -0
- package/v2Components/CommonTestAndPreview/tests/constants.test.js +25 -2
- package/v2Components/CommonTestAndPreview/tests/index.test.js +7 -0
- package/v2Components/CommonTestAndPreview/tests/reducer.test.js +71 -0
- package/v2Components/CommonTestAndPreview/tests/selectors.test.js +17 -0
- package/v2Components/HtmlEditor/hooks/__tests__/useValidation.test.js +320 -0
- package/v2Components/HtmlEditor/utils/__tests__/htmlValidator.enhanced.test.js +132 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +35 -3
- package/v2Containers/InApp/index.js +182 -13
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +1408 -1276
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +321 -288
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +5246 -4872
package/constants/unified.js
CHANGED
|
@@ -45,6 +45,7 @@ export const GIFT_CARDS = 'GIFT_CARDS';
|
|
|
45
45
|
export const PROMO_ENGINE = 'PROMO_ENGINE';
|
|
46
46
|
export const LIQUID_SUPPORT = 'ENABLE_LIQUID_SUPPORT';
|
|
47
47
|
export const ENABLE_NEW_MPUSH = 'ENABLE_NEW_MPUSH';
|
|
48
|
+
export const ENABLE_NEW_EDITOR_FLOW_INAPP = 'ENABLE_NEW_EDITOR_FLOW_INAPP';
|
|
48
49
|
export const SUPPORT_CK_EDITOR = 'SUPPORT_CK_EDITOR';
|
|
49
50
|
export const CUSTOM_TAG = 'CustomTagMessage';
|
|
50
51
|
export const CUSTOMER_EXTENDED_FIELD = 'Customer extended fields';
|
package/package.json
CHANGED
package/services/api.js
CHANGED
|
@@ -735,4 +735,21 @@ export const getBeePopupBuilderToken = () => {
|
|
|
735
735
|
return request(url, getAPICallObject('GET'));
|
|
736
736
|
};
|
|
737
737
|
|
|
738
|
+
/**
|
|
739
|
+
* Look up member by identifier (email or mobile) for add test customer flow.
|
|
740
|
+
* Uses standard API auth headers (no x-cap-ct) to avoid CORS preflight issues with node layer.
|
|
741
|
+
* @param {string} identifierType - 'email' or 'mobile'
|
|
742
|
+
* @param {string} identifierValue - email address or mobile number
|
|
743
|
+
* @returns {Promise} Promise resolving to { success, response: { exists, customerDetails } }
|
|
744
|
+
*/
|
|
745
|
+
export const getMembersLookup = (identifierType, identifierValue) => {
|
|
746
|
+
const url = `${API_ENDPOINT}/members?identifierType=${encodeURIComponent(identifierType)}&identifierValue=${encodeURIComponent(identifierValue)}`;
|
|
747
|
+
return request(url, getAPICallObject('GET'));
|
|
748
|
+
};
|
|
749
|
+
|
|
750
|
+
export const createTestCustomer = (payload) => {
|
|
751
|
+
const url = `${API_ENDPOINT}/testCustomers`;
|
|
752
|
+
return request(url, getAPICallObject('POST', payload));
|
|
753
|
+
};
|
|
754
|
+
|
|
738
755
|
export {request, getAPICallObject};
|
|
@@ -28,6 +28,8 @@ import {
|
|
|
28
28
|
getAssetStatus,
|
|
29
29
|
getBeePopupBuilderToken,
|
|
30
30
|
getCmsAccounts,
|
|
31
|
+
getMembersLookup,
|
|
32
|
+
createTestCustomer,
|
|
31
33
|
} from '../api';
|
|
32
34
|
import { mockData } from './mockData';
|
|
33
35
|
import getSchema from '../getSchema';
|
|
@@ -1007,3 +1009,86 @@ describe('getCmsAccounts', () => {
|
|
|
1007
1009
|
expect(result).toBeInstanceOf(Promise);
|
|
1008
1010
|
});
|
|
1009
1011
|
});
|
|
1012
|
+
|
|
1013
|
+
describe('getMembersLookup', () => {
|
|
1014
|
+
beforeEach(() => {
|
|
1015
|
+
global.fetch = jest.fn();
|
|
1016
|
+
global.fetch.mockReturnValue(Promise.resolve({
|
|
1017
|
+
status: 200,
|
|
1018
|
+
json: () => Promise.resolve({ success: true, response: { exists: false, customerDetails: [] } }),
|
|
1019
|
+
}));
|
|
1020
|
+
});
|
|
1021
|
+
|
|
1022
|
+
it('should return a Promise', () => {
|
|
1023
|
+
const result = getMembersLookup('email', 'user@example.com');
|
|
1024
|
+
expect(result).toBeInstanceOf(Promise);
|
|
1025
|
+
});
|
|
1026
|
+
|
|
1027
|
+
it('should be callable with identifierType and identifierValue', () => {
|
|
1028
|
+
expect(typeof getMembersLookup).toBe('function');
|
|
1029
|
+
const result = getMembersLookup('mobile', '9123456789');
|
|
1030
|
+
expect(result).toBeInstanceOf(Promise);
|
|
1031
|
+
});
|
|
1032
|
+
|
|
1033
|
+
it('should call fetch with correct URL encoding and GET method', () => {
|
|
1034
|
+
global.fetch.mockClear();
|
|
1035
|
+
getMembersLookup('email', 'user+test@example.com');
|
|
1036
|
+
expect(global.fetch).toHaveBeenCalled();
|
|
1037
|
+
const calls = global.fetch.mock.calls;
|
|
1038
|
+
const withEncoding = calls.find(
|
|
1039
|
+
(c) =>
|
|
1040
|
+
c[0] &&
|
|
1041
|
+
String(c[0]).includes('members') &&
|
|
1042
|
+
String(c[0]).includes('identifierType=email') &&
|
|
1043
|
+
String(c[0]).includes('user%2Btest%40example.com')
|
|
1044
|
+
);
|
|
1045
|
+
if (withEncoding) {
|
|
1046
|
+
const [url, options] = withEncoding;
|
|
1047
|
+
expect(url).toContain('identifierType=email');
|
|
1048
|
+
expect(url).toContain('identifierValue=user%2Btest%40example.com');
|
|
1049
|
+
expect(options?.method || 'GET').toBe('GET');
|
|
1050
|
+
}
|
|
1051
|
+
const anyMembersCall = calls.find((c) => c[0] && String(c[0]).includes('members'));
|
|
1052
|
+
expect(anyMembersCall).toBeDefined();
|
|
1053
|
+
expect(anyMembersCall[0]).toContain('identifierType=');
|
|
1054
|
+
expect(anyMembersCall[0]).toContain('identifierValue=');
|
|
1055
|
+
expect(anyMembersCall[1]?.method || 'GET').toBe('GET');
|
|
1056
|
+
});
|
|
1057
|
+
});
|
|
1058
|
+
|
|
1059
|
+
describe('createTestCustomer', () => {
|
|
1060
|
+
beforeEach(() => {
|
|
1061
|
+
global.fetch = jest.fn();
|
|
1062
|
+
global.fetch.mockReturnValue(Promise.resolve({
|
|
1063
|
+
status: 200,
|
|
1064
|
+
json: () => Promise.resolve({ success: true }),
|
|
1065
|
+
}));
|
|
1066
|
+
});
|
|
1067
|
+
|
|
1068
|
+
it('should return a Promise', () => {
|
|
1069
|
+
const payload = { customer: { email: 'test@example.com', firstName: 'Test' } };
|
|
1070
|
+
const result = createTestCustomer(payload);
|
|
1071
|
+
expect(result).toBeInstanceOf(Promise);
|
|
1072
|
+
});
|
|
1073
|
+
|
|
1074
|
+
it('should accept customerId payload for existing customer', () => {
|
|
1075
|
+
const payload = { customerId: 'cust-123' };
|
|
1076
|
+
const result = createTestCustomer(payload);
|
|
1077
|
+
expect(result).toBeInstanceOf(Promise);
|
|
1078
|
+
expect(global.fetch).toHaveBeenCalled();
|
|
1079
|
+
const lastCall = global.fetch.mock.calls[global.fetch.mock.calls.length - 1];
|
|
1080
|
+
expect(lastCall[0]).toContain('testCustomers');
|
|
1081
|
+
expect(lastCall[1].method).toBe('POST');
|
|
1082
|
+
expect(lastCall[1].body).toBe(JSON.stringify(payload));
|
|
1083
|
+
});
|
|
1084
|
+
|
|
1085
|
+
it('should call fetch with /testCustomers URL and POST method', () => {
|
|
1086
|
+
const payload = { customer: { email: 'n@b.co', firstName: 'N' } };
|
|
1087
|
+
createTestCustomer(payload);
|
|
1088
|
+
expect(global.fetch).toHaveBeenCalled();
|
|
1089
|
+
const lastCall = global.fetch.mock.calls[global.fetch.mock.calls.length - 1];
|
|
1090
|
+
expect(lastCall[0]).toContain('testCustomers');
|
|
1091
|
+
expect(lastCall[1].method).toBe('POST');
|
|
1092
|
+
expect(lastCall[1].body).toBe(JSON.stringify(payload));
|
|
1093
|
+
});
|
|
1094
|
+
});
|
package/utils/common.js
CHANGED
|
@@ -24,7 +24,8 @@ import {
|
|
|
24
24
|
ENABLE_WEBPUSH,
|
|
25
25
|
LIQUID_SUPPORT,
|
|
26
26
|
SUPPORT_CK_EDITOR,
|
|
27
|
-
ENABLE_NEW_MPUSH
|
|
27
|
+
ENABLE_NEW_MPUSH,
|
|
28
|
+
ENABLE_NEW_EDITOR_FLOW_INAPP
|
|
28
29
|
} from '../constants/unified';
|
|
29
30
|
import { apiMessageFormatHandler } from './commonUtils';
|
|
30
31
|
|
|
@@ -137,10 +138,16 @@ export const isEmailUnsubscribeTagMandatory = Auth.hasFeatureAccess.bind(
|
|
|
137
138
|
EMAIL_UNSUBSCRIBE_TAG_MANDATORY,
|
|
138
139
|
);
|
|
139
140
|
|
|
140
|
-
export const hasNewMobilePushFeatureEnabled = Auth.hasFeatureAccess.bind(
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
);
|
|
141
|
+
// export const hasNewMobilePushFeatureEnabled = Auth.hasFeatureAccess.bind(
|
|
142
|
+
// null,
|
|
143
|
+
// ENABLE_NEW_MPUSH,
|
|
144
|
+
// );
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
export const hasNewEditorFlowInAppEnabled = () => {
|
|
149
|
+
return false;
|
|
150
|
+
}
|
|
144
151
|
|
|
145
152
|
//filtering tags based on scope
|
|
146
153
|
export const filterTags = (tagsToFilter, tagsList) => tagsList?.filter(
|
package/utils/commonUtils.js
CHANGED
|
@@ -18,6 +18,8 @@ import {
|
|
|
18
18
|
import { GLOBAL_CONVERT_OPTIONS } from "../v2Components/FormBuilder/constants";
|
|
19
19
|
import { checkSupport, extractNames, skipTags as defaultSkipTags, isInsideLiquidBlock } from "./tagValidations";
|
|
20
20
|
import { SMS_TRAI_VAR } from '../v2Containers/SmsTrai/Edit/constants';
|
|
21
|
+
import { EMAIL_REGEX, PHONE_REGEX } from '../v2Components/CommonTestAndPreview/constants';
|
|
22
|
+
|
|
21
23
|
export const apiMessageFormatHandler = (id, fallback) => (
|
|
22
24
|
<FormattedMessage id={id} defaultMessage={fallback} />
|
|
23
25
|
);
|
|
@@ -587,3 +589,11 @@ export const checkForPersonalizationTokens = (formData) => {
|
|
|
587
589
|
}
|
|
588
590
|
return false;
|
|
589
591
|
};
|
|
592
|
+
|
|
593
|
+
export const isValidEmail = (email) => EMAIL_REGEX.test(email);
|
|
594
|
+
export const isValidMobile = (mobile) => PHONE_REGEX.test(mobile);
|
|
595
|
+
|
|
596
|
+
export const formatPhoneNumber = (phone) => {
|
|
597
|
+
if (!phone) return '';
|
|
598
|
+
return String(phone).replace(/[^\d]/g, '');
|
|
599
|
+
};
|
|
@@ -8,6 +8,11 @@ import {
|
|
|
8
8
|
validateCarouselCards,
|
|
9
9
|
hasPersonalizationTags,
|
|
10
10
|
checkForPersonalizationTokens,
|
|
11
|
+
isValidEmail,
|
|
12
|
+
isValidMobile,
|
|
13
|
+
formatPhoneNumber,
|
|
14
|
+
getMessageForDevice,
|
|
15
|
+
getTitleForDevice,
|
|
11
16
|
} from "../commonUtils";
|
|
12
17
|
import { skipTags } from "../tagValidations";
|
|
13
18
|
import { SMS_TRAI_VAR } from '../../v2Containers/SmsTrai/Edit/constants';
|
|
@@ -586,6 +591,170 @@ describe("validateLiquidTemplateContent", () => {
|
|
|
586
591
|
});
|
|
587
592
|
});
|
|
588
593
|
|
|
594
|
+
describe("isValidEmail", () => {
|
|
595
|
+
it("returns true for valid email addresses", () => {
|
|
596
|
+
expect(isValidEmail("user@example.com")).toBe(true);
|
|
597
|
+
expect(isValidEmail("test.user@domain.co")).toBe(true);
|
|
598
|
+
expect(isValidEmail("a@b.co")).toBe(true);
|
|
599
|
+
});
|
|
600
|
+
|
|
601
|
+
it("returns false for invalid email addresses", () => {
|
|
602
|
+
expect(isValidEmail("")).toBe(false);
|
|
603
|
+
expect(isValidEmail("invalid")).toBe(false);
|
|
604
|
+
expect(isValidEmail("@nodomain.com")).toBe(false);
|
|
605
|
+
expect(isValidEmail("noatsign.com")).toBe(false);
|
|
606
|
+
expect(isValidEmail("missingtld@domain")).toBe(false);
|
|
607
|
+
expect(isValidEmail(" user@example.com ")).toBe(false);
|
|
608
|
+
});
|
|
609
|
+
|
|
610
|
+
it("returns true for edge case single-char local part", () => {
|
|
611
|
+
expect(isValidEmail("x@y.co")).toBe(true);
|
|
612
|
+
});
|
|
613
|
+
});
|
|
614
|
+
|
|
615
|
+
describe("isValidMobile", () => {
|
|
616
|
+
it("returns true for valid mobile numbers (8-15 digits, no leading zero)", () => {
|
|
617
|
+
expect(isValidMobile("12345678")).toBe(true);
|
|
618
|
+
expect(isValidMobile("9123456789")).toBe(true);
|
|
619
|
+
expect(isValidMobile("123456789012345")).toBe(true);
|
|
620
|
+
});
|
|
621
|
+
|
|
622
|
+
it("returns false for invalid mobile numbers", () => {
|
|
623
|
+
expect(isValidMobile("")).toBe(false);
|
|
624
|
+
expect(isValidMobile("01234567")).toBe(false);
|
|
625
|
+
expect(isValidMobile("1234567")).toBe(false);
|
|
626
|
+
expect(isValidMobile("1234567890123456")).toBe(false);
|
|
627
|
+
expect(isValidMobile("abc12345678")).toBe(false);
|
|
628
|
+
expect(isValidMobile("12345 67890")).toBe(false);
|
|
629
|
+
});
|
|
630
|
+
|
|
631
|
+
it("returns true for exactly 8 and exactly 15 digits", () => {
|
|
632
|
+
expect(isValidMobile("12345678")).toBe(true);
|
|
633
|
+
expect(isValidMobile("123456789012345")).toBe(true);
|
|
634
|
+
});
|
|
635
|
+
});
|
|
636
|
+
|
|
637
|
+
describe("formatPhoneNumber", () => {
|
|
638
|
+
it("returns empty string for falsy input", () => {
|
|
639
|
+
expect(formatPhoneNumber("")).toBe("");
|
|
640
|
+
expect(formatPhoneNumber(null)).toBe("");
|
|
641
|
+
expect(formatPhoneNumber(undefined)).toBe("");
|
|
642
|
+
});
|
|
643
|
+
|
|
644
|
+
it("strips non-digit characters", () => {
|
|
645
|
+
expect(formatPhoneNumber("91 234 567 890")).toBe("91234567890");
|
|
646
|
+
expect(formatPhoneNumber("+91-234567890")).toBe("91234567890");
|
|
647
|
+
expect(formatPhoneNumber("(123) 456-7890")).toBe("1234567890");
|
|
648
|
+
});
|
|
649
|
+
|
|
650
|
+
it("returns digits-only string unchanged", () => {
|
|
651
|
+
expect(formatPhoneNumber("9123456789")).toBe("9123456789");
|
|
652
|
+
});
|
|
653
|
+
|
|
654
|
+
it("returns empty string for whitespace-only input", () => {
|
|
655
|
+
expect(formatPhoneNumber(" ")).toBe("");
|
|
656
|
+
});
|
|
657
|
+
});
|
|
658
|
+
|
|
659
|
+
describe("hasPersonalizationTags", () => {
|
|
660
|
+
it("returns true when text has liquid tags {{ }}", () => {
|
|
661
|
+
expect(hasPersonalizationTags("Hello {{name}}")).toBe(true);
|
|
662
|
+
expect(hasPersonalizationTags("{{foo}}")).toBe(true);
|
|
663
|
+
});
|
|
664
|
+
|
|
665
|
+
it("returns true when text has bracket tags [ ]", () => {
|
|
666
|
+
expect(hasPersonalizationTags("Hello [event.name]")).toBe(true);
|
|
667
|
+
expect(hasPersonalizationTags("[tag]")).toBe(true);
|
|
668
|
+
});
|
|
669
|
+
|
|
670
|
+
it("returns false for empty or no tags", () => {
|
|
671
|
+
expect(hasPersonalizationTags("")).toBeFalsy();
|
|
672
|
+
expect(hasPersonalizationTags()).toBeFalsy();
|
|
673
|
+
expect(hasPersonalizationTags("plain text")).toBe(false);
|
|
674
|
+
expect(hasPersonalizationTags("only {{ open")).toBe(false);
|
|
675
|
+
});
|
|
676
|
+
|
|
677
|
+
it("returns false when only [ or only ] present without matching pair", () => {
|
|
678
|
+
expect(hasPersonalizationTags("only [ open")).toBe(false);
|
|
679
|
+
expect(hasPersonalizationTags("only ] close")).toBe(false);
|
|
680
|
+
});
|
|
681
|
+
|
|
682
|
+
it("returns true when liquid tags have content with spaces", () => {
|
|
683
|
+
expect(hasPersonalizationTags("Hello {{ customer.name }}")).toBe(true);
|
|
684
|
+
});
|
|
685
|
+
});
|
|
686
|
+
|
|
687
|
+
describe("getMessageForDevice", () => {
|
|
688
|
+
it("returns message for device from templateData", () => {
|
|
689
|
+
const templateData = {
|
|
690
|
+
versions: {
|
|
691
|
+
android: { base: { expandableDetails: { message: "Android msg" } } },
|
|
692
|
+
ios: { base: { expandableDetails: { message: "iOS msg" } } },
|
|
693
|
+
},
|
|
694
|
+
};
|
|
695
|
+
expect(getMessageForDevice(templateData, "android")).toBe("Android msg");
|
|
696
|
+
expect(getMessageForDevice(templateData, "ios")).toBe("iOS msg");
|
|
697
|
+
});
|
|
698
|
+
|
|
699
|
+
it("returns undefined for missing path", () => {
|
|
700
|
+
expect(getMessageForDevice(null, "android")).toBeUndefined();
|
|
701
|
+
expect(getMessageForDevice({}, "android")).toBeUndefined();
|
|
702
|
+
expect(getMessageForDevice({ versions: {} }, "android")).toBeUndefined();
|
|
703
|
+
});
|
|
704
|
+
|
|
705
|
+
it("returns undefined when base exists but expandableDetails is missing", () => {
|
|
706
|
+
expect(getMessageForDevice({ versions: { android: { base: {} } } }, "android")).toBeUndefined();
|
|
707
|
+
});
|
|
708
|
+
});
|
|
709
|
+
|
|
710
|
+
describe("getTitleForDevice", () => {
|
|
711
|
+
it("returns title for device from templateData", () => {
|
|
712
|
+
const templateData = {
|
|
713
|
+
versions: {
|
|
714
|
+
android: { base: { title: "Android title" } },
|
|
715
|
+
ios: { base: { title: "iOS title" } },
|
|
716
|
+
},
|
|
717
|
+
};
|
|
718
|
+
expect(getTitleForDevice(templateData, "android")).toBe("Android title");
|
|
719
|
+
expect(getTitleForDevice(templateData, "ios")).toBe("iOS title");
|
|
720
|
+
});
|
|
721
|
+
|
|
722
|
+
it("returns empty string for missing title", () => {
|
|
723
|
+
expect(getTitleForDevice(null, "android")).toBe("");
|
|
724
|
+
expect(getTitleForDevice({}, "android")).toBe("");
|
|
725
|
+
expect(getTitleForDevice({ versions: { android: { base: {} } } }, "android")).toBe("");
|
|
726
|
+
});
|
|
727
|
+
|
|
728
|
+
it("returns empty string when base.title is undefined", () => {
|
|
729
|
+
expect(getTitleForDevice({ versions: { android: { base: { title: undefined } } } }, "android")).toBe("");
|
|
730
|
+
});
|
|
731
|
+
});
|
|
732
|
+
|
|
733
|
+
describe("checkForPersonalizationTokens", () => {
|
|
734
|
+
it("returns true when formData contains liquid or bracket tokens", () => {
|
|
735
|
+
expect(checkForPersonalizationTokens({ 0: { content: "Hi {{name}}" } })).toBe(true);
|
|
736
|
+
expect(checkForPersonalizationTokens({ tab1: { message: "Hello [event.id]" } })).toBe(true);
|
|
737
|
+
});
|
|
738
|
+
|
|
739
|
+
it("returns false for empty or no tokens", () => {
|
|
740
|
+
expect(checkForPersonalizationTokens(null)).toBe(false);
|
|
741
|
+
expect(checkForPersonalizationTokens({})).toBe(false);
|
|
742
|
+
expect(checkForPersonalizationTokens({ 0: { content: "plain" } })).toBe(false);
|
|
743
|
+
});
|
|
744
|
+
|
|
745
|
+
it("returns false for non-object formData", () => {
|
|
746
|
+
expect(checkForPersonalizationTokens("string")).toBe(false);
|
|
747
|
+
});
|
|
748
|
+
|
|
749
|
+
it("returns true for two-level nested object containing token", () => {
|
|
750
|
+
expect(checkForPersonalizationTokens({ tab: { body: "Hi {{name}}" } })).toBe(true);
|
|
751
|
+
});
|
|
752
|
+
|
|
753
|
+
it("returns false for formData with array value (no string tokens)", () => {
|
|
754
|
+
expect(checkForPersonalizationTokens({ 0: { items: ["a", "b"] } })).toBe(false);
|
|
755
|
+
});
|
|
756
|
+
});
|
|
757
|
+
|
|
589
758
|
describe("validateMobilePushContent", () => {
|
|
590
759
|
const formatMessage = jest.fn(msg => msg.id);
|
|
591
760
|
const messages = {
|
|
@@ -63,6 +63,7 @@ const CapDeviceContent = (props) => {
|
|
|
63
63
|
deepLinkValue,
|
|
64
64
|
setDeepLinkValue,
|
|
65
65
|
onCopyTitleAndContent,
|
|
66
|
+
isOtherDeviceSupported,
|
|
66
67
|
tags,
|
|
67
68
|
onTagSelect,
|
|
68
69
|
handleOnTagsContextChange,
|
|
@@ -167,13 +168,15 @@ const CapDeviceContent = (props) => {
|
|
|
167
168
|
return (
|
|
168
169
|
<>
|
|
169
170
|
<CapRow className="creatives-device-content">
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
171
|
+
{isOtherDeviceSupported && (
|
|
172
|
+
<CapLink
|
|
173
|
+
title={isAndroid
|
|
174
|
+
? formatMessage(messages.copyContentFromIOS)
|
|
175
|
+
: formatMessage(messages.copyCotentFromAndroid)}
|
|
176
|
+
className="inapp-copy-content"
|
|
177
|
+
onClick={onCopyTitleAndContent}
|
|
178
|
+
/>
|
|
179
|
+
)}
|
|
177
180
|
<CapRow className="creatives-inapp-title">
|
|
178
181
|
<CapColumn
|
|
179
182
|
className="inapp-content-main"
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import PropTypes from "prop-types";
|
|
2
|
+
import { FormattedMessage } from "react-intl";
|
|
3
|
+
import CapButton from "@capillarytech/cap-ui-library/CapButton";
|
|
4
|
+
import CapIcon from "@capillarytech/cap-ui-library/CapIcon";
|
|
5
|
+
import messages from "./messages";
|
|
6
|
+
import React from "react";
|
|
7
|
+
|
|
8
|
+
const AddTestCustomerButton = ({
|
|
9
|
+
searchValue,
|
|
10
|
+
handleAddTestCustomer
|
|
11
|
+
}) => (
|
|
12
|
+
<CapButton
|
|
13
|
+
onClick={handleAddTestCustomer}
|
|
14
|
+
type="flat"
|
|
15
|
+
size="small"
|
|
16
|
+
className="test-customer-add-btn"
|
|
17
|
+
prefix={
|
|
18
|
+
<CapIcon
|
|
19
|
+
type="add-profile"
|
|
20
|
+
className="add-test-customer-icon"
|
|
21
|
+
/>
|
|
22
|
+
}
|
|
23
|
+
>
|
|
24
|
+
<FormattedMessage
|
|
25
|
+
{...messages.addTestCustomerWithValue}
|
|
26
|
+
values={{
|
|
27
|
+
searchValue: (
|
|
28
|
+
<span className="test-customer-add-btn-value" title={searchValue || ""}>
|
|
29
|
+
"{searchValue}"
|
|
30
|
+
</span>
|
|
31
|
+
),
|
|
32
|
+
}}
|
|
33
|
+
/>
|
|
34
|
+
</CapButton>
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
AddTestCustomerButton.propTypes = {
|
|
38
|
+
searchValue: PropTypes.string.isRequired,
|
|
39
|
+
handleAddTestCustomer: PropTypes.func.isRequired
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default AddTestCustomerButton;
|