@capillarytech/creatives-library 9.1.8-alpha.sprint-cap-214249.38 → 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 (127) hide show
  1. package/constants/unified.js +4 -0
  2. package/index.js +13 -0
  3. package/package.json +1 -1
  4. package/services/getSchema.js +4 -1
  5. package/services/tests/getSchema.test.js +2 -2
  6. package/translations/en.json +1 -0
  7. package/translations/ja-JP.json +1 -0
  8. package/translations/zh.json +1 -0
  9. package/utils/common.js +6 -0
  10. package/utils/createMobilePushPayload.js +33 -47
  11. package/utils/tagValidations.js +35 -4
  12. package/utils/templateVarUtils.js +49 -0
  13. package/utils/tests/createMobilePushPayload.test.js +8 -102
  14. package/utils/tests/tagValidations.test.js +48 -0
  15. package/utils/tests/templateVarUtils.test.js +89 -0
  16. package/v2Components/CapMpushCTA/index.js +9 -10
  17. package/v2Components/CapMpushCTA/index.scss +3 -29
  18. package/v2Components/CapTagList/TagFallbackPanel.js +124 -0
  19. package/v2Components/CapTagList/constants.js +5 -0
  20. package/v2Components/CapTagList/index.js +46 -7
  21. package/v2Components/CapTagList/messages.js +44 -0
  22. package/v2Components/CapTagList/style.scss +113 -1
  23. package/v2Components/CapTagList/tests/TagFallback.test.js +222 -0
  24. package/v2Components/CapTagList/utils.js +17 -0
  25. package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +13 -26
  26. package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -13
  27. package/v2Components/CommonTestAndPreview/constants.js +3 -2
  28. package/v2Components/CommonTestAndPreview/index.js +62 -62
  29. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +5 -79
  30. package/v2Components/CommonTestAndPreview/tests/index.test.js +0 -86
  31. package/v2Components/CommonTestAndPreview/tests/utils.test.js +102 -0
  32. package/v2Components/CommonTestAndPreview/utils.js +42 -3
  33. package/v2Components/FormBuilder/Classic.js +24 -14
  34. package/v2Components/FormBuilder/Functional/channels/mobilepush/config.js +1 -0
  35. package/v2Components/FormBuilder/Functional/channels/mobilepush/getEditorErrorDescriptor.js +1 -1
  36. package/v2Components/FormBuilder/Functional/channels/mobilepush/tests/validate.test.js +57 -0
  37. package/v2Components/FormBuilder/Functional/channels/mobilepush/validate.js +4 -4
  38. package/v2Components/FormBuilder/Functional/channels/sms/getEditorErrorDescriptor.js +3 -0
  39. package/v2Components/FormBuilder/Functional/channels/sms/tests/getEditorErrorDescriptor.test.js +5 -0
  40. package/v2Components/FormBuilder/Functional/channels/sms/tests/validate.test.js +6 -0
  41. package/v2Components/FormBuilder/Functional/channels/sms/validate.js +3 -1
  42. package/v2Components/FormBuilder/Functional/renderers/mpushRenderers.js +3 -0
  43. package/v2Components/FormBuilder/Functional/tests/manual.typingPerf.test.js +135 -0
  44. package/v2Components/FormBuilder/Functional/tests/mpush.crossFlowParity.test.js +1 -1
  45. package/v2Components/FormBuilder/Functional/tests/mpush.ctaFlows.parity.test.js +320 -0
  46. package/v2Components/FormBuilder/Functional/tests/mpush.editContainer.parity.test.js +148 -0
  47. package/v2Components/FormBuilder/Functional/tests/mpush.libraryValidity.parity.test.js +152 -0
  48. package/v2Components/FormBuilder/Functional/tests/mpush.shellEvents.test.js +1 -1
  49. package/v2Components/FormBuilder/Functional/tests/mpush.singlePlatform.test.js +1 -1
  50. package/v2Components/FormBuilder/Functional/tests/mpushRenderers.test.js +22 -0
  51. package/v2Components/FormBuilder/tests/mpush.characterization.test.js +2 -2
  52. package/v2Components/TemplatePreview/_templatePreview.scss +2 -12
  53. package/v2Components/TemplatePreview/index.js +17 -30
  54. package/v2Components/TemplatePreview/tests/index.test.js +0 -61
  55. package/v2Containers/Cap/index.js +3 -0
  56. package/v2Containers/Cap/messages.js +4 -0
  57. package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +1 -0
  58. package/v2Containers/CreativesContainer/SlideBoxContent.js +151 -70
  59. package/v2Containers/CreativesContainer/index.js +6 -3
  60. package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +0 -29
  61. package/v2Containers/InApp/index.js +4 -1
  62. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +3 -0
  63. package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +2 -0
  64. package/v2Containers/Line/Container/Text/index.js +3 -1
  65. package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +16 -0
  66. package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +18 -0
  67. package/v2Containers/MobilePush/Create/_mobilePushCreate.scss +70 -0
  68. package/v2Containers/MobilePush/Create/actions.js +52 -0
  69. package/v2Containers/MobilePush/Create/constants.js +26 -0
  70. package/v2Containers/MobilePush/Create/index.js +2149 -0
  71. package/v2Containers/MobilePush/Create/messages.js +349 -0
  72. package/v2Containers/MobilePush/Create/reducer.js +72 -0
  73. package/v2Containers/MobilePush/Create/sagas.js +79 -0
  74. package/v2Containers/MobilePush/Create/selectors.js +29 -0
  75. package/v2Containers/MobilePush/Create/test/contentValidity.test.js +154 -0
  76. package/v2Containers/MobilePush/Create/test/saga.test.js +19 -0
  77. package/v2Containers/MobilePush/Create/test/stayOpenOnSave.test.js +80 -0
  78. package/v2Containers/MobilePush/Edit/_mobilePushCreate.scss +65 -0
  79. package/v2Containers/MobilePush/Edit/actions.js +94 -0
  80. package/v2Containers/MobilePush/Edit/constants.js +37 -0
  81. package/v2Containers/MobilePush/Edit/index.js +2407 -0
  82. package/v2Containers/MobilePush/Edit/messages.js +341 -0
  83. package/v2Containers/MobilePush/Edit/reducer.js +113 -0
  84. package/v2Containers/MobilePush/Edit/sagas.js +113 -0
  85. package/v2Containers/MobilePush/Edit/selectors.js +33 -0
  86. package/v2Containers/MobilePush/Edit/test/contentValidity.test.js +149 -0
  87. package/v2Containers/MobilePush/Edit/test/saga.test.js +255 -0
  88. package/v2Containers/MobilePush/Edit/test/stayOpenOnSave.test.js +60 -0
  89. package/v2Containers/MobilePush/commonMethods.js +333 -0
  90. package/v2Containers/MobilePush/eventsMap.js +130 -0
  91. package/v2Containers/MobilePush/tests/commonMethods.test.js +401 -0
  92. package/v2Containers/MobilePushNew/components/CtaButtons.js +47 -52
  93. package/v2Containers/MobilePushNew/components/MediaUploaders.js +192 -207
  94. package/v2Containers/MobilePushNew/components/PlatformContentFields.js +121 -116
  95. package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +208 -30
  96. package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +72 -316
  97. package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +16 -45
  98. package/v2Containers/MobilePushNew/constants.js +0 -5
  99. package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +1 -63
  100. package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +0 -52
  101. package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +1 -38
  102. package/v2Containers/MobilePushNew/hooks/useUpload.js +39 -29
  103. package/v2Containers/MobilePushNew/index.js +192 -454
  104. package/v2Containers/MobilePushNew/index.scss +4 -188
  105. package/v2Containers/MobilePushNew/messages.js +6 -86
  106. package/v2Containers/MobilePushNew/tests/index.test.js +1 -450
  107. package/v2Containers/MobilePushNew/tests/utils.test.js +0 -25
  108. package/v2Containers/MobilePushNew/utils.js +0 -8
  109. package/v2Containers/MobilepushWrapper/_mobilepushWrapper.scss +22 -0
  110. package/v2Containers/MobilepushWrapper/index.js +178 -0
  111. package/v2Containers/MobilepushWrapper/messages.js +29 -0
  112. package/v2Containers/Rcs/index.js +8 -1
  113. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +59 -0
  114. package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +4 -0
  115. package/v2Containers/SmsTrai/Edit/index.js +17 -7
  116. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +42 -0
  117. package/v2Containers/Templates/_templates.scss +2 -10
  118. package/v2Containers/Templates/index.js +90 -84
  119. package/v2Containers/Templates/tests/index.test.js +0 -68
  120. package/v2Containers/Viber/index.js +3 -1
  121. package/v2Containers/WebPush/Create/utils/validation.js +6 -0
  122. package/v2Containers/WebPush/Create/utils/validation.test.js +50 -0
  123. package/v2Containers/Whatsapp/index.js +9 -5
  124. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +2 -2
  125. package/v2Containers/Zalo/index.js +4 -1
  126. package/v2Components/CapMpushCTA/tests/index.test.js +0 -89
  127. /package/{v2Components/FormBuilder/Functional/tests/fixtures/mpushInitialSchema.js → v2Containers/MobilePush/initialSchema.js} +0 -0
