@capillarytech/creatives-library 8.0.31 → 8.0.33

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.
@@ -110,3 +110,4 @@ export const BADGES_ISSUE = 'BADGES_ISSUE';
110
110
 
111
111
  export const CUSTOMER_BARCODE_TAG = "customer_barcode";
112
112
  export const COPY_OF = "Copy of";
113
+ export const ENTRY_TRIGGER_TAG_REGEX = /\bentryTrigger_\w+(_\w+)?(\(\w+\))?/g;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.31",
4
+ "version": "8.0.33",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -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) => {
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import '@testing-library/jest-dom';
3
- import { checkSupport, extractNames, getTagMapValue, preprocessHtml, validateIfTagClosed,validateTags} from '../tagValidations';
3
+ import { checkSupport, extractNames, getTagMapValue, preprocessHtml, validateIfTagClosed,validateTags, skipTags } from '../tagValidations';
4
4
  import { eventContextTags } from '../../v2Containers/TagList/tests/mockdata';
5
5
 
6
6
  describe("check if curly brackets are balanced", () => {
@@ -376,6 +376,34 @@ 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 not add childName to supportedList which does not have dot in eventContextTags", () => {
390
+ // This case is unlikely to happen as we are not supporting tags without dot in eventContextTags
391
+ const response = { data: [{ name: "entryTrigger_lifetimePoints", children: [{name: "userId"}] }]};
392
+ const tagObject = {};
393
+ const eventContextTags = [{ tagName: "entryTrigger_lifetimePoints", children: [{name: "userId"}] }];
394
+ const isLiquidFlow = true;
395
+ const result = checkSupport(response, tagObject, eventContextTags, isLiquidFlow);
396
+ expect(result).toEqual( [ "entryTrigger_lifetimePoints" ]);
397
+ });
398
+
399
+ it("should add only parent tag to supportedList if isLiquidFlow false", () => {
400
+ const response = { data: [{ name: "leaderboard", children: [{name: "person.userId"}]}]};
401
+ const tagObject = {};
402
+ const eventContextTags = [{ tagName: "leaderboard", subTags: ["userId"]}];
403
+ const isLiquidFlow = false;
404
+ const result = checkSupport(response, tagObject, eventContextTags, isLiquidFlow);
405
+ expect(result).toEqual( [ 'leaderboard' ]);
406
+ });
379
407
  });
380
408
 
381
409
  describe('preprocessHtml', () => {
@@ -454,4 +482,18 @@ describe("getTagMapValue", () => {
454
482
  const result = getTagMapValue(object);
455
483
  expect(result).toEqual({ name: "233" });
456
484
  });
485
+ });
486
+
487
+ describe("skipTags", () => {
488
+ it("should return false for event context tags", () => {
489
+ const tag = "entryTrigger_uniqueTagPrefix(raindrops_match)";
490
+ const result = skipTags(tag);
491
+ expect(result).toEqual(false);
492
+ });
493
+
494
+ it("should return true for tags matching regex patterns", () => {
495
+ const tag = "voucher(12345)";
496
+ const result = skipTags(tag);
497
+ expect(result).toEqual(true);
498
+ });
457
499
  });
@@ -50,7 +50,7 @@
50
50
  .hide{
51
51
  display: none;
52
52
  }
53
- .error{
53
+ .error-form-builder {
54
54
  color : #F34F56;
55
55
  }
56
56
 
@@ -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;
@@ -2478,7 +2483,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2478
2483
  <TextArea
2479
2484
  id={val.id}
2480
2485
  placeholder={val.placeholder ? val.placeholder : ''}
2481
- className={`${ifError ? 'error' : ''}`}
2486
+ className={`${ifError ? 'error-form-builder' : ''}`}
2482
2487
  errorMessage={errorMessageText}
2483
2488
  label={val.label}
2484
2489
  autosize={val.autosize ? val.autosizeParams : 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.tagsBasedOnEntryTriggerEvent);
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
- tagsBasedOnEntryTriggerEvent: {
15
- id: `${scope}.tagsBasedOnEntryTriggerEvent`,
16
- defaultMessage: 'Tags based on entry trigger event',
14
+ entryEvent: {
15
+ id: `${scope}.entryEvent`,
16
+ defaultMessage: 'Entry event',
17
17
  },
18
18
  });
@@ -46,7 +46,7 @@ describe("TagList test : UNIT", () => {
46
46
  it('should render event context tags correctly from generateTags', () => {
47
47
  initializeTagList({eventContextTags});
48
48
  addLabelBtnAssertion();
49
- const EVENT_CONTEXT_TAG_HEADER = getByText('Tags based on entry trigger event');
49
+ const EVENT_CONTEXT_TAG_HEADER = getByText('Entry event');
50
50
  expect(EVENT_CONTEXT_TAG_HEADER).toBeInTheDocument();
51
51
  fireEvent.click(EVENT_CONTEXT_TAG_HEADER);
52
52
  expect(getByText('lifetimePurchases')).toBeInTheDocument();