@capillarytech/creatives-library 8.0.290 → 8.0.292-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.
Files changed (80) hide show
  1. package/constants/unified.js +3 -1
  2. package/initialState.js +0 -2
  3. package/package.json +1 -1
  4. package/utils/common.js +5 -8
  5. package/utils/commonUtils.js +4 -85
  6. package/utils/tagValidations.js +83 -223
  7. package/utils/tests/commonUtil.test.js +147 -124
  8. package/utils/tests/tagValidations.test.js +441 -358
  9. package/v2Components/CommonTestAndPreview/SendTestMessage.js +1 -33
  10. package/v2Components/CommonTestAndPreview/actions.js +0 -20
  11. package/v2Components/CommonTestAndPreview/constants.js +0 -10
  12. package/v2Components/CommonTestAndPreview/index.js +15 -133
  13. package/v2Components/CommonTestAndPreview/reducer.js +0 -47
  14. package/v2Components/CommonTestAndPreview/sagas.js +0 -60
  15. package/v2Components/CommonTestAndPreview/selectors.js +0 -51
  16. package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +0 -127
  17. package/v2Components/CommonTestAndPreview/tests/actions.test.js +0 -50
  18. package/v2Components/CommonTestAndPreview/tests/constants.test.js +0 -18
  19. package/v2Components/CommonTestAndPreview/tests/index.test.js +1 -214
  20. package/v2Components/CommonTestAndPreview/tests/reducer.test.js +0 -118
  21. package/v2Components/CommonTestAndPreview/tests/sagas.test.js +0 -145
  22. package/v2Components/CommonTestAndPreview/tests/selectors.test.js +0 -146
  23. package/v2Components/ErrorInfoNote/index.js +2 -5
  24. package/v2Components/FormBuilder/index.js +137 -203
  25. package/v2Components/FormBuilder/messages.js +0 -8
  26. package/v2Components/HtmlEditor/HTMLEditor.js +0 -5
  27. package/v2Components/HtmlEditor/__tests__/HTMLEditor.apiErrors.test.js +0 -1
  28. package/v2Components/HtmlEditor/__tests__/HTMLEditor.test.js +0 -15
  29. package/v2Components/HtmlEditor/components/CodeEditorPane/index.js +1 -2
  30. package/v2Components/TestAndPreviewSlidebox/index.js +0 -14
  31. package/v2Containers/Cap/mockData.js +0 -14
  32. package/v2Containers/Cap/reducer.js +3 -55
  33. package/v2Containers/Cap/tests/reducer.test.js +0 -102
  34. package/v2Containers/CreativesContainer/SlideBoxContent.js +5 -1
  35. package/v2Containers/CreativesContainer/SlideBoxFooter.js +13 -5
  36. package/v2Containers/CreativesContainer/index.js +38 -7
  37. package/v2Containers/Email/index.js +1 -5
  38. package/v2Containers/EmailWrapper/components/EmailHTMLEditor.js +23 -70
  39. package/v2Containers/EmailWrapper/components/__tests__/EmailHTMLEditor.test.js +29 -137
  40. package/v2Containers/FTP/index.js +2 -51
  41. package/v2Containers/FTP/messages.js +0 -4
  42. package/v2Containers/InApp/index.js +4 -104
  43. package/v2Containers/InApp/tests/index.test.js +17 -6
  44. package/v2Containers/InappAdvance/index.js +4 -108
  45. package/v2Containers/InappAdvance/tests/index.test.js +2 -0
  46. package/v2Containers/Line/Container/Text/index.js +0 -1
  47. package/v2Containers/MobilePush/Create/index.js +42 -19
  48. package/v2Containers/MobilePush/Edit/index.js +42 -19
  49. package/v2Containers/MobilePushNew/index.js +12 -32
  50. package/v2Containers/MobilepushWrapper/index.js +3 -1
  51. package/v2Containers/Rcs/index.js +12 -37
  52. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +12 -649
  53. package/v2Containers/Sms/Create/index.js +39 -3
  54. package/v2Containers/Sms/Create/messages.js +4 -0
  55. package/v2Containers/Sms/Edit/index.js +35 -3
  56. package/v2Containers/Sms/commonMethods.js +3 -6
  57. package/v2Containers/Sms/tests/commonMethods.test.js +122 -0
  58. package/v2Containers/SmsTrai/Edit/index.js +11 -47
  59. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +6 -147
  60. package/v2Containers/SmsWrapper/index.js +2 -0
  61. package/v2Containers/Viber/index.js +0 -1
  62. package/v2Containers/WebPush/Create/hooks/useTagManagement.js +1 -3
  63. package/v2Containers/WebPush/Create/hooks/useTagManagement.test.js +0 -7
  64. package/v2Containers/WebPush/Create/index.js +2 -2
  65. package/v2Containers/WebPush/Create/utils/validation.js +17 -2
  66. package/v2Containers/WebPush/Create/utils/validation.test.js +59 -24
  67. package/v2Containers/Whatsapp/index.js +10 -18
  68. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +4225 -26174
  69. package/v2Containers/Zalo/index.js +3 -11
  70. package/v2Components/CommonTestAndPreview/DeliverySettings/DeliverySettings.scss +0 -33
  71. package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +0 -397
  72. package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.scss +0 -35
  73. package/v2Components/CommonTestAndPreview/DeliverySettings/TECH_DETAILING_DELIVERY_SETTINGS.md +0 -725
  74. package/v2Components/CommonTestAndPreview/DeliverySettings/constants.js +0 -92
  75. package/v2Components/CommonTestAndPreview/DeliverySettings/index.js +0 -243
  76. package/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +0 -111
  77. package/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js +0 -91
  78. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +0 -782
  79. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +0 -200
  80. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/utils/parseSenderDetailsResponse.test.js +0 -235