@@ -7,7 +7,7 @@ import { configureStore } from '@capillarytech/vulcan-react-sdk/utils';
7
7
  import { initialReducer } from '../../../../initialReducer';
8
8
  import history from '../../../../utils/history';
9
9
  import MediaUploaders from '../MediaUploaders';
10
- import { ANDROID, IOS, DEEP_LINK } from '../../constants';
10
+ import { ANDROID, IOS } from '../../constants';
11
11
  import { act } from 'react';
12
12
  import messages from '../../messages';
13
13
 
@@ -202,27 +202,11 @@ jest.mock('../../../../v2Components/CapVideoUpload', () =>
202
202
  <div data-testid="cap-video-upload">
203
203
  <button
204
204
  type="button"
205
- // Real CapVideoUpload calls back with (index, data)
206
- onClick={() => props.onVideoUploadUpdateAssestList(0, { videoSrc: 'mock-video-url', previewUrl: 'mock-preview-url' })}
205
+ onClick={() => props.onVideoUploadUpdateAssestList('mock-video-url')}
207
206
  data-testid="video-upload-button"
208
207
  >
209
208
  Upload Video
210
209
  </button>
211
- <button
212
- type="button"
213
- // Real Re upload clears the video, then opens the file picker
214
- onClick={() => props.onVideoUploadUpdateAssestList(0, { videoSrc: '', previewUrl: '' })}
215
- data-testid="video-reupload-button"
216
- >
217
- Re upload Video
218
- </button>
219
- <button
220
- type="button"
221
- onClick={() => props.uploadAsset({ name: 'test.mp4' }, 'video', {}, props.index)}
222
- data-testid="video-file-upload-button"
223
- >
224
- Pick Video File
225
- </button>
226
210
  </div>
227
211
  );
228
212
  }
