@capillarytech/creatives-library 9.1.8-alpha.sprint-cap-214249.38 → 9.2.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 +4 -0
- package/index.js +13 -0
- package/package.json +1 -1
- package/services/getSchema.js +4 -1
- package/services/tests/getSchema.test.js +2 -2
- package/translations/en.json +1 -0
- package/translations/ja-JP.json +1 -0
- package/translations/zh.json +1 -0
- package/utils/common.js +6 -0
- package/utils/createMobilePushPayload.js +33 -47
- package/utils/tagValidations.js +35 -4
- package/utils/templateVarUtils.js +49 -0
- package/utils/tests/createMobilePushPayload.test.js +8 -102
- package/utils/tests/tagValidations.test.js +48 -0
- package/utils/tests/templateVarUtils.test.js +89 -0
- package/v2Components/CapMpushCTA/index.js +9 -10
- package/v2Components/CapMpushCTA/index.scss +3 -29
- package/v2Components/CapTagList/TagFallbackPanel.js +124 -0
- package/v2Components/CapTagList/constants.js +5 -0
- package/v2Components/CapTagList/index.js +46 -7
- package/v2Components/CapTagList/messages.js +44 -0
- package/v2Components/CapTagList/style.scss +113 -1
- package/v2Components/CapTagList/tests/TagFallback.test.js +222 -0
- package/v2Components/CapTagList/utils.js +17 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +13 -26
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -13
- package/v2Components/CommonTestAndPreview/constants.js +3 -2
- package/v2Components/CommonTestAndPreview/index.js +62 -62
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +5 -79
- package/v2Components/CommonTestAndPreview/tests/index.test.js +0 -86
- package/v2Components/CommonTestAndPreview/tests/utils.test.js +102 -0
- package/v2Components/CommonTestAndPreview/utils.js +42 -3
- package/v2Components/FormBuilder/Classic.js +24 -14
- package/v2Components/FormBuilder/Functional/channels/mobilepush/config.js +1 -0
- package/v2Components/FormBuilder/Functional/channels/mobilepush/getEditorErrorDescriptor.js +1 -1
- package/v2Components/FormBuilder/Functional/channels/mobilepush/tests/validate.test.js +57 -0
- package/v2Components/FormBuilder/Functional/channels/mobilepush/validate.js +4 -4
- package/v2Components/FormBuilder/Functional/channels/sms/getEditorErrorDescriptor.js +3 -0
- package/v2Components/FormBuilder/Functional/channels/sms/tests/getEditorErrorDescriptor.test.js +5 -0
- package/v2Components/FormBuilder/Functional/channels/sms/tests/validate.test.js +6 -0
- package/v2Components/FormBuilder/Functional/channels/sms/validate.js +3 -1
- package/v2Components/FormBuilder/Functional/renderers/mpushRenderers.js +3 -0
- package/v2Components/FormBuilder/Functional/tests/manual.typingPerf.test.js +135 -0
- package/v2Components/FormBuilder/Functional/tests/mpush.crossFlowParity.test.js +1 -1
- package/v2Components/FormBuilder/Functional/tests/mpush.ctaFlows.parity.test.js +320 -0
- package/v2Components/FormBuilder/Functional/tests/mpush.editContainer.parity.test.js +148 -0
- package/v2Components/FormBuilder/Functional/tests/mpush.libraryValidity.parity.test.js +152 -0
- package/v2Components/FormBuilder/Functional/tests/mpush.shellEvents.test.js +1 -1
- package/v2Components/FormBuilder/Functional/tests/mpush.singlePlatform.test.js +1 -1
- package/v2Components/FormBuilder/Functional/tests/mpushRenderers.test.js +22 -0
- package/v2Components/FormBuilder/tests/mpush.characterization.test.js +2 -2
- package/v2Components/TemplatePreview/_templatePreview.scss +2 -12
- package/v2Components/TemplatePreview/index.js +17 -30
- package/v2Components/TemplatePreview/tests/index.test.js +0 -61
- package/v2Containers/Cap/index.js +3 -0
- package/v2Containers/Cap/messages.js +4 -0
- package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +1 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +151 -70
- package/v2Containers/CreativesContainer/index.js +6 -3
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +0 -29
- package/v2Containers/InApp/index.js +4 -1
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +3 -0
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +2 -0
- package/v2Containers/Line/Container/Text/index.js +3 -1
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +16 -0
- package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +18 -0
- package/v2Containers/MobilePush/Create/_mobilePushCreate.scss +70 -0
- package/v2Containers/MobilePush/Create/actions.js +52 -0
- package/v2Containers/MobilePush/Create/constants.js +26 -0
- package/v2Containers/MobilePush/Create/index.js +2149 -0
- package/v2Containers/MobilePush/Create/messages.js +349 -0
- package/v2Containers/MobilePush/Create/reducer.js +72 -0
- package/v2Containers/MobilePush/Create/sagas.js +79 -0
- package/v2Containers/MobilePush/Create/selectors.js +29 -0
- package/v2Containers/MobilePush/Create/test/contentValidity.test.js +154 -0
- package/v2Containers/MobilePush/Create/test/saga.test.js +19 -0
- package/v2Containers/MobilePush/Create/test/stayOpenOnSave.test.js +80 -0
- package/v2Containers/MobilePush/Edit/_mobilePushCreate.scss +65 -0
- package/v2Containers/MobilePush/Edit/actions.js +94 -0
- package/v2Containers/MobilePush/Edit/constants.js +37 -0
- package/v2Containers/MobilePush/Edit/index.js +2407 -0
- package/v2Containers/MobilePush/Edit/messages.js +341 -0
- package/v2Containers/MobilePush/Edit/reducer.js +113 -0
- package/v2Containers/MobilePush/Edit/sagas.js +113 -0
- package/v2Containers/MobilePush/Edit/selectors.js +33 -0
- package/v2Containers/MobilePush/Edit/test/contentValidity.test.js +149 -0
- package/v2Containers/MobilePush/Edit/test/saga.test.js +255 -0
- package/v2Containers/MobilePush/Edit/test/stayOpenOnSave.test.js +60 -0
- package/v2Containers/MobilePush/commonMethods.js +333 -0
- package/v2Containers/MobilePush/eventsMap.js +130 -0
- package/v2Containers/MobilePush/tests/commonMethods.test.js +401 -0
- package/v2Containers/MobilePushNew/components/CtaButtons.js +47 -52
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +192 -207
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +121 -116
- package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +208 -30
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +72 -316
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +16 -45
- package/v2Containers/MobilePushNew/constants.js +0 -5
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +1 -63
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +0 -52
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +1 -38
- package/v2Containers/MobilePushNew/hooks/useUpload.js +39 -29
- package/v2Containers/MobilePushNew/index.js +192 -454
- package/v2Containers/MobilePushNew/index.scss +4 -188
- package/v2Containers/MobilePushNew/messages.js +6 -86
- package/v2Containers/MobilePushNew/tests/index.test.js +1 -450
- package/v2Containers/MobilePushNew/tests/utils.test.js +0 -25
- package/v2Containers/MobilePushNew/utils.js +0 -8
- package/v2Containers/MobilepushWrapper/_mobilepushWrapper.scss +22 -0
- package/v2Containers/MobilepushWrapper/index.js +178 -0
- package/v2Containers/MobilepushWrapper/messages.js +29 -0
- package/v2Containers/Rcs/index.js +8 -1
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +59 -0
- package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +4 -0
- package/v2Containers/SmsTrai/Edit/index.js +17 -7
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +42 -0
- package/v2Containers/Templates/_templates.scss +2 -10
- package/v2Containers/Templates/index.js +90 -84
- package/v2Containers/Templates/tests/index.test.js +0 -68
- package/v2Containers/Viber/index.js +3 -1
- package/v2Containers/WebPush/Create/utils/validation.js +6 -0
- package/v2Containers/WebPush/Create/utils/validation.test.js +50 -0
- package/v2Containers/Whatsapp/index.js +9 -5
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +2 -2
- package/v2Containers/Zalo/index.js +4 -1
- package/v2Components/CapMpushCTA/tests/index.test.js +0 -89
- /package/{v2Components/FormBuilder/Functional/tests/fixtures/mpushInitialSchema.js → v2Containers/MobilePush/initialSchema.js} +0 -0
package/constants/unified.js
CHANGED
|
@@ -46,6 +46,7 @@ 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';
|
|
49
50
|
export const ENABLE_NEW_EDITOR_FLOW_INAPP = 'ENABLE_NEW_EDITOR_FLOW_INAPP';
|
|
50
51
|
// Per-channel flags for the FormBuilder V3 migration. Each routes its channel to
|
|
51
52
|
// the new functional FormBuilder; later channels get their own flags (…_EMAIL).
|
|
@@ -160,6 +161,9 @@ export const UNSUBSCRIBE_TAG = 'unsubscribe';
|
|
|
160
161
|
export const UNSUBSCRIBE_TAG_REGEX = new RegExp(`\\{\\{\\s*${UNSUBSCRIBE_TAG}\\s*\\}\\}`);
|
|
161
162
|
/** Matches {{ ... }} and captures the inner tag content (for scanning content for tags). */
|
|
162
163
|
export const TAG_CONTENT_REGEX = /{{([^}]+)}}/g;
|
|
164
|
+
// `default:` filter inside a tag, and the same filter with a quoted value e.g. default: 'x'
|
|
165
|
+
export const DEFAULT_FILTER_REGEX = /^\s*default\s*:/;
|
|
166
|
+
export const QUOTED_DEFAULT_REGEX = /^\s*default\s*:\s*('[^']*'|"[^"]*")\s*$/;
|
|
163
167
|
export const ENTRY_TRIGGER_TAG_REGEX = /\bentryTrigger\.\w+(?:\.\w+)?(?:\(\w+\))?/g;
|
|
164
168
|
/** Strips characters not allowed in a downloaded file name, keeping alphanumerics, `-`, `_` and spaces. */
|
|
165
169
|
export const SAFE_FILE_NAME_REGEX = /[^a-zA-Z0-9-_ ]/g;
|
package/index.js
CHANGED
|
@@ -52,10 +52,19 @@ import Gallery from './v2Containers/Assets/Gallery';
|
|
|
52
52
|
import galleryReducer from './v2Containers/Assets/Gallery/reducer';
|
|
53
53
|
import gallerySagas from './v2Containers/Assets/Gallery/sagas';
|
|
54
54
|
|
|
55
|
+
import MobilepushCreate from './v2Containers/MobilePush/Create';
|
|
56
|
+
import mobilepushCreateReducer from './v2Containers/MobilePush/Create/reducer';
|
|
57
|
+
import mobilepushCreateSaga from './v2Containers/MobilePush/Create/sagas';
|
|
58
|
+
|
|
55
59
|
import FTP from './v2Containers/FTP';
|
|
56
60
|
import FTPReducer from './v2Containers/FTP/reducer';
|
|
57
61
|
import FTPSagas from './v2Containers/FTP/sagas';
|
|
58
62
|
|
|
63
|
+
import MobilepushEdit from './v2Containers/MobilePush/Edit';
|
|
64
|
+
import mobilepushEditReducer from './v2Containers/MobilePush/Edit/reducer';
|
|
65
|
+
import mobilepushEditSaga from './v2Containers/MobilePush/Edit/sagas';
|
|
66
|
+
|
|
67
|
+
|
|
59
68
|
import LineCreate from './v2Containers/Line/Container';
|
|
60
69
|
import lineCreateReducer from './v2Containers/Line/Container/reducer';
|
|
61
70
|
import lineCreateSaga from './v2Containers/Line/Container/sagas';
|
|
@@ -119,6 +128,8 @@ const CallTaskContainer = {CallTask, callTaskReducer, callTaskSaga};
|
|
|
119
128
|
const WeChatMapTemplateContainer = {WeChatMapTemplate, weChatMapTemplateReducer, weChatMapTemplateSaga};
|
|
120
129
|
const WeChatRichMediaCreateContainer = {WeChatRichMediaCreate, weChatRichMediaCreateReducer, weChatRichMediaCreateSaga};
|
|
121
130
|
const WeChatRichMediaEditContainer = {WeChatRichMediaEdit, weChatRichMediaEditReducer, weChatRichMediaEditSaga};
|
|
131
|
+
const MobilePushCreateContainer = {MobilepushCreate, mobilepushCreateReducer, mobilepushCreateSaga};
|
|
132
|
+
const MobilePushEditContainer = {MobilepushEdit, mobilepushEditReducer, mobilepushEditSaga};
|
|
122
133
|
const LineCreateContainer = {LineCreate, lineCreateReducer, lineCreateSaga};
|
|
123
134
|
const TemplatesV2Container = {TemplatesV2, templateReducer, templateSaga};
|
|
124
135
|
const FacebookContainer = {Facebook, facebookReducer, facebookSaga};
|
|
@@ -166,6 +177,8 @@ export { CapContainer,
|
|
|
166
177
|
SmsEdit,
|
|
167
178
|
Email,
|
|
168
179
|
LineCreateContainer,
|
|
180
|
+
MobilePushCreateContainer,
|
|
181
|
+
MobilePushEditContainer,
|
|
169
182
|
TemplatesV2Container,
|
|
170
183
|
CreativesContainer,
|
|
171
184
|
updateCharCount,
|
package/package.json
CHANGED
package/services/getSchema.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SMS, EMAIL, WECHAT } from '../v2Containers/CreativesContainer/constants';
|
|
1
|
+
import { SMS, EMAIL, MOBILE_PUSH, WECHAT } from '../v2Containers/CreativesContainer/constants';
|
|
2
2
|
export default function getSchema(channel) {
|
|
3
3
|
let schemaPath = '../containers/';
|
|
4
4
|
switch (channel.toUpperCase()) {
|
|
@@ -8,6 +8,9 @@ export default function getSchema(channel) {
|
|
|
8
8
|
case EMAIL:
|
|
9
9
|
schemaPath = import(`../v2Containers/Email/initialSchema`);
|
|
10
10
|
break;
|
|
11
|
+
case MOBILE_PUSH:
|
|
12
|
+
schemaPath = import(`../v2Containers/MobilePush/initialSchema`);
|
|
13
|
+
break;
|
|
11
14
|
case WECHAT:
|
|
12
15
|
schemaPath = import(`../v2Containers/WeChat/MapTemplates/initialSchema`);
|
|
13
16
|
break;
|
|
@@ -37,14 +37,14 @@ describe('getSchema', () => {
|
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
it('should return
|
|
40
|
+
it('should return MOBILE_PUSH schema when channel is "mobile_push"', () => {
|
|
41
41
|
const result = getSchema('mobile_push');
|
|
42
42
|
return result.then((module) => {
|
|
43
43
|
expect(module).toBeDefined();
|
|
44
44
|
});
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
it('should return
|
|
47
|
+
it('should return MOBILE_PUSH schema when channel is "MOBILE_PUSH" (uppercase)', () => {
|
|
48
48
|
const result = getSchema('MOBILE_PUSH');
|
|
49
49
|
return result.then((module) => {
|
|
50
50
|
expect(module).toBeDefined();
|
package/translations/en.json
CHANGED
|
@@ -317,6 +317,7 @@
|
|
|
317
317
|
"creatives.componentsV2.TopBar.profile": "Profile",
|
|
318
318
|
"creatives.componentsV2.TopBar.settings": "Settings",
|
|
319
319
|
"creatives.componentsV2.unbalanacedCurlyBraces": "Invalid label, please close all curly braces",
|
|
320
|
+
"creatives.componentsV2.unquotedTagDefaultValue": "Invalid label, default value must be within quotes",
|
|
320
321
|
"creatives.componentsv2.MobilePushPreviewV2.header": "This is the MobilePushPreviewV2 component !",
|
|
321
322
|
"creatives.containers.Assets.Gallery.alphabetically": "Alphabetically",
|
|
322
323
|
"creatives.containers.Assets.Gallery.assetDeleteFailed": "Image deletion failed.",
|
package/translations/ja-JP.json
CHANGED
|
@@ -316,6 +316,7 @@
|
|
|
316
316
|
"creatives.componentsV2.TopBar.profile": "",
|
|
317
317
|
"creatives.componentsV2.TopBar.settings": "",
|
|
318
318
|
"creatives.componentsV2.unbalanacedCurlyBraces": "",
|
|
319
|
+
"creatives.componentsV2.unquotedTagDefaultValue": "",
|
|
319
320
|
"creatives.componentsv2.MobilePushPreviewV2.header": "",
|
|
320
321
|
"creatives.containers.Assets.Gallery.alphabetically": "",
|
|
321
322
|
"creatives.containers.Assets.Gallery.assetDeleteFailed": "",
|
package/translations/zh.json
CHANGED
|
@@ -316,6 +316,7 @@
|
|
|
316
316
|
"creatives.componentsV2.TopBar.profile": "",
|
|
317
317
|
"creatives.componentsV2.TopBar.settings": "",
|
|
318
318
|
"creatives.componentsV2.unbalanacedCurlyBraces": "",
|
|
319
|
+
"creatives.componentsV2.unquotedTagDefaultValue": "",
|
|
319
320
|
"creatives.componentsv2.MobilePushPreviewV2.header": "",
|
|
320
321
|
"creatives.containers.Assets.Gallery.alphabetically": "",
|
|
321
322
|
"creatives.containers.Assets.Gallery.assetDeleteFailed": "",
|
package/utils/common.js
CHANGED
|
@@ -24,6 +24,7 @@ import {
|
|
|
24
24
|
ENABLE_WECHAT,
|
|
25
25
|
ENABLE_WEBPUSH,
|
|
26
26
|
SUPPORT_CK_EDITOR,
|
|
27
|
+
ENABLE_NEW_MPUSH,
|
|
27
28
|
ENABLE_NEW_EDITOR_FLOW_INAPP,
|
|
28
29
|
ENABLE_NEW_FORMBUILDER_SMS,
|
|
29
30
|
ENABLE_NEW_FORMBUILDER_MPUSH,
|
|
@@ -143,6 +144,11 @@ export const isEmailUnsubscribeTagOptional = Auth.hasFeatureAccess.bind(
|
|
|
143
144
|
EMAIL_UNSUBSCRIBE_TAG_MANDATORY,
|
|
144
145
|
);
|
|
145
146
|
|
|
147
|
+
export const hasNewMobilePushFeatureEnabled = Auth.hasFeatureAccess.bind(
|
|
148
|
+
null,
|
|
149
|
+
ENABLE_NEW_MPUSH,
|
|
150
|
+
);
|
|
151
|
+
|
|
146
152
|
export const hasNewEditorFlowInAppEnabled = Auth.hasFeatureAccess.bind(
|
|
147
153
|
null,
|
|
148
154
|
ENABLE_NEW_EDITOR_FLOW_INAPP,
|
|
@@ -27,7 +27,6 @@ import messages from '../v2Containers/MobilePushNew/messages';
|
|
|
27
27
|
* @param {Object} params.accountData - Account data for the payload
|
|
28
28
|
* @param {boolean} params.sameContent - Whether content is shared between platforms
|
|
29
29
|
* @param {Object} params.options - Additional options
|
|
30
|
-
* @param {string} [params.options.skipPlatform] - ANDROID or IOS: leave out a supported platform the user chose not to configure
|
|
31
30
|
* @param {Object} params.intl - Internationalization object for messages
|
|
32
31
|
*/
|
|
33
32
|
const createMobilePushPayload = ({
|
|
@@ -42,8 +41,8 @@ const createMobilePushPayload = ({
|
|
|
42
41
|
intl,
|
|
43
42
|
}) => {
|
|
44
43
|
// Platform support checks must be at the top
|
|
45
|
-
const isAndroidSupported = accountData?.configs?.android === '1'
|
|
46
|
-
const isIosSupported = accountData?.configs?.ios === '1'
|
|
44
|
+
const isAndroidSupported = accountData?.configs?.android === '1';
|
|
45
|
+
const isIosSupported = accountData?.configs?.ios === '1';
|
|
47
46
|
|
|
48
47
|
const {
|
|
49
48
|
accountId: accountIdFromAccountData, id, licenseCode: licenseCodeFromAccountData, sourceAccountIdentifier, sourceType: sourceTypeFromAccountData, sourceTypeName,
|
|
@@ -122,44 +121,6 @@ const createMobilePushPayload = ({
|
|
|
122
121
|
return payload;
|
|
123
122
|
};
|
|
124
123
|
|
|
125
|
-
/**
|
|
126
|
-
* Carousel cards as Save sends them (also used by the Test & Preview payload)
|
|
127
|
-
* @param {Array} carouselData - Editor carousel cards
|
|
128
|
-
* @returns {Array} Cards with deep link keys appended to button links
|
|
129
|
-
*/
|
|
130
|
-
export function buildCarouselCards(carouselData = []) {
|
|
131
|
-
return (carouselData || []).map((card) => {
|
|
132
|
-
const {
|
|
133
|
-
mediaType,
|
|
134
|
-
imageUrl,
|
|
135
|
-
videoSrc,
|
|
136
|
-
videoPreviewImg,
|
|
137
|
-
buttons,
|
|
138
|
-
} = card || {};
|
|
139
|
-
|
|
140
|
-
return {
|
|
141
|
-
mediaType: mediaType || IMAGE.toLowerCase(),
|
|
142
|
-
imageUrl: imageUrl || '',
|
|
143
|
-
videoSrc: videoSrc || '',
|
|
144
|
-
// Thumbnail, so the phone preview can show the video card when editing
|
|
145
|
-
...(videoPreviewImg && { videoPreviewImg }),
|
|
146
|
-
buttons: buttons ? buttons.map((button) => {
|
|
147
|
-
const { linkType: buttonLinkType, deepLinkKeys, deepLinkValue: buttonDeepLinkValue } = button || {};
|
|
148
|
-
if (buttonLinkType === DEEP_LINK && deepLinkKeys && buttonDeepLinkValue) {
|
|
149
|
-
const deepLinkKeysArray = Array.isArray(deepLinkKeys) ? deepLinkKeys : [deepLinkKeys];
|
|
150
|
-
const updatedDeepLinkValue = appendDeepLinkKeysToUrl(buttonDeepLinkValue, deepLinkKeysArray);
|
|
151
|
-
|
|
152
|
-
return {
|
|
153
|
-
...button,
|
|
154
|
-
deepLinkValue: updatedDeepLinkValue,
|
|
155
|
-
};
|
|
156
|
-
}
|
|
157
|
-
return button;
|
|
158
|
-
}) : [],
|
|
159
|
-
};
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
|
|
163
124
|
/**
|
|
164
125
|
* Builds platform-specific content for the payload
|
|
165
126
|
* @param {Object} content - Platform content (Android/iOS)
|
|
@@ -168,7 +129,7 @@ export function buildCarouselCards(carouselData = []) {
|
|
|
168
129
|
* @param {string} platform - Platform (ANDROID/IOS)
|
|
169
130
|
* @returns {Object} Platform-specific content
|
|
170
131
|
*/
|
|
171
|
-
|
|
132
|
+
function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview, platform) {
|
|
172
133
|
const {
|
|
173
134
|
title = '',
|
|
174
135
|
message = '',
|
|
@@ -223,8 +184,7 @@ export function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview,
|
|
|
223
184
|
platformContent.expandableDetails.style = VIDEO;
|
|
224
185
|
platformContent.expandableDetails.message = message;
|
|
225
186
|
platformContent.expandableDetails.media = [{
|
|
226
|
-
|
|
227
|
-
url: content?.videoSrc || content?.mediaList?.[0]?.url || '',
|
|
187
|
+
url: mpushVideoSrcAndPreview.mpushVideoSrc || (content?.mediaList?.[0]?.url || ''),
|
|
228
188
|
text: content?.mediaList?.[0]?.text || '',
|
|
229
189
|
type: VIDEO,
|
|
230
190
|
}];
|
|
@@ -241,11 +201,11 @@ export function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview,
|
|
|
241
201
|
type: type.toLowerCase(),
|
|
242
202
|
}];
|
|
243
203
|
} else {
|
|
244
|
-
//
|
|
204
|
+
// If no mediaList but mpushVideoSrc exists
|
|
245
205
|
platformContent.expandableDetails.style = GIF;
|
|
246
206
|
platformContent.expandableDetails.message = message;
|
|
247
207
|
platformContent.expandableDetails.media = [{
|
|
248
|
-
url:
|
|
208
|
+
url: mpushVideoSrcAndPreview.mpushVideoSrc,
|
|
249
209
|
text: '',
|
|
250
210
|
type: GIF, // Backend expects GIF type for GIFs
|
|
251
211
|
}];
|
|
@@ -258,7 +218,33 @@ export function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview,
|
|
|
258
218
|
|
|
259
219
|
// Handle carouselData
|
|
260
220
|
if (content?.carouselData?.length > 0) {
|
|
261
|
-
platformContent.expandableDetails.carouselData =
|
|
221
|
+
platformContent.expandableDetails.carouselData = content.carouselData.map((card) => {
|
|
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
|
+
});
|
|
262
248
|
}
|
|
263
249
|
|
|
264
250
|
// Handle mediaList
|
package/utils/tagValidations.js
CHANGED
|
@@ -8,7 +8,15 @@
|
|
|
8
8
|
|
|
9
9
|
import lodashForEach from 'lodash/forEach';
|
|
10
10
|
import lodashCloneDeep from 'lodash/cloneDeep';
|
|
11
|
-
import {
|
|
11
|
+
import {
|
|
12
|
+
ENTRY_TRIGGER_TAG_REGEX,
|
|
13
|
+
SKIP_TAGS_REGEX_GROUPS,
|
|
14
|
+
TAG_CONTENT_REGEX,
|
|
15
|
+
UNSUBSCRIBE_TAG,
|
|
16
|
+
UNSUBSCRIBE_TAG_REGEX,
|
|
17
|
+
DEFAULT_FILTER_REGEX,
|
|
18
|
+
QUOTED_DEFAULT_REGEX,
|
|
19
|
+
} from '../constants/unified';
|
|
12
20
|
|
|
13
21
|
const DEFAULT = 'default';
|
|
14
22
|
const SUBTAGS = 'subtags';
|
|
@@ -89,9 +97,8 @@ export const validateTagsCore = ({
|
|
|
89
97
|
}
|
|
90
98
|
|
|
91
99
|
response.isBraceError = !validateIfTagClosed(contentForBraceCheck);
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
} else if (response?.missingTags?.length > 0) {
|
|
100
|
+
response.isDefaultQuoteError = !response.isBraceError && hasUnquotedTagDefault(contentForBraceCheck);
|
|
101
|
+
if (response.isBraceError || response.isDefaultQuoteError || response?.missingTags?.length > 0) {
|
|
95
102
|
response.valid = false;
|
|
96
103
|
}
|
|
97
104
|
return response;
|
|
@@ -203,6 +210,30 @@ export const validateIfTagClosed = (value) => {
|
|
|
203
210
|
return (l1 == l2 && l2 == l3 && l1 == l3);
|
|
204
211
|
};
|
|
205
212
|
|
|
213
|
+
// Splits a tag body into filters on `|` outside quotes (Liquid has no escaped quotes).
|
|
214
|
+
const splitTagFilters = (body) => {
|
|
215
|
+
const filters = [''];
|
|
216
|
+
let quote = null;
|
|
217
|
+
[...body].forEach((char) => {
|
|
218
|
+
if (quote) {
|
|
219
|
+
if (char === quote) quote = null;
|
|
220
|
+
} else if (char === "'" || char === '"') {
|
|
221
|
+
quote = char;
|
|
222
|
+
} else if (char === '|') {
|
|
223
|
+
filters.push('');
|
|
224
|
+
return;
|
|
225
|
+
}
|
|
226
|
+
filters[filters.length - 1] += char;
|
|
227
|
+
});
|
|
228
|
+
return filters;
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
// `default:` inside a {{ }} tag must be followed by a quoted value, e.g. {{tag | default: 'x'}}
|
|
232
|
+
export const hasUnquotedTagDefault = (value = '') =>
|
|
233
|
+
(String(value).match(/{{.*?}}/g) || []).some((tag) => splitTagFilters(tag.slice(2, -2))
|
|
234
|
+
.slice(1)
|
|
235
|
+
.some((filter) => DEFAULT_FILTER_REGEX.test(filter) && !QUOTED_DEFAULT_REGEX.test(filter)));
|
|
236
|
+
|
|
206
237
|
//replaces encoded string with their respective characters
|
|
207
238
|
export const preprocessHtml = (content) => {
|
|
208
239
|
const replacements = {
|
|
@@ -13,6 +13,7 @@ import {
|
|
|
13
13
|
MUSTACHE_VAR_NAME_CAPTURE_REGEX,
|
|
14
14
|
MUSTACHE_VAR_TOKEN_FULL_STRING_REGEX,
|
|
15
15
|
} from '../constants/unified';
|
|
16
|
+
import { HORIZONTAL_WHITESPACE_ONLY_REGEX, SMS_TRAI_VAR } from '../v2Containers/SmsTrai/Edit/constants';
|
|
16
17
|
|
|
17
18
|
export { COMBINED_SMS_TEMPLATE_VAR_REGEX, DEFAULT_MUSTACHE_VAR_REGEX } from '../constants/unified';
|
|
18
19
|
|
|
@@ -131,6 +132,54 @@ export const reconcileVarMapToSlotFormat = (rawVarMap = {}, segments = [], regex
|
|
|
131
132
|
return slotMap;
|
|
132
133
|
};
|
|
133
134
|
|
|
135
|
+
export const getDltSlotKey = (segmentIndex) => `${SMS_TRAI_VAR}_${segmentIndex}`;
|
|
136
|
+
|
|
137
|
+
const isHorizontalWhitespaceOnly = (segment) => (
|
|
138
|
+
typeof segment === 'string' && segment.replace(HORIZONTAL_WHITESPACE_ONLY_REGEX, '') === ''
|
|
139
|
+
);
|
|
140
|
+
|
|
141
|
+
export const collectDltSlotRuns = (text) => {
|
|
142
|
+
if (!text || typeof text !== 'string') return [];
|
|
143
|
+
const segments = splitTemplateVarString(text, DLT_VAR_BODY_CAPTURE_REGEX);
|
|
144
|
+
const runs = [];
|
|
145
|
+
let runLength = 1;
|
|
146
|
+
let horizontalSpaceCount = 0;
|
|
147
|
+
for (let i = 0; i < (segments?.length ?? 0); i += 1) {
|
|
148
|
+
if (!isDltHashVarToken(segments[i])) continue;
|
|
149
|
+
const nextElem = segments[i === segments.length - 1 ? -1 : i + 1];
|
|
150
|
+
if (isHorizontalWhitespaceOnly(nextElem)) horizontalSpaceCount += 1;
|
|
151
|
+
if (segments[i] !== nextElem && !isHorizontalWhitespaceOnly(nextElem)) {
|
|
152
|
+
const keyIndex = i - runLength - horizontalSpaceCount + 1;
|
|
153
|
+
runs.push({
|
|
154
|
+
token: segments[keyIndex],
|
|
155
|
+
firstIndex: keyIndex,
|
|
156
|
+
endIndex: i + 1,
|
|
157
|
+
});
|
|
158
|
+
runLength = 1;
|
|
159
|
+
horizontalSpaceCount = 0;
|
|
160
|
+
} else {
|
|
161
|
+
runLength += 1;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
return runs;
|
|
165
|
+
};
|
|
166
|
+
|
|
167
|
+
export const resolveDltSmsTemplate = (templateStr = '', slotValues = {}) => {
|
|
168
|
+
if (!templateStr || typeof templateStr !== 'string') return templateStr;
|
|
169
|
+
const runs = collectDltSlotRuns(templateStr);
|
|
170
|
+
if (runs.length === 0) return templateStr;
|
|
171
|
+
const resolved = splitTemplateVarString(templateStr, DLT_VAR_BODY_CAPTURE_REGEX);
|
|
172
|
+
runs.forEach((run) => {
|
|
173
|
+
const value = slotValues?.[getDltSlotKey(run.firstIndex)];
|
|
174
|
+
if (value === null || value === undefined || value === '') return;
|
|
175
|
+
for (let i = run.firstIndex; i < run.endIndex; i += 1) {
|
|
176
|
+
if (i === run.firstIndex) resolved[i] = String(value);
|
|
177
|
+
else if (isDltHashVarToken(resolved[i])) resolved[i] = '';
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
return resolved.join('');
|
|
181
|
+
};
|
|
182
|
+
|
|
134
183
|
/**
|
|
135
184
|
* Looks up the inner name of a `{{name}}` or `{#name#}` token in a flat key→value map.
|
|
136
185
|
* Handles both exact matches and dot-path suffixes (e.g. `tag.FORMAT_1` → name `FORMAT_1`).
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IntlProvider } from 'react-intl';
|
|
2
|
-
import createMobilePushPayload
|
|
2
|
+
import createMobilePushPayload from '../createMobilePushPayload';
|
|
3
3
|
import messages from '../../v2Containers/MobilePushNew/messages';
|
|
4
4
|
|
|
5
5
|
// Create a mock intl object
|
|
@@ -48,7 +48,6 @@ jest.mock('../createMobilePushPayload', () => {
|
|
|
48
48
|
__esModule: true,
|
|
49
49
|
default: mockCreateMobilePushPayload,
|
|
50
50
|
appendDeepLinkKeysToUrl: originalModule.appendDeepLinkKeysToUrl,
|
|
51
|
-
buildCarouselCards: originalModule.buildCarouselCards,
|
|
52
51
|
};
|
|
53
52
|
});
|
|
54
53
|
|
|
@@ -262,21 +261,6 @@ describe('createMobilePushPayload', () => {
|
|
|
262
261
|
accountData: unsupportedAccountData,
|
|
263
262
|
})).not.toThrow();
|
|
264
263
|
});
|
|
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
|
-
});
|
|
280
264
|
});
|
|
281
265
|
|
|
282
266
|
// Account Data Validation Tests
|
|
@@ -351,67 +335,33 @@ describe('createMobilePushPayload', () => {
|
|
|
351
335
|
expect(result.versions.base.ANDROID.expandableDetails.image).toBe('test-image.jpg');
|
|
352
336
|
});
|
|
353
337
|
|
|
354
|
-
it('should handle VIDEO media type with
|
|
338
|
+
it('should handle VIDEO media type with mpushVideoSrc', () => {
|
|
355
339
|
const result = callWithIntl({
|
|
356
340
|
templateName: 'Test',
|
|
357
341
|
androidContent: {
|
|
358
342
|
title: 'Title',
|
|
359
343
|
message: 'Message',
|
|
360
344
|
mediaType: 'VIDEO',
|
|
361
|
-
videoSrc: 'test-video.mp4',
|
|
362
345
|
},
|
|
363
346
|
iosContent: { title: 'Title', message: 'Message' },
|
|
364
347
|
accountData: mockAccountData,
|
|
365
|
-
|
|
366
|
-
mpushVideoSrcAndPreview: { mpushVideoSrc: 'other-tab.mp4' },
|
|
348
|
+
mpushVideoSrcAndPreview: { mpushVideoSrc: 'test-video.mp4' },
|
|
367
349
|
});
|
|
368
350
|
expect(result.versions.base.ANDROID.expandableDetails.media[0].url).toBe('test-video.mp4');
|
|
369
351
|
expect(result.versions.base.ANDROID.expandableDetails.media[0].type).toBe('VIDEO');
|
|
370
352
|
});
|
|
371
353
|
|
|
372
|
-
it('should
|
|
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', () => {
|
|
354
|
+
it('should handle GIF media type with mpushVideoSrc', () => {
|
|
404
355
|
const result = callWithIntl({
|
|
405
356
|
templateName: 'Test',
|
|
406
357
|
androidContent: {
|
|
407
358
|
title: 'Title',
|
|
408
359
|
message: 'Message',
|
|
409
360
|
mediaType: 'GIF',
|
|
410
|
-
videoSrc: 'test-gif.gif',
|
|
411
361
|
},
|
|
412
362
|
iosContent: { title: 'Title', message: 'Message' },
|
|
413
363
|
accountData: mockAccountData,
|
|
414
|
-
mpushVideoSrcAndPreview: { mpushVideoSrc: '
|
|
364
|
+
mpushVideoSrcAndPreview: { mpushVideoSrc: 'test-gif.gif' },
|
|
415
365
|
});
|
|
416
366
|
expect(result.versions.base.ANDROID.expandableDetails.media[0].url).toBe('test-gif.gif');
|
|
417
367
|
expect(result.versions.base.ANDROID.expandableDetails.media[0].type).toBe('GIF');
|
|
@@ -910,12 +860,13 @@ describe('createMobilePushPayload', () => {
|
|
|
910
860
|
title: 'Title',
|
|
911
861
|
message: 'Message',
|
|
912
862
|
mediaType: 'GIF',
|
|
913
|
-
videoSrc: 'test-gif.gif',
|
|
914
863
|
},
|
|
915
864
|
iosContent: { title: 'Title', message: 'Message' },
|
|
916
865
|
accountData: mockAccountData,
|
|
866
|
+
mpushVideoSrcAndPreview: { mpushVideoSrc: 'test-gif.gif' },
|
|
917
867
|
});
|
|
918
|
-
|
|
868
|
+
// When mediaType is GIF and mpushVideoSrc is provided, it converts to VIDEO for backend compatibility
|
|
869
|
+
expect(result.versions.base.ANDROID.expandableDetails.media[0].type).toBe('GIF');
|
|
919
870
|
});
|
|
920
871
|
|
|
921
872
|
it('should handle options with custom mode', () => {
|
|
@@ -1371,48 +1322,3 @@ describe('createMobilePushPayload', () => {
|
|
|
1371
1322
|
});
|
|
1372
1323
|
});
|
|
1373
1324
|
});
|
|
1374
|
-
|
|
1375
|
-
describe('buildCarouselCards', () => {
|
|
1376
|
-
it.each([
|
|
1377
|
-
['no argument', undefined],
|
|
1378
|
-
['null', null],
|
|
1379
|
-
['an empty array', []],
|
|
1380
|
-
])('returns [] for %s', (_label, input) => {
|
|
1381
|
-
expect(buildCarouselCards(input)).toEqual([]);
|
|
1382
|
-
});
|
|
1383
|
-
|
|
1384
|
-
it('fills defaults for a missing card', () => {
|
|
1385
|
-
expect(buildCarouselCards([null])).toEqual([
|
|
1386
|
-
{ mediaType: 'image', imageUrl: '', videoSrc: '', buttons: [] },
|
|
1387
|
-
]);
|
|
1388
|
-
});
|
|
1389
|
-
|
|
1390
|
-
it('keeps the video thumbnail only when there is one', () => {
|
|
1391
|
-
const [withThumb, withoutThumb] = buildCarouselCards([
|
|
1392
|
-
{ mediaType: 'video', videoSrc: 'a.mp4', videoPreviewImg: 'a.png' },
|
|
1393
|
-
{ mediaType: 'video', videoSrc: 'b.mp4', videoPreviewImg: '' },
|
|
1394
|
-
]);
|
|
1395
|
-
|
|
1396
|
-
expect(withThumb).toEqual({ mediaType: 'video', imageUrl: '', videoSrc: 'a.mp4', videoPreviewImg: 'a.png', buttons: [] });
|
|
1397
|
-
expect(withoutThumb).toEqual({ mediaType: 'video', imageUrl: '', videoSrc: 'b.mp4', buttons: [] });
|
|
1398
|
-
});
|
|
1399
|
-
|
|
1400
|
-
it('appends deep link keys and leaves other buttons as they are', () => {
|
|
1401
|
-
const externalButton = { linkType: 'EXTERNAL_LINK', externalLinkValue: 'https://x.com' };
|
|
1402
|
-
const [card] = buildCarouselCards([{
|
|
1403
|
-
mediaType: 'image',
|
|
1404
|
-
imageUrl: 'a.jpg',
|
|
1405
|
-
buttons: [
|
|
1406
|
-
{ linkType: 'DEEP_LINK', deepLinkValue: 'app://home', deepLinkKeys: 'id' },
|
|
1407
|
-
externalButton,
|
|
1408
|
-
null,
|
|
1409
|
-
],
|
|
1410
|
-
}]);
|
|
1411
|
-
|
|
1412
|
-
expect(card.buttons).toEqual([
|
|
1413
|
-
{ linkType: 'DEEP_LINK', deepLinkValue: 'app://home?id=id', deepLinkKeys: 'id' },
|
|
1414
|
-
externalButton,
|
|
1415
|
-
null,
|
|
1416
|
-
]);
|
|
1417
|
-
});
|
|
1418
|
-
});
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
skipTags,
|
|
12
12
|
checkIfSupportedTag,
|
|
13
13
|
transformInjectedTags,
|
|
14
|
+
hasUnquotedTagDefault,
|
|
14
15
|
} from '../tagValidations';
|
|
15
16
|
import { containsBase64Images } from '../content';
|
|
16
17
|
|
|
@@ -193,6 +194,53 @@ describe("check if curly brackets are balanced", () => {
|
|
|
193
194
|
})
|
|
194
195
|
})
|
|
195
196
|
|
|
197
|
+
describe('hasUnquotedTagDefault', () => {
|
|
198
|
+
it('allows tags without default and defaults within quotes', () => {
|
|
199
|
+
expect(hasUnquotedTagDefault('{{badge_description}}')).toBe(false);
|
|
200
|
+
expect(hasUnquotedTagDefault("{{badge_description | default: ''}}")).toBe(false);
|
|
201
|
+
expect(hasUnquotedTagDefault("{{badge_description | default: 'Rafeeq'}}")).toBe(false);
|
|
202
|
+
expect(hasUnquotedTagDefault('{{badge_description | default: "Rafeeq\'s"}}')).toBe(false);
|
|
203
|
+
expect(hasUnquotedTagDefault("Hi {{a|default:' '}} {{b}} plain text")).toBe(false);
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
it('flags default with missing or unquoted value', () => {
|
|
207
|
+
expect(hasUnquotedTagDefault('{{badge_description | default: }}')).toBe(true);
|
|
208
|
+
expect(hasUnquotedTagDefault('{{badge_description | default: Rafeeq}}')).toBe(true);
|
|
209
|
+
expect(hasUnquotedTagDefault("{{badge_description | default: 'Rafeeq}}")).toBe(true);
|
|
210
|
+
expect(hasUnquotedTagDefault("{{a}} {{b | default: 'x' y}}")).toBe(true);
|
|
211
|
+
});
|
|
212
|
+
|
|
213
|
+
it('ignores pipes inside quotes and allows chained filters', () => {
|
|
214
|
+
expect(hasUnquotedTagDefault("{{name | replace: '| default:', 'x'}}")).toBe(false);
|
|
215
|
+
expect(hasUnquotedTagDefault("{{name | default: 'a | default: b'}}")).toBe(false);
|
|
216
|
+
expect(hasUnquotedTagDefault("{{name | default: 'a|b'}}")).toBe(false);
|
|
217
|
+
expect(hasUnquotedTagDefault("{{name | default: 'x' | append: '!'}}")).toBe(false);
|
|
218
|
+
expect(hasUnquotedTagDefault("{{name | append: 'x' | default: 'y'}}")).toBe(false);
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
it('rejects backslash-escaped quotes since Liquid has no escapes', () => {
|
|
222
|
+
expect(hasUnquotedTagDefault("{{name | default: 'it\\'s'}}")).toBe(true);
|
|
223
|
+
});
|
|
224
|
+
});
|
|
225
|
+
|
|
226
|
+
describe('validateTagsCore default quote check', () => {
|
|
227
|
+
const run = (content) => validateTagsCore({
|
|
228
|
+
contentForBraceCheck: content, contentForUnsubscribeScan: content, tags: null, currentModule: 'default', isFullMode: true,
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it('marks unquoted default as invalid with isDefaultQuoteError', () => {
|
|
232
|
+
expect(run('{{name | default: Rafeeq}}')).toEqual(expect.objectContaining({ valid: false, isBraceError: false, isDefaultQuoteError: true }));
|
|
233
|
+
});
|
|
234
|
+
|
|
235
|
+
it('keeps quoted default valid', () => {
|
|
236
|
+
expect(run("{{name | default: 'Rafeeq'}}")).toEqual(expect.objectContaining({ valid: true, isDefaultQuoteError: false }));
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
it('reports only brace error when braces are not closed', () => {
|
|
240
|
+
expect(run('{{name | default: Rafeeq}')).toEqual(expect.objectContaining({ isBraceError: true, isDefaultQuoteError: false }));
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
|
|
196
244
|
describe("validateTags", () => {
|
|
197
245
|
const tagsParam = [
|
|
198
246
|
{
|