@@ -127,6 +127,40 @@ describe('validation', () => {
127
127
  expect(result).toBe('Personalization tags are not supported for anonymous customers');
128
128
  expect(mockFormatMessage).toHaveBeenCalledWith(mockMessages.personalizationTokensErrorMessage);
129
129
  });
130
+
131
+ it('should return brace error when validationConfig is provided and validateTags returns isBraceError', () => {
132
+ const validationConfig = { tagsParam: [], location: {}, tagModule: '' };
133
+ validateTags.mockReturnValue({ isBraceError: true });
134
+ const result = validateTitle(
135
+ 'Valid Title',
136
+ mockFormatMessage,
137
+ mockMessages,
138
+ false,
139
+ validationConfig,
140
+ false
141
+ );
142
+ expect(result).toBe('Unbalanced curly braces');
143
+ expect(mockFormatMessage).toHaveBeenCalledWith(globalMessages.unbalanacedCurlyBraces);
144
+ expect(validateTags).toHaveBeenCalledWith({
145
+ content: 'Valid Title',
146
+ ...validationConfig,
147
+ isFullMode: false,
148
+ });
149
+ });
150
+
151
+ it('should not run tag validation when validationConfig is null', () => {
152
+ validateTags.mockClear();
153
+ const result = validateTitle('Valid Title', mockFormatMessage, mockMessages, false, null);
154
+ expect(result).toBe('');
155
+ expect(validateTags).not.toHaveBeenCalled();
156
+ });
157
+
158
+ it('should not run tag validation when validationConfig is undefined', () => {
159
+ validateTags.mockClear();
160
+ const result = validateTitle('Valid Title', mockFormatMessage, mockMessages, false, undefined);
161
+ expect(result).toBe('');
162
+ expect(validateTags).not.toHaveBeenCalled();
163
+ });
130
164
  });
131
165
 
