@capillarytech/creatives-library 9.1.8-alpha.sprint-cap-214249.39 → 9.2.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 (87) hide show
  1. package/constants/unified.js +4 -0
  2. package/package.json +1 -1
  3. package/translations/en.json +1 -0
  4. package/translations/ja-JP.json +1 -0
  5. package/translations/zh.json +1 -0
  6. package/utils/common.js +6 -0
  7. package/utils/createMobilePushPayload.js +33 -50
  8. package/utils/tagValidations.js +35 -4
  9. package/utils/templateVarUtils.js +49 -0
  10. package/utils/tests/createMobilePushPayload.test.js +8 -113
  11. package/utils/tests/tagValidations.test.js +48 -0
  12. package/utils/tests/templateVarUtils.test.js +89 -0
  13. package/v2Components/CapMpushCTA/index.js +9 -10
  14. package/v2Components/CapMpushCTA/index.scss +3 -29
  15. package/v2Components/CapTagList/TagFallbackPanel.js +124 -0
  16. package/v2Components/CapTagList/constants.js +5 -0
  17. package/v2Components/CapTagList/index.js +46 -7
  18. package/v2Components/CapTagList/messages.js +44 -0
  19. package/v2Components/CapTagList/style.scss +113 -1
  20. package/v2Components/CapTagList/tests/TagFallback.test.js +222 -0
  21. package/v2Components/CapTagList/utils.js +17 -0
  22. package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +12 -20
  23. package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -13
  24. package/v2Components/CommonTestAndPreview/constants.js +3 -2
  25. package/v2Components/CommonTestAndPreview/index.js +61 -61
  26. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +5 -81
  27. package/v2Components/CommonTestAndPreview/tests/index.test.js +0 -86
  28. package/v2Components/CommonTestAndPreview/tests/utils.test.js +102 -0
  29. package/v2Components/CommonTestAndPreview/utils.js +42 -3
  30. package/v2Components/FormBuilder/Classic.js +24 -14
  31. package/v2Components/FormBuilder/Functional/channels/mobilepush/config.js +1 -0
  32. package/v2Components/FormBuilder/Functional/channels/mobilepush/getEditorErrorDescriptor.js +1 -1
  33. package/v2Components/FormBuilder/Functional/channels/mobilepush/tests/validate.test.js +57 -0
  34. package/v2Components/FormBuilder/Functional/channels/mobilepush/validate.js +4 -4
  35. package/v2Components/FormBuilder/Functional/channels/sms/getEditorErrorDescriptor.js +3 -0
  36. package/v2Components/FormBuilder/Functional/channels/sms/tests/getEditorErrorDescriptor.test.js +5 -0
  37. package/v2Components/FormBuilder/Functional/channels/sms/tests/validate.test.js +6 -0
  38. package/v2Components/FormBuilder/Functional/channels/sms/validate.js +3 -1
  39. package/v2Components/FormBuilder/Functional/renderers/mpushRenderers.js +3 -0
  40. package/v2Components/FormBuilder/Functional/tests/mpushRenderers.test.js +22 -0
  41. package/v2Components/TemplatePreview/_templatePreview.scss +2 -12
  42. package/v2Components/TemplatePreview/index.js +16 -24
  43. package/v2Components/TemplatePreview/tests/index.test.js +0 -68
  44. package/v2Containers/Cap/messages.js +4 -0
  45. package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +1 -0
  46. package/v2Containers/CreativesContainer/SlideBoxContent.js +6 -4
  47. package/v2Containers/CreativesContainer/index.js +1 -2
  48. package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +0 -43
  49. package/v2Containers/InApp/index.js +4 -1
  50. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +3 -0
  51. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +2 -0
  52. package/v2Containers/Line/Container/Text/index.js +3 -1
  53. package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +16 -0
  54. package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +18 -0
  55. package/v2Containers/MobilePushNew/components/CtaButtons.js +47 -52
  56. package/v2Containers/MobilePushNew/components/MediaUploaders.js +216 -297
  57. package/v2Containers/MobilePushNew/components/PlatformContentFields.js +125 -158
  58. package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +208 -30
  59. package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +108 -464
  60. package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +35 -106
  61. package/v2Containers/MobilePushNew/constants.js +0 -5
  62. package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +1 -63
  63. package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +0 -52
  64. package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +1 -40
  65. package/v2Containers/MobilePushNew/hooks/useUpload.js +39 -29
  66. package/v2Containers/MobilePushNew/index.js +239 -488
  67. package/v2Containers/MobilePushNew/index.scss +4 -205
  68. package/v2Containers/MobilePushNew/messages.js +6 -106
  69. package/v2Containers/MobilePushNew/tests/index.test.js +1 -469
  70. package/v2Containers/MobilePushNew/tests/utils.test.js +0 -70
  71. package/v2Containers/MobilePushNew/utils.js +0 -56
  72. package/v2Containers/Rcs/index.js +8 -1
  73. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +59 -0
  74. package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +4 -0
  75. package/v2Containers/SmsTrai/Edit/index.js +17 -7
  76. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +42 -0
  77. package/v2Containers/Templates/_templates.scss +2 -10
  78. package/v2Containers/Templates/index.js +81 -83
  79. package/v2Containers/Templates/tests/index.test.js +0 -68
  80. package/v2Containers/Viber/index.js +3 -1
  81. package/v2Containers/WebPush/Create/utils/validation.js +6 -0
  82. package/v2Containers/WebPush/Create/utils/validation.test.js +50 -0
  83. package/v2Containers/Whatsapp/index.js +9 -5
  84. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +2 -2
  85. package/v2Containers/Zalo/index.js +4 -1
  86. package/v2Components/CapMpushCTA/tests/index.test.js +0 -89
  87. package/v2Containers/MobilePushNew/components/TapLinkActions.js +0 -76