@@ -504,42 +488,6 @@ jest.mock('../../messages', () => ({
504
488
  id: 'creatives.containersV2.MobilePushNew.actionOnClickBody',
505
489
  defaultMessage: 'Action on click of notification body',
506
490
  },
507
- cardTap: {
508
- id: 'creatives.containersV2.MobilePushNew.cardTap',
509
- defaultMessage: 'Card tap',
510
- },
511
- cardTapDescription: {
512
- id: 'creatives.containersV2.MobilePushNew.cardTapDescription',
513
- defaultMessage: 'What happens when someone taps this card.',
514
- },
515
- cardTapAppHelp: {
516
- id: 'creatives.containersV2.MobilePushNew.cardTapAppHelp',
517
- defaultMessage: 'Opens your app. Choose a link to send people to a specific page from this card instead.',
518
- },
519
- whenTappedOpen: {
520
- id: 'creatives.containersV2.MobilePushNew.whenTappedOpen',
521
- defaultMessage: 'When tapped, open',
522
- },
523
- tapActionApp: {
524
- id: 'creatives.containersV2.MobilePushNew.tapActionApp',
525
- defaultMessage: 'App (default)',
526
- },
527
- tapActionDeepLink: {
528
- id: 'creatives.containersV2.MobilePushNew.tapActionDeepLink',
529
- defaultMessage: 'Deep link',
530
- },
531
- tapActionExternalLink: {
532
- id: 'creatives.containersV2.MobilePushNew.tapActionExternalLink',
533
- defaultMessage: 'External link',
534
- },
535
- url: {
536
- id: 'creatives.containersV2.MobilePushNew.url',
537
- defaultMessage: 'URL',
538
- },
539
- enterUrl: {
540
- id: 'creatives.containersV2.MobilePushNew.enterUrl',
541
- defaultMessage: 'Enter URL',
542
- },
543
491
  },
544
492
  }));
545
493
 
@@ -671,7 +619,7 @@ describe('MediaUploaders', () => {
671
619
  });
672
620
 
673
621
  fireEvent.click(screen.getByTestId('video-upload-button'));
674
- expect(setUpdateMpushVideoSrc).toHaveBeenCalledWith(0, { videoSrc: 'mock-video-url', previewUrl: 'mock-preview-url' });
622
+ expect(setUpdateMpushVideoSrc).toHaveBeenCalledWith('mock-video-url');
675
623
  });
676
624
  });
677
625
 
@@ -689,7 +637,7 @@ describe('MediaUploaders', () => {
689
637
  });
690
638
 
691
639
  fireEvent.click(screen.getByTestId('video-upload-button'));
692
- expect(setUpdateMpushVideoSrc).toHaveBeenCalledWith(0, { videoSrc: 'mock-video-url', previewUrl: 'mock-preview-url' });
640
+ expect(setUpdateMpushVideoSrc).toHaveBeenCalledWith('mock-video-url');
693
641
  });
694
642
  });
695
643
 
@@ -726,8 +674,9 @@ describe('MediaUploaders', () => {
726
674
  const carouselCard = screen.getByText('Card 1');
727
675
  expect(carouselCard).toBeInTheDocument();
728
676
 
729
- expect(screen.getByText('Card tap')).toBeInTheDocument();
730
- expect(screen.getByText('When tapped, open')).toBeInTheDocument();
677
+ // Check if the buttons and links section is rendered
678
+ const buttonsAndLinks = screen.getByText('Buttons and links');
679
+ expect(buttonsAndLinks).toBeInTheDocument();
731
680
  });
732
681
 
733
682
  it('should initialize carousel data when empty', () => {
@@ -803,8 +752,15 @@ describe('MediaUploaders', () => {
803
752
  formatMessage: mockFormatMessage,
804
753
  });
805
754
 
806
- expect(screen.getAllByTestId('cap-custom-select')[0]).toHaveValue('EXTERNAL_LINK');
755
+ // First check if the checkbox is checked
756
+ const actionOnClickCheckbox = screen.getByTestId('cap-checkbox');
757
+ expect(actionOnClickCheckbox).toBeChecked();
807
758
 
759
+ // First select the external link type
760
+ const linkTypeSelect = screen.getAllByTestId('cap-custom-select')[0];
761
+ fireEvent.change(linkTypeSelect, { target: { value: 'EXTERNAL_LINK' } });
762
+
763
+ // Wait for the external link input to be rendered
808
764
  const externalLinkInput = screen.getByTestId('cap-input-mobile-push-external-link-input-ANDROID-0');
809
765
  expect(externalLinkInput).toBeInTheDocument();
810
766
  expect(externalLinkInput.value).toBe('https://example.com');
@@ -875,7 +831,7 @@ describe('MediaUploaders', () => {
875
831
  </Provider>
876
832
  );
877
833
 
878
- expect(clearImageDataByMediaType).toHaveBeenCalledWith('IMAGE', ANDROID);
834
+ expect(clearImageDataByMediaType).toHaveBeenCalledWith('IMAGE');
879
835
  });
880
836
 
881
837
  it('should clear image data when switching from CAROUSEL to IMAGE', () => {
@@ -897,36 +853,7 @@ describe('MediaUploaders', () => {
897
853
  </Provider>
898
854
  );
899
855
 
900
- expect(clearImageDataByMediaType).toHaveBeenCalledWith('IMAGE', ANDROID);
901
- });
902
-
903
- // A tab switch gives the hidden pane a new clearImageDataByMediaType; that alone must not clear anything
904
- it('does not clear when only the callbacks change (tab switch), and clears its own platform on a real change', () => {
905
- const firstClear = jest.fn();
906
- const onCarouselDataChange = jest.fn();
907
- const renderPane = (mediaType, clearImageDataByMediaType) => (
908
- <Provider store={mockStore}>
909
- <IntlProvider messages={messages} locale="en">
910
- <MediaUploaders
911
- {...defaultProps}
912
- activeTab={IOS}
913
- mediaType={mediaType}
914
- clearImageDataByMediaType={clearImageDataByMediaType}
915
- onCarouselDataChange={onCarouselDataChange}
916
- />
917
- </IntlProvider>
918
- </Provider>
919
- );
920
- const { rerender } = render(renderPane('VIDEO', firstClear));
921
-
922
- const clearAfterTabSwitch = jest.fn();
923
- rerender(renderPane('VIDEO', clearAfterTabSwitch));
924
- expect(firstClear).not.toHaveBeenCalled();
925
- expect(clearAfterTabSwitch).not.toHaveBeenCalled();
926
- expect(onCarouselDataChange).not.toHaveBeenCalled();
927
-
928
- rerender(renderPane('NONE', clearAfterTabSwitch));
929
- expect(clearAfterTabSwitch).toHaveBeenCalledWith('IMAGE', IOS);
856
+ expect(clearImageDataByMediaType).toHaveBeenCalledWith('IMAGE');
930
857
  });
931
858
  });
