@capillarytech/creatives-library 9.2.4-beta.sprint-cap-214027-tags-ux-changes.49 → 9.2.4
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/AppRoot.js +3 -5
- package/bootstrap.js +3 -0
- package/config/path.js +2 -0
- package/constants/unified.js +0 -11
- package/package.json +1 -1
- package/services/api.js +52 -28
- package/translations/en.json +0 -1
- package/translations/ja-JP.json +0 -1
- package/translations/zh.json +0 -1
- package/utils/authWrapper.js +2 -0
- package/utils/common.js +0 -7
- package/utils/devAuth.js +38 -0
- package/utils/history.js +8 -4
- package/utils/mfeHistory.js +17 -12
- package/utils/tagValidations.js +4 -37
- package/utils/tests/devAuth.test.js +37 -0
- package/utils/tests/history.test.js +28 -0
- package/utils/tests/mfeHistory.test.js +29 -3
- package/utils/tests/tagValidations.test.js +0 -63
- package/v2Components/CapTagList/index.js +64 -242
- package/v2Components/CapTagList/messages.js +0 -68
- package/v2Components/CapTagList/style.scss +1 -278
- package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +8 -0
- package/v2Components/CommonTestAndPreview/DeliverySettings/index.js +41 -3
- package/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +12 -0
- package/v2Components/CommonTestAndPreview/SendTestMessage.js +12 -0
- package/v2Components/CommonTestAndPreview/constants.js +3 -0
- package/v2Components/CommonTestAndPreview/index.js +101 -11
- package/v2Components/CommonTestAndPreview/reducer.js +8 -2
- package/v2Components/CommonTestAndPreview/selectors.js +6 -0
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +11 -0
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +92 -0
- package/v2Components/CommonTestAndPreview/tests/index.test.js +196 -0
- package/v2Components/CommonTestAndPreview/tests/reducer.test.js +4 -0
- package/v2Components/CommonTestAndPreview/tests/selectors.test.js +10 -0
- package/v2Components/ErrorInfoNote/index.js +11 -32
- package/v2Components/ErrorInfoNote/messages.js +0 -4
- package/v2Components/ErrorInfoNote/style.scss +0 -4
- package/v2Components/ErrorInfoNote/utils.js +0 -3
- package/v2Components/FormBuilder/Classic.js +16 -29
- package/v2Components/FormBuilder/Functional/channels/mobilepush/config.js +0 -1
- package/v2Components/FormBuilder/Functional/channels/mobilepush/getEditorErrorDescriptor.js +1 -1
- package/v2Components/FormBuilder/Functional/channels/mobilepush/tests/validate.test.js +0 -69
- package/v2Components/FormBuilder/Functional/channels/mobilepush/validate.js +4 -4
- package/v2Components/FormBuilder/Functional/channels/sms/getEditorErrorDescriptor.js +0 -3
- package/v2Components/FormBuilder/Functional/channels/sms/tests/getEditorErrorDescriptor.test.js +0 -17
- package/v2Components/FormBuilder/Functional/channels/sms/tests/validate.test.js +0 -18
- package/v2Components/FormBuilder/Functional/channels/sms/validate.js +1 -3
- package/v2Components/FormBuilder/Functional/renderers/mpushRenderers.js +0 -3
- package/v2Components/FormBuilder/Functional/renderers/smsRenderers.js +2 -5
- package/v2Components/FormBuilder/Functional/tests/mpushRenderers.test.js +0 -22
- package/v2Components/FormBuilder/Functional/tests/smsRenderers.test.js +1 -1
- package/v2Components/HtmlEditor/components/ValidationTabs/_validationTabs.scss +0 -4
- package/v2Components/HtmlEditor/components/ValidationTabs/index.js +3 -17
- package/v2Components/HtmlEditor/components/ValidationTabs/messages.js +0 -4
- package/v2Components/HtmlEditor/utils/__tests__/renderIssueMessage.test.js +40 -32
- package/v2Components/HtmlEditor/utils/renderIssueMessage.js +24 -31
- package/v2Components/HtmlEditor/utils/validationConstants.js +0 -2
- package/v2Components/NavigationBar/mfeModuleHeader.config.js +23 -4
- package/v2Components/NavigationBar/tests/mfeModuleHeader.config.test.js +4 -2
- package/v2Components/TestAndPreviewSlidebox/index.js +8 -0
- package/v2Containers/Cap/index.js +7 -1
- package/v2Containers/Cap/messages.js +0 -4
- package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +0 -1
- package/v2Containers/CommunicationFlow/CommunicationFlow.js +6 -1
- package/v2Containers/CommunicationFlow/Tests/CommunicationFlow.test.js +75 -1
- package/v2Containers/CommunicationFlow/constants.js +1 -0
- package/v2Containers/CommunicationFlow/messages.js +12 -0
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/ChannelSelectionStep.js +4 -0
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/DeliverySettingsSection.js +161 -19
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/SenderDetails.js +31 -4
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/DeliverySettingsSection.test.js +352 -0
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/SenderDetails.test.js +25 -0
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/Tests/deliverySettingsConfig.test.js +80 -0
- package/v2Containers/CommunicationFlow/steps/DeliverySettingsStep/deliverySettingsConfig.js +26 -8
- package/v2Containers/CreativesContainer/index.js +20 -0
- package/v2Containers/CreativesContainer/tests/index.test.js +82 -0
- package/v2Containers/CustomTags/Create/ValidationResultsModal.js +80 -0
- package/v2Containers/CustomTags/Create/_customTagCreate.scss +177 -0
- package/v2Containers/CustomTags/Create/index.js +584 -0
- package/v2Containers/CustomTags/CustomTagsRoot.js +15 -0
- package/v2Containers/CustomTags/Detail/_customTagDetail.scss +81 -0
- package/v2Containers/CustomTags/Detail/index.js +278 -0
- package/v2Containers/CustomTags/Edit/index.js +96 -0
- package/v2Containers/CustomTags/_customTags.scss +61 -0
- package/v2Containers/CustomTags/actions.js +44 -0
- package/v2Containers/CustomTags/components/NoAccess.js +31 -0
- package/v2Containers/CustomTags/components/StatusPill.js +31 -0
- package/v2Containers/CustomTags/components/_featureNotEnabled.scss +44 -0
- package/v2Containers/CustomTags/components/_statusPill.scss +57 -0
- package/v2Containers/CustomTags/components/withCustomTagsFeature.js +118 -0
- package/v2Containers/CustomTags/constants.js +153 -0
- package/v2Containers/CustomTags/index.js +387 -0
- package/v2Containers/CustomTags/messages.js +159 -0
- package/v2Containers/CustomTags/mockdata/customTags.js +40 -0
- package/v2Containers/CustomTags/reducer.js +129 -0
- package/v2Containers/CustomTags/sagas.js +140 -0
- package/v2Containers/CustomTags/selectors.js +84 -0
- package/v2Containers/CustomTags/tests/api.test.js +55 -0
- package/v2Containers/CustomTags/tests/create.test.js +536 -0
- package/v2Containers/CustomTags/tests/customTagsRoot.test.js +32 -0
- package/v2Containers/CustomTags/tests/detail.test.js +120 -0
- package/v2Containers/CustomTags/tests/edit.test.js +69 -0
- package/v2Containers/CustomTags/tests/featureGate.test.js +115 -0
- package/v2Containers/CustomTags/tests/fixtures.js +11 -0
- package/v2Containers/CustomTags/tests/index.test.js +189 -0
- package/v2Containers/CustomTags/tests/mockdata.test.js +33 -0
- package/v2Containers/CustomTags/tests/reducer.test.js +143 -0
- package/v2Containers/CustomTags/tests/sagas.test.js +267 -0
- package/v2Containers/CustomTags/tests/selectors.test.js +62 -0
- package/v2Containers/CustomTags/tests/tagGroups.mock.js +97 -0
- package/v2Containers/CustomTags/tests/utils.test.js +317 -0
- package/v2Containers/CustomTags/utils.js +187 -0
- package/v2Containers/Facebook/Advertisement/index.js +1 -2
- package/v2Containers/InApp/index.js +1 -4
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +0 -3
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +0 -2
- package/v2Containers/Line/Container/Text/index.js +2 -5
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +125 -177
- package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +0 -18
- package/v2Containers/MobilePushNew/index.js +1 -4
- package/v2Containers/Rcs/accountUtils.js +53 -0
- package/v2Containers/Rcs/carouselUtils.js +31 -0
- package/v2Containers/Rcs/components/CarouselCard.js +4 -0
- package/v2Containers/Rcs/components/CarouselCardMedia.js +14 -8
- package/v2Containers/Rcs/constants.js +46 -0
- package/v2Containers/Rcs/index.js +38 -26
- package/v2Containers/Rcs/tests/CarouselCardMedia.test.js +75 -0
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +1142 -1258
- package/v2Containers/Rcs/tests/accountUtils.test.js +178 -0
- package/v2Containers/Rcs/tests/carouselUtils.test.js +73 -0
- package/v2Containers/Rcs/tests/testAndPreviewAccount.test.js +188 -0
- package/v2Containers/Sms/Create/index.js +1 -5
- package/v2Containers/Sms/Edit/index.js +1 -5
- package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +0 -4
- package/v2Containers/SmsTrai/Edit/index.js +5 -13
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +27 -15
- package/v2Containers/TagList/index.js +0 -6
- package/v2Containers/TagList/tests/TagList.test.js +4 -10
- package/v2Containers/Templates/ChannelTypeIllustration.js +11 -0
- package/v2Containers/Templates/index.js +32 -12
- package/v2Containers/Templates/messages.js +4 -0
- package/v2Containers/Templates/tests/ChannelTypeIllustration.test.js +14 -2
- package/v2Containers/Templates/tests/index.test.js +221 -0
- package/v2Containers/Viber/index.js +2 -5
- package/v2Containers/WebPush/Create/tests/contentValidity.test.js +0 -1
- package/v2Containers/WebPush/Create/tests/stayOpenOnSave.test.js +0 -1
- package/v2Containers/WebPush/Create/utils/validation.js +0 -6
- package/v2Containers/WebPush/Create/utils/validation.test.js +0 -50
- package/v2Containers/Whatsapp/index.js +6 -11
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +2 -2
- package/v2Containers/Zalo/index.js +1 -4
- package/utils/mockGroupedTags.js +0 -44
- package/utils/tests/mockGroupedTags.test.js +0 -59
- package/v2Components/CapTagList/TagFallbackPanel.js +0 -126
- package/v2Components/CapTagList/constants.js +0 -21
- package/v2Components/CapTagList/tests/TagDescription.test.js +0 -268
- package/v2Components/CapTagList/tests/TagFallback.test.js +0 -255
- package/v2Components/CapTagList/utils.js +0 -74
- package/v2Components/ErrorInfoNote/ErrorInfoNote.test.js +0 -53
- package/v2Components/HighlightedTextArea/MessageTextArea.js +0 -16
- package/v2Components/HighlightedTextArea/constants.js +0 -27
- package/v2Components/HighlightedTextArea/index.js +0 -148
- package/v2Components/HighlightedTextArea/messages.js +0 -18
- package/v2Components/HighlightedTextArea/smsCounter.js +0 -11
- package/v2Components/HighlightedTextArea/style.scss +0 -110
- package/v2Components/HighlightedTextArea/tests/HighlightedTextArea.test.js +0 -97
- package/v2Components/HighlightedTextArea/utils.js +0 -17
- package/v2Components/HtmlEditor/components/ValidationTabs/__tests__/ValidationTabs.test.js +0 -42
- package/v2Components/HtmlEditor/utils/renderLegacyIssueMessage.js +0 -56
- package/v2Components/LiquidGenerator/constants.js +0 -5
- package/v2Components/LiquidGenerator/index.js +0 -154
- package/v2Components/LiquidGenerator/messages.js +0 -50
- package/v2Components/LiquidGenerator/style.scss +0 -160
- package/v2Components/LiquidGenerator/tests/LiquidGenerator.test.js +0 -107
- package/v2Components/LiquidGenerator/utils.js +0 -42
- package/v2Containers/Cap/mockdata/groupedStandardTags.json +0 -17386
package/AppRoot.js
CHANGED
|
@@ -12,11 +12,10 @@ import './styles/main.scss';
|
|
|
12
12
|
import { initialReducer } from './initialReducer';
|
|
13
13
|
import { translationMessages } from './i18n';
|
|
14
14
|
import initialState from './initialState';
|
|
15
|
-
import pathConfig from './config/path';
|
|
16
15
|
import { isMFEMode } from './utils/mfeDetect';
|
|
17
16
|
import { loadBeePlugin } from './utils/beePluginLoader';
|
|
18
17
|
import { emitFirstPaintReadyIfNotDataLanding } from './utils/mfeFirstPaintReady';
|
|
19
|
-
import
|
|
18
|
+
import { createAppHistory } from './utils/history';
|
|
20
19
|
import { MFEEventBus } from '@capillarytech/cap-ui-utils';
|
|
21
20
|
import appConfig from './app-config';
|
|
22
21
|
|
|
@@ -25,9 +24,8 @@ loadCapUI();
|
|
|
25
24
|
|
|
26
25
|
const AppRoot = ({ basename: _basename = '/creatives/ui', history: hostHistory }) => {
|
|
27
26
|
const { store, history } = useMemo(() => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
: createBrowserHistory({ basename: pathConfig.publicPath });
|
|
27
|
+
// Host history (MFE) or our own browser history — both rebased the same way (utils/history).
|
|
28
|
+
const hist = createAppHistory(hostHistory || createBrowserHistory());
|
|
31
29
|
const st = configureStore(initialState, initialReducer, hist);
|
|
32
30
|
return { store: st, history: hist };
|
|
33
31
|
}, [hostHistory]);
|
package/bootstrap.js
CHANGED
|
@@ -37,6 +37,9 @@ import ignoredErrorMessages from './utils/ignoredErrorMessages';
|
|
|
37
37
|
import App from './containers/App';
|
|
38
38
|
import ConfigProvider from 'antd/lib/config-provider';
|
|
39
39
|
import { getCapThemeConfig, loadCapUI } from '@capillarytech/cap-ui-library/utils';
|
|
40
|
+
import { seedDevAuth } from './utils/devAuth';
|
|
41
|
+
|
|
42
|
+
seedDevAuth();
|
|
40
43
|
|
|
41
44
|
loadCapUI();
|
|
42
45
|
|
package/config/path.js
CHANGED
package/constants/unified.js
CHANGED
|
@@ -160,9 +160,6 @@ export const UNSUBSCRIBE_TAG = 'unsubscribe';
|
|
|
160
160
|
export const UNSUBSCRIBE_TAG_REGEX = new RegExp(`\\{\\{\\s*${UNSUBSCRIBE_TAG}\\s*\\}\\}`);
|
|
161
161
|
/** Matches {{ ... }} and captures the inner tag content (for scanning content for tags). */
|
|
162
162
|
export const TAG_CONTENT_REGEX = /{{([^}]+)}}/g;
|
|
163
|
-
// `default:` filter inside a tag, and the same filter with a quoted value e.g. default: 'x'
|
|
164
|
-
export const DEFAULT_FILTER_REGEX = /^\s*default\s*:/;
|
|
165
|
-
export const QUOTED_DEFAULT_REGEX = /^\s*default\s*:\s*('[^']*'|"[^"]*")\s*$/;
|
|
166
163
|
export const ENTRY_TRIGGER_TAG_REGEX = /\bentryTrigger\.\w+(?:\.\w+)?(?:\(\w+\))?/g;
|
|
167
164
|
/** Strips characters not allowed in a downloaded file name, keeping alphanumerics, `-`, `_` and spaces. */
|
|
168
165
|
export const SAFE_FILE_NAME_REGEX = /[^a-zA-Z0-9-_ ]/g;
|
|
@@ -242,11 +239,3 @@ export const HTTP_METHODS = Object.freeze({
|
|
|
242
239
|
PATCH: 'PATCH',
|
|
243
240
|
DELETE: 'DELETE',
|
|
244
241
|
});
|
|
245
|
-
|
|
246
|
-
// Temporary org feature flag for the personalization tags revamp (CAP-214027); remove once the backend support is released.
|
|
247
|
-
export const ENABLE_TAGS_REVAMP = 'ENABLE_TAGS_REVAMP';
|
|
248
|
-
|
|
249
|
-
// Development-only: local storage key that turns on the mock of the regrouped standard tags (see utils/mockGroupedTags.js)
|
|
250
|
-
export const MOCK_GROUPED_TAGS_STORAGE_KEY = 'MOCK_GROUPED_TAGS';
|
|
251
|
-
export const TIMELINE_CONTEXT = 'timeline';
|
|
252
|
-
export const OUTBOUND_CONTEXT = 'outbound';
|
package/package.json
CHANGED
package/services/api.js
CHANGED
|
@@ -6,6 +6,7 @@ import { GA, decompressJsonObject } from '@capillarytech/cap-ui-utils';
|
|
|
6
6
|
import get from 'lodash/get';
|
|
7
7
|
import { loadItem, clearItem } from './localStorageApi';
|
|
8
8
|
import { isMFEMode } from '../utils/mfeDetect';
|
|
9
|
+
import { isDevTokenAuth, logDevAuthFailure } from '../utils/devAuth';
|
|
9
10
|
import config from '../config/app';
|
|
10
11
|
import pathConfig from '../config/path';
|
|
11
12
|
import getSchema from './getSchema';
|
|
@@ -13,7 +14,7 @@ import * as API from '../utils/ApiCaller';
|
|
|
13
14
|
import { addBaseToTemplate, transformCustomFieldsData } from '../utils/commonUtils';
|
|
14
15
|
import { EMAIL, SMS, TRANSACTION } from '../v2Containers/CreativesContainer/constants';
|
|
15
16
|
import { HTTP_METHODS } from '../constants/unified';
|
|
16
|
-
import {
|
|
17
|
+
import { getMockValidateQueryResponse } from '../v2Containers/CustomTags/mockdata/customTags';
|
|
17
18
|
let API_ENDPOINT = config.development.api_endpoint;
|
|
18
19
|
let EXPORT_API_ENDPOINT = config.development.exports_api_endpoint;
|
|
19
20
|
let CAMPAIGNS_API_ENDPOINT = config.development.campaigns_api_endpoint;
|
|
@@ -96,7 +97,12 @@ function checkStatus(response) {
|
|
|
96
97
|
return response;
|
|
97
98
|
}
|
|
98
99
|
const isLoginPage = window.location.pathname.indexOf('/login') !== -1;
|
|
99
|
-
if (
|
|
100
|
+
if ((status === 401 || status === 403) && isDevTokenAuth()) {
|
|
101
|
+
// Redirecting would reload-loop since the dev token is re-seeded on every load.
|
|
102
|
+
logDevAuthFailure(status, response.url);
|
|
103
|
+
} else if (!isLoginPage) {
|
|
104
|
+
redirectIfUnauthenticated(response);
|
|
105
|
+
}
|
|
100
106
|
|
|
101
107
|
const error = new Error(statusText);
|
|
102
108
|
error.response = response;
|
|
@@ -463,31 +469,6 @@ export const getUserList = () => {
|
|
|
463
469
|
return API.get(url);// request(url, getAPICallObject('GET'));
|
|
464
470
|
};
|
|
465
471
|
|
|
466
|
-
const requestTagMeta = async (queryParams) => {
|
|
467
|
-
const url = `${API_ENDPOINT}/meta/${queryParams.type}?query=${JSON.stringify(queryParams)}`;
|
|
468
|
-
const useMockTags = queryParams.type === 'TAG' && isMockGroupedTagsEnabled();
|
|
469
|
-
let result;
|
|
470
|
-
try {
|
|
471
|
-
result = await request(url, getAPICallObject('GET'));// request(url, getAPICallObject('GET'));
|
|
472
|
-
} catch (error) {
|
|
473
|
-
if (!useMockTags) throw error;
|
|
474
|
-
}
|
|
475
|
-
if (useMockTags) {
|
|
476
|
-
// development only: the regrouped standard tags are not deployed yet (see utils/mockGroupedTags.js)
|
|
477
|
-
if (result?.response?.metaEntities) {
|
|
478
|
-
result.response.metaEntities.standard = await getMockStandardTags(queryParams);
|
|
479
|
-
} else {
|
|
480
|
-
result = await buildMockTagsResponse(queryParams);
|
|
481
|
-
}
|
|
482
|
-
}
|
|
483
|
-
const customFields = get(result, 'response.metaEntities.custom', {});
|
|
484
|
-
if (customFields && Object.keys(customFields)?.length > 0) {
|
|
485
|
-
const transformedData = transformCustomFieldsData(customFields);
|
|
486
|
-
result.response.metaEntities.custom = transformedData;
|
|
487
|
-
}
|
|
488
|
-
return result;
|
|
489
|
-
};
|
|
490
|
-
|
|
491
472
|
export const fetchSchemaForEntity = async ({queryParams}) => {
|
|
492
473
|
if (queryParams.version === "v2" && queryParams.type === "LAYOUT") {
|
|
493
474
|
const schema = getSchema(queryParams.layout);
|
|
@@ -496,7 +477,14 @@ export const fetchSchemaForEntity = async ({queryParams}) => {
|
|
|
496
477
|
console.error(err);
|
|
497
478
|
});
|
|
498
479
|
}
|
|
499
|
-
|
|
480
|
+
const url = `${API_ENDPOINT}/meta/${queryParams.type}?query=${JSON.stringify(queryParams)}`;
|
|
481
|
+
const result = await request(url, getAPICallObject('GET'));// request(url, getAPICallObject('GET'));
|
|
482
|
+
const customFields = get(result, 'response.metaEntities.custom', {});
|
|
483
|
+
if (customFields && Object.keys(customFields)?.length > 0) {
|
|
484
|
+
const transformedData = transformCustomFieldsData(customFields);
|
|
485
|
+
result.response.metaEntities.custom = transformedData;
|
|
486
|
+
}
|
|
487
|
+
return result;
|
|
500
488
|
};
|
|
501
489
|
|
|
502
490
|
export const fetchWeCrmAccounts = (sourceName) => {
|
|
@@ -642,6 +630,42 @@ export const getFacebookPreview = ({previewData}) => {
|
|
|
642
630
|
};
|
|
643
631
|
|
|
644
632
|
|
|
633
|
+
// Query string with every defined, non-empty value URI-encoded (search text can contain anything).
|
|
634
|
+
const toQueryString = (queryParams = {}) => {
|
|
635
|
+
const params = new URLSearchParams();
|
|
636
|
+
Object.entries(queryParams || {}).forEach(([key, value]) => {
|
|
637
|
+
if (value != null && value !== '') {
|
|
638
|
+
params.append(key, value);
|
|
639
|
+
}
|
|
640
|
+
});
|
|
641
|
+
const query = params.toString();
|
|
642
|
+
return query ? `?${query}` : '';
|
|
643
|
+
};
|
|
644
|
+
|
|
645
|
+
const CUSTOM_TAG_GROUPS_URL = `${API_ENDPOINT}/customTags/tagGroups`;
|
|
646
|
+
|
|
647
|
+
// Custom tags listing: GET /customTags/tagGroups (optional `search`, `tag_group` filters)
|
|
648
|
+
export const getCustomTags = ({ queryParams = {} } = {}) =>
|
|
649
|
+
request(`${CUSTOM_TAG_GROUPS_URL}${toQueryString(queryParams)}`, getAPICallObject(HTTP_METHODS.GET));
|
|
650
|
+
|
|
651
|
+
// Custom tag group detail / edit: GET /customTags/tagGroups/:tagGroupName (404 if absent)
|
|
652
|
+
export const getCustomTagByName = ({ tagGroupName }) =>
|
|
653
|
+
request(`${CUSTOM_TAG_GROUPS_URL}/${encodeURIComponent(tagGroupName)}`, getAPICallObject(HTTP_METHODS.GET));
|
|
654
|
+
|
|
655
|
+
// Create a custom tag group: POST /customTags/tagGroups (payload from utils.buildPublishPayload)
|
|
656
|
+
export const createCustomTagGroup = ({ payload }) =>
|
|
657
|
+
request(CUSTOM_TAG_GROUPS_URL, getAPICallObject(HTTP_METHODS.POST, payload));
|
|
658
|
+
|
|
659
|
+
// Update a custom tag group: PUT /customTags/tagGroups/:tagGroupName (payload from utils.buildUpdatePayload)
|
|
660
|
+
export const updateCustomTagGroup = ({ tagGroupName, payload }) =>
|
|
661
|
+
request(
|
|
662
|
+
`${CUSTOM_TAG_GROUPS_URL}/${encodeURIComponent(tagGroupName)}`,
|
|
663
|
+
getAPICallObject(HTTP_METHODS.PUT, payload),
|
|
664
|
+
);
|
|
665
|
+
|
|
666
|
+
// TODO(custom-tags): mock validate (runs the tag SQL on sample customers); replace with the real endpoint
|
|
667
|
+
export const validateCustomTagQuery = ({ query }) => getMockValidateQueryResponse(query);
|
|
668
|
+
|
|
645
669
|
export const getOrgOUs = ({ orgID }) => {
|
|
646
670
|
const url = `${ARYA_ENDPOINT}/org/${orgID}/oulist`;
|
|
647
671
|
return request(url, getAPICallObject('GET'));
|
package/translations/en.json
CHANGED
|
@@ -317,7 +317,6 @@
|
|
|
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",
|
|
321
320
|
"creatives.componentsv2.MobilePushPreviewV2.header": "This is the MobilePushPreviewV2 component !",
|
|
322
321
|
"creatives.containers.Assets.Gallery.alphabetically": "Alphabetically",
|
|
323
322
|
"creatives.containers.Assets.Gallery.assetDeleteFailed": "Image deletion failed.",
|
package/translations/ja-JP.json
CHANGED
|
@@ -316,7 +316,6 @@
|
|
|
316
316
|
"creatives.componentsV2.TopBar.profile": "",
|
|
317
317
|
"creatives.componentsV2.TopBar.settings": "",
|
|
318
318
|
"creatives.componentsV2.unbalanacedCurlyBraces": "",
|
|
319
|
-
"creatives.componentsV2.unquotedTagDefaultValue": "",
|
|
320
319
|
"creatives.componentsv2.MobilePushPreviewV2.header": "",
|
|
321
320
|
"creatives.containers.Assets.Gallery.alphabetically": "",
|
|
322
321
|
"creatives.containers.Assets.Gallery.assetDeleteFailed": "",
|
package/translations/zh.json
CHANGED
|
@@ -316,7 +316,6 @@
|
|
|
316
316
|
"creatives.componentsV2.TopBar.profile": "",
|
|
317
317
|
"creatives.componentsV2.TopBar.settings": "",
|
|
318
318
|
"creatives.componentsV2.unbalanacedCurlyBraces": "",
|
|
319
|
-
"creatives.componentsV2.unquotedTagDefaultValue": "",
|
|
320
319
|
"creatives.componentsv2.MobilePushPreviewV2.header": "",
|
|
321
320
|
"creatives.containers.Assets.Gallery.alphabetically": "",
|
|
322
321
|
"creatives.containers.Assets.Gallery.assetDeleteFailed": "",
|
package/utils/authWrapper.js
CHANGED
|
@@ -9,11 +9,13 @@ import { routerActions } from 'connected-react-router';
|
|
|
9
9
|
// import { UserAuthWrapper } from 'redux-auth-wrapper';
|
|
10
10
|
import { createSelector } from 'reselect';
|
|
11
11
|
import { makeSelectAuthenticated } from '../v2Containers/Cap/selectors';
|
|
12
|
+
import { isDevTokenAuth } from './devAuth';
|
|
12
13
|
// import config from '../config/app';
|
|
13
14
|
const orginUrl = window.location.origin;
|
|
14
15
|
// const loginUrl = '/auth/login';
|
|
15
16
|
|
|
16
17
|
export const getIsLoggedIn = () => {
|
|
18
|
+
if (isDevTokenAuth()) return true;
|
|
17
19
|
let isLoggedIn = false;
|
|
18
20
|
if (
|
|
19
21
|
process.env.NODE_ENV === 'production' &&
|
package/utils/common.js
CHANGED
|
@@ -28,7 +28,6 @@ import {
|
|
|
28
28
|
ENABLE_NEW_FORMBUILDER_SMS,
|
|
29
29
|
ENABLE_NEW_FORMBUILDER_MPUSH,
|
|
30
30
|
SUPPORT_ENGAGEMENT_MODULE,
|
|
31
|
-
ENABLE_TAGS_REVAMP,
|
|
32
31
|
} from '../constants/unified';
|
|
33
32
|
import { apiMessageFormatHandler } from './commonUtils';
|
|
34
33
|
|
|
@@ -115,12 +114,6 @@ export const hasJPLocaleHideFeatureEnabled = Auth.hasFeatureAccess.bind(
|
|
|
115
114
|
JP_LOCALE_HIDE_FEATURE,
|
|
116
115
|
);
|
|
117
116
|
|
|
118
|
-
export const hasTagsRevampEnabled = Auth.hasFeatureAccess.bind(
|
|
119
|
-
null,
|
|
120
|
-
ENABLE_TAGS_REVAMP,
|
|
121
|
-
);
|
|
122
|
-
|
|
123
|
-
|
|
124
117
|
export const hasWechatFeatureEnabled = Auth.hasFeatureAccess.bind(
|
|
125
118
|
null,
|
|
126
119
|
ENABLE_WECHAT,
|
package/utils/devAuth.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// Local-dev passwordless auth: seeds INTOUCH_DEV_CT/OID from .env into token/orgID; no-op in production.
|
|
2
|
+
import { saveItem } from '../services/localStorageApi';
|
|
3
|
+
|
|
4
|
+
const readEnv = (getter) => {
|
|
5
|
+
try {
|
|
6
|
+
if (process.env.NODE_ENV === 'production') return '';
|
|
7
|
+
return getter() || '';
|
|
8
|
+
} catch (e) {
|
|
9
|
+
return '';
|
|
10
|
+
}
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export const getDevCt = () => readEnv(() => process.env.INTOUCH_DEV_CT);
|
|
14
|
+
export const getDevOid = () => readEnv(() => process.env.INTOUCH_DEV_OID);
|
|
15
|
+
|
|
16
|
+
export const isDevTokenAuth = () => !!getDevCt();
|
|
17
|
+
|
|
18
|
+
export const seedDevAuth = () => {
|
|
19
|
+
const ct = getDevCt();
|
|
20
|
+
const oid = getDevOid();
|
|
21
|
+
if (!ct) return false;
|
|
22
|
+
saveItem('token', ct);
|
|
23
|
+
if (oid) {
|
|
24
|
+
saveItem('orgID', /^\d+$/.test(oid) ? Number(oid) : oid);
|
|
25
|
+
}
|
|
26
|
+
saveItem('isLoggedIn', true);
|
|
27
|
+
return true;
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
export const logDevAuthFailure = (status, url) => {
|
|
31
|
+
// eslint-disable-next-line no-console
|
|
32
|
+
console.error(
|
|
33
|
+
`[dev-auth] ${status} from ${url} using INTOUCH_DEV_CT/INTOUCH_DEV_OID from .env.\n` +
|
|
34
|
+
'Your dev token is likely expired or the OID does not match it. Not redirecting to login ' +
|
|
35
|
+
'(that would reload-loop). Fix: SSO-login to nightly in a browser, copy fresh CT and OID ' +
|
|
36
|
+
'cookie values into .env, then restart `npm start`.',
|
|
37
|
+
);
|
|
38
|
+
};
|
package/utils/history.js
CHANGED
|
@@ -2,11 +2,15 @@ import { createBrowserHistory } from 'history';
|
|
|
2
2
|
import pathConfig from '../config/path';
|
|
3
3
|
import rebaseHistory from './mfeHistory';
|
|
4
4
|
|
|
5
|
-
//
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
// History relative to /creatives/ui that can still navigate to roots outside it (e.g. /custom-tags/ui).
|
|
6
|
+
export const createAppHistory = (baseHistory = createBrowserHistory()) =>
|
|
7
|
+
rebaseHistory(baseHistory, pathConfig.publicPath, {
|
|
8
|
+
externalRoots: [pathConfig.customTagsPublicPath],
|
|
9
|
+
});
|
|
10
|
+
|
|
11
|
+
// Dev matches the MFE build (paths outside /creatives/ui work locally); production keeps the plain basename history.
|
|
8
12
|
const history = process.env.NODE_ENV === 'development'
|
|
9
|
-
?
|
|
13
|
+
? createAppHistory()
|
|
10
14
|
: createBrowserHistory({
|
|
11
15
|
basename: pathConfig.publicPath,
|
|
12
16
|
});
|
package/utils/mfeHistory.js
CHANGED
|
@@ -12,10 +12,11 @@
|
|
|
12
12
|
* routing keeps working unchanged, and navigation still flows through the single shared
|
|
13
13
|
* history. Standalone (no host history) is unaffected; the remote keeps creating its own.
|
|
14
14
|
*
|
|
15
|
-
*
|
|
16
|
-
* (by app-only code); they are left as they are both ways: never prefixed on navigation, and
|
|
17
|
-
* never stripped when read (stripBase only strips the prefix).
|
|
15
|
+
* Roots outside the prefix (registerOwnedPath, or the `externalRoots` option) are never prefixed or stripped.
|
|
18
16
|
*/
|
|
17
|
+
export const isUnderRoot = (root, pathname) =>
|
|
18
|
+
pathname === root || pathname.startsWith(`${root}/`);
|
|
19
|
+
|
|
19
20
|
const ownedPaths = new Set();
|
|
20
21
|
|
|
21
22
|
export const registerOwnedPath = (path) => {
|
|
@@ -23,16 +24,17 @@ export const registerOwnedPath = (path) => {
|
|
|
23
24
|
};
|
|
24
25
|
|
|
25
26
|
const isOwnedPath = (pathname = '') => [...ownedPaths]
|
|
26
|
-
.some((owned) => owned && (
|
|
27
|
+
.some((owned) => owned && isUnderRoot(owned, pathname));
|
|
27
28
|
|
|
28
|
-
const addBase = (base, to) => {
|
|
29
|
+
const addBase = (base, to, externalRoots = []) => {
|
|
29
30
|
if (typeof to === 'string') {
|
|
30
31
|
if (!to.startsWith('/')) return to; // already relative to current location
|
|
31
|
-
|
|
32
|
+
const pathname = to.split(/[?#]/)[0];
|
|
33
|
+
if (isOwnedPath(pathname) || externalRoots.some(root => isUnderRoot(root, pathname))) return to;
|
|
32
34
|
return to === '/' ? base : `${base}${to}`;
|
|
33
35
|
}
|
|
34
36
|
if (to && typeof to === 'object') {
|
|
35
|
-
return { ...to, pathname: addBase(base, to.pathname || '/') };
|
|
37
|
+
return { ...to, pathname: addBase(base, to.pathname || '/', externalRoots) };
|
|
36
38
|
}
|
|
37
39
|
return to;
|
|
38
40
|
};
|
|
@@ -44,9 +46,10 @@ const stripBase = (base, pathname) => {
|
|
|
44
46
|
return pathname;
|
|
45
47
|
};
|
|
46
48
|
|
|
47
|
-
export default function rebaseHistory(history, rawBase) {
|
|
49
|
+
export default function rebaseHistory(history, rawBase, { externalRoots = [] } = {}) {
|
|
48
50
|
const base = String(rawBase || '').replace(/\/+$/, ''); // normalise: no trailing slash
|
|
49
51
|
if (!base) return history;
|
|
52
|
+
const withBase = to => addBase(base, to, externalRoots);
|
|
50
53
|
const view = loc => ({ ...loc, pathname: stripBase(base, loc.pathname) });
|
|
51
54
|
return {
|
|
52
55
|
get length() {
|
|
@@ -58,8 +61,8 @@ export default function rebaseHistory(history, rawBase) {
|
|
|
58
61
|
get location() {
|
|
59
62
|
return view(history.location);
|
|
60
63
|
},
|
|
61
|
-
push: (to, state) => history.push(
|
|
62
|
-
replace: (to, state) => history.replace(
|
|
64
|
+
push: (to, state) => history.push(withBase(to), state),
|
|
65
|
+
replace: (to, state) => history.replace(withBase(to), state),
|
|
63
66
|
go: n => history.go(n),
|
|
64
67
|
goBack: () => history.goBack(),
|
|
65
68
|
goForward: () => history.goForward(),
|
|
@@ -69,8 +72,10 @@ export default function rebaseHistory(history, rawBase) {
|
|
|
69
72
|
createHref: to =>
|
|
70
73
|
history.createHref(
|
|
71
74
|
typeof to === 'string'
|
|
72
|
-
?
|
|
73
|
-
: { ...to, pathname:
|
|
75
|
+
? withBase(to)
|
|
76
|
+
: { ...to, pathname: withBase((to && to.pathname) || '/') },
|
|
74
77
|
),
|
|
78
|
+
// Lets callers check whether a path outside the prefix can be pushed client-side.
|
|
79
|
+
externalRoots,
|
|
75
80
|
};
|
|
76
81
|
}
|
package/utils/tagValidations.js
CHANGED
|
@@ -8,16 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import lodashForEach from 'lodash/forEach';
|
|
10
10
|
import lodashCloneDeep from 'lodash/cloneDeep';
|
|
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';
|
|
20
|
-
import { hasTagsRevampEnabled } from './common';
|
|
11
|
+
import { ENTRY_TRIGGER_TAG_REGEX, SKIP_TAGS_REGEX_GROUPS, TAG_CONTENT_REGEX, UNSUBSCRIBE_TAG, UNSUBSCRIBE_TAG_REGEX } from '../constants/unified';
|
|
21
12
|
|
|
22
13
|
const DEFAULT = 'default';
|
|
23
14
|
const SUBTAGS = 'subtags';
|
|
@@ -98,9 +89,9 @@ export const validateTagsCore = ({
|
|
|
98
89
|
}
|
|
99
90
|
|
|
100
91
|
response.isBraceError = !validateIfTagClosed(contentForBraceCheck);
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
if (response
|
|
92
|
+
if (response.isBraceError) {
|
|
93
|
+
response.valid = false;
|
|
94
|
+
} else if (response?.missingTags?.length > 0) {
|
|
104
95
|
response.valid = false;
|
|
105
96
|
}
|
|
106
97
|
return response;
|
|
@@ -212,30 +203,6 @@ export const validateIfTagClosed = (value) => {
|
|
|
212
203
|
return (l1 == l2 && l2 == l3 && l1 == l3);
|
|
213
204
|
};
|
|
214
205
|
|
|
215
|
-
// Splits a tag body into filters on `|` outside quotes (Liquid has no escaped quotes).
|
|
216
|
-
const splitTagFilters = (body) => {
|
|
217
|
-
const filters = [''];
|
|
218
|
-
let quote = null;
|
|
219
|
-
[...body].forEach((char) => {
|
|
220
|
-
if (quote) {
|
|
221
|
-
if (char === quote) quote = null;
|
|
222
|
-
} else if (char === "'" || char === '"') {
|
|
223
|
-
quote = char;
|
|
224
|
-
} else if (char === '|') {
|
|
225
|
-
filters.push('');
|
|
226
|
-
return;
|
|
227
|
-
}
|
|
228
|
-
filters[filters.length - 1] += char;
|
|
229
|
-
});
|
|
230
|
-
return filters;
|
|
231
|
-
};
|
|
232
|
-
|
|
233
|
-
// `default:` inside a {{ }} tag must be followed by a quoted value, e.g. {{tag | default: 'x'}}
|
|
234
|
-
export const hasUnquotedTagDefault = (value = '') =>
|
|
235
|
-
(String(value).match(/{{.*?}}/g) || []).some((tag) => splitTagFilters(tag.slice(2, -2))
|
|
236
|
-
.slice(1)
|
|
237
|
-
.some((filter) => DEFAULT_FILTER_REGEX.test(filter) && !QUOTED_DEFAULT_REGEX.test(filter)));
|
|
238
|
-
|
|
239
206
|
//replaces encoded string with their respective characters
|
|
240
207
|
export const preprocessHtml = (content) => {
|
|
241
208
|
const replacements = {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { seedDevAuth, isDevTokenAuth, logDevAuthFailure } from '../devAuth';
|
|
2
|
+
import { getIsLoggedIn } from '../authWrapper';
|
|
3
|
+
|
|
4
|
+
describe('devAuth', () => {
|
|
5
|
+
const { INTOUCH_DEV_CT, INTOUCH_DEV_OID } = process.env;
|
|
6
|
+
afterEach(() => {
|
|
7
|
+
process.env.INTOUCH_DEV_CT = INTOUCH_DEV_CT;
|
|
8
|
+
process.env.INTOUCH_DEV_OID = INTOUCH_DEV_OID;
|
|
9
|
+
localStorage.clear();
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
it('is a no-op when INTOUCH_DEV_CT is unset', () => {
|
|
13
|
+
delete process.env.INTOUCH_DEV_CT;
|
|
14
|
+
expect(isDevTokenAuth()).toBe(false);
|
|
15
|
+
expect(seedDevAuth()).toBe(false);
|
|
16
|
+
expect(localStorage.getItem('token')).toBeNull();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('overwrites stale token/orgID and makes the user logged in', () => {
|
|
20
|
+
localStorage.setItem('token', JSON.stringify('stale'));
|
|
21
|
+
localStorage.setItem('orgID', JSON.stringify(1));
|
|
22
|
+
process.env.INTOUCH_DEV_CT = 'ct-value';
|
|
23
|
+
process.env.INTOUCH_DEV_OID = '50074';
|
|
24
|
+
expect(seedDevAuth()).toBe(true);
|
|
25
|
+
expect(JSON.parse(localStorage.getItem('token'))).toBe('ct-value');
|
|
26
|
+
expect(JSON.parse(localStorage.getItem('orgID'))).toBe(50074);
|
|
27
|
+
localStorage.removeItem('token');
|
|
28
|
+
expect(getIsLoggedIn()).toBe(true);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('logs instead of throwing on auth failure', () => {
|
|
32
|
+
const spy = jest.spyOn(console, 'error').mockImplementation(() => {});
|
|
33
|
+
logDevAuthFailure(401, '/arya/api/v1/auth/user');
|
|
34
|
+
expect(spy).toHaveBeenCalledWith(expect.stringContaining('401'));
|
|
35
|
+
spy.mockRestore();
|
|
36
|
+
});
|
|
37
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { createMemoryHistory } from 'history';
|
|
2
|
+
import { createAppHistory } from '../history';
|
|
3
|
+
|
|
4
|
+
describe('createAppHistory', () => {
|
|
5
|
+
it('keeps /creatives/ui-relative routing for app paths', () => {
|
|
6
|
+
const base = createMemoryHistory({ initialEntries: ['/creatives/ui/v2'] });
|
|
7
|
+
const history = createAppHistory(base);
|
|
8
|
+
expect(history.location.pathname).toBe('/v2');
|
|
9
|
+
history.push({ pathname: '/email', search: '?a=1' });
|
|
10
|
+
expect(base.location.pathname).toBe('/creatives/ui/email');
|
|
11
|
+
expect(base.location.search).toBe('?a=1');
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
it('navigates client-side to /custom-tags/ui paths without prefixing them', () => {
|
|
15
|
+
const base = createMemoryHistory({ initialEntries: ['/custom-tags/ui'] });
|
|
16
|
+
const history = createAppHistory(base);
|
|
17
|
+
const listener = jest.fn();
|
|
18
|
+
history.listen(listener);
|
|
19
|
+
history.push('/custom-tags/ui/123');
|
|
20
|
+
expect(base.location.pathname).toBe('/custom-tags/ui/123');
|
|
21
|
+
expect(history.location.pathname).toBe('/custom-tags/ui/123');
|
|
22
|
+
expect(listener).toHaveBeenCalledWith(
|
|
23
|
+
expect.objectContaining({ pathname: '/custom-tags/ui/123' }),
|
|
24
|
+
'PUSH',
|
|
25
|
+
);
|
|
26
|
+
expect(history.externalRoots).toEqual(['/custom-tags/ui']);
|
|
27
|
+
});
|
|
28
|
+
});
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { createMemoryHistory } from 'history';
|
|
2
|
-
import rebaseHistory, { registerOwnedPath } from '../mfeHistory';
|
|
2
|
+
import rebaseHistory, { registerOwnedPath, isUnderRoot } from '../mfeHistory';
|
|
3
3
|
|
|
4
4
|
const OWNED = '/own-page/ui';
|
|
5
5
|
|
|
6
|
-
const setup = (initial = '/creatives/ui/v2') => {
|
|
6
|
+
const setup = (initial = '/creatives/ui/v2', opts) => {
|
|
7
7
|
const shared = createMemoryHistory({ initialEntries: [initial] });
|
|
8
|
-
return { shared, history: rebaseHistory(shared, '/creatives/ui') };
|
|
8
|
+
return { shared, history: rebaseHistory(shared, '/creatives/ui', opts) };
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
describe('rebaseHistory', () => {
|
|
@@ -50,4 +50,30 @@ describe('rebaseHistory', () => {
|
|
|
50
50
|
history.push(OWNED);
|
|
51
51
|
expect(listener.mock.calls.map(([location]) => location.pathname)).toEqual(['/v2', OWNED]);
|
|
52
52
|
});
|
|
53
|
+
|
|
54
|
+
it('without externalRoots, still prefixes /custom-tags/ui', () => {
|
|
55
|
+
const { shared, history } = setup();
|
|
56
|
+
history.push('/custom-tags/ui/1');
|
|
57
|
+
expect(shared.location.pathname).toBe('/creatives/ui/custom-tags/ui/1');
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('passes paths under an external root through un-prefixed', () => {
|
|
61
|
+
const { shared, history } = setup(undefined, { externalRoots: ['/custom-tags/ui'] });
|
|
62
|
+
history.push('/custom-tags/ui/1');
|
|
63
|
+
expect(shared.location.pathname).toBe('/custom-tags/ui/1');
|
|
64
|
+
expect(history.location.pathname).toBe('/custom-tags/ui/1');
|
|
65
|
+
history.push('/custom-tags/ui?status=ACTIVE');
|
|
66
|
+
expect(shared.location.pathname).toBe('/custom-tags/ui');
|
|
67
|
+
expect(shared.location.search).toBe('?status=ACTIVE');
|
|
68
|
+
history.replace({ pathname: '/custom-tags/ui' });
|
|
69
|
+
expect(shared.location.pathname).toBe('/custom-tags/ui');
|
|
70
|
+
expect(history.createHref({ pathname: '/custom-tags/ui/2' })).toBe('/custom-tags/ui/2');
|
|
71
|
+
expect(history.externalRoots).toEqual(['/custom-tags/ui']);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it('only matches whole path segments', () => {
|
|
75
|
+
expect(isUnderRoot('/custom-tags/ui', '/custom-tags/ui')).toBe(true);
|
|
76
|
+
expect(isUnderRoot('/custom-tags/ui', '/custom-tags/ui/1')).toBe(true);
|
|
77
|
+
expect(isUnderRoot('/custom-tags/ui', '/custom-tags/uix')).toBe(false);
|
|
78
|
+
});
|
|
53
79
|
});
|
|
@@ -1,14 +1,4 @@
|
|
|
1
1
|
import '@testing-library/jest-dom';
|
|
2
|
-
import { hasTagsRevampEnabled } from '../common';
|
|
3
|
-
|
|
4
|
-
jest.mock('../common', () => ({
|
|
5
|
-
...jest.requireActual('../common'),
|
|
6
|
-
hasTagsRevampEnabled: jest.fn(),
|
|
7
|
-
}));
|
|
8
|
-
|
|
9
|
-
beforeEach(() => {
|
|
10
|
-
hasTagsRevampEnabled.mockReturnValue(true);
|
|
11
|
-
});
|
|
12
2
|
import {
|
|
13
3
|
hasUnsubscribeTag,
|
|
14
4
|
validateTagsCore,
|
|
@@ -21,7 +11,6 @@ import {
|
|
|
21
11
|
skipTags,
|
|
22
12
|
checkIfSupportedTag,
|
|
23
13
|
transformInjectedTags,
|
|
24
|
-
hasUnquotedTagDefault,
|
|
25
14
|
} from '../tagValidations';
|
|
26
15
|
import { containsBase64Images } from '../content';
|
|
27
16
|
|
|
@@ -204,58 +193,6 @@ describe("check if curly brackets are balanced", () => {
|
|
|
204
193
|
})
|
|
205
194
|
})
|
|
206
195
|
|
|
207
|
-
describe('hasUnquotedTagDefault', () => {
|
|
208
|
-
it('allows tags without default and defaults within quotes', () => {
|
|
209
|
-
expect(hasUnquotedTagDefault('{{badge_description}}')).toBe(false);
|
|
210
|
-
expect(hasUnquotedTagDefault("{{badge_description | default: ''}}")).toBe(false);
|
|
211
|
-
expect(hasUnquotedTagDefault("{{badge_description | default: 'Rafeeq'}}")).toBe(false);
|
|
212
|
-
expect(hasUnquotedTagDefault('{{badge_description | default: "Rafeeq\'s"}}')).toBe(false);
|
|
213
|
-
expect(hasUnquotedTagDefault("Hi {{a|default:' '}} {{b}} plain text")).toBe(false);
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
it('flags default with missing or unquoted value', () => {
|
|
217
|
-
expect(hasUnquotedTagDefault('{{badge_description | default: }}')).toBe(true);
|
|
218
|
-
expect(hasUnquotedTagDefault('{{badge_description | default: Rafeeq}}')).toBe(true);
|
|
219
|
-
expect(hasUnquotedTagDefault("{{badge_description | default: 'Rafeeq}}")).toBe(true);
|
|
220
|
-
expect(hasUnquotedTagDefault("{{a}} {{b | default: 'x' y}}")).toBe(true);
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
it('ignores pipes inside quotes and allows chained filters', () => {
|
|
224
|
-
expect(hasUnquotedTagDefault("{{name | replace: '| default:', 'x'}}")).toBe(false);
|
|
225
|
-
expect(hasUnquotedTagDefault("{{name | default: 'a | default: b'}}")).toBe(false);
|
|
226
|
-
expect(hasUnquotedTagDefault("{{name | default: 'a|b'}}")).toBe(false);
|
|
227
|
-
expect(hasUnquotedTagDefault("{{name | default: 'x' | append: '!'}}")).toBe(false);
|
|
228
|
-
expect(hasUnquotedTagDefault("{{name | append: 'x' | default: 'y'}}")).toBe(false);
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
it('rejects backslash-escaped quotes since Liquid has no escapes', () => {
|
|
232
|
-
expect(hasUnquotedTagDefault("{{name | default: 'it\\'s'}}")).toBe(true);
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
|
|
236
|
-
describe('validateTagsCore default quote check', () => {
|
|
237
|
-
const run = (content) => validateTagsCore({
|
|
238
|
-
contentForBraceCheck: content, contentForUnsubscribeScan: content, tags: null, currentModule: 'default', isFullMode: true,
|
|
239
|
-
});
|
|
240
|
-
|
|
241
|
-
it('marks unquoted default as invalid with isDefaultQuoteError', () => {
|
|
242
|
-
expect(run('{{name | default: Rafeeq}}')).toEqual(expect.objectContaining({ valid: false, isBraceError: false, isDefaultQuoteError: true }));
|
|
243
|
-
});
|
|
244
|
-
|
|
245
|
-
it('skips the default quote check when the tags revamp is disabled', () => {
|
|
246
|
-
hasTagsRevampEnabled.mockReturnValueOnce(false);
|
|
247
|
-
expect(run('{{name | default: Rafeeq}}')).toEqual(expect.objectContaining({ valid: true, isDefaultQuoteError: false }));
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
it('keeps quoted default valid', () => {
|
|
251
|
-
expect(run("{{name | default: 'Rafeeq'}}")).toEqual(expect.objectContaining({ valid: true, isDefaultQuoteError: false }));
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
it('reports only brace error when braces are not closed', () => {
|
|
255
|
-
expect(run('{{name | default: Rafeeq}')).toEqual(expect.objectContaining({ isBraceError: true, isDefaultQuoteError: false }));
|
|
256
|
-
});
|
|
257
|
-
});
|
|
258
|
-
|
|
259
196
|
describe("validateTags", () => {
|
|
260
197
|
const tagsParam = [
|
|
261
198
|
{
|