@capillarytech/creatives-library 7.17.219 → 7.17.220-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/package.json +1 -1
- package/utils/tagValidations.js +8 -1
- package/utils/tests/tagValidations.test.js +18 -0
- package/v2Components/FormBuilder/index.js +2 -1
- 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
|
@@ -17,7 +17,7 @@ const SUBTAGS = 'subtags';
|
|
|
17
17
|
* @param {Object} response - The response object to check.
|
|
18
18
|
* @param {Object} tagObject - The tagLookupMap.
|
|
19
19
|
*/
|
|
20
|
-
export const checkSupport = (response = {}, tagObject = {}, eventContextTags = []) => {
|
|
20
|
+
export const checkSupport = (response = {}, tagObject = {}, eventContextTags = [], isLiquidFlow = false) => {
|
|
21
21
|
const supportedList = [];
|
|
22
22
|
// Verifies the presence of the tag in the 'Add Labels' section.
|
|
23
23
|
// Incase of journey event context the tags won't be available in the tagObject(tagLookupMap).
|
|
@@ -25,6 +25,13 @@ export const checkSupport = (response = {}, tagObject = {}, eventContextTags = [
|
|
|
25
25
|
|
|
26
26
|
// Verify if childTag is a valid sub-tag of parentTag from the 'Add Labels' section or if it's unsupported.
|
|
27
27
|
const checkSubtags = (parentTag, childName) => {
|
|
28
|
+
// For event context tags the parentTag will be the event context tag name and subtags will be the child attributes for leaderboards
|
|
29
|
+
if (checkNameInTagObjectOrEventContext(parentTag) && isLiquidFlow && eventContextTags?.length) {
|
|
30
|
+
const childNameAfterDot = childName?.split(".")?.[1];
|
|
31
|
+
if (eventContextTags?.some((tag) => tag?.subTags?.includes(childNameAfterDot))) {
|
|
32
|
+
supportedList.push(childName);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
28
35
|
if (!tagObject?.[parentTag]) return false;
|
|
29
36
|
let updatedChildName = childName;
|
|
30
37
|
if (childName?.includes(".")) {
|
|
@@ -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', () => {
|
|
@@ -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)
|
|
@@ -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();
|