132
166
  describe('validateUrl', () => {
@@ -183,10 +217,8 @@ describe('validation', () => {
183
217
  describe('validateMessageContent', () => {
184
218
  const mockValidationConfig = {
185
219
  tagsParam: [],
186
- injectedTagsParams: [],
187
220
  location: {},
188
221
  tagModule: '',
189
- eventContextTags: [],
190
222
  };
191
223
 
192
224
  beforeEach(() => {
@@ -225,17 +257,6 @@ describe('validation', () => {
225
257
  });
226
258
  });
227
259
 
228
- it('should return error message for unsupported tags', () => {
229
- validateTags.mockReturnValue({
230
- unsupportedTags: ['tag1', 'tag2'],
231
- });
232
- const result = validateMessageContent('Message with {tag1} and {tag2}', mockFormatMessage, mockMessages, mockValidationConfig);
233
- expect(result).toBe('Unsupported tags: tag1, tag2');
234
- expect(mockFormatMessage).toHaveBeenCalledWith(globalMessages.unsupportedTagsValidationError, {
235
- unsupportedTags: 'tag1, tag2',
236
- });
237
- });
238
-
239
260
  it('should return error message for unbalanced curly braces', () => {
240
261
  validateTags.mockReturnValue({
241
262
  isBraceError: true,
@@ -245,22 +266,11 @@ describe('validation', () => {
245
266
  expect(mockFormatMessage).toHaveBeenCalledWith(globalMessages.unbalanacedCurlyBraces);
246
267
  });
247
268
 
248
- it('should return error message for both unsupported tags and brace error (unsupported tags takes precedence)', () => {
249
- validateTags.mockReturnValue({
250
- unsupportedTags: ['tag1'],
251
- isBraceError: true,
252
- });
253
- const result = validateMessageContent('Message with {tag1}', mockFormatMessage, mockMessages, mockValidationConfig);
254
- expect(result).toBe('Unsupported tags: tag1');
255
- });
256
-
257
269
  it('should pass validation config to validateTags', () => {
258
270
  const customConfig = {
259
271
  tagsParam: [{ id: 1, name: 'Tag1' }],
260
- injectedTagsParams: [{ id: 2, name: 'Tag2' }],
261
272
  location: { query: { type: 'test' } },
262
273
  tagModule: 'custom',
263
- eventContextTags: [{ id: 3, name: 'Tag3' }],
264
274
  };
265
275
  validateTags.mockReturnValue({});
266
276
  validateMessageContent('Valid message', mockFormatMessage, mockMessages, customConfig);
@@ -306,6 +316,31 @@ describe('validation', () => {
306
316
  expect(result).toBe('Personalization tags are not supported for anonymous customers');
307
317
  expect(mockFormatMessage).toHaveBeenCalledWith(mockMessages.personalizationTokensErrorMessage);
308
318
  });
319
+
320
+ it('should return unsupported tags error when validateTags returns unsupportedTags', () => {
321
+ validateTags.mockReturnValue({ unsupportedTags: ['invalidTag', 'otherTag'] });
322
+ const result = validateMessageContent(
323
+ 'Hello {{invalidTag}}',
324
+ mockFormatMessage,
325
+ mockMessages,
326
+ mockValidationConfig
327
+ );
328
+ expect(result).toBe('Unsupported tags: invalidTag, otherTag');
329
+ expect(mockFormatMessage).toHaveBeenCalledWith(
330
+ globalMessages.unsupportedTagsValidationError,
331
+ { unsupportedTags: 'invalidTag, otherTag' }
332
+ );
333
+ });
334
+
335
+ it('should pass isFullMode to validateTags when provided', () => {
336
+ validateTags.mockReturnValue({});
337
+ validateMessageContent('Valid message', mockFormatMessage, mockMessages, mockValidationConfig, true);
338
+ expect(validateTags).toHaveBeenCalledWith({
339
+ content: 'Valid message',
340
+ ...mockValidationConfig,
341
+ isFullMode: true,
342
+ });
343
+ });
309
344
  });
310
345
  });
311
346
 
@@ -637,22 +637,21 @@ export const Whatsapp = (props) => {
637
637
  validateTags({
638
638
  content: contentData.join(""),
639
639
  tagsParam: tags,
640
- injectedTagsParams: injectedTags,
641
640
  location,
642
641
  tagModule: getDefaultTags,
643
- eventContextTags,
644
642
  isFullMode,
645
643
  }) || {};
646
- const unsupportedTagsLengthCheck =
647
- validationResponse?.unsupportedTags?.length > 0;
648
644
  if (type === HEADER_TEXT) {
649
645
  headerTagValidationResponse = validationResponse;
650
- updateIsHeaderTagValidationError(unsupportedTagsLengthCheck);
646
+ updateIsHeaderTagValidationError(validationResponse.isBraceError);
651
647
  } else if (type === CAROUSEL_TEXT) {
652
- return [{fieldName: "carouselTagValidationErrMessage", value: validationResponse}, {fieldName: "carouselTagValidationErr", value: unsupportedTagsLengthCheck}];
648
+ return [
649
+ { fieldName: "carouselTagValidationErrMessage", value: validationResponse.isBraceError ? validationResponse : {} },
650
+ { fieldName: "carouselTagValidationErr", value: validationResponse.isBraceError },
651
+ ];
653
652
  } else {
654
653
  tagValidationResponse = validationResponse;
655
- updateIsTagValidationError(unsupportedTagsLengthCheck);
654
+ updateIsTagValidationError(validationResponse.isBraceError);
656
655
  }
657
656
  }
658
657
  };
@@ -2682,18 +2681,11 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
2682
2681
  } else {
2683
2682
  validationResponse = tagValidationResponse;
2684
2683
  }
2685
- const { unsupportedTags = [], isBraceError } = validationResponse;
2686
-
2687
- let tagError = "";
2688
- if (unsupportedTags.length > 0) {
2689
- tagError = formatMessage(globalMessages.unsupportedTagsValidationError, {
2690
- unsupportedTags,
2691
- });
2692
- }
2684
+ const { isBraceError } = validationResponse || {};
2693
2685
  if (isBraceError) {
2694
- tagError = formatMessage(globalMessages.unbalanacedCurlyBraces);
2686
+ return <CapError>{formatMessage(globalMessages.unbalanacedCurlyBraces)}</CapError>;
2695
2687
  }
2696
- return <CapError>{tagError}</CapError>;
2688
+ return null;
2697
2689
  };
2698
2690
 
2699
2691
  const editModeContent = () => (
@@ -3212,7 +3204,7 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
3212
3204
  <TestAndPreviewSlidebox
3213
3205
  show={propsShowTestAndPreviewSlidebox || showTestAndPreviewSlidebox}
3214
3206
  onClose={handleCloseTestAndPreview}
3215
- formData={getTemplateContent()}
3207
+ formData={null} // WhatsApp doesn't use formData structure like SMS
3216
3208
  content={getTemplateContent()}
3217
3209
  currentChannel={WHATSAPP}
3218
3210
  />