932
859
 
@@ -1050,44 +977,6 @@ describe('MediaUploaders', () => {
1050
977
  });
1051
978
 
1052
979
  describe('Carousel card management', () => {
1053
- const doneCard = (mediaType, media) => ({
1054
- mediaType,
1055
- imageUrl: mediaType === 'image' ? media : '',
1056
- videoSrc: mediaType === 'video' ? media : '',
1057
- buttons: [{ actionOnClick: false, linkType: 'DEEP_LINK', deepLinkValue: '', externalLinkValue: '' }],
1058
- });
1059
-
1060
- it('opens the new card after adding it', () => {
1061
- const onCarouselDataChange = jest.fn();
1062
- const setCarouselActiveTabIndex = jest.fn();
1063
- renderComponent({
1064
- mediaType: 'CAROUSEL',
1065
- carouselData: [doneCard('image', 'a.jpg'), doneCard('image', 'b.jpg')],
1066
- onCarouselDataChange,
1067
- setCarouselActiveTabIndex,
1068
- });
1069
- setCarouselActiveTabIndex.mockClear();
1070
-
1071
- fireEvent.click(document.querySelector('.add-carousel-content-button'));
1072
-
1073
- expect(onCarouselDataChange).toHaveBeenCalledWith(ANDROID, expect.any(Array));
1074
- expect(onCarouselDataChange.mock.calls.pop()[1]).toHaveLength(3);
1075
- expect(setCarouselActiveTabIndex).toHaveBeenCalledWith(2);
1076
- });
1077
-
1078
- it.each([
1079
- ['an image card has no image', [doneCard('image', 'a.jpg'), doneCard('image', '')]],
1080
- ['a video card has no video', [doneCard('video', 'a.mp4'), doneCard('video', '')]],
1081
- ])('disables add while %s', (_label, carouselData) => {
1082
- renderComponent({ mediaType: 'CAROUSEL', carouselData });
1083
- expect(document.querySelector('.add-carousel-content-button')).toBeDisabled();
1084
- });
1085
-
1086
- it('enables add once every video card has its video', () => {
1087
- renderComponent({ mediaType: 'CAROUSEL', carouselData: [doneCard('video', 'a.mp4'), doneCard('video', 'b.mp4')] });
1088
- expect(document.querySelector('.add-carousel-content-button')).not.toBeDisabled();
1089
- });
1090
-
1091
980
  it('should add new carousel card when add button is clicked', () => {
1092
981
  const onCarouselDataChange = jest.fn();
1093
982
  renderComponent({
@@ -1095,7 +984,7 @@ describe('MediaUploaders', () => {
1095
984
  carouselData: [
1096
985
  {
1097
986
  mediaType: 'image',
1098
- imageUrl: 'card1.jpg',
987
+ imageUrl: '',
1099
988
  buttons: [{
1100
989
  actionOnClick: false,
1101
990
  linkType: 'DEEP_LINK',
@@ -1262,62 +1151,26 @@ describe('MediaUploaders', () => {
1262
1151
  onCarouselDataChange,
1263
1152
  });
1264
1153
 
1265
- const tapSelect = screen.getAllByTestId('cap-custom-select')[0];
1266
- expect(tapSelect).toHaveValue('APP');
1267
- expect(screen.getByText('Opens your app. Choose a link to send people to a specific page from this card instead.')).toBeInTheDocument();
1268
-
1269
- fireEvent.change(tapSelect, { target: { value: 'EXTERNAL_LINK' } });
1270
- expect(onCarouselDataChange).toHaveBeenCalledWith(
1271
- ANDROID,
1272
- expect.arrayContaining([
1273
- expect.objectContaining({
1274
- buttons: expect.arrayContaining([
1275
- expect.objectContaining({ actionOnClick: true, linkType: 'EXTERNAL_LINK' }),
1276
- ]),
1277
- }),
1278
- ])
1279
- );
1280
- });
1281
-
1282
- it('should turn the card action off and clear links when App is chosen', () => {
1283
- const onCarouselDataChange = jest.fn();
1284
- const updateCarouselLinkError = jest.fn();
1285
- renderComponent({
1286
- mediaType: 'CAROUSEL',
1287
- carouselData: [
1288
- {
1289
- mediaType: 'image',
1290
- imageUrl: '',
1291
- buttons: [{
1292
- actionOnClick: true,
1293
- linkType: 'EXTERNAL_LINK',
1294
- deepLinkValue: '',
1295
- deepLinkKeys: [],
1296
- externalLinkValue: 'https://example.com',
1297
- }],
1298
- }
1299
- ],
1300
- onCarouselDataChange,
1301
- updateCarouselLinkError,
1302
- });
1303
-
1304
- fireEvent.change(screen.getAllByTestId('cap-custom-select')[0], { target: { value: 'APP' } });
1305
- expect(onCarouselDataChange).toHaveBeenCalledWith(
1306
- ANDROID,
1307
- expect.arrayContaining([
1308
- expect.objectContaining({
1309
- buttons: expect.arrayContaining([
1310
- expect.objectContaining({
1311
- actionOnClick: false,
1312
- linkType: 'DEEP_LINK',
1313
- externalLinkValue: '',
1314
- deepLinkValue: '',
1315
- }),
1316
- ]),
1317
- }),
1318
- ])
1319
- );
1320
- expect(updateCarouselLinkError).toHaveBeenCalledWith(0, 'externalLink', null);
1154
+ // Find checkbox by class name since it renders with cap-checkbox-v2
1155
+ const checkbox = document.querySelector('.cap-checkbox-v2 input[type="checkbox"]');
1156
+ if (checkbox) {
1157
+ fireEvent.click(checkbox);
1158
+ expect(onCarouselDataChange).toHaveBeenCalledWith(
1159
+ ANDROID,
1160
+ expect.arrayContaining([
1161
+ expect.objectContaining({
1162
+ buttons: expect.arrayContaining([
1163
+ expect.objectContaining({
1164
+ actionOnClick: true,
1165
+ })
1166
+ ])
1167
+ })
1168
+ ])
1169
+ );
1170
+ } else {
1171
+ // If checkbox not found, just verify component renders
1172
+ expect(screen.getByTestId('cap-image-upload')).toBeInTheDocument();
1173
+ }
1321
1174
  });
1322
1175
 
1323
1176
  it('should handle carousel link type change', () => {
@@ -1341,7 +1194,18 @@ describe('MediaUploaders', () => {
1341
1194
  updateCarouselLinkError,
1342
1195
  });
1343
1196
 
1344
- expect(screen.getAllByTestId('cap-custom-select')[0]).toHaveValue('DEEP_LINK');
1197
+ // Should show action checkbox and description when carousel is rendered
1198
+ const checkbox = document.querySelector('.cap-checkbox-v2');
1199
+ if (checkbox) {
1200
+ expect(checkbox).toBeInTheDocument();
1201
+
1202
+ // The checkbox should be checked since actionOnClick is true
1203
+ const checkboxInput = checkbox.querySelector('input[type="checkbox"]');
1204
+ expect(checkboxInput.checked).toBe(true);
1205
+ } else {
1206
+ // If checkbox not found, just verify component renders
1207
+ expect(screen.getByTestId('cap-image-upload')).toBeInTheDocument();
1208
+ }
1345
1209
  });
1346
1210
 
1347
1211
  it('should validate deep link when value changes', () => {
@@ -1370,7 +1234,16 @@ describe('MediaUploaders', () => {
1370
1234
  }
1371
1235
  });
1372
1236
 
1373
- expect(screen.getAllByTestId('cap-custom-select')[0]).toHaveValue('DEEP_LINK');
1237
+ // Should render carousel component with action checkbox
1238
+ const checkbox = document.querySelector('.cap-checkbox-v2');
1239
+ if (checkbox) {
1240
+ expect(checkbox).toBeInTheDocument();
1241
+ } else {
1242
+ // If checkbox not found, just verify component renders
1243
+ expect(screen.getByTestId('cap-image-upload')).toBeInTheDocument();
1244
+ }
1245
+
1246
+ // Verify deep link props are available and component renders correctly
1374
1247
  expect(screen.getByTestId('cap-image-upload')).toBeInTheDocument();
1375
1248
  });
1376
1249
 
@@ -1602,9 +1475,8 @@ describe('MediaUploaders', () => {
1602
1475
  onCarouselDataChange,
1603
1476
  });
1604
1477
 
1605
- // Saved video cards open with video boxes, not the default image ones
1606
- expect(screen.getByTestId('cap-video-upload')).toBeInTheDocument();
1607
- expect(screen.queryByTestId('cap-image-upload')).toBeNull();
1478
+ // Should render carousel component
1479
+ expect(screen.getByTestId('cap-image-upload')).toBeInTheDocument();
1608
1480
  });
1609
1481
 
1610
1482
  it('should handle carousel video upload when video component is used', () => {
@@ -1651,8 +1523,7 @@ describe('MediaUploaders', () => {
1651
1523
  </Provider>
1652
1524
  );
1653
1525
 
1654
- expect(screen.getByTestId('cap-video-upload')).toBeInTheDocument();
1655
- expect(screen.queryByTestId('cap-image-upload')).toBeNull();
1526
+ expect(screen.getByTestId('cap-image-upload')).toBeInTheDocument();
1656
1527
  });
1657
1528
  });
1658
1529
 
@@ -2096,7 +1967,11 @@ describe('MediaUploaders', () => {
2096
1967
  carouselActiveTabIndex: 0,
2097
1968
  });
2098
1969
 
2099
- fireEvent.change(screen.getAllByTestId('cap-custom-select')[0], { target: { value: 'DEEP_LINK' } });
1970
+ // Should render carousel with buttons
1971
+ const checkbox = screen.getByTestId('cap-checkbox');
1972
+ fireEvent.click(checkbox);
1973
+
1974
+ // Should call onCarouselDataChange when checkbox changes
2100
1975
  expect(onCarouselDataChange).toHaveBeenCalled();
2101
1976
  });
2102
1977
 
@@ -2123,7 +1998,9 @@ describe('MediaUploaders', () => {
2123
1998
  }
2124
1999
  });
2125
2000
 
2126
- expect(screen.getAllByTestId('cap-custom-select')).toHaveLength(2); // Tap action and deep link selects
2001
+ // Should render action links components
2002
+ expect(screen.getByTestId('cap-checkbox')).toBeInTheDocument();
2003
+ expect(screen.getAllByTestId('cap-custom-select')).toHaveLength(2); // Link type and deep link selects
2127
2004
  });
2128
2005
 
2129
2006
  it('should show carousel link errors when present', () => {
@@ -2196,7 +2073,7 @@ describe('MediaUploaders', () => {
2196
2073
 
2197
2074
  // Should render carousel without action links section
2198
2075
  expect(screen.getByTestId('cap-tab')).toBeInTheDocument();
2199
- expect(screen.queryByText('When tapped, open')).not.toBeInTheDocument();
2076
+ expect(screen.queryByTestId('cap-checkbox')).not.toBeInTheDocument();
2200
2077
  });
2201
2078
 
2202
2079
  it('should handle multiple carousel cards with tab operations', () => {
@@ -2427,7 +2304,6 @@ describe('MediaUploaders', () => {
2427
2304
  expect.arrayContaining([
2428
2305
  expect.objectContaining({
2429
2306
  videoSrc: 'mock-video-url',
2430
- videoPreviewImg: 'mock-preview-url',
2431
2307
  })
2432
2308
  ])
2433
2309
  );
@@ -4345,124 +4221,4 @@ describe('MediaUploaders', () => {
4345
4221
  );
4346
4222
  });
4347
4223
  });
4348
-
4349
- describe('Carousel media switch and video uploads', () => {
4350
- const button = { actionOnClick: false, linkType: DEEP_LINK, deepLinkValue: '', externalLinkValue: '' };
4351
- const videoCard = (src) => ({
4352
- mediaType: 'video', imageUrl: '', videoSrc: src, videoPreviewImg: src ? `${src}.png` : '', buttons: [button],
4353
- });
4354
- const uploaded = (metaInfo) => ({ uploadedAssetData0: { metaInfo } });
4355
- const lastCards = (fn) => fn.mock.calls[fn.mock.calls.length - 1][1];
4356
-
4357
- const renderCarousel = (props) => {
4358
- const allProps = { ...defaultProps, mediaType: 'CAROUSEL', activeTab: ANDROID, ...props };
4359
- const ui = (extra = {}) => (
4360
- <Provider store={mockStore}>
4361
- <IntlProvider messages={messages} locale="en">
4362
- <MediaUploaders {...allProps} {...extra} />
4363
- </IntlProvider>
4364
- </Provider>
4365
- );
4366
- const utils = render(ui());
4367
- return { ...utils, rerenderWith: (extra) => utils.rerender(ui(extra)) };
4368
- };
4369
-
4370
- it('switching to video keeps video fields, clears images and adds default buttons', () => {
4371
- const onCarouselDataChange = jest.fn();
4372
- renderCarousel({
4373
- onCarouselDataChange,
4374
- carouselData: [
4375
- { mediaType: 'image', imageUrl: 'a.jpg', videoSrc: 'a.mp4', videoPreviewImg: 'a.png', buttons: [button] },
4376
- { mediaType: 'image', imageUrl: 'b.jpg', videoSrc: '', videoPreviewImg: '' },
4377
- ],
4378
- });
4379
-
4380
- fireEvent.click(screen.getByTestId('radio-video'));
4381
-
4382
- expect(lastCards(onCarouselDataChange)).toEqual([
4383
- { mediaType: 'video', imageUrl: '', videoSrc: 'a.mp4', videoPreviewImg: 'a.png', buttons: [button] },
4384
- {
4385
- mediaType: 'video',
4386
- imageUrl: '',
4387
- videoSrc: '',
4388
- videoPreviewImg: '',
4389
- buttons: [{ actionOnClick: false, linkType: DEEP_LINK, deepLinkValue: '', externalLinkValue: '' }],
4390
- },
4391
- ]);
4392
- expect(screen.getAllByTestId('cap-video-upload')).toHaveLength(2);
4393
- });
4394
-
4395
- it('switching to image keeps the image and clears the video and its thumbnail', () => {
4396
- const onCarouselDataChange = jest.fn();
4397
- renderCarousel({
4398
- onCarouselDataChange,
4399
- carouselData: [{ mediaType: 'video', imageUrl: 'a.jpg', videoSrc: 'a.mp4', videoPreviewImg: 'a.png', buttons: [button] }],
4400
- });
4401
-
4402
- fireEvent.click(screen.getByTestId('radio-image'));
4403
-
4404
- expect(lastCards(onCarouselDataChange)).toEqual([
4405
- { mediaType: 'image', imageUrl: 'a.jpg', videoSrc: '', videoPreviewImg: '', buttons: [button] },
4406
- ]);
4407
- expect(screen.getByTestId('cap-image-upload')).toBeInTheDocument();
4408
- });
4409
-
4410
- it('re upload on card 2 clears it, and the file picked through card 1\'s input lands on card 2', () => {
4411
- const onCarouselDataChange = jest.fn();
4412
- const uploadMpushAsset = jest.fn();
4413
- const carouselData = [videoCard('a.mp4'), videoCard('b.mp4')];
4414
- const { rerenderWith } = renderCarousel({ onCarouselDataChange, uploadMpushAsset, carouselData });
4415
-
4416
- fireEvent.click(screen.getAllByTestId('video-reupload-button')[1]);
4417
- expect(lastCards(onCarouselDataChange)).toEqual([
4418
- carouselData[0],
4419
- { ...carouselData[1], videoSrc: '', videoPreviewImg: '' },
4420
- ]);
4421
-
4422
- // Re upload clicks the page's first file input, which belongs to card 1
4423
- fireEvent.click(screen.getAllByTestId('video-file-upload-button')[0]);
4424
- expect(uploadMpushAsset).toHaveBeenCalledWith({ name: 'test.mp4' }, 'video', {}, 0);
4425
-
4426
- onCarouselDataChange.mockClear();
4427
- rerenderWith({ imageData: uploaded({ secure_file_path: 'c.mp4', file_name: 'c.mp4', video_file_path_preview: 'c.png' }) });
4428
-
4429
- expect(lastCards(onCarouselDataChange)).toEqual([
4430
- carouselData[0],
4431
- { ...carouselData[1], videoSrc: 'c.mp4', videoPreviewImg: 'c.png' },
4432
- ]);
4433
- });
4434
-
4435
- it.each([
4436
- ['the video preview', { video_file_path_preview: 'p.png', preview_image_url: 'i.png' }, 'p.png'],
4437
- ['the preview image when there is no video preview', { preview_image_url: 'i.png' }, 'i.png'],
4438
- ['no thumbnail when neither is sent', {}, ''],
4439
- ])('an uploaded video card gets %s', (_label, previews, expectedThumb) => {
4440
- const onCarouselDataChange = jest.fn();
4441
- const carouselData = [videoCard('')];
4442
- const { rerenderWith } = renderCarousel({ onCarouselDataChange, carouselData });
4443
-
4444
- fireEvent.click(screen.getByTestId('video-file-upload-button'));
4445
- onCarouselDataChange.mockClear();
4446
- rerenderWith({ imageData: uploaded({ secure_file_path: 'v.mp4', ...previews }) });
4447
-
4448
- expect(lastCards(onCarouselDataChange)).toEqual([
4449
- { ...carouselData[0], videoSrc: 'v.mp4', videoPreviewImg: expectedThumb },
4450
- ]);
4451
- });
4452
-
4453
- it('a new upload does not reapply the previous upload\'s result', () => {
4454
- const onCarouselDataChange = jest.fn();
4455
- const imageData = uploaded({ secure_file_path: 'v.mp4', file_name: 'v.mp4' });
4456
- const { rerenderWith } = renderCarousel({ onCarouselDataChange, carouselData: [videoCard('')] });
4457
-
4458
- fireEvent.click(screen.getByTestId('video-file-upload-button'));
4459
- rerenderWith({ imageData });
4460
- expect(onCarouselDataChange).toHaveBeenCalled();
4461
-
4462
- onCarouselDataChange.mockClear();
4463
- fireEvent.click(screen.getByTestId('video-file-upload-button'));
4464
-
4465
- expect(onCarouselDataChange).not.toHaveBeenCalled();
4466
- });
4467
- });
4468
4224
  });
@@ -101,15 +101,6 @@ jest.mock("../../messages", () => ({
101
101
  deepLink: { id: "deepLink", defaultMessage: "Deep Link" },
102
102
  externalLink: { id: "externalLink", defaultMessage: "External Link" },
103
103
  enterExternalLink: { id: "enterExternalLink", defaultMessage: "Enter external link" },
104
- notificationTap: { id: "notificationTap", defaultMessage: "Notification tap" },
105
- notificationTapDescription: { id: "notificationTapDescription", defaultMessage: "What happens when someone taps the notification itself." },
106
- whenTappedOpen: { id: "whenTappedOpen", defaultMessage: "When tapped, open" },
107
- tapActionApp: { id: "tapActionApp", defaultMessage: "App (default)" },
108
- tapActionAppHelp: { id: "tapActionAppHelp", defaultMessage: "Opens your app. Choose a link to send people to a specific page instead." },
109
- tapActionDeepLink: { id: "tapActionDeepLink", defaultMessage: "Deep link" },
110
- tapActionExternalLink: { id: "tapActionExternalLink", defaultMessage: "External link" },
111
- url: { id: "url", defaultMessage: "URL" },
112
- enterUrl: { id: "enterUrl", defaultMessage: "Enter URL" },
113
104
  deepLinkKeys: { id: "deepLinkKeys", defaultMessage: "Deep Link Keys" },
114
105
  deepLinkKeysPlaceholder: { id: "deepLinkKeysPlaceholder", defaultMessage: "Enter {key}" },
115
106
  deepLinkKeysRequired: { id: "deepLinkKeysRequired", defaultMessage: "Deep link keys are required" },
@@ -134,7 +125,6 @@ jest.mock("../../constants", () => ({
134
125
  ],
135
126
  DEEP_LINK: "DEEP_LINK",
136
127
  EXTERNAL_LINK: "EXTERNAL_LINK",
137
- TAP_ACTION_APP: "APP",
138
128
  }));
139
129
 
140
130
  describe("PlatformContentFields", () => {
@@ -157,7 +147,8 @@ describe("PlatformContentFields", () => {
157
147
  handleTitleChange: jest.fn(),
158
148
  handleMessageChange: jest.fn(),
159
149
  handleMediaTypeChange: jest.fn(),
160
- handleTapActionChange: jest.fn(),
150
+ handleActionOnClickChange: jest.fn(),
151
+ handleLinkTypeChange: jest.fn(),
161
152
  handleDeepLinkChange: jest.fn(),
162
153
  handleDeepLinkKeysChange: jest.fn(),
163
154
  handleExternalLinkChange: jest.fn(),
@@ -318,50 +309,30 @@ describe("PlatformContentFields", () => {
318
309
  });
319
310
  });
320
311
 
321
- describe("Notification tap", () => {
322
- // Second select: the first one is Media type
323
- const getTapSelect = (container) => container.querySelectorAll("select")[1];
324
-
325
- it("shows App (default) with its help text when there is no tap action", () => {
326
- const { container } = renderComponent({
327
- content: { ...defaultProps.content, actionOnClick: false },
328
- });
329
-
330
- expect(container.textContent).toContain("Notification tap");
331
- expect(container.textContent).toContain("When tapped, open");
332
- expect(getTapSelect(container)).toHaveValue("APP");
333
- expect(container.textContent).toContain("Opens your app. Choose a link to send people to a specific page instead.");
334
- expect(container.textContent).not.toContain("Buttons and Links");
335
- });
336
-
337
- it("calls the tap action handler with the chosen option", () => {
338
- const { container } = renderComponent();
312
+ describe("Action on Click", () => {
313
+ it("should call action on click change handler", () => {
314
+ const { getByTestId } = renderComponent();
315
+ const checkbox = getByTestId("action-checkbox");
339
316
 
340
- fireEvent.change(getTapSelect(container), { target: { value: EXTERNAL_LINK } });
317
+ fireEvent.click(checkbox);
341
318
 
342
- expect(defaultProps.handlers.handleTapActionChange).toHaveBeenCalledWith(EXTERNAL_LINK);
319
+ expect(defaultProps.handlers.handleActionOnClickChange).toHaveBeenCalled();
343
320
  });
344
321
 
345
- it("shows the deep link select, without the App help text, for Deep link", () => {
322
+ it("should show action controls when actionOnClick is true", () => {
346
323
  const { container } = renderComponent({
347
- content: { ...defaultProps.content, actionOnClick: true, linkType: DEEP_LINK },
324
+ content: { ...defaultProps.content, actionOnClick: true },
348
325
  });
349
326
 
350
- expect(getTapSelect(container)).toHaveValue(DEEP_LINK);
351
- expect(container.querySelectorAll("select")).toHaveLength(3);
352
- expect(container.textContent).not.toContain("Opens your app.");
327
+ expect(container.textContent).toContain("Link Type");
353
328
  });
354
329
 
355
- it("shows the URL input for External link", () => {
330
+ it("should hide action controls when actionOnClick is false", () => {
356
331
  const { container } = renderComponent({
357
- content: { ...defaultProps.content, actionOnClick: true, linkType: EXTERNAL_LINK },
358
- // plain fn: resetMocks wipes jest.fn implementations
359
- formatMessage: (msg) => msg?.defaultMessage ?? "",
332
+ content: { ...defaultProps.content, actionOnClick: false },
360
333
  });
361
334
 
362
- expect(getTapSelect(container)).toHaveValue(EXTERNAL_LINK);
363
- expect(container.textContent).toContain("URL");
364
- expect(container.querySelector("#mobile-push-external-link-input")).toHaveAttribute("placeholder", "Enter URL");
335
+ expect(container.textContent).not.toContain("Link Type");
365
336
  });
366
337
  });
367
338
 
@@ -409,7 +380,7 @@ describe("PlatformContentFields", () => {
409
380
  content: { ...defaultProps.content, mediaType: "CAROUSEL" },
410
381
  });
411
382
 
412
- expect(container.textContent).not.toContain("Notification tap");
383
+ expect(container.textContent).not.toContain("Buttons and Links");
413
384
  expect(container.textContent).not.toContain("CtaButtons");
414
385
  });
415
386
 
@@ -418,7 +389,7 @@ describe("PlatformContentFields", () => {
418
389
  content: { ...defaultProps.content, mediaType: "IMAGE" },
419
390
  });
420
391
 
421
- expect(container.textContent).toContain("Notification tap");
392
+ expect(container.textContent).toContain("Buttons and Links");
422
393
  });
423
394
  });
424
395
 
@@ -50,8 +50,6 @@ export const MEDIA_TYPES_OPTIONS = [
50
50
  export const MOBILE_PUSH_CHANNEL = "MOBILEPUSH";
51
51
  export const ANDROID = "ANDROID";
52
52
  export const IOS = "IOS";
53
- // Platforms dropdown value for Android and iOS together
54
- export const BOTH_PLATFORMS = "BOTH";
55
53
  export const ALLOWED_IMAGE_EXTENSIONS_REGEX = /\.(jpe?g|png)$/i;
56
54
  export const MPUSH_IMG_SIZE = 2000000; // 2MB
57
55
  export const MPUSH_VIDEO_SIZE = 209715200; // 200MB (200 * 1024 * 1024)
@@ -75,9 +73,6 @@ export const LINK_TYPE_OPTIONS = [
75
73
  { label: 'External Link', value: EXTERNAL_LINK },
76
74
  ];
77
75
 
78
- // "When tapped, open" dropdown value for opening the app (no link); the other values are DEEP_LINK / EXTERNAL_LINK
79
- export const TAP_ACTION_APP = 'APP';
80
-
81
76
  export const EXTERNAL_LINK_LOWERCASE = 'external link';
82
77
  export const PRIMARY = 'PRIMARY';
83
78
  export const SECONDARY = 'SECONDARY';