@capillarytech/creatives-library 7.17.220 → 7.17.222
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/containers/App/constants.js +1 -0
- package/package.json +1 -1
- package/utils/tagValidations.js +13 -1
- package/utils/tests/tagValidations.test.js +18 -0
- package/v2Components/FormBuilder/index.js +7 -2
- package/v2Containers/TagList/index.js +1 -1
- package/v2Containers/TagList/messages.js +3 -3
- package/v2Containers/TagList/tests/TagList.test.js +1 -1
package/package.json
CHANGED
package/utils/tagValidations.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
|
|
9
9
|
import lodashForEach from 'lodash/forEach';
|
|
10
10
|
import lodashCloneDeep from 'lodash/cloneDeep';
|
|
11
|
+
import { ENTRY_TRIGGER_TAG_REGEX } from '../containers/App/constants';
|
|
11
12
|
|
|
12
13
|
const DEFAULT = 'default';
|
|
13
14
|
const SUBTAGS = 'subtags';
|
|
@@ -17,7 +18,7 @@ const SUBTAGS = 'subtags';
|
|
|
17
18
|
* @param {Object} response - The response object to check.
|
|
18
19
|
* @param {Object} tagObject - The tagLookupMap.
|
|
19
20
|
*/
|
|
20
|
-
export const checkSupport = (response = {}, tagObject = {}, eventContextTags = []) => {
|
|
21
|
+
export const checkSupport = (response = {}, tagObject = {}, eventContextTags = [], isLiquidFlow = false) => {
|
|
21
22
|
const supportedList = [];
|
|
22
23
|
// Verifies the presence of the tag in the 'Add Labels' section.
|
|
23
24
|
// Incase of journey event context the tags won't be available in the tagObject(tagLookupMap).
|
|
@@ -25,6 +26,13 @@ export const checkSupport = (response = {}, tagObject = {}, eventContextTags = [
|
|
|
25
26
|
|
|
26
27
|
// Verify if childTag is a valid sub-tag of parentTag from the 'Add Labels' section or if it's unsupported.
|
|
27
28
|
const checkSubtags = (parentTag, childName) => {
|
|
29
|
+
// For event context tags the parentTag will be the event context tag name and subtags will be the child attributes for leaderboards
|
|
30
|
+
if (checkNameInTagObjectOrEventContext(parentTag) && isLiquidFlow && eventContextTags?.length) {
|
|
31
|
+
const childNameAfterDot = childName?.split(".")?.[1];
|
|
32
|
+
if (eventContextTags?.some((tag) => tag?.subTags?.includes(childNameAfterDot))) {
|
|
33
|
+
supportedList.push(childName);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
28
36
|
if (!tagObject?.[parentTag]) return false;
|
|
29
37
|
let updatedChildName = childName;
|
|
30
38
|
if (childName?.includes(".")) {
|
|
@@ -195,6 +203,10 @@ const indexOfEnd = (targetString, string) => {
|
|
|
195
203
|
}
|
|
196
204
|
|
|
197
205
|
export const skipTags = (tag) => {
|
|
206
|
+
// If the tag contains the word "entryTrigger_", then it's an event context tag and should not be skipped.
|
|
207
|
+
if (tag?.match(ENTRY_TRIGGER_TAG_REGEX)) {
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
198
210
|
const regexGroups = ["dynamic_expiry_date_after_\\d+_days.FORMAT_\\d", "unsubscribe\\(#[a-zA-Z\\d]{6}\\)","Link_to_[a-zA-z]","SURVEY.*.TOKEN", "^[A-Za-z].*\\([a-zA-Z\\d]*\\)"];
|
|
199
211
|
let skipped = false;
|
|
200
212
|
lodashForEach(regexGroups, (group) => {
|
|
@@ -376,6 +376,24 @@ describe("checkSupport", () => {
|
|
|
376
376
|
const result = checkSupport(response, {});
|
|
377
377
|
expect(result).toEqual([]);
|
|
378
378
|
});
|
|
379
|
+
|
|
380
|
+
it("should add childName to supportedList if it is a subtag of parentTag in eventContextTags", () => {
|
|
381
|
+
const response = { data: [{ name: "leaderboard", children: [{name: "person.userId"}]}]};
|
|
382
|
+
const tagObject = {};
|
|
383
|
+
const eventContextTags = [{ tagName: "leaderboard", subTags: ["userId"]}];
|
|
384
|
+
const isLiquidFlow = true;
|
|
385
|
+
const result = checkSupport(response, tagObject, eventContextTags, isLiquidFlow);
|
|
386
|
+
expect(result).toEqual( [ 'leaderboard', 'person.userId' ]);
|
|
387
|
+
});
|
|
388
|
+
|
|
389
|
+
it("should add only parent tag to supportedList if isLiquidFlow false", () => {
|
|
390
|
+
const response = { data: [{ name: "leaderboard", children: [{name: "person.userId"}]}]};
|
|
391
|
+
const tagObject = {};
|
|
392
|
+
const eventContextTags = [{ tagName: "leaderboard", subTags: ["userId"]}];
|
|
393
|
+
const isLiquidFlow = false;
|
|
394
|
+
const result = checkSupport(response, tagObject, eventContextTags, isLiquidFlow);
|
|
395
|
+
expect(result).toEqual( [ 'leaderboard' ]);
|
|
396
|
+
});
|
|
379
397
|
});
|
|
380
398
|
|
|
381
399
|
describe('preprocessHtml', () => {
|
|
@@ -55,7 +55,7 @@ import { convert } from 'html-to-text';
|
|
|
55
55
|
import { OUTBOUND } from './constants';
|
|
56
56
|
import { GET_TRANSLATION_MAPPED } from '../../containers/TagList/constants';
|
|
57
57
|
import moment from 'moment';
|
|
58
|
-
import { CUSTOMER_BARCODE_TAG , COPY_OF} from '../../containers/App/constants';
|
|
58
|
+
import { CUSTOMER_BARCODE_TAG , COPY_OF, ENTRY_TRIGGER_TAG_REGEX} from '../../containers/App/constants';
|
|
59
59
|
import { hasLiquidSupportFeature, isEmailUnsubscribeTagMandatory } from '../../utils/common';
|
|
60
60
|
import { isUrl } from '../../v2Containers/Line/Container/Wrapper/utils';
|
|
61
61
|
import { bindActionCreators } from 'redux';
|
|
@@ -1121,7 +1121,8 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1121
1121
|
const supportedLiquidTags = checkSupport(
|
|
1122
1122
|
result,
|
|
1123
1123
|
this.props?.metaEntities?.tagLookupMap,
|
|
1124
|
-
this.props?.eventContextTags
|
|
1124
|
+
this.props?.eventContextTags,
|
|
1125
|
+
this.liquidFlow,
|
|
1125
1126
|
);
|
|
1126
1127
|
const unsupportedLiquidTags = extractedLiquidTags?.filter(
|
|
1127
1128
|
(tag) => !supportedLiquidTags?.includes(tag) && !this.skipTags(tag)
|
|
@@ -1197,6 +1198,10 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1197
1198
|
};
|
|
1198
1199
|
|
|
1199
1200
|
skipTags(tag) {
|
|
1201
|
+
// If the tag contains the word "entryTrigger_", then it's an event context tag and it should not be skipped.
|
|
1202
|
+
if (tag?.match(ENTRY_TRIGGER_TAG_REGEX)) {
|
|
1203
|
+
return false;
|
|
1204
|
+
}
|
|
1200
1205
|
const regexGroups = ["dynamic_expiry_date_after_\\d+_days.FORMAT_\\d", "unsubscribe\\(#[a-zA-Z\\d]{6}\\)","Link_to_[a-zA-z]","SURVEY.*.TOKEN","^[A-Za-z].*\\([a-zA-Z\\d]*\\)"];
|
|
1201
1206
|
//const regexGroups = [];
|
|
1202
1207
|
let skipped = false;
|
|
@@ -105,7 +105,7 @@ export class TagList extends React.Component { // eslint-disable-line react/pref
|
|
|
105
105
|
}
|
|
106
106
|
}
|
|
107
107
|
if (eventContextTags?.length) {
|
|
108
|
-
const TAG_HEADER_MSG_LABEL = this.props.intl.formatMessage(messages.
|
|
108
|
+
const TAG_HEADER_MSG_LABEL = this.props.intl.formatMessage(messages.entryEvent);
|
|
109
109
|
eventContextTagsObj.EventContextTags = {
|
|
110
110
|
name: TAG_HEADER_MSG_LABEL,
|
|
111
111
|
desc: TAG_HEADER_MSG_LABEL,
|
|
@@ -11,8 +11,8 @@ export default defineMessages({
|
|
|
11
11
|
id: `${scope}.header`,
|
|
12
12
|
defaultMessage: 'This is TagList container !',
|
|
13
13
|
},
|
|
14
|
-
|
|
15
|
-
id: `${scope}.
|
|
16
|
-
defaultMessage: '
|
|
14
|
+
entryEvent: {
|
|
15
|
+
id: `${scope}.entryEvent`,
|
|
16
|
+
defaultMessage: 'Entry event',
|
|
17
17
|
},
|
|
18
18
|
});
|
|
@@ -44,7 +44,7 @@ describe("TagList test : UNIT", () => {
|
|
|
44
44
|
it('should render event context tags correctly from generateTags', () => {
|
|
45
45
|
initializeTagList({eventContextTags});
|
|
46
46
|
addLabelBtnAssertion();
|
|
47
|
-
const EVENT_CONTEXT_TAG_HEADER = getByText('
|
|
47
|
+
const EVENT_CONTEXT_TAG_HEADER = getByText('Entry event');
|
|
48
48
|
expect(EVENT_CONTEXT_TAG_HEADER).toBeInTheDocument();
|
|
49
49
|
fireEvent.click(EVENT_CONTEXT_TAG_HEADER);
|
|
50
50
|
expect(getByText('lifetimePurchases')).toBeInTheDocument();
|