@@ -279,8 +279,8 @@ describe('MobilePushPreviewContent', () => {
279
279
  </TestWrapper>
280
280
  );
281
281
 
282
- expect(screen.getByText('Action 1')).toBeTruthy();
283
- expect(screen.getByText('Action 2')).toBeTruthy();
282
+ expect(screen.getByText('ACTION 1')).toBeTruthy();
283
+ expect(screen.getByText('ACTION 2')).toBeTruthy();
284
284
  });
285
285
 
286
286
  it('should use actionText as fallback for label', () => {
@@ -304,7 +304,7 @@ describe('MobilePushPreviewContent', () => {
304
304
  </TestWrapper>
305
305
  );
306
306
 
307
- expect(screen.getByText('Action Text')).toBeTruthy();
307
+ expect(screen.getByText('ACTION TEXT')).toBeTruthy();
308
308
  });
309
309
 
310
310
  it('should not render actions when carouselData is present', () => {
@@ -330,7 +330,7 @@ describe('MobilePushPreviewContent', () => {
330
330
  </TestWrapper>
331
331
  );
332
332
 
333
- expect(screen.queryByText('Action 1')).toBeNull();
333
+ expect(screen.queryByText('ACTION 1')).toBeNull();
334
334
  });
335
335
 
336
336
  it('should filter out actions without label or actionText', () => {
@@ -354,7 +354,7 @@ describe('MobilePushPreviewContent', () => {
354
354
  <ComponentToRender {...props} />
355
355
  </TestWrapper>
356
356
  );
357
- expect(screen.getByText('Action 1')).toBeTruthy();
357
+ expect(screen.getByText('ACTION 1')).toBeTruthy();
358
358
  });
359
359
  });
360
360
 
@@ -368,13 +368,11 @@ describe('MobilePushPreviewContent', () => {
368
368
  bodyText: 'Body',
369
369
  carouselData: [
370
370
  {
371
- mediaType: 'IMAGE',
372
371
  title: 'Carousel Item 1',
373
372
  message: 'Message 1',
374
373
  imageUrl: 'https://image1.url',
375
374
  },
376
375
  {
377
- mediaType: 'IMAGE',
378
376
  title: 'Carousel Item 2',
379
377
  message: 'Message 2',
380
378
  imageUrl: 'https://image2.url',
@@ -394,76 +392,6 @@ describe('MobilePushPreviewContent', () => {
394
392
  expect(screen.getByText('Carousel Item 2')).toBeTruthy();
395
393
  });
396
394
 
397
- it('should render every card, with or without media, in a horizontal row', () => {
398
- const props = {
399
- ...defaultProps,
400
- content: {
401
- androidContent: {
402
- header: 'Header',
403
- carouselData: [
404
- { mediaType: 'IMAGE', imageUrl: 'https://a.url', title: 'Card 1' },
405
- { mediaType: 'IMAGE', title: 'Empty card' },
406
- { mediaType: 'VIDEO', videoPreviewImg: 'https://b.url', title: 'Card 3' },
407
- ],
408
- },
409
- },
410
- };
411
-
412
- const { container } = render(
413
- <TestWrapper>
414
- <ComponentToRender {...props} />
415
- </TestWrapper>
416
- );
417
-
418
- expect(container.querySelectorAll('.mobile-push-carousel-card')).toHaveLength(3);
419
- expect(screen.getByText('Empty card')).toBeInTheDocument();
420
- const scrollRow = container.querySelector('.scroll-container');
421
- expect(scrollRow.className).not.toMatch(/ant-row-legacy|cap-row-vertical/);
422
- });
423
-
424
- it('should render a video card with no thumbnail as the video itself', () => {
425
- const props = {
426
- ...defaultProps,
427
- content: {
428
- androidContent: {
429
- header: 'Header',
430
- carouselData: [{ mediaType: 'video', videoSrc: 'https://v.mp4', title: 'Video card' }],
431
- },
432
- },
433
- };
434
-
435
- const { container } = render(
436
- <TestWrapper>
437
- <ComponentToRender {...props} />
438
- </TestWrapper>
439
- );
440
-
441
- expect(container.querySelectorAll('.mobile-push-carousel-card')).toHaveLength(1);
442
- expect(container.querySelector('video.carousel-video-preview')).toHaveAttribute('src', 'https://v.mp4');
443
- });
444
-
445
- it('should render an empty card while no media is uploaded', () => {
446
- const props = {
447
- ...defaultProps,
448
- content: {
449
- androidContent: {
450
- header: 'Header',
451
- carouselData: [{ mediaType: 'IMAGE', title: 'Empty card' }],
452
- },
453
- },
454
- };
455
-
456
- const { container } = render(
457
- <TestWrapper>
458
- <ComponentToRender {...props} />
459
- </TestWrapper>
460
- );
461
-
462
- expect(container.querySelector('.mobile-push-carousel-container')).toBeTruthy();
463
- expect(container.querySelectorAll('.mobile-push-carousel-card')).toHaveLength(1);
464
- expect(container.querySelector('.carousel-image')).toBeNull();
465
- });
466
-
467
395
  it('should render carousel with image media type', () => {
468
396
  const props = {
469
397
  ...defaultProps,
@@ -560,8 +488,6 @@ describe('MobilePushPreviewContent', () => {
560
488
  bodyText: 'Body',
561
489
  carouselData: [
562
490
  {
563
- mediaType: 'IMAGE',
564
- imageUrl: 'https://image.url',
565
491
  header: 'Carousel Header',
566
492
  message: 'Message',
567
493
  },
@@ -588,8 +514,6 @@ describe('MobilePushPreviewContent', () => {
588
514
  bodyText: 'Body',
589
515
  carouselData: [
590
516
  {
591
- mediaType: 'IMAGE',
592
- imageUrl: 'https://image.url',
593
517
  title: 'Title',
594
518
  bodyText: 'Carousel Body',
595
519
  },
@@ -602,92 +602,6 @@ describe('CommonTestAndPreview', () => {
602
602
  });
603
603
  });
604
604
 
605
- describe('Mobile push video payload - handleSendTestMessage', () => {
606
- // resetMocks in the jest config wipes the module mock's implementation before each test
607
- beforeEach(() => {
608
- // eslint-disable-next-line global-require
609
- require('../../../utils/cdnTransformation').getCdnUrl.mockImplementation(({ url }) => `cdn_${url}`);
610
- });
611
-
612
- const sendAndGetContent = async (props) => {
613
- render(
614
- <TestWrapper>
615
- <CommonTestAndPreview {...defaultProps} channel={CHANNELS.MOBILEPUSH} {...props} />
616
- </TestWrapper>
617
- );
618
- await waitFor(() => expect(lastSendTestMessageProps).toBeTruthy());
619
- lastSendTestMessageProps.handleSendTestMessage();
620
- const [payload] = mockActions.createMessageMetaRequested.mock.calls[0];
621
- return payload.mpushMessageContent;
622
- };
623
-
624
- it('sends a VIDEO style with the raw video url from the edit flow form data', async () => {
625
- const { androidContent, iosContent } = await sendAndGetContent({
626
- formData: [
627
- { 'message-title': 'T', 'message-editor': 'M', image: 'old.jpg', video: 'https://s3/a.mp4' },
628
- { 'message-title2': 'T2', 'message-editor2': 'M2', image: 'ios.jpg', video: '' },
629
- ],
630
- });
631
- expect(androidContent.type).toBe('VIDEO');
632
- expect(androidContent.expandableDetails.style).toBe('VIDEO');
633
- expect(androidContent.expandableDetails.media).toEqual([{ url: 'https://s3/a.mp4', text: '', type: 'VIDEO' }]);
634
- expect(androidContent.expandableDetails.image).toBeUndefined();
635
- expect(iosContent.type).toBe('IMAGE');
636
- expect(iosContent.expandableDetails.style).toBe('BIG_PICTURE');
637
- expect(iosContent.expandableDetails.image).toBe('cdn_ios.jpg');
638
- expect(iosContent.expandableDetails.media).toBeUndefined();
639
- });
640
-
641
- it('reads bodyVideo from the list (three-dots) content, but not for a GIF', async () => {
642
- const { androidContent, iosContent } = await sendAndGetContent({
643
- formData: undefined,
644
- content: {
645
- androidContent: { header: 'T', bodyText: 'M', bodyVideo: { videoSrc: 'https://s3/a.mp4' } },
646
- iosContent: { header: 'T2', bodyText: 'M2', bodyVideo: { videoSrc: 'https://s3/b.gif' }, bodyGif: 'https://s3/b.gif' },
647
- },
648
- });
649
- expect(androidContent.expandableDetails.media).toEqual([{ url: 'https://s3/a.mp4', text: '', type: 'VIDEO' }]);
650
- expect(androidContent.type).toBe('VIDEO');
651
- expect(iosContent.type).toBe('TEXT');
652
- expect(iosContent.expandableDetails.style).toBe('BIG_TEXT');
653
- expect(iosContent.expandableDetails.media).toBeUndefined();
654
- });
655
-
656
- const imageCard = { mediaType: 'image', imageUrl: 'https://s3/1.png', videoSrc: '', buttons: [] };
657
- const videoCard = { mediaType: 'video', imageUrl: '', videoSrc: 'https://s3/2.mp4', buttons: [] };
658
-
659
- it('sends carousel cards and the media list from the edit flow form data', async () => {
660
- const { androidContent, iosContent } = await sendAndGetContent({
661
- formData: [
662
- { 'message-title': 'T', 'message-editor': 'M', image: '', video: '', carouselData: [imageCard, videoCard] },
663
- { 'message-title2': 'T2', 'message-editor2': 'M2', image: '', video: '', carouselData: [] },
664
- ],
665
- });
666
- expect(androidContent.type).toBe('CAROUSEL');
667
- expect(androidContent.expandableDetails.style).toBe('MANUAL_CAROUSEL');
668
- expect(androidContent.expandableDetails.carouselData).toEqual([imageCard, videoCard]);
669
- expect(androidContent.expandableDetails.media).toEqual([
670
- { url: 'https://s3/1.png', type: 'IMAGE', text: '' },
671
- { url: 'https://s3/2.mp4', type: 'VIDEO', text: '' },
672
- ]);
673
- expect(iosContent.type).toBe('TEXT');
674
- expect(iosContent.expandableDetails.carouselData).toBeUndefined();
675
- });
676
-
677
- it('sends saved carousel cards from the list (three-dots) content', async () => {
678
- const { iosContent } = await sendAndGetContent({
679
- formData: undefined,
680
- content: {
681
- androidContent: { header: 'T', bodyText: 'M' },
682
- iosContent: { header: 'T2', bodyText: 'M2', carouselData: [videoCard] },
683
- },
684
- });
685
- expect(iosContent.type).toBe('CAROUSEL');
686
- expect(iosContent.expandableDetails.style).toBe('MANUAL_CAROUSEL');
687
- expect(iosContent.expandableDetails.media).toEqual([{ url: 'https://s3/2.mp4', type: 'VIDEO', text: '' }]);
688
- });
689
- });
690
-
691
605
  describe('Carousel payload (getCarouselMappedData) - handleSendTestMessage', () => {
692
606
  it('should map empty carouselData to empty cards when mediaType is CAROUSEL', async () => {
693
607
  const props = {
@@ -16,6 +16,10 @@ import {
16
16
  getWhatsappCarouselTagExtractionText,
17
17
  mergeZaloUnfilledParamTags,
18
18
  fillSlotMapFromCustomValues,
19
+ buildDltSmsSlotTags,
20
+ appendDltSmsTagRows,
21
+ getSmsDltMappedTagText,
22
+ dropBlankValues,
19
23
  } from '../utils';
20
24
 
21
25
  describe('CommonTestAndPreview/utils', () => {
@@ -342,4 +346,102 @@ describe('CommonTestAndPreview/utils', () => {
342
346
  expect(mergeSyntheticMustacheTags(null, 'no tags')).toEqual([]);
343
347
  });
344
348
  });
349
+
350
+ describe('getPersonalizationTagColumnLabel (DLT slot label)', () => {
351
+ it('prefers tokenLabel so a DLT slot reads as its position', () => {
352
+ expect(getPersonalizationTagColumnLabel({ tokenLabel: '*1', fullPath: '{#var#}_2' }))
353
+ .toBe('*1');
354
+ });
355
+
356
+ it('still falls back to fullPath/name for other channels', () => {
357
+ expect(getPersonalizationTagColumnLabel({ fullPath: 'a.b' })).toBe('a.b');
358
+ });
359
+ });
360
+
361
+ describe('buildDltSmsSlotTags', () => {
362
+ it('emits one OPTIONAL row per DLT slot, keyed like the editor (R3)', () => {
363
+ expect(buildDltSmsSlotTags('Dear {#var#}, order {#var#} shipped')).toEqual([
364
+ { name: '{#var#}_1', fullPath: '{#var#}_1', tokenLabel: '*1', metaData: { userDriven: true }, children: [] },
365
+ { name: '{#var#}_3', fullPath: '{#var#}_3', tokenLabel: '*2', metaData: { userDriven: true }, children: [] },
366
+ ]);
367
+ });
368
+
369
+ it('collapses a whitespace-separated run of tokens into ONE row, labelled by its position', () => {
370
+ expect(buildDltSmsSlotTags('{#a#} {#b#}')).toEqual([
371
+ { name: '{#var#}_0', fullPath: '{#var#}_0', tokenLabel: '*1', metaData: { userDriven: true }, children: [] },
372
+ ]);
373
+ });
374
+
375
+ it('keys typed tokens (short, long and pipe-combined forms) by segment index', () => {
376
+ expect(buildDltSmsSlotTags('{#num#} and {#url|ott#}').map((t) => t.name))
377
+ .toEqual(['{#var#}_0', '{#var#}_2']);
378
+ });
379
+
380
+ it('ignores mustache tokens and non-DLT bodies', () => {
381
+ expect(buildDltSmsSlotTags('Hi {{name}}')).toEqual([]);
382
+ expect(buildDltSmsSlotTags('plain')).toEqual([]);
383
+ expect(buildDltSmsSlotTags(undefined)).toEqual([]);
384
+ });
385
+
386
+ it('drops both slots when each already has a mapping, so only the mapped tag surfaces', () => {
387
+ expect(buildDltSmsSlotTags('Book now at {#urlott#} and get {#num#} reward points', {
388
+ '{#var#}_1': 'mk;lkn',
389
+ '{#var#}_3': '{{store_name}}',
390
+ })).toEqual([]);
391
+ });
392
+
393
+ it('keeps a row only for the unmapped slot, labelled by its position', () => {
394
+ expect(buildDltSmsSlotTags('Book now at {#urlott#} and get {#num#} reward points', {
395
+ '{#var#}_1': 'mk;lkn',
396
+ })).toEqual([
397
+ { name: '{#var#}_3', fullPath: '{#var#}_3', tokenLabel: '*2', metaData: { userDriven: true }, children: [] },
398
+ ]);
399
+ });
400
+ });
401
+
402
+ describe('appendDltSmsTagRows', () => {
403
+ const smsBody = 'Book now at {#urlott#} and get {#num#} reward points';
404
+ const bothMapped = { '{#var#}_1': 'mk;lkn', '{#var#}_3': '{{store_name}}' };
405
+
406
+ it('adds the tag used inside a slot mapping, as an optional row', () => {
407
+ expect(appendDltSmsTagRows([], bothMapped, smsBody))
408
+ .toEqual([{ name: 'store_name', metaData: { userDriven: true }, children: [] }]);
409
+ });
410
+
411
+ it('adds no row when every slot holds a literal', () => {
412
+ expect(appendDltSmsTagRows([], { '{#var#}_1': 'mk;lkn', '{#var#}_3': 'x' }, smsBody)).toEqual([]);
413
+ });
414
+
415
+ it('keeps an existing row and does not duplicate it', () => {
416
+ expect(appendDltSmsTagRows([{ name: 'store_name' }], bothMapped, smsBody))
417
+ .toEqual([{ name: 'store_name' }]);
418
+ });
419
+
420
+ it('still emits a *N row for a slot with no mapping', () => {
421
+ expect(appendDltSmsTagRows([], { '{#var#}_1': 'mk;lkn' }, smsBody).map((tag) => tag.tokenLabel))
422
+ .toEqual(['*2']);
423
+ });
424
+
425
+ it('leaves other channels untouched', () => {
426
+ expect(appendDltSmsTagRows([{ name: 'a' }], {}, 'plain body')).toEqual([{ name: 'a' }]);
427
+ });
428
+
429
+ it('joins only the non-empty mapped values as tag text', () => {
430
+ expect(getSmsDltMappedTagText({ a: 'mk;lkn', b: '{{store_name}}', c: '' }))
431
+ .toBe('mk;lkn {{store_name}}');
432
+ });
433
+ });
434
+
435
+ describe('dropBlankValues', () => {
436
+ it('drops blanks so a seeded empty row cannot shadow a real value (Critical A)', () => {
437
+ expect(dropBlankValues({ '{#var#}_1': 'Pat', '{#var#}_3': '', a: null, b: undefined, c: 'x' }))
438
+ .toEqual({ '{#var#}_1': 'Pat', c: 'x' });
439
+ });
440
+
441
+ it('tolerates null and undefined', () => {
442
+ expect(dropBlankValues(null)).toEqual({});
443
+ expect(dropBlankValues(undefined)).toEqual({});
444
+ expect(dropBlankValues({})).toEqual({});
445
+ });
446
+ });
345
447
  });
@@ -1,10 +1,17 @@
1
1
  import get from 'lodash/get';
2
- import { extractTemplateVariables } from '../../utils/templateVarUtils';
2
+ import {
3
+ collectDltSlotRuns,
4
+ extractTemplateVariables,
5
+ getDltSlotKey,
6
+ } from '../../utils/templateVarUtils';
3
7
  import { SMS_MUSTACHE_TAG_PATTERN, WHATSAPP_SLOT_KEY_PATTERN } from './constants';
4
8
 
5
9
  /** Show token path from extract-tags (fullPath preferred, falls back to name). */
6
- export const getPersonalizationTagColumnLabel = (tagNode) =>
7
- tagNode?.fullPath ?? tagNode?.name ?? '';
10
+ export const getPersonalizationTagColumnLabel = (tagNode) => tagNode?.tokenLabel ?? tagNode?.fullPath ?? tagNode?.name ?? '';
11
+
12
+ export const dropBlankValues = (values = {}) => Object.fromEntries(
13
+ Object.entries(values || {}).filter(([, value]) => value !== '' && value !== null && value !== undefined),
14
+ );
8
15
 
9
16
  /** Non-global so ensureGlobalRegexForExecLoop creates a fresh instance on each call. */
10
17
  const SMS_MUSTACHE_VAR_REGEX = /\{\{([^}]+)\}\}/;
@@ -119,6 +126,38 @@ export const fillSlotMapFromCustomValues = (slotMap, customValues = {}) => {
119
126
  return filledSlotMap;
120
127
  };
121
128
 
129
+ export const buildDltSmsSlotTags = (body = '', mappedValues = {}) => {
130
+ if (!body || typeof body !== 'string') return [];
131
+ return collectDltSlotRuns(body).reduce((rows, run, index) => {
132
+ const slotKey = getDltSlotKey(run.firstIndex);
133
+ const mappedValue = mappedValues?.[slotKey];
134
+ if (mappedValue !== '' && mappedValue !== null && mappedValue !== undefined) return rows;
135
+ rows.push({
136
+ name: slotKey,
137
+ fullPath: slotKey,
138
+ tokenLabel: `*${index + 1}`,
139
+ metaData: { userDriven: true },
140
+ children: [],
141
+ });
142
+ return rows;
143
+ }, []);
144
+ };
145
+
146
+ export const getSmsDltMappedTagText = (varMapped = {}) => Object.values(varMapped || {})
147
+ .filter((value) => typeof value === 'string' && value.length > 0)
148
+ .join(' ');
149
+
150
+ export const appendDltSmsTagRows = (rows = [], varMapped = {}, body = '') => {
151
+ const mappedRows = mergeSyntheticMustacheTags([], getSmsDltMappedTagText(varMapped))
152
+ .map((tag) => ({ ...tag, metaData: { ...tag?.metaData, userDriven: true } }));
153
+ const existingNames = new Set((rows || []).map((tag) => tag?.name));
154
+ return [
155
+ ...(rows || []),
156
+ ...mappedRows.filter((tag) => !existingNames.has(tag.name)),
157
+ ...buildDltSmsSlotTags(body, varMapped),
158
+ ];
159
+ };
160
+
122
161
  /** RCS createMessageMeta: normalize media shape (mediaUrl, thumbnailUrl, height string). */
123
162
  export const normalizeRcsTestCardMedia = (media) => {
124
163
  if (!media || typeof media !== 'object') return undefined;
@@ -81,7 +81,8 @@ const tagsTypes = {
81
81
  const errorMessageForTags = {
82
82
  MISSING_TAG_ERROR: 'missingTagsError',
83
83
  GENERIC_VALIDATION_ERROR: 'genericValidationError',
84
- TAG_BRACKET_COUNT_MISMATCH_ERROR: 'tagBracketCountMismatchError'
84
+ TAG_BRACKET_COUNT_MISMATCH_ERROR: 'tagBracketCountMismatchError',
85
+ TAG_DEFAULT_QUOTE_ERROR: 'tagDefaultQuoteError',
85
86
  };
86
87
 
87
88
  // Isolated input for EMAIL template-name: only this tiny component re-renders on each keystroke.
@@ -856,9 +857,11 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
856
857
  if (tagResult.valid) {
857
858
  errorData[count][`sms-editor${index > 1 ? index : ''}`] = false;
858
859
  } else {
859
- const { MISSING_TAG_ERROR, GENERIC_VALIDATION_ERROR, TAG_BRACKET_COUNT_MISMATCH_ERROR } = errorMessageForTags || {};
860
- const { missingTags, isBraceError } = tagResult;
861
- errorData[count][`sms-editor${index > 1 ? index : ''}`] = missingTags && missingTags.length ? MISSING_TAG_ERROR : (isBraceError ? TAG_BRACKET_COUNT_MISMATCH_ERROR : GENERIC_VALIDATION_ERROR);
860
+ const { MISSING_TAG_ERROR, GENERIC_VALIDATION_ERROR, TAG_BRACKET_COUNT_MISMATCH_ERROR, TAG_DEFAULT_QUOTE_ERROR } = errorMessageForTags || {};
861
+ const { missingTags, isBraceError, isDefaultQuoteError } = tagResult;
862
+ let smsEditorError = isDefaultQuoteError ? TAG_DEFAULT_QUOTE_ERROR : GENERIC_VALIDATION_ERROR;
863
+ if (isBraceError) smsEditorError = TAG_BRACKET_COUNT_MISMATCH_ERROR;
864
+ errorData[count][`sms-editor${index > 1 ? index : ''}`] = missingTags && missingTags.length ? MISSING_TAG_ERROR : smsEditorError;
862
865
  errorData[count][`bracket-error`] = isBraceError && TAG_BRACKET_COUNT_MISMATCH_ERROR;
863
866
  isValid = false;
864
867
  }
@@ -992,7 +995,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
992
995
  if(this.props.schema && this.props.schema.channel && this.props.schema.channel.toUpperCase() === "MOBILEPUSH"){
993
996
  let androidValid = true, iosValid = true;
994
997
  let isOnlyAndroid = false, isOnlyIos = false;
995
- const { TAG_BRACKET_COUNT_MISMATCH_ERROR } = errorMessageForTags;
998
+ const { TAG_BRACKET_COUNT_MISMATCH_ERROR, TAG_DEFAULT_QUOTE_ERROR } = errorMessageForTags;
996
999
  const androidData = {};
997
1000
  if (this.state.formData && this.state.formData[0]) {
998
1001
  for(let data in this.state.formData[0]){
@@ -1041,8 +1044,8 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1041
1044
  if (tagValidationResponse.valid) {
1042
1045
  errorData[parseInt(index)][`message-editor${selector}`] = false;
1043
1046
  } else {
1044
- const { isBraceError } = tagValidationResponse;
1045
- errorData[parseInt(index)][`message-editor${selector}`] = isBraceError ? TAG_BRACKET_COUNT_MISMATCH_ERROR : true;
1047
+ const { isBraceError, isDefaultQuoteError } = tagValidationResponse;
1048
+ errorData[parseInt(index)][`message-editor${selector}`] = isBraceError ? TAG_BRACKET_COUNT_MISMATCH_ERROR : (isDefaultQuoteError ? TAG_DEFAULT_QUOTE_ERROR : true);
1046
1049
  errorData[parseInt(index)][`bracket-error`] = isBraceError && TAG_BRACKET_COUNT_MISMATCH_ERROR;
1047
1050
  isValid = false;
1048
1051
  }
@@ -1073,8 +1076,8 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1073
1076
  if (tagValidationResponse.valid) {
1074
1077
  errorData[parseInt(index)][`message-title${selector}`] = false;
1075
1078
  } else {
1076
- const {isBraceError} = tagValidationResponse;
1077
- errorData[parseInt(index)][`message-title${selector}`] = isBraceError ? TAG_BRACKET_COUNT_MISMATCH_ERROR : true;
1079
+ const { isBraceError, isDefaultQuoteError } = tagValidationResponse;
1080
+ errorData[parseInt(index)][`message-title${selector}`] = isBraceError ? TAG_BRACKET_COUNT_MISMATCH_ERROR : (isDefaultQuoteError ? TAG_DEFAULT_QUOTE_ERROR : true);
1078
1081
  errorData[parseInt(index)][`bracket-error`] = isBraceError && TAG_BRACKET_COUNT_MISMATCH_ERROR;
1079
1082
  isValid = false;
1080
1083
  }
@@ -1358,6 +1361,9 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
1358
1361
  if (tagValidationResponse?.isBraceError){
1359
1362
  errorString += this.props.intl.formatMessage(globalMessages.unbalanacedCurlyBraces);
1360
1363
  }
1364
+ if (tagValidationResponse?.isDefaultQuoteError) {
1365
+ errorString += this.props.intl.formatMessage(globalMessages.unquotedTagDefaultValue);
1366
+ }
1361
1367
  if (tagValidationResponse?.isContentEmpty) {
1362
1368
  errorString += this.props.intl.formatMessage(messages.emailBodyEmptyError);
1363
1369
  // Adds a bypass for cases where content is initially empty in the creation flow.
@@ -2922,7 +2928,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2922
2928
  const errorType = (isVersionEnable ? errorData[`${currentTab - 1}`][val.id] : errorData[val.id]);
2923
2929
  const ifError = checkValidation && errorType;
2924
2930
  const messageContent = isVersionEnable ? formData[`${currentTab - 1}`][val.id] : formData[val.id];
2925
- const { MISSING_TAG_ERROR, TAG_BRACKET_COUNT_MISMATCH_ERROR } = errorMessageForTags;
2931
+ const { MISSING_TAG_ERROR, TAG_BRACKET_COUNT_MISMATCH_ERROR, TAG_DEFAULT_QUOTE_ERROR } = errorMessageForTags;
2926
2932
  const { formatMessage } = this.props.intl;
2927
2933
 
2928
2934
  const aiContentBotDisabled = isAiContentBotDisabled();
@@ -2935,6 +2941,9 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2935
2941
  case TAG_BRACKET_COUNT_MISMATCH_ERROR:
2936
2942
  errorMessageText = formatMessage(globalMessages.unbalanacedCurlyBraces);
2937
2943
  break;
2944
+ case TAG_DEFAULT_QUOTE_ERROR:
2945
+ errorMessageText = formatMessage(globalMessages.unquotedTagDefaultValue);
2946
+ break;
2938
2947
  case true:
2939
2948
  errorMessageText = formatMessage(messages.genericTagsValidationError);
2940
2949
  break;
@@ -3564,7 +3573,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
3564
3573
  const errorType = isVersionEnable ? this.state.errorData[`${this.state.currentTab - 1}`][val.id] : this.state.errorData[val.id];
3565
3574
  const aiContentBotDisabled = isAiContentBotDisabled();
3566
3575
  ifError = this.state.checkValidation && (isVersionEnable ? this.state.errorData[`${this.state.currentTab - 1}`][val.id] : this.state.errorData[val.id]);
3567
- const { TAG_BRACKET_COUNT_MISMATCH_ERROR } = errorMessageForTags;
3576
+ const { TAG_BRACKET_COUNT_MISMATCH_ERROR, TAG_DEFAULT_QUOTE_ERROR } = errorMessageForTags;
3568
3577
  const { formatMessage } = this.props.intl;
3569
3578
  const value = isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : this.state.formData[val.id];
3570
3579
  // Show personalization error for title field inline (same as message textarea) when restrictPersonalization is true
@@ -3572,9 +3581,10 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
3572
3581
  if (hasPersonalizationError) {
3573
3582
  ifError = true;
3574
3583
  }
3575
- let errorMessageText = hasPersonalizationError
3576
- ? formatMessage(messages.personalizationTagsErrorMessage)
3577
- : (errorType === TAG_BRACKET_COUNT_MISMATCH_ERROR ? formatMessage(globalMessages.unbalanacedCurlyBraces) : (val.errorMessage && ifError ? val.errorMessage : ''));
3584
+ let errorMessageText = val.errorMessage && ifError ? val.errorMessage : '';
3585
+ if (errorType === TAG_BRACKET_COUNT_MISMATCH_ERROR) errorMessageText = formatMessage(globalMessages.unbalanacedCurlyBraces);
3586
+ if (errorType === TAG_DEFAULT_QUOTE_ERROR) errorMessageText = formatMessage(globalMessages.unquotedTagDefaultValue);
3587
+ if (hasPersonalizationError) errorMessageText = formatMessage(messages.personalizationTagsErrorMessage);
3578
3588
  if (styling === 'semantic') {
3579
3589
  const isEmailStandaloneHighFreq = val.standalone && this.props.schema?.channel?.toUpperCase() === EMAIL;
3580
3590
  if (isEmailStandaloneHighFreq) {
@@ -12,6 +12,7 @@ import { TEMPLATE_NAME_FIELD } from '../../constants';
12
12
  // boolean true). Mirrors errorMessageForTags.TAG_BRACKET_COUNT_MISMATCH_ERROR.
13
13
  export const ERROR_VALUE = {
14
14
  BRACKET: 'tagBracketCountMismatchError',
15
+ DEFAULT_QUOTE: 'tagDefaultQuoteError',
15
16
  };
16
17
 
17
18
  // Legacy tab semantics: 1-based currentTab, 1=Android, 2=iOS (Classic.js:483-486).
@@ -69,6 +69,6 @@ export default function getEditorErrorDescriptor(legacyFormData = {}, ctx = {})
69
69
  if (!field?.errorMessage) return null;
70
70
  return {
71
71
  text: field.errorMessage,
72
- kind: editorError === ERROR_VALUE.BRACKET ? EDITOR_ERROR_KIND.BRACE : EDITOR_ERROR_KIND.MISSING,
72
+ kind: [ERROR_VALUE.BRACKET, ERROR_VALUE.DEFAULT_QUOTE].includes(editorError) ? EDITOR_ERROR_KIND.BRACE : EDITOR_ERROR_KIND.MISSING,
73
73
  };
74
74
  }
@@ -5,6 +5,7 @@
5
5
  */
6
6
  import validateMobilePush, { isValidExternalLink } from '../validate';
7
7
  import { ERROR_VALUE } from '../config';
8
+ import * as tagValidations from '../../../../../../utils/tagValidations';
8
9
 
9
10
  const baseOptions = { tags: [], isFullMode: true, isEmbedded: false };
10
11
 
@@ -261,6 +262,62 @@ describe('channels/mobilepush/validate', () => {
261
262
  expect(result.platform.androidValid).toBe(true); // NOT cleared, like the editor
262
263
  expect(result.isValid).toBe(false);
263
264
  });
265
+
266
+ describe('unquoted tag default value', () => {
267
+ afterEach(() => jest.restoreAllMocks());
268
+
269
+ it('EDITOR: writes DEFAULT_QUOTE, bracket-error stays false and the tab flag is kept', () => {
270
+ const result = validateMobilePush(bothPlatforms({
271
+ 0: {
272
+ 'message-title': 'hello', 'message-editor': 'hi {{name | default: Rafeeq}}', "base": true, "tabKey": 'k0',
273
+ },
274
+ }), baseOptions);
275
+ expect(result.isValid).toBe(false);
276
+ expect(result.errorData[0]['message-editor']).toBe(ERROR_VALUE.DEFAULT_QUOTE);
277
+ expect(result.errorData[0]['bracket-error']).toBe(false);
278
+ expect(result.platform.androidValid).toBe(true);
279
+ });
280
+
281
+ it('TITLE: writes DEFAULT_QUOTE and bracket-error stays false', () => {
282
+ const result = validateMobilePush(bothPlatforms({
283
+ 0: {
284
+ 'message-title': 'hi {{name | default: }}', 'message-editor': 'body', "base": true, "tabKey": 'k0',
285
+ },
286
+ }), baseOptions);
287
+ expect(result.isValid).toBe(false);
288
+ expect(result.errorData[0]['message-title']).toBe(ERROR_VALUE.DEFAULT_QUOTE);
289
+ expect(result.errorData[0]['bracket-error']).toBe(false);
290
+ });
291
+
292
+ it('iOS tab uses the suffixed ids for DEFAULT_QUOTE', () => {
293
+ const result = validateMobilePush(bothPlatforms({
294
+ 1: { 'message-title2': "{{a | default: x}}", 'message-editor2': "{{b | default: y}}", "tabKey": 'k1' },
295
+ }), baseOptions);
296
+ expect(result.errorData[1]['message-editor2']).toBe(ERROR_VALUE.DEFAULT_QUOTE);
297
+ expect(result.errorData[1]['message-title2']).toBe(ERROR_VALUE.DEFAULT_QUOTE);
298
+ });
299
+
300
+ it('quoted default value stays valid', () => {
301
+ const result = validateMobilePush(bothPlatforms({
302
+ 0: {
303
+ 'message-title': "hi {{name | default: 'Rafeeq'}}", 'message-editor': "{{name | default: ''}}", "base": true, "tabKey": 'k0',
304
+ },
305
+ }), baseOptions);
306
+ expect(result.errorData[0]['message-title']).toBe(false);
307
+ expect(result.errorData[0]['message-editor']).toBe(false);
308
+ });
309
+
310
+ it('invalid without brace/quote error (e.g. missing tags) falls back to generic true', () => {
311
+ jest.spyOn(tagValidations, 'validateTagsCore').mockReturnValue({
312
+ valid: false, missingTags: ['unsubscribe'], isBraceError: false, isDefaultQuoteError: false,
313
+ });
314
+ const result = validateMobilePush(bothPlatforms(), baseOptions);
315
+ expect(result.errorData[0]['message-editor']).toBe(true);
316
+ expect(result.errorData[0]['message-title']).toBe(true);
317
+ expect(result.errorData[0]['bracket-error']).toBe(false);
318
+ expect(result.isValid).toBe(false);
319
+ });
320
+ });
264
321
  });
265
322
 
266
323
  describe('isValidExternalLink', () => {
@@ -128,8 +128,8 @@ export default function validateMobilePush(formData = {}, options = {}) {
128
128
  if (tagValidation.valid) {
129
129
  tabErrors[`message-editor${suffix}`] = false;
130
130
  } else {
131
- const { isBraceError } = tagValidation;
132
- tabErrors[`message-editor${suffix}`] = isBraceError ? ERROR_VALUE.BRACKET : true;
131
+ const { isBraceError, isDefaultQuoteError } = tagValidation;
132
+ tabErrors[`message-editor${suffix}`] = isBraceError ? ERROR_VALUE.BRACKET : (isDefaultQuoteError ? ERROR_VALUE.DEFAULT_QUOTE : true);
133
133
  tabErrors['bracket-error'] = isBraceError && ERROR_VALUE.BRACKET;
134
134
  isValid = false; // NOTE: isCurrentTabValid deliberately NOT cleared (Classic parity)
135
135
  }
@@ -157,8 +157,8 @@ export default function validateMobilePush(formData = {}, options = {}) {
157
157
  if (tagValidation.valid) {
158
158
  tabErrors[`message-title${suffix}`] = false;
159
159
  } else {
160
- const { isBraceError } = tagValidation;
161
- tabErrors[`message-title${suffix}`] = isBraceError ? ERROR_VALUE.BRACKET : true;
160
+ const { isBraceError, isDefaultQuoteError } = tagValidation;
161
+ tabErrors[`message-title${suffix}`] = isBraceError ? ERROR_VALUE.BRACKET : (isDefaultQuoteError ? ERROR_VALUE.DEFAULT_QUOTE : true);
162
162
  tabErrors['bracket-error'] = isBraceError && ERROR_VALUE.BRACKET;
163
163
  isValid = false; // isCurrentTabValid NOT cleared (Classic parity)
164
164
  }
@@ -34,6 +34,9 @@ export default function getEditorErrorDescriptor(legacyFormData = {}, options =
34
34
  if (tagValidation?.isBraceError) {
35
35
  return { message: globalMessages.unbalanacedCurlyBraces, kind: EDITOR_ERROR_KIND.BRACE };
36
36
  }
37
+ if (tagValidation?.isDefaultQuoteError) {
38
+ return { message: globalMessages.unquotedTagDefaultValue, kind: EDITOR_ERROR_KIND.BRACE };
39
+ }
37
40
  if (tagValidation?.missingTags?.length) {
38
41
  return {
39
42
  message: formMessages.missingTagsValidationError,
@@ -16,6 +16,11 @@ describe('getEditorErrorDescriptor (SMS)', () => {
16
16
  expect(d).toEqual({ message: globalMessages.unbalanacedCurlyBraces, kind: 'brace' });
17
17
  });
18
18
 
19
+ it('unquoted default value -> unquotedTagDefaultValue descriptor tagged kind:brace', () => {
20
+ const d = getEditorErrorDescriptor(fd('Hi {{full_name | default: Rafeeq}}'), ctx);
21
+ expect(d).toEqual({ message: globalMessages.unquotedTagDefaultValue, kind: 'brace' });
22
+ });
23
+
19
24
  it('valid content -> null (no error)', () => {
20
25
  expect(getEditorErrorDescriptor(fd('hello world'), ctx)).toBeNull();
21
26
  });