@capillarytech/creatives-library 8.0.227 → 8.0.228

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.227",
4
+ "version": "8.0.228",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
@@ -19,6 +19,7 @@ const SUBTAGS = 'subtags';
19
19
  * @param {Object} tagObject - The tagLookupMap.
20
20
  */
21
21
  export const checkSupport = (response = {}, tagObject = {}, eventContextTags = [], isLiquidFlow = false, forwardedTags = {}) => {
22
+
22
23
  const supportedList = [];
23
24
  // Verifies the presence of the tag in the 'Add Labels' section.
24
25
  // Incase of journey event context the tags won't be available in the tagObject(tagLookupMap).
@@ -39,7 +40,7 @@ export const checkSupport = (response = {}, tagObject = {}, eventContextTags = [
39
40
  let updatedChildName = childName;
40
41
  let updatedWithoutDotChildName = childName;
41
42
  if (childName?.includes(".")) {
42
- updatedChildName = `.${childName?.split(".")?.[1]}`;
43
+ updatedChildName = "." + childName?.split(".")?.[1];
43
44
  updatedWithoutDotChildName = childName?.split(".")?.[1];
44
45
  }
45
46
  if (tagObject?.[parentTag]) {
@@ -70,6 +71,7 @@ export const checkSupport = (response = {}, tagObject = {}, eventContextTags = [
70
71
  if (item?.children?.length) {
71
72
  processChildren(item?.name, item?.children);
72
73
  }
74
+
73
75
  }
74
76
 
75
77
 
@@ -78,19 +80,19 @@ export const checkSupport = (response = {}, tagObject = {}, eventContextTags = [
78
80
 
79
81
  const handleForwardedTags = (forwardedTags) => {
80
82
  const result = [];
81
- Object.keys(forwardedTags).forEach((key) => {
83
+ Object.keys(forwardedTags).forEach(key => {
82
84
  result.push(key); // Add the main key to the result array
83
-
85
+
84
86
  // Check if there are subtags for the current key
85
87
  if (forwardedTags[key].subtags) {
86
88
  // If subtags exist, add all subtag keys to the result array
87
- Object.keys(forwardedTags[key].subtags).forEach((subkey) => {
88
- result.push(subkey);
89
+ Object.keys(forwardedTags[key].subtags).forEach(subkey => {
90
+ result.push(subkey);
89
91
  });
90
92
  }
91
93
  });
92
94
  return result;
93
- };
95
+ }
94
96
 
95
97
  /**
96
98
  * Extracts the names from the given data.
@@ -153,7 +155,7 @@ export const validateTags = ({
153
155
  unsupportedTags: [],
154
156
  isBraceError: false,
155
157
  };
156
- if (tags && tags.length) {
158
+ if(tags && tags.length) {
157
159
  lodashForEach(tags, ({
158
160
  definition: {
159
161
  supportedModules,
@@ -214,7 +216,7 @@ export const validateTags = ({
214
216
  // validations (eg button) are handled on valid property coming from the response.
215
217
  response.isBraceError ? response.valid = false : response.valid = true;
216
218
  return response;
217
- };
219
+ }
218
220
 
219
221
  /**
220
222
  * Checks if the given tag is supported based on the injected tags.
@@ -231,14 +233,14 @@ export const checkIfSupportedTag = (checkingTag, injectedTags) => {
231
233
  result = true;
232
234
  }
233
235
  });
234
-
236
+
235
237
  return result;
236
- };
238
+ }
237
239
 
238
240
  const indexOfEnd = (targetString, string) => {
239
- const io = targetString.indexOf(string);
241
+ let io = targetString.indexOf(string);
240
242
  return io == -1 ? -1 : io + string.length;
241
- };
243
+ }
242
244
 
243
245
  export const skipTags = (tag) => {
244
246
  // If the tag contains the word "entryTrigger.", then it's an event context tag and should not be skipped.
@@ -266,100 +268,35 @@ export const transformInjectedTags = (tags) => {
266
268
  if (subKey !== '') {
267
269
  temp['tag-header'] = true;
268
270
  if (subKey !== SUBTAGS) {
269
- temp.subtags = lodashCloneDeep(temp[subKey]);
271
+ temp.subtags =lodashCloneDeep(temp[subKey]);
270
272
  delete temp[subKey];
271
273
  }
272
274
  temp.subtags = transformInjectedTags(temp.subtags);
273
275
  }
274
276
  });
275
277
  return tags;
276
- };
278
+ }
277
279
 
278
280
  //checks if the opening curly brackets have corresponding closing brackets
279
281
  export const validateIfTagClosed = (value) => {
280
282
  if (value.includes("{{{{") || value.includes("}}}}")) {
281
283
  return false;
282
284
  }
283
- const regex1 = /{{.*?}}/g;
284
- const regex2 = /{{/g;
285
- const regex3 = /}}/g;
285
+ let regex1 = /{{.*?}}/g;
286
+ let regex2 = /{{/g;
287
+ let regex3 = /}}/g;
286
288
 
287
- const l1 = value.match(regex1)?.length;
288
- const l2 = value.match(regex2)?.length;
289
- const l3 = value.match(regex3)?.length;
289
+ let l1 = value.match(regex1)?.length;
290
+ let l2 = value.match(regex2)?.length;
291
+ let l3 = value.match(regex3)?.length;
290
292
 
291
293
  return (l1 == l2 && l2 == l3 && l1 == l3);
292
- };
293
-
294
- /**
295
- * Validates tag format: ensures tags are in format {{tag_name}} and checks for invalid patterns
296
- * Validates against:
297
- * - Single braces like {tag} (must be {{tag}})
298
- * - Invalid patterns like {{first or first}}, {{first and first}}
299
- * - Empty tag names
300
- * - Unclosed single braces within tag names
301
- * @param {string} textContent - The text content to validate
302
- * @returns {boolean} - True if all tags have valid format, false otherwise
303
- */
304
- export const validateTagFormat = (textContent) => {
305
- // Find all potential tag patterns {{tag_name}}
306
- const tagPattern = /{{[^}]*}}/g;
307
- const matches = textContent.match(tagPattern) || [];
308
-
309
- // Remove all valid {{tag}} patterns from content to check for invalid braces
310
- let contentWithoutValidTags = textContent;
311
- matches.forEach((match) => {
312
- contentWithoutValidTags = contentWithoutValidTags.replace(match, '');
313
- });
314
-
315
- // Check if there are any remaining braces (single braces or unclosed braces)
316
- // These would be invalid patterns like {tag}, {first, first}, etc.
317
- if (contentWithoutValidTags.includes('{') || contentWithoutValidTags.includes('}')) {
318
- return false;
319
- }
320
-
321
- // Check each tag for valid format
322
- const allTagsValid = matches.every((match) => {
323
- // Valid tag format: {{tag_name}} - must start with {{ and end with }}
324
- if (!match.startsWith('{{') || !match.endsWith('}}')) {
325
- return false;
326
- }
327
-
328
- // Extract tag name (content between {{ and }})
329
- const tagName = match.slice(2, -2).trim();
330
-
331
- // Tag name should not be empty
332
- if (!tagName) {
333
- return false;
334
- }
335
-
336
- // Check for invalid patterns in tag name
337
- // Invalid patterns: "first or first", "first and first", etc.
338
- const invalidPatterns = [
339
- /\s+or\s+/i, // " or " as separate word (e.g., "first or first")
340
- /\s+and\s+/i, // " and " as separate word
341
- ];
342
-
343
- const hasInvalidPattern = invalidPatterns.some((pattern) => pattern.test(tagName));
344
- if (hasInvalidPattern) {
345
- return false;
346
- }
347
-
348
- // Check for unclosed single braces in tag name (e.g., {{first{name}})
349
- const singleOpenBraces = (tagName.match(/{/g) || []).length;
350
- const singleCloseBraces = (tagName.match(/}/g) || []).length;
351
- if (singleOpenBraces !== singleCloseBraces) {
352
- return false;
353
- }
354
-
355
- return true;
356
- });
357
-
358
- return allTagsValid;
294
+
359
295
  };
360
296
 
361
297
  //replaces encoded string with their respective characters
362
298
  export const preprocessHtml = (content) => {
299
+
363
300
  const replacements = {
364
301
  "'": "'",
365
302
  """: "'",
@@ -367,7 +304,7 @@ export const preprocessHtml = (content) => {
367
304
  "&": "&",
368
305
  "&lt;": "<",
369
306
  "&gt;": ">",
370
- "\n": "", // Handling newlines by replacing them with an empty string
307
+ "\n": "", // Handling newlines by replacing them with an empty string
371
308
  };
372
309
 
373
310
 
@@ -381,22 +318,28 @@ export const preprocessHtml = (content) => {
381
318
  });
382
319
 
383
320
  // Step 2: Perform the standard replacements on the entire content
384
- return contentWithStyleFixes?.replace(/&#39;|&quot;|&amp;|&lt;|&gt;|"|\n/g, (match) => replacements[match]);
321
+ return contentWithStyleFixes?.replace(/&#39;|&quot;|&amp;|&lt;|&gt;|"|\n/g, match => replacements[match]);
385
322
  };
386
323
 
387
324
  //this is used to get the subtags from custom or extended tags
388
- export const getTagMapValue = (object = {}) => Object.values(
389
- object
390
- ).reduce((acc, current) => ({ ...acc, ...current?.subtags ?? {} }), {});
391
-
392
- export const getLoyaltyTagsMapValue = (object = {}) => Object.entries(object).reduce((acc, [key, current]) => {
393
- if (current?.subtags && Object.keys(current.subtags).length > 0) {
394
- // If subtags exist → merge them
395
- return { ...acc, ...(current.subtags ?? {}) };
396
- }
397
- // If no subtags keep the tag itself
398
- return { ...acc, [key]: current };
399
- }, {});
325
+ export const getTagMapValue = (object = {}) => {
326
+ return Object.values(
327
+ object
328
+ ).reduce((acc, current) => {
329
+ return { ...acc, ...current?.subtags ?? {} };
330
+ }, {});
331
+ };
332
+
333
+ export const getLoyaltyTagsMapValue = (object = {}) => {
334
+ return Object.entries(object).reduce((acc, [key, current]) => {
335
+ if (current?.subtags && Object.keys(current.subtags).length > 0) {
336
+ // If subtags exist → merge them
337
+ return { ...acc, ...(current.subtags ?? {}) };
338
+ }
339
+ // If no subtags → keep the tag itself
340
+ return { ...acc, [key]: current };
341
+ }, {});
342
+ };
400
343
 
401
344
 
402
345
  /**
@@ -405,25 +348,27 @@ export const getLoyaltyTagsMapValue = (object = {}) => Object.entries(object).re
405
348
  * @param {Object} object - The input object containing top-level keys with optional subtags.
406
349
  * @returns {Object} - A flat map containing all top-level keys and their subtags.
407
350
  */
408
- export const getForwardedMapValues = (object = {}) => Object?.entries(object)?.reduce((acc, [key, current]) => {
409
- // Check if current has 'subtags' and it's an object
410
- if (current && current?.subtags && typeof current?.subtags === 'object') {
411
- // Add the top-level key with its 'name' and 'desc'
412
- acc[key] = {
413
- name: current?.name,
414
- desc: current?.desc,
415
- };
416
-
417
- // Merge the subtags into the accumulator
418
- acc = { ...acc, ...current?.subtags };
419
- } else if (current && typeof current === 'object') {
420
- // If no 'subtags', add the top-level key with its 'name' and 'desc'
421
- acc[key] = {
422
- name: current?.name,
423
- desc: current?.desc,
424
- };
425
- }
426
-
427
- // If the current entry is not an object or lacks 'name'/'desc', skip it
428
- return acc;
429
- }, {});
351
+ export const getForwardedMapValues = (object = {}) => {
352
+ return Object?.entries(object)?.reduce((acc, [key, current]) => {
353
+ // Check if current has 'subtags' and it's an object
354
+ if (current && current?.subtags && typeof current?.subtags === 'object') {
355
+ // Add the top-level key with its 'name' and 'desc'
356
+ acc[key] = {
357
+ name: current?.name,
358
+ desc: current?.desc,
359
+ };
360
+
361
+ // Merge the subtags into the accumulator
362
+ acc = { ...acc, ...current?.subtags };
363
+ } else if (current && typeof current === 'object') {
364
+ // If no 'subtags', add the top-level key with its 'name' and 'desc'
365
+ acc[key] = {
366
+ name: current?.name,
367
+ desc: current?.desc,
368
+ };
369
+ }
370
+
371
+ // If the current entry is not an object or lacks 'name'/'desc', skip it
372
+ return acc;
373
+ }, {});
374
+ };
@@ -10,36 +10,35 @@ import {
10
10
  validateTags,
11
11
  skipTags,
12
12
  isInsideLiquidBlock,
13
- validateTagFormat,
14
13
  } from '../tagValidations';
15
14
  import { containsBase64Images } from '../content';
16
15
  import { eventContextTags } from '../../v2Containers/TagList/tests/mockdata';
17
16
 
18
17
  describe("check if curly brackets are balanced", () => {
19
- it("test for balanced curly brackets", () => {
20
- let value = "hello {{optout";
21
- const res = validateIfTagClosed(value);
22
- expect(res).toEqual(false);
23
- value += "}}";
24
- const result = validateIfTagClosed(value);
25
- expect(result).toEqual(true);
26
- //valid cases
27
- expect(validateIfTagClosed("{{{Hello}}}")).toEqual(true);
28
- expect(validateIfTagClosed("{{{Hello}}")).toEqual(true);
29
- expect(validateIfTagClosed("{{Hello}}}")).toEqual(true);
30
-
31
- //invalid cases
32
- expect(validateIfTagClosed("{{Hello}")).toEqual(false);
33
- expect(validateIfTagClosed("{Hello}}")).toEqual(false);
34
- expect(validateIfTagClosed("{{{Hello}")).toEqual(false);
35
- expect(validateIfTagClosed("{Hello}}}")).toEqual(false);
36
- expect(validateIfTagClosed("{{{{Hello}}}}")).toEqual(false);
37
- expect(validateIfTagClosed("{{{{{Hello}}}}}")).toEqual(false);
38
- expect(validateIfTagClosed("{{{{Hello}}")).toEqual(false);
39
- expect(validateIfTagClosed("{{{{Hello}}World}}")).toEqual(false);
40
- expect(validateIfTagClosed("{{Hello{{World}}")).toEqual(false);
41
- });
42
- });
18
+ it("test for balanced curly brackets", () => {
19
+ let value = "hello {{optout"
20
+ let res = validateIfTagClosed(value);
21
+ expect(res).toEqual(false);
22
+ value += "}}"
23
+ let result = validateIfTagClosed(value);
24
+ expect(result).toEqual(true);
25
+ //valid cases
26
+ expect(validateIfTagClosed("{{{Hello}}}")).toEqual(true);
27
+ expect(validateIfTagClosed("{{{Hello}}")).toEqual(true);
28
+ expect(validateIfTagClosed("{{Hello}}}")).toEqual(true);
29
+
30
+ //invalid cases
31
+ expect(validateIfTagClosed("{{Hello}")).toEqual(false);
32
+ expect(validateIfTagClosed("{Hello}}")).toEqual(false);
33
+ expect(validateIfTagClosed("{{{Hello}")).toEqual(false);
34
+ expect(validateIfTagClosed("{Hello}}}")).toEqual(false);
35
+ expect(validateIfTagClosed("{{{{Hello}}}}")).toEqual(false);
36
+ expect(validateIfTagClosed("{{{{{Hello}}}}}")).toEqual(false);
37
+ expect(validateIfTagClosed("{{{{Hello}}")).toEqual(false);
38
+ expect(validateIfTagClosed("{{{{Hello}}World}}")).toEqual(false);
39
+ expect(validateIfTagClosed("{{Hello{{World}}")).toEqual(false);
40
+ })
41
+ })
43
42
 
44
43
  describe("validateTags", () => {
45
44
  const tagsParam = [
@@ -86,12 +85,12 @@ describe("validateTags", () => {
86
85
 
87
86
  it("should return invalid response when a mandatory tag is missing", () => {
88
87
  const content = "Hello {{tag1}}, {{tag2}}, {{tag3}}";
89
- const updatedTagsParam = [...tagsParam, {
88
+ const updatedTagsParam = [...tagsParam, {
90
89
  definition: {
91
90
  supportedModules: [{ context: "DEFAULT", mandatory: true }],
92
91
  value: "tag4",
93
92
  },
94
- }];
93
+ },];
95
94
  const injectedTagsParams = [];
96
95
  const location = { query: { module: "DEFAULT" } };
97
96
  const tagModule = null;
@@ -352,9 +351,9 @@ describe("checkSupport", () => {
352
351
  data: [{ name: "tag1" }, { name: "tag2" }, { name: "tag3" }],
353
352
  };
354
353
  const tagObject = {
355
- "tag1": { definition: { subtags: ["tag1.1", "tag1.2"] } },
356
- "tag2": { definition: { subtags: ["tag2.1", "tag2.2"] } },
357
- "tag3": { definition: { subtags: ["tag3.1", "tag3.2"] } },
354
+ tag1: { definition: { subtags: ["tag1.1", "tag1.2"] } },
355
+ tag2: { definition: { subtags: ["tag2.1", "tag2.2"] } },
356
+ tag3: { definition: { subtags: ["tag3.1", "tag3.2"] } },
358
357
  "tag1.1": {},
359
358
  "tag2.1": {},
360
359
  "tag3.1": {},
@@ -387,9 +386,9 @@ describe("checkSupport", () => {
387
386
  ],
388
387
  };
389
388
  const tagObject = {
390
- "tag1": { definition: { subtags: [".1", "tag1.2"] } },
391
- "tag2": { definition: { subtags: ["tag2.1", "tag2.2"] } },
392
- "tag3": { definition: { subtags: ["tag3.1", "tag3.2"] } },
389
+ tag1: { definition: { subtags: [".1", "tag1.2"] } },
390
+ tag2: { definition: { subtags: ["tag2.1", "tag2.2"] } },
391
+ tag3: { definition: { subtags: ["tag3.1", "tag3.2"] } },
393
392
  "tag1.1": {},
394
393
  "tag2.1": {},
395
394
  "tag3.1": {},
@@ -406,9 +405,9 @@ describe("checkSupport", () => {
406
405
  ],
407
406
  };
408
407
  const tagObject = {
409
- "tag1": { definition: { subtags: [".1", "tag1.2"] } },
410
- "tag2": { definition: { subtags: ["tag2.1", "tag2.2"] } },
411
- "tag3": { definition: { subtags: ["tag3.1", "tag3.2"] } },
408
+ tag1: { definition: { subtags: [".1", "tag1.2"] } },
409
+ tag2: { definition: { subtags: ["tag2.1", "tag2.2"] } },
410
+ tag3: { definition: { subtags: ["tag3.1", "tag3.2"] } },
412
411
  "tag1.1": {},
413
412
  "tag2.1": {},
414
413
  "tag3.1": {},
@@ -434,7 +433,7 @@ describe("checkSupport", () => {
434
433
  const eventContextTags = [{ tagName: "leaderboard", subTags: ["userId"]}];
435
434
  const isLiquidFlow = true;
436
435
  const result = checkSupport(response, tagObject, eventContextTags, isLiquidFlow);
437
- expect(result).toEqual( ['leaderboard', 'person.userId']);
436
+ expect(result).toEqual( [ 'leaderboard', 'person.userId' ]);
438
437
  });
439
438
 
440
439
  it("should not add childName to supportedList which does not have dot in eventContextTags", () => {
@@ -444,7 +443,7 @@ describe("checkSupport", () => {
444
443
  const eventContextTags = [{ tagName: "entryTrigger.lifetimePoints", children: [{name: "userId"}] }];
445
444
  const isLiquidFlow = true;
446
445
  const result = checkSupport(response, tagObject, eventContextTags, isLiquidFlow);
447
- expect(result).toEqual( ["entryTrigger.lifetimePoints"]);
446
+ expect(result).toEqual( [ "entryTrigger.lifetimePoints" ]);
448
447
  });
449
448
 
450
449
  it("should add only parent tag to supportedList if isLiquidFlow false", () => {
@@ -453,7 +452,7 @@ describe("checkSupport", () => {
453
452
  const eventContextTags = [{ tagName: "leaderboard", subTags: ["userId"]}];
454
453
  const isLiquidFlow = false;
455
454
  const result = checkSupport(response, tagObject, eventContextTags, isLiquidFlow);
456
- expect(result).toEqual( ['leaderboard']);
455
+ expect(result).toEqual( [ 'leaderboard' ]);
457
456
  });
458
457
 
459
458
  it("test for checking loyalty tags in that are coming in forwardedTags", () => {
@@ -473,7 +472,7 @@ describe("checkSupport", () => {
473
472
  },
474
473
  };
475
474
  const result = checkSupport(response, tagObject, [], isLiquidFlow, forwardedTags);
476
- expect(result).toEqual( ['leaderboard', 'person.userId']);
475
+ expect(result).toEqual( [ 'leaderboard', 'person.userId' ]);
477
476
  });
478
477
  });
479
478
 
@@ -530,6 +529,8 @@ describe('preprocessHtml', () => {
530
529
  const expectedOutput = "<style {line-height:0;font-size:75%} >sup{line-height:0;font-size:75% }</style> ";
531
530
  expect(preprocessHtml(input)).toEqual(expectedOutput);
532
531
  });
532
+
533
+
533
534
  });
534
535
 
535
536
 
@@ -555,7 +556,7 @@ describe("getTagMapValue", () => {
555
556
  },
556
557
  };
557
558
  const result = getTagMapValue(object);
558
- expect(result).toEqual({ name: "233", tagName: "234" });
559
+ expect(result).toEqual({ name: "233", tagName: "234", });
559
560
  });
560
561
  it("should return the tag map value when an object is provided but subtag is not present in one of the obj", () => {
561
562
  const object = {
@@ -887,9 +888,9 @@ describe("getLoyaltyTagsMapValue", () => {
887
888
  },
888
889
  };
889
890
  const inputCopy = JSON.parse(JSON.stringify(object));
890
-
891
+
891
892
  getLoyaltyTagsMapValue(object);
892
-
893
+
893
894
  expect(object).toEqual(inputCopy);
894
895
  });
895
896
 
@@ -1392,7 +1393,7 @@ describe('containsBase64Images', () => {
1392
1393
 
1393
1394
  beforeEach(() => {
1394
1395
  mockCapNotification = {
1395
- error: jest.fn(),
1396
+ error: jest.fn()
1396
1397
  };
1397
1398
  mockCallback = jest.fn();
1398
1399
  });
@@ -1419,7 +1420,7 @@ describe('containsBase64Images', () => {
1419
1420
  it('should return true for content with base64 images and trigger notification', () => {
1420
1421
  const content = '<img src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8/5+hHgAHggJ/PchI7wAAAABJRU5ErkJggg==" alt="test" />';
1421
1422
  expect(containsBase64Images({content, CapNotification: mockCapNotification, callback: mockCallback})).toBe(true);
1422
-
1423
+
1423
1424
  expect(mockCapNotification.error).toHaveBeenCalledWith({
1424
1425
  key: 'base64Error',
1425
1426
  message: 'Base64 images are not allowed. Please upload your image to a gallery and use it, or add the image URL instead.',
@@ -1451,12 +1452,12 @@ describe('containsBase64Images', () => {
1451
1452
  const jpegContent = '<img src="data:image/jpeg;base64,/9j/4AAQ..." />';
1452
1453
  const gifContent = '<img src="data:image/gif;base64,R0lGODlh..." />';
1453
1454
  const webpContent = '<img src="data:image/webp;base64,UklGRi..." />';
1454
-
1455
+
1455
1456
  expect(containsBase64Images({content: pngContent, CapNotification: mockCapNotification})).toBe(true);
1456
1457
  expect(containsBase64Images({content: jpegContent, CapNotification: mockCapNotification})).toBe(true);
1457
1458
  expect(containsBase64Images({content: gifContent, CapNotification: mockCapNotification})).toBe(true);
1458
1459
  expect(containsBase64Images({content: webpContent, CapNotification: mockCapNotification})).toBe(true);
1459
-
1460
+
1460
1461
  expect(mockCapNotification.error).toHaveBeenCalledTimes(4);
1461
1462
  });
1462
1463
 
@@ -1488,209 +1489,11 @@ describe('containsBase64Images', () => {
1488
1489
  it('should execute callback only when base64 images are found', () => {
1489
1490
  const contentWithBase64 = '<img src="data:image/png;base64,iVBORw0..." alt="test" />';
1490
1491
  const contentWithoutBase64 = '<img src="https://example.com/image.jpg" alt="test" />';
1491
-
1492
+
1492
1493
  containsBase64Images({content: contentWithBase64, callback: mockCallback});
1493
1494
  expect(mockCallback).toHaveBeenCalledTimes(1);
1494
-
1495
+
1495
1496
  containsBase64Images({content: contentWithoutBase64, callback: mockCallback});
1496
1497
  expect(mockCallback).toHaveBeenCalledTimes(1); // Should still be 1, not called again
1497
1498
  });
1498
1499
  });
1499
-
1500
- describe('validateTagFormat', () => {
1501
- describe('valid tag formats', () => {
1502
- it('should return true for empty string', () => {
1503
- expect(validateTagFormat('')).toBe(true);
1504
- });
1505
-
1506
- it('should return true for text without tags', () => {
1507
- expect(validateTagFormat('Hello world')).toBe(true);
1508
- expect(validateTagFormat('No tags here at all')).toBe(true);
1509
- });
1510
-
1511
- it('should return true for a single valid tag', () => {
1512
- expect(validateTagFormat('{{tag_name}}')).toBe(true);
1513
- expect(validateTagFormat('{{first_name}}')).toBe(true);
1514
- expect(validateTagFormat('{{customer.name}}')).toBe(true);
1515
- });
1516
-
1517
- it('should return true for multiple valid tags', () => {
1518
- expect(validateTagFormat('Hello {{first_name}}, your order {{order_id}} is ready')).toBe(true);
1519
- expect(validateTagFormat('{{tag1}} and {{tag2}} and {{tag3}}')).toBe(true);
1520
- });
1521
-
1522
- it('should return true for tags with various characters', () => {
1523
- expect(validateTagFormat('{{tag_name_123}}')).toBe(true);
1524
- expect(validateTagFormat('{{customer.first_name}}')).toBe(true);
1525
- expect(validateTagFormat('{{tag-name}}')).toBe(true);
1526
- expect(validateTagFormat('{{tag.name}}')).toBe(true);
1527
- });
1528
-
1529
- it('should return true for tags with whitespace in tag name (trimmed)', () => {
1530
- expect(validateTagFormat('{{ tag_name }}')).toBe(true);
1531
- expect(validateTagFormat('{{ tag_name }}')).toBe(true);
1532
- });
1533
-
1534
- it('should return true for tags with special characters in tag name', () => {
1535
- expect(validateTagFormat('{{tag@name}}')).toBe(true);
1536
- expect(validateTagFormat('{{tag#name}}')).toBe(true);
1537
- expect(validateTagFormat('{{tag$name}}')).toBe(true);
1538
- });
1539
- });
1540
-
1541
- describe('invalid tag formats - single braces', () => {
1542
- it('should return false for single opening brace', () => {
1543
- expect(validateTagFormat('{tag}')).toBe(false);
1544
- expect(validateTagFormat('Hello {name}')).toBe(false);
1545
- });
1546
-
1547
- it('should return false for single closing brace', () => {
1548
- expect(validateTagFormat('tag}')).toBe(false);
1549
- expect(validateTagFormat('Hello name}')).toBe(false);
1550
- });
1551
-
1552
- it('should return false for unclosed single brace', () => {
1553
- expect(validateTagFormat('{tag')).toBe(false);
1554
- expect(validateTagFormat('tag}')).toBe(false);
1555
- });
1556
-
1557
- it('should return false for mixed single and double braces', () => {
1558
- expect(validateTagFormat('{{valid}} and {invalid}')).toBe(false);
1559
- expect(validateTagFormat('{invalid} and {{valid}}')).toBe(false);
1560
- });
1561
- });
1562
-
1563
- describe('invalid tag formats - unclosed double braces', () => {
1564
- it('should return false for unclosed opening double braces', () => {
1565
- expect(validateTagFormat('{{tag')).toBe(false);
1566
- expect(validateTagFormat('{{tag}')).toBe(false);
1567
- });
1568
-
1569
- it('should return false for unclosed closing double braces', () => {
1570
- expect(validateTagFormat('tag}}')).toBe(false);
1571
- expect(validateTagFormat('{tag}}')).toBe(false);
1572
- });
1573
-
1574
- it('should return false for mismatched braces', () => {
1575
- expect(validateTagFormat('{{tag}')).toBe(false);
1576
- expect(validateTagFormat('{tag}}')).toBe(false);
1577
- });
1578
- });
1579
-
1580
- describe('invalid tag formats - empty tag names', () => {
1581
- it('should return false for empty tag name', () => {
1582
- expect(validateTagFormat('{{}}')).toBe(false);
1583
- });
1584
-
1585
- it('should return false for tag with only whitespace', () => {
1586
- expect(validateTagFormat('{{ }}')).toBe(false);
1587
- });
1588
- });
1589
-
1590
- describe('invalid tag formats - invalid patterns', () => {
1591
- it('should return false for tag with "or" pattern', () => {
1592
- expect(validateTagFormat('{{first or first}}')).toBe(false);
1593
- expect(validateTagFormat('{{tag1 or tag2}}')).toBe(false);
1594
- expect(validateTagFormat('{{name OR name}}')).toBe(false);
1595
- expect(validateTagFormat('{{first Or first}}')).toBe(false);
1596
- });
1597
-
1598
- it('should return false for tag with "and" pattern', () => {
1599
- expect(validateTagFormat('{{first and first}}')).toBe(false);
1600
- expect(validateTagFormat('{{tag1 and tag2}}')).toBe(false);
1601
- expect(validateTagFormat('{{name AND name}}')).toBe(false);
1602
- expect(validateTagFormat('{{first And first}}')).toBe(false);
1603
- });
1604
-
1605
- it('should return false for tag with "or" pattern in mixed case', () => {
1606
- expect(validateTagFormat('{{first Or first}}')).toBe(false);
1607
- expect(validateTagFormat('{{first OR first}}')).toBe(false);
1608
- expect(validateTagFormat('{{first oR first}}')).toBe(false);
1609
- });
1610
-
1611
- it('should return false for tag with "and" pattern in mixed case', () => {
1612
- expect(validateTagFormat('{{first And first}}')).toBe(false);
1613
- expect(validateTagFormat('{{first AND first}}')).toBe(false);
1614
- expect(validateTagFormat('{{first aNd first}}')).toBe(false);
1615
- });
1616
-
1617
- it('should allow "or" and "and" as part of other words', () => {
1618
- expect(validateTagFormat('{{order_id}}')).toBe(true);
1619
- expect(validateTagFormat('{{customer_name}}')).toBe(true);
1620
- expect(validateTagFormat('{{landing_page}}')).toBe(true);
1621
- });
1622
- });
1623
-
1624
- describe('invalid tag formats - unclosed single braces in tag name', () => {
1625
- it('should return false for unclosed single opening brace in tag name', () => {
1626
- expect(validateTagFormat('{{first{name}}')).toBe(false);
1627
- expect(validateTagFormat('{{tag{value}}')).toBe(false);
1628
- });
1629
-
1630
- it('should return false for unclosed single closing brace in tag name', () => {
1631
- expect(validateTagFormat('{{first}name}}')).toBe(false);
1632
- expect(validateTagFormat('{{tag}value}}')).toBe(false);
1633
- });
1634
-
1635
- it('should return false for mismatched single braces in tag name', () => {
1636
- expect(validateTagFormat('{{first{name}}')).toBe(false);
1637
- expect(validateTagFormat('{{first}name}}')).toBe(false);
1638
- });
1639
-
1640
- it('should return false for balanced single braces in tag name (regex cannot match)', () => {
1641
- // The regex pattern /{{[^}]*}}/g stops at the first }, so {{first{name}}}
1642
- // would leave a remaining } brace, making it invalid
1643
- expect(validateTagFormat('{{first{name}}}')).toBe(false);
1644
- expect(validateTagFormat('{{tag{value}}}')).toBe(false);
1645
- });
1646
- });
1647
-
1648
- describe('invalid tag formats - remaining braces after removing valid tags', () => {
1649
- it('should return false when there are remaining single braces after valid tags', () => {
1650
- expect(validateTagFormat('{{valid}} {invalid}')).toBe(false);
1651
- expect(validateTagFormat('{invalid} {{valid}}')).toBe(false);
1652
- });
1653
-
1654
- it('should return false when there are remaining unclosed braces', () => {
1655
- expect(validateTagFormat('{{valid}} {unclosed')).toBe(false);
1656
- expect(validateTagFormat('{{valid}} unclosed}')).toBe(false);
1657
- });
1658
-
1659
- it('should return false for complex mixed valid and invalid patterns', () => {
1660
- expect(validateTagFormat('{{tag1}} and {tag2} and {{tag3}}')).toBe(false);
1661
- });
1662
- });
1663
-
1664
- describe('edge cases', () => {
1665
- it('should return false for tags that do not start with {{', () => {
1666
- expect(validateTagFormat('{tag}}')).toBe(false);
1667
- });
1668
-
1669
- it('should return false for tags that do not end with }}', () => {
1670
- expect(validateTagFormat('{{tag}')).toBe(false);
1671
- });
1672
-
1673
- it('should handle multiple invalid tags', () => {
1674
- expect(validateTagFormat('{{first or first}} and {{second and second}}')).toBe(false);
1675
- });
1676
-
1677
- it('should return false if any tag is invalid in a string with multiple tags', () => {
1678
- expect(validateTagFormat('{{valid1}} {{valid2}} {{invalid or invalid}}')).toBe(false);
1679
- expect(validateTagFormat('{{invalid or invalid}} {{valid1}} {{valid2}}')).toBe(false);
1680
- });
1681
-
1682
- it('should return true for all valid tags even with many tags', () => {
1683
- expect(validateTagFormat('{{tag1}} {{tag2}} {{tag3}} {{tag4}} {{tag5}}')).toBe(true);
1684
- });
1685
-
1686
- it('should handle tags with nested structure', () => {
1687
- expect(validateTagFormat('{{customer.first_name}}')).toBe(true);
1688
- expect(validateTagFormat('{{order.items.count}}')).toBe(true);
1689
- });
1690
-
1691
- it('should handle tags with numbers and underscores', () => {
1692
- expect(validateTagFormat('{{tag_123}}')).toBe(true);
1693
- expect(validateTagFormat('{{tag1_2_3}}')).toBe(true);
1694
- });
1695
- });
1696
- });
@@ -1491,6 +1491,16 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1491
1491
  if (tag?.match(ENTRY_TRIGGER_TAG_REGEX)) {
1492
1492
  return false;
1493
1493
  }
1494
+
1495
+ // Skip specific tags for email channel
1496
+ const isEmailChannel = this.props?.schema?.channel?.toUpperCase() === EMAIL;
1497
+ if (isEmailChannel) {
1498
+ const emailSkipTags = ['image', 'info', 'teaser', 'desc'];
1499
+ if (emailSkipTags.includes(tag?.toLowerCase())) {
1500
+ return true;
1501
+ }
1502
+ }
1503
+
1494
1504
  // Use some() to check if any pattern matches (stops on first match)
1495
1505
  return SKIP_TAGS_REGEX_GROUPS.some((group) => {
1496
1506
  // Create a new RegExp for each test to avoid state issues with global flag
@@ -9,19 +9,6 @@ import CapTreeSelect from '@capillarytech/cap-ui-library/CapTreeSelect';
9
9
  import isEmpty from 'lodash/isEmpty';
10
10
  import messages from './messages';
11
11
 
12
- const isSendTestButtonDisabled = ({
13
- selectedTestEntities,
14
- formData,
15
- isSendingTestMessage,
16
- isContentValid,
17
- }) => {
18
- const hasSelectedEntities = !isEmpty(selectedTestEntities);
19
- const hasTemplateSubject = !isEmpty(formData['template-subject']) || !isEmpty(formData[0]?.['template-subject']);
20
- const isReadyToSend = hasSelectedEntities && hasTemplateSubject && isContentValid && !isSendingTestMessage;
21
-
22
- return !isReadyToSend;
23
- };
24
-
25
12
  const SendTestMessage = ({
26
13
  isFetchingTestCustomers,
27
14
  isFetchingTestGroups,
@@ -32,7 +19,6 @@ const SendTestMessage = ({
32
19
  formData,
33
20
  isSendingTestMessage,
34
21
  formatMessage,
35
- isContentValid = true,
36
22
  }) => (
37
23
  <CapStepsAccordian
38
24
  showNumberSteps={false}
@@ -57,16 +43,7 @@ const SendTestMessage = ({
57
43
  multiple
58
44
  placeholder={formatMessage(messages.testCustomersPlaceholder)}
59
45
  />
60
- <CapButton
61
- onClick={handleSendTestMessage}
62
- disabled={isSendTestButtonDisabled({
63
- selectedTestEntities,
64
- formData,
65
- isSendingTestMessage,
66
- isContentValid,
67
- })}
68
- title={!isContentValid ? formatMessage(messages.contentInvalid) : ''}
69
- >
46
+ <CapButton onClick={handleSendTestMessage} disabled={isEmpty(selectedTestEntities) || (isEmpty(formData['template-subject']) && isEmpty(formData[0]?.['template-subject'])) || isSendingTestMessage}>
70
47
  <FormattedMessage {...messages.sendTestButton} />
71
48
  </CapButton>
72
49
  </CapRow>),
@@ -86,7 +63,6 @@ SendTestMessage.propTypes = {
86
63
  formData: PropTypes.object.isRequired,
87
64
  isSendingTestMessage: PropTypes.bool.isRequired,
88
65
  formatMessage: PropTypes.func.isRequired,
89
- isContentValid: PropTypes.bool,
90
66
  };
91
67
 
92
68
  export default SendTestMessage;
@@ -52,7 +52,6 @@ import {
52
52
  INITIAL_PAYLOAD, EMAIL, TEST, DESKTOP, ACTIVE, MOBILE,
53
53
  } from './constants';
54
54
  import { GLOBAL_CONVERT_OPTIONS } from '../FormBuilder/constants';
55
- import { validateIfTagClosed, validateTagFormat } from '../../utils/tagValidations';
56
55
 
57
56
  const TestAndPreviewSlidebox = (props) => {
58
57
  const {
@@ -104,58 +103,10 @@ const TestAndPreviewSlidebox = (props) => {
104
103
  const [selectedTestEntities, setSelectedTestEntities] = useState([]);
105
104
  const [beeContent, setBeeContent] = useState(''); // Track BEE editor content separately
106
105
  const previousBeeContentRef = useRef(''); // Track previous BEE content to prevent unnecessary updates
107
- const [isContentValid, setIsContentValid] = useState(true); // Track if content tags are valid
108
106
 
109
107
  const isUpdatePreviewDisabled = useMemo(() => (
110
- requiredTags.some((tag) => !customValues[tag.fullPath]) || !isContentValid
111
- ), [requiredTags, customValues, isContentValid]);
112
-
113
- /**
114
- * Validates tags in content: checks for proper tag format and balanced braces
115
- * Uses validateIfTagClosed and validateTagFormat from utils/tagValidations
116
- * @param {string} content - The HTML content to validate
117
- * @returns {boolean} - True if content is valid, false otherwise
118
- */
119
- const validateContentTags = (content) => {
120
- if (!content) return true;
121
-
122
- try {
123
- // Convert HTML to text (same as what's used for tag extraction)
124
- // This ensures we validate the same content that will be used for tag extraction
125
- const textContent = convert(content, GLOBAL_CONVERT_OPTIONS);
126
-
127
- // Check if there are any braces in the content
128
- const hasBraces = textContent.includes('{') || textContent.includes('}');
129
-
130
- // If no braces exist, content is valid (no tag validation needed)
131
- if (!hasBraces) {
132
- return true;
133
- }
134
-
135
- // First check if tags are properly closed using the utility function from tagValidations
136
- // This validates that all opening braces have corresponding closing braces
137
- if (!validateIfTagClosed(textContent)) {
138
- return false;
139
- }
140
-
141
- // Now validate tag format: tags must be in format {{tag_name}}
142
- return validateTagFormat(textContent);
143
- } catch (error) {
144
- // If conversion fails, fall back to validating the original content
145
- console.warn('Error converting content for validation:', error);
146
- const hasBraces = content.includes('{') || content.includes('}');
147
- if (!hasBraces) {
148
- return true;
149
- }
150
-
151
- // Apply same validation to original content
152
- if (!validateIfTagClosed(content)) {
153
- return false;
154
- }
155
-
156
- return validateTagFormat(content);
157
- }
158
- };
108
+ requiredTags.some((tag) => !customValues[tag.fullPath])
109
+ ), [requiredTags, customValues]);
159
110
 
160
111
  // Function to resolve tags in text with custom values
161
112
  const resolveTagsInText = (text, tagValues) => {
@@ -202,10 +153,6 @@ const TestAndPreviewSlidebox = (props) => {
202
153
  if (existingContent && existingContent.trim() !== '') {
203
154
  // We already have content, update local state only if it's different
204
155
  if (existingContent !== previousBeeContentRef.current) {
205
- // Validate content tags for BEE editor
206
- const isValid = validateContentTags(existingContent);
207
- setIsContentValid(isValid);
208
-
209
156
  previousBeeContentRef.current = existingContent;
210
157
  setBeeContent(existingContent);
211
158
  setPreviewDataHtml({
@@ -239,10 +186,6 @@ const TestAndPreviewSlidebox = (props) => {
239
186
  }
240
187
 
241
188
  if (htmlFile) {
242
- // Validate content tags
243
- const isValid = validateContentTags(htmlFile);
244
- setIsContentValid(isValid);
245
-
246
189
  // Update our states
247
190
  previousBeeContentRef.current = htmlFile;
248
191
  setBeeContent(htmlFile);
@@ -251,16 +194,9 @@ const TestAndPreviewSlidebox = (props) => {
251
194
  resolvedTitle: formData['template-subject'] || ''
252
195
  });
253
196
 
254
- // Only extract tags if content is valid
255
- if (isValid) {
256
- const payloadContent = convert(htmlFile, GLOBAL_CONVERT_OPTIONS);
257
- actions.extractTagsRequested(formData['template-subject'] || '', payloadContent);
258
- } else {
259
- // Show error notification for invalid content
260
- CapNotification.error({
261
- message: formatMessage(messages.contentInvalid),
262
- });
263
- }
197
+ // Always extract tags when content changes
198
+ const payloadContent = convert(htmlFile, GLOBAL_CONVERT_OPTIONS);
199
+ actions.extractTagsRequested(formData['template-subject'] || '', payloadContent);
264
200
  }
265
201
 
266
202
  // Restore original handler
@@ -275,45 +211,23 @@ const TestAndPreviewSlidebox = (props) => {
275
211
  const templateContent = currentTabData?.[activeTab]?.['template-content'];
276
212
 
277
213
  if (templateContent) {
278
- // Validate content tags
279
- const isValid = validateContentTags(templateContent);
280
- setIsContentValid(isValid);
281
-
282
214
  // Update preview with initial content
283
215
  setPreviewDataHtml({
284
216
  resolvedBody: templateContent,
285
217
  resolvedTitle: formData['template-subject'] || ''
286
218
  });
287
219
 
288
- // Only extract tags if content is valid
289
- if (isValid) {
290
- const payloadContent = convert(templateContent, GLOBAL_CONVERT_OPTIONS);
291
- actions.extractTagsRequested(formData['template-subject'] || '', payloadContent);
292
- } else {
293
- // Show error notification for invalid content
294
- CapNotification.error({
295
- message: formatMessage(messages.contentInvalid),
296
- });
297
- }
220
+ // Always extract tags when showing
221
+ const payloadContent = convert(templateContent, GLOBAL_CONVERT_OPTIONS);
222
+ actions.extractTagsRequested(formData['template-subject'] || '', payloadContent);
298
223
  } else {
299
224
  // Fallback to content prop if no template content
300
- const contentToValidate = getCurrentContent;
301
- const isValid = validateContentTags(contentToValidate);
302
- setIsContentValid(isValid);
303
-
304
- // Only extract tags if content is valid
305
- if (isValid) {
306
- const payloadContent = convert(
307
- contentToValidate,
308
- GLOBAL_CONVERT_OPTIONS
309
- );
310
- actions.extractTagsRequested(formData['template-subject'] || '', payloadContent);
311
- } else {
312
- // Show error notification for invalid content
313
- CapNotification.error({
314
- message: formatMessage(messages.contentInvalid),
315
- });
316
- }
225
+ const payloadContent = convert(
226
+ getCurrentContent,
227
+ GLOBAL_CONVERT_OPTIONS
228
+ );
229
+ // Always extract tags when showing
230
+ actions.extractTagsRequested(formData['template-subject'] || '', payloadContent);
317
231
  }
318
232
  }
319
233
 
@@ -329,28 +243,17 @@ const TestAndPreviewSlidebox = (props) => {
329
243
  const isDragDrop = currentTabData?.[activeTab]?.is_drag_drop;
330
244
  const templateContent = currentTabData?.[activeTab]?.['template-content'];
331
245
 
332
- if (templateContent && templateContent.trim() !== '' && show) {
333
- // Common function to handle content update with validation
246
+ if (templateContent && templateContent.trim() !== '') {
247
+ // Common function to handle content update
334
248
  const handleContentUpdate = (content) => {
335
- // Validate content tags for each update
336
- const isValid = validateContentTags(content);
337
- setIsContentValid(isValid);
338
-
339
249
  setPreviewDataHtml({
340
250
  resolvedBody: content,
341
251
  resolvedTitle: formData['template-subject'] || ''
342
252
  });
343
253
 
344
- // Only extract tags if content is valid
345
- if (isValid) {
346
- const payloadContent = convert(content, GLOBAL_CONVERT_OPTIONS);
347
- actions.extractTagsRequested(formData['template-subject'] || '', payloadContent);
348
- } else {
349
- // Show error notification for invalid content
350
- CapNotification.error({
351
- message: formatMessage(messages.contentInvalid),
352
- });
353
- }
254
+ // Extract tags from content
255
+ const payloadContent = convert(content, GLOBAL_CONVERT_OPTIONS);
256
+ actions.extractTagsRequested(formData['template-subject'] || '', payloadContent);
354
257
  };
355
258
 
356
259
  if (isDragDrop) {
@@ -384,7 +287,6 @@ const TestAndPreviewSlidebox = (props) => {
384
287
  setTagsExtracted(false);
385
288
  setPreviewDevice('desktop');
386
289
  setSelectedTestEntities([]);
387
- setIsContentValid(true);
388
290
  actions.clearPrefilledValues();
389
291
  }
390
292
  }, [show]);
@@ -628,22 +530,6 @@ const TestAndPreviewSlidebox = (props) => {
628
530
 
629
531
  // Handle update preview
630
532
  const handleUpdatePreview = async () => {
631
- // Re-validate content to get latest state (in case liquid errors were fixed)
632
- const currentTabData = formData[currentTab - 1];
633
- const activeTab = currentTabData?.activeTab;
634
- const templateContent = currentTabData?.[activeTab]?.['template-content'];
635
- const contentToValidate = templateContent || getCurrentContent;
636
- const isValid = validateContentTags(contentToValidate);
637
- setIsContentValid(isValid);
638
-
639
- // Check if content is valid before updating preview
640
- if (!isValid) {
641
- CapNotification.error({
642
- message: formatMessage(messages.contentInvalid),
643
- });
644
- return;
645
- }
646
-
647
533
  try {
648
534
  // Include unsubscribe tag if content contains it
649
535
  const resolvedTags = { ...customValues };
@@ -673,20 +559,9 @@ const TestAndPreviewSlidebox = (props) => {
673
559
  const currentTabData = formData[currentTab - 1];
674
560
  const activeTab = currentTabData?.activeTab;
675
561
  const templateContent = currentTabData?.[activeTab]?.['template-content'];
676
- const content = templateContent || getCurrentContent;
677
-
678
- // Validate content tags before extracting
679
- const isValid = validateContentTags(content);
680
- setIsContentValid(isValid);
681
-
682
- if (!isValid) {
683
- CapNotification.error({
684
- message: formatMessage(messages.contentInvalid),
685
- });
686
- return;
687
- }
688
562
 
689
563
  // Check for personalization tags (excluding unsubscribe)
564
+ const content = templateContent || getCurrentContent;
690
565
  const tags = content.match(/{{[^}]+}}/g) || [];
691
566
  const hasPersonalizationTags = tags.some(tag => !tag.includes('unsubscribe'));
692
567
 
@@ -715,22 +590,6 @@ const TestAndPreviewSlidebox = (props) => {
715
590
  };
716
591
 
717
592
  const handleSendTestMessage = () => {
718
- // Re-validate content to get latest state (in case liquid errors were fixed)
719
- const currentTabData = formData[currentTab - 1];
720
- const activeTab = currentTabData?.activeTab;
721
- const templateContent = currentTabData?.[activeTab]?.['template-content'];
722
- const contentToValidate = templateContent || getCurrentContent;
723
- const isValid = validateContentTags(contentToValidate);
724
- setIsContentValid(isValid);
725
-
726
- // Check if content is valid before sending test message
727
- if (!isValid) {
728
- CapNotification.error({
729
- message: formatMessage(messages.contentInvalid),
730
- });
731
- return;
732
- }
733
-
734
593
  const allUserIds = [];
735
594
  selectedTestEntities.forEach((entityId) => {
736
595
  const group = testGroups.find((g) => g.groupId === entityId);
@@ -826,7 +685,6 @@ const TestAndPreviewSlidebox = (props) => {
826
685
  formData={formData}
827
686
  isSendingTestMessage={isSendingTestMessage}
828
687
  formatMessage={formatMessage}
829
- isContentValid={isContentValid}
830
688
  />
831
689
  );
832
690
 
@@ -144,12 +144,4 @@ export default defineMessages({
144
144
  id: `${scope}.invalidJSON`,
145
145
  defaultMessage: 'Invalid JSON input',
146
146
  },
147
- contentInvalid: {
148
- id: `${scope}.contentInvalid`,
149
- defaultMessage: 'Content is invalid. Please fix the tags in your content before testing or previewing.',
150
- },
151
- previewUpdateError: {
152
- id: `${scope}.previewUpdateError`,
153
- defaultMessage: 'Failed to update preview',
154
- },
155
147
  });