@capillarytech/creatives-library 9.2.1-alpha.sprint-cap-214249.42 → 9.2.1

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 (51) hide show
  1. package/AppRoot.js +4 -7
  2. package/constants/unified.js +1 -0
  3. package/package.json +1 -1
  4. package/utils/beePluginLoader.js +106 -0
  5. package/utils/common.js +6 -0
  6. package/utils/createMobilePushPayload.js +51 -56
  7. package/utils/tests/beePluginLoader.test.js +199 -0
  8. package/utils/tests/createMobilePushPayload.test.js +10 -162
  9. package/v2Components/CapMpushCTA/index.js +57 -47
  10. package/v2Components/CapMpushCTA/index.scss +5 -43
  11. package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +8 -11
  12. package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -13
  13. package/v2Components/CommonTestAndPreview/constants.js +0 -2
  14. package/v2Components/CommonTestAndPreview/index.js +10 -48
  15. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +5 -83
  16. package/v2Components/CommonTestAndPreview/tests/index.test.js +0 -86
  17. package/v2Components/TemplatePreview/_templatePreview.scss +2 -12
  18. package/v2Components/TemplatePreview/index.js +12 -14
  19. package/v2Components/TemplatePreview/tests/index.test.js +0 -69
  20. package/v2Containers/BeeEditor/index.js +49 -22
  21. package/v2Containers/BeeEditor/index.scss +12 -0
  22. package/v2Containers/BeeEditor/messages.js +8 -0
  23. package/v2Containers/BeeEditor/test/index.test.js +78 -0
  24. package/v2Containers/BeePopupEditor/index.js +22 -11
  25. package/v2Containers/CreativesContainer/SlideBoxContent.js +9 -5
  26. package/v2Containers/CreativesContainer/index.js +1 -2
  27. package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +0 -43
  28. package/v2Containers/Email/index.js +2 -2
  29. package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +25 -23
  30. package/v2Containers/MobilePushNew/components/CtaButtons.js +47 -52
  31. package/v2Containers/MobilePushNew/components/MediaUploaders.js +222 -314
  32. package/v2Containers/MobilePushNew/components/PlatformContentFields.js +130 -161
  33. package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +208 -30
  34. package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +123 -484
  35. package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +46 -152
  36. package/v2Containers/MobilePushNew/constants.js +0 -12
  37. package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +1 -63
  38. package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +0 -78
  39. package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +1 -40
  40. package/v2Containers/MobilePushNew/hooks/useUpload.js +46 -42
  41. package/v2Containers/MobilePushNew/index.js +273 -503
  42. package/v2Containers/MobilePushNew/index.scss +4 -215
  43. package/v2Containers/MobilePushNew/messages.js +6 -106
  44. package/v2Containers/MobilePushNew/tests/index.test.js +1 -482
  45. package/v2Containers/MobilePushNew/tests/utils.test.js +0 -122
  46. package/v2Containers/MobilePushNew/utils.js +0 -107
  47. package/v2Containers/Templates/_templates.scss +2 -10
  48. package/v2Containers/Templates/index.js +81 -83
  49. package/v2Containers/Templates/tests/index.test.js +0 -68
  50. package/v2Components/CapMpushCTA/tests/index.test.js +0 -150
  51. package/v2Containers/MobilePushNew/components/TapLinkActions.js +0 -76
@@ -8,8 +8,8 @@ import {
8
8
  } from "../../constants";
9
9
 
10
10
  // Simple mock components
11
- jest.mock("@capillarytech/cap-ui-library/CapRow", () => ({ children, className }) => <div className={className}>{children}</div>);
12
- jest.mock("@capillarytech/cap-ui-library/CapColumn", () => ({ children, className, onClick }) => <div className={className} onClick={onClick}>{children}</div>);
11
+ jest.mock("@capillarytech/cap-ui-library/CapRow", () => ({ children }) => <div>{children}</div>);
12
+ jest.mock("@capillarytech/cap-ui-library/CapColumn", () => ({ children }) => <div>{children}</div>);
13
13
  jest.mock("@capillarytech/cap-ui-library/CapInput", () => {
14
14
  const MockCapInput = ({
15
15
  value, onChange, errorMessage, error, ...props
@@ -101,18 +101,8 @@ 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
- tapLinkSaveDisabled: { id: "tapLinkSaveDisabled", defaultMessage: "Please complete the above fields to enable Save" },
116
106
  deepLinkKeysRequired: { id: "deepLinkKeysRequired", defaultMessage: "Deep link keys are required" },
117
107
  addLabels: { id: "addLabels", defaultMessage: "Add labels" },
118
108
  personalizationTagsErrorMessage: { id: "personalizationTagsErrorMessage", defaultMessage: "Personalization tags are not supported for anonymous customers, please remove the tags." },
@@ -135,12 +125,6 @@ jest.mock("../../constants", () => ({
135
125
  ],
136
126
  DEEP_LINK: "DEEP_LINK",
137
127
  EXTERNAL_LINK: "EXTERNAL_LINK",
138
- TAP_ACTION_APP: "APP",
139
- TAP_ACTION_OPTIONS: [
140
- { labelKey: "tapActionApp", value: "APP" },
141
- { labelKey: "tapActionDeepLink", value: "DEEP_LINK" },
142
- { labelKey: "tapActionExternalLink", value: "EXTERNAL_LINK" },
143
- ],
144
128
  }));
145
129
 
146
130
  describe("PlatformContentFields", () => {
@@ -163,11 +147,11 @@ describe("PlatformContentFields", () => {
163
147
  handleTitleChange: jest.fn(),
164
148
  handleMessageChange: jest.fn(),
165
149
  handleMediaTypeChange: jest.fn(),
166
- handleTapActionChange: jest.fn(),
150
+ handleActionOnClickChange: jest.fn(),
151
+ handleLinkTypeChange: jest.fn(),
167
152
  handleDeepLinkChange: jest.fn(),
168
153
  handleDeepLinkKeysChange: jest.fn(),
169
154
  handleExternalLinkChange: jest.fn(),
170
- handleTapLinkSavedChange: jest.fn(),
171
155
  onTagSelect: jest.fn(),
172
156
  handleOnTagsContextChange: jest.fn(),
173
157
  },
@@ -325,91 +309,30 @@ describe("PlatformContentFields", () => {
325
309
  });
326
310
  });
327
311
 
328
- describe("Notification tap", () => {
329
- // Second select: the first one is Media type
330
- const getTapSelect = (container) => container.querySelectorAll("select")[1];
331
-
332
- it("shows App (default) with its help text when there is no tap action", () => {
333
- const { container } = renderComponent({
334
- content: { ...defaultProps.content, actionOnClick: false },
335
- });
336
-
337
- expect(container.textContent).toContain("Notification tap");
338
- expect(container.textContent).toContain("When tapped, open");
339
- expect(getTapSelect(container)).toHaveValue("APP");
340
- expect(container.textContent).toContain("Opens your app. Choose a link to send people to a specific page instead.");
341
- expect(container.textContent).not.toContain("Buttons and Links");
342
- });
343
-
344
- it("calls the tap action handler with the chosen option", () => {
345
- const { container } = renderComponent();
346
-
347
- fireEvent.change(getTapSelect(container), { target: { value: EXTERNAL_LINK } });
348
-
349
- expect(defaultProps.handlers.handleTapActionChange).toHaveBeenCalledWith(EXTERNAL_LINK);
350
- });
351
-
352
- it("shows the deep link select, without the App help text, for Deep link", () => {
353
- const { container } = renderComponent({
354
- content: { ...defaultProps.content, actionOnClick: true, tapLinkSaved: false, linkType: DEEP_LINK },
355
- });
356
-
357
- expect(getTapSelect(container)).toHaveValue(DEEP_LINK);
358
- expect(container.querySelectorAll("select")).toHaveLength(3);
359
- expect(container.textContent).not.toContain("Opens your app.");
360
- });
361
-
362
- it("shows the URL input for External link", () => {
363
- const { container } = renderComponent({
364
- content: { ...defaultProps.content, actionOnClick: true, tapLinkSaved: false, linkType: EXTERNAL_LINK },
365
- // plain fn: resetMocks wipes jest.fn implementations
366
- formatMessage: (msg) => msg?.defaultMessage ?? "",
367
- });
368
-
369
- expect(getTapSelect(container)).toHaveValue(EXTERNAL_LINK);
370
- expect(container.textContent).toContain("URL");
371
- expect(container.querySelector("#mobile-push-external-link-input")).toHaveAttribute("placeholder", "Enter URL");
372
- });
373
-
374
- // plain fn: resetMocks wipes jest.fn implementations
375
- const plainFormatMessage = (msg) => msg?.defaultMessage ?? "";
376
-
377
- it("shows a saved link as one row; edit reopens it, delete sets App", () => {
378
- const { container } = renderComponent({
379
- content: { ...defaultProps.content, actionOnClick: true, linkType: EXTERNAL_LINK },
380
- formatMessage: plainFormatMessage,
381
- });
312
+ describe("Action on Click", () => {
313
+ it("should call action on click change handler", () => {
314
+ const { getByTestId } = renderComponent();
315
+ const checkbox = getByTestId("action-checkbox");
382
316
 
383
- expect(container.querySelector(".mpush-saved-tap-link")).toBeInTheDocument();
384
- expect(container.textContent).toContain("https://example.com");
385
- expect(container.querySelector("#mobile-push-external-link-input")).toBeNull();
317
+ fireEvent.click(checkbox);
386
318
 
387
- fireEvent.click(container.querySelector(".mpush-saved-tap-link-edit-icon"));
388
- expect(defaultProps.handlers.handleTapLinkSavedChange).toHaveBeenCalledWith(false);
389
- fireEvent.click(container.querySelector(".mpush-saved-tap-link-delete-icon"));
390
- expect(defaultProps.handlers.handleTapActionChange).toHaveBeenCalledWith("APP");
319
+ expect(defaultProps.handlers.handleActionOnClickChange).toHaveBeenCalled();
391
320
  });
392
321
 
393
- it("saves an open link once it is filled", () => {
322
+ it("should show action controls when actionOnClick is true", () => {
394
323
  const { container } = renderComponent({
395
- content: { ...defaultProps.content, actionOnClick: true, tapLinkSaved: false, linkType: EXTERNAL_LINK },
396
- formatMessage: plainFormatMessage,
324
+ content: { ...defaultProps.content, actionOnClick: true },
397
325
  });
398
326
 
399
- const saveButton = container.querySelector(".mpush-tap-save-btn");
400
- expect(saveButton).not.toBeDisabled();
401
- fireEvent.click(saveButton);
402
- expect(defaultProps.handlers.handleTapLinkSavedChange).toHaveBeenCalledWith(true);
327
+ expect(container.textContent).toContain("Link Type");
403
328
  });
404
329
 
405
- it("keeps Save off while the link is empty", () => {
330
+ it("should hide action controls when actionOnClick is false", () => {
406
331
  const { container } = renderComponent({
407
- content: { ...defaultProps.content, actionOnClick: true, tapLinkSaved: false, linkType: DEEP_LINK },
408
- linkProps: { ...defaultProps.linkProps, deepLinkValue: "" },
409
- formatMessage: plainFormatMessage,
332
+ content: { ...defaultProps.content, actionOnClick: false },
410
333
  });
411
334
 
412
- expect(container.querySelector(".mpush-tap-save-btn")).toBeDisabled();
335
+ expect(container.textContent).not.toContain("Link Type");
413
336
  });
414
337
  });
415
338
 
@@ -430,7 +353,7 @@ describe("PlatformContentFields", () => {
430
353
  describe("External Link Input", () => {
431
354
  it("should call external link change handler", () => {
432
355
  const { container } = renderComponent({
433
- content: { ...defaultProps.content, actionOnClick: true, tapLinkSaved: false, linkType: EXTERNAL_LINK },
356
+ content: { ...defaultProps.content, actionOnClick: true, linkType: EXTERNAL_LINK },
434
357
  });
435
358
 
436
359
  const externalLinkInput = container.querySelector('input[value="https://example.com"]');
@@ -443,7 +366,7 @@ describe("PlatformContentFields", () => {
443
366
 
444
367
  it("should display external link error when present", () => {
445
368
  const { getByTestId } = renderComponent({
446
- content: { ...defaultProps.content, actionOnClick: true, tapLinkSaved: false, linkType: EXTERNAL_LINK },
369
+ content: { ...defaultProps.content, actionOnClick: true, linkType: EXTERNAL_LINK },
447
370
  errors: { ...defaultProps.errors, externalLink: "Invalid URL" },
448
371
  });
449
372
 
@@ -457,7 +380,7 @@ describe("PlatformContentFields", () => {
457
380
  content: { ...defaultProps.content, mediaType: "CAROUSEL" },
458
381
  });
459
382
 
460
- expect(container.textContent).not.toContain("Notification tap");
383
+ expect(container.textContent).not.toContain("Buttons and Links");
461
384
  expect(container.textContent).not.toContain("CtaButtons");
462
385
  });
463
386
 
@@ -466,7 +389,7 @@ describe("PlatformContentFields", () => {
466
389
  content: { ...defaultProps.content, mediaType: "IMAGE" },
467
390
  });
468
391
 
469
- expect(container.textContent).toContain("Notification tap");
392
+ expect(container.textContent).toContain("Buttons and Links");
470
393
  });
471
394
  });
472
395
 
@@ -513,14 +436,14 @@ describe("PlatformContentFields", () => {
513
436
  const mockLinkProps = {
514
437
  deepLink: mockDeepLink,
515
438
  deepLinkValue: 'test-deep-link',
516
- deepLinkKeysValue: ['key1=value1', 'key2=value2'],
439
+ deepLinkKeysValue: ['key1', 'key2'],
517
440
  externalLinkValue: '',
518
441
  };
519
442
  const mockContent = {
520
443
  title: 'Test Title',
521
444
  message: 'Test Message',
522
445
  mediaType: 'IMAGE',
523
- actionOnClick: true, tapLinkSaved: false,
446
+ actionOnClick: true,
524
447
  linkType: 'DEEP_LINK',
525
448
  };
526
449
 
@@ -539,11 +462,9 @@ describe("PlatformContentFields", () => {
539
462
  />
540
463
  );
541
464
 
542
- // One input per configured key, showing the value typed for it
543
- expect(getByText('key1')).toBeInTheDocument();
544
- expect(getByText('key2')).toBeInTheDocument();
545
- expect(getByDisplayValue('value1')).toBeInTheDocument();
546
- expect(getByDisplayValue('value2')).toBeInTheDocument();
465
+ // Check that deep link keys are displayed correctly
466
+ expect(getByText('key1, key2')).toBeInTheDocument();
467
+ expect(getByDisplayValue('key1, key2')).toBeInTheDocument();
547
468
  });
548
469
 
549
470
  it('should handle deep link keys with single key from selection', () => {
@@ -560,7 +481,7 @@ describe("PlatformContentFields", () => {
560
481
  title: 'Test Title',
561
482
  message: 'Test Message',
562
483
  mediaType: 'IMAGE',
563
- actionOnClick: true, tapLinkSaved: false,
484
+ actionOnClick: true,
564
485
  linkType: 'DEEP_LINK',
565
486
  };
566
487
 
@@ -598,7 +519,7 @@ describe("PlatformContentFields", () => {
598
519
  title: 'Test Title',
599
520
  message: 'Test Message',
600
521
  mediaType: 'IMAGE',
601
- actionOnClick: true, tapLinkSaved: false,
522
+ actionOnClick: true,
602
523
  linkType: 'DEEP_LINK',
603
524
  };
604
525
 
@@ -635,7 +556,7 @@ describe("PlatformContentFields", () => {
635
556
  title: 'Test Title',
636
557
  message: 'Test Message',
637
558
  mediaType: 'IMAGE',
638
- actionOnClick: true, tapLinkSaved: false,
559
+ actionOnClick: true,
639
560
  linkType: 'DEEP_LINK',
640
561
  };
641
562
 
@@ -665,14 +586,14 @@ describe("PlatformContentFields", () => {
665
586
  const mockLinkProps = {
666
587
  deepLink: mockDeepLink,
667
588
  deepLinkValue: 'test-deep-link',
668
- deepLinkKeysValue: 'single-key=string-key-value',
589
+ deepLinkKeysValue: 'string-key-value',
669
590
  externalLinkValue: '',
670
591
  };
671
592
  const mockContent = {
672
593
  title: 'Test Title',
673
594
  message: 'Test Message',
674
595
  mediaType: 'IMAGE',
675
- actionOnClick: true, tapLinkSaved: false,
596
+ actionOnClick: true,
676
597
  linkType: 'DEEP_LINK',
677
598
  };
678
599
 
@@ -709,7 +630,7 @@ describe("PlatformContentFields", () => {
709
630
  title: 'Test Title',
710
631
  message: 'Test Message',
711
632
  mediaType: 'IMAGE',
712
- actionOnClick: true, tapLinkSaved: false,
633
+ actionOnClick: true,
713
634
  linkType: 'DEEP_LINK',
714
635
  };
715
636
 
@@ -747,7 +668,7 @@ describe("PlatformContentFields", () => {
747
668
  title: 'Test Title',
748
669
  message: 'Test Message',
749
670
  mediaType: 'IMAGE',
750
- actionOnClick: true, tapLinkSaved: false,
671
+ actionOnClick: true,
751
672
  linkType: 'DEEP_LINK',
752
673
  };
753
674
 
@@ -766,9 +687,11 @@ describe("PlatformContentFields", () => {
766
687
  />
767
688
  );
768
689
 
769
- // Each input asks for its own key
770
- expect(defaultProps.formatMessage).toHaveBeenCalledWith(expect.any(Object), { key: 'key1' });
771
- expect(defaultProps.formatMessage).toHaveBeenCalledWith(expect.any(Object), { key: 'key2' });
690
+ // Verify that formatMessage was called with the fallback placeholder
691
+ expect(defaultProps.formatMessage).toHaveBeenCalledWith(
692
+ expect.any(Object),
693
+ { key: 'key1, key2' }
694
+ );
772
695
  });
773
696
 
774
697
  it('should handle deep link keys error display', () => {
@@ -785,7 +708,7 @@ describe("PlatformContentFields", () => {
785
708
  title: 'Test Title',
786
709
  message: 'Test Message',
787
710
  mediaType: 'IMAGE',
788
- actionOnClick: true, tapLinkSaved: false,
711
+ actionOnClick: true,
789
712
  linkType: 'DEEP_LINK',
790
713
  };
791
714
  const mockErrors = {
@@ -811,39 +734,11 @@ describe("PlatformContentFields", () => {
811
734
  expect(getByText('Deep link keys error message')).toBeInTheDocument();
812
735
  });
813
736
 
814
- it('sends the configured key with the typed value', () => {
815
- const handleDeepLinkKeysChange = jest.fn();
816
- const { getByPlaceholderText } = render(
817
- <PlatformContentFields
818
- deviceType="ANDROID"
819
- content={{
820
- title: 'Test Title', message: 'Test Message', mediaType: 'IMAGE', actionOnClick: true, tapLinkSaved: false, linkType: 'DEEP_LINK',
821
- }}
822
- errors={{}}
823
- handlers={{ ...defaultProps.handlers, handleDeepLinkKeysChange }}
824
- tagListProps={defaultProps.tagListProps}
825
- mediaUploaderProps={defaultProps.mediaUploaderProps}
826
- ctaButtonProps={defaultProps.ctaButtonProps}
827
- linkProps={{
828
- deepLink: [{ value: 'https://www.youtube.com/', keys: ['testing_purpose'] }],
829
- deepLinkValue: 'https://www.youtube.com/',
830
- deepLinkKeysValue: [],
831
- externalLinkValue: '',
832
- }}
833
- sameContent={false}
834
- formatMessage={(msg, values) => (values?.key ? `Please input ${values.key} here` : msg.defaultMessage)}
835
- />
836
- );
837
-
838
- fireEvent.change(getByPlaceholderText('Please input testing_purpose here'), { target: { value: 'androidDeeplink' } });
839
- expect(handleDeepLinkKeysChange).toHaveBeenCalledWith(['testing_purpose=androidDeeplink']);
840
- });
841
-
842
737
  // Test cases for uncovered lines
843
738
  describe('Deep link null/undefined handling', () => {
844
739
  it('should handle null deepLink in options', () => {
845
740
  const { container } = renderComponent({
846
- content: { ...defaultProps.content, actionOnClick: true, tapLinkSaved: false, linkType: DEEP_LINK },
741
+ content: { ...defaultProps.content, actionOnClick: true, linkType: DEEP_LINK },
847
742
  linkProps: {
848
743
  deepLink: null, // This should trigger the fallback to empty array
849
744
  deepLinkValue: '',
@@ -857,7 +752,7 @@ describe("PlatformContentFields", () => {
857
752
 
858
753
  it('should handle undefined deepLink in options', () => {
859
754
  const { container } = renderComponent({
860
- content: { ...defaultProps.content, actionOnClick: true, tapLinkSaved: false, linkType: DEEP_LINK },
755
+ content: { ...defaultProps.content, actionOnClick: true, linkType: DEEP_LINK },
861
756
  linkProps: {
862
757
  deepLink: undefined, // This should trigger the fallback to empty array
863
758
  deepLinkValue: '',
@@ -885,7 +780,7 @@ describe("PlatformContentFields", () => {
885
780
  title: 'Test Title',
886
781
  message: 'Test Message',
887
782
  mediaType: 'IMAGE',
888
- actionOnClick: true, tapLinkSaved: false,
783
+ actionOnClick: true,
889
784
  linkType: 'DEEP_LINK',
890
785
  };
891
786
 
@@ -924,7 +819,7 @@ describe("PlatformContentFields", () => {
924
819
  title: 'Test Title',
925
820
  message: 'Test Message',
926
821
  mediaType: 'IMAGE',
927
- actionOnClick: true, tapLinkSaved: false,
822
+ actionOnClick: true,
928
823
  linkType: 'DEEP_LINK',
929
824
  };
930
825
 
@@ -963,7 +858,7 @@ describe("PlatformContentFields", () => {
963
858
  title: 'Test Title',
964
859
  message: 'Test Message',
965
860
  mediaType: 'IMAGE',
966
- actionOnClick: true, tapLinkSaved: false,
861
+ actionOnClick: true,
967
862
  linkType: 'DEEP_LINK',
968
863
  };
969
864
 
@@ -985,8 +880,7 @@ describe("PlatformContentFields", () => {
985
880
  );
986
881
 
987
882
  // Should find the base deep link and display keys
988
- expect(getByText('category')).toBeInTheDocument();
989
- expect(getByText('filter')).toBeInTheDocument();
883
+ expect(getByText('category, filter')).toBeInTheDocument();
990
884
  });
991
885
 
992
886
  it('should handle empty query parameters in deep link value', () => {
@@ -1003,7 +897,7 @@ describe("PlatformContentFields", () => {
1003
897
  title: 'Test Title',
1004
898
  message: 'Test Message',
1005
899
  mediaType: 'IMAGE',
1006
- actionOnClick: true, tapLinkSaved: false,
900
+ actionOnClick: true,
1007
901
  linkType: 'DEEP_LINK',
1008
902
  };
1009
903
 
@@ -1036,7 +930,7 @@ describe("PlatformContentFields", () => {
1036
930
  const { container } = renderComponent({
1037
931
  content: {
1038
932
  ...defaultProps.content,
1039
- actionOnClick: true, tapLinkSaved: false,
933
+ actionOnClick: true,
1040
934
  linkType: EXTERNAL_LINK,
1041
935
  },
1042
936
  linkProps: {
@@ -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,16 +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
- // "When tapped, open" options; labelKey is the messages.js key
82
- export const TAP_ACTION_OPTIONS = [
83
- { labelKey: 'tapActionApp', value: TAP_ACTION_APP },
84
- { labelKey: 'tapActionDeepLink', value: DEEP_LINK },
85
- { labelKey: 'tapActionExternalLink', value: EXTERNAL_LINK },
86
- ];
87
-
88
76
  export const EXTERNAL_LINK_LOWERCASE = 'external link';
89
77
  export const PRIMARY = 'PRIMARY';
90
78
  export const SECONDARY = 'SECONDARY';
@@ -1,7 +1,7 @@
1
1
  import { renderHook, act } from '@testing-library/react';
2
2
  import usePlatformSync from '../usePlatformSync';
3
3
  import {
4
- ANDROID, GIF, IMAGE, IOS, VIDEO, DEEP_LINK, EXTERNAL_LINK, TAP_ACTION_APP,
4
+ ANDROID, GIF, IMAGE, IOS, VIDEO,
5
5
  } from '../../constants';
6
6
  import { NONE } from '../../../Whatsapp/constants';
7
7
 
@@ -979,68 +979,6 @@ describe('usePlatformSync Hook', () => {
979
979
  });
980
980
  });
981
981
 
982
- describe('handleTapActionChange', () => {
983
- it('turns the tap action on with External link in one update', () => {
984
- const { result } = renderHook(() => usePlatformSync(defaultProps));
985
-
986
- act(() => {
987
- result.current.handleTapActionChange(ANDROID, EXTERNAL_LINK);
988
- });
989
-
990
- expect(mockSetAndroidContent).toHaveBeenCalledTimes(1);
991
- expect(mockSetAndroidContent).toHaveBeenCalledWith(expect.objectContaining({
992
- actionOnClick: true,
993
- linkType: EXTERNAL_LINK,
994
- deepLinkValue: '',
995
- externalLinkValue: '',
996
- }));
997
- expect(mockSetIosContent).not.toHaveBeenCalled();
998
- });
999
-
1000
- it('turns the tap action off and resets the link for App', () => {
1001
- const props = {
1002
- ...defaultProps,
1003
- iosContent: {
1004
- ...defaultIosContent, actionOnClick: true, linkType: EXTERNAL_LINK, externalLinkValue: 'https://x.com',
1005
- },
1006
- };
1007
- const { result } = renderHook(() => usePlatformSync(props));
1008
-
1009
- act(() => {
1010
- result.current.handleTapActionChange(IOS, TAP_ACTION_APP);
1011
- });
1012
-
1013
- expect(mockSetIosContent).toHaveBeenCalledWith(expect.objectContaining({
1014
- actionOnClick: false,
1015
- linkType: DEEP_LINK,
1016
- externalLinkValue: '',
1017
- }));
1018
- });
1019
-
1020
- it('does nothing when the same option is chosen again', () => {
1021
- const { result } = renderHook(() => usePlatformSync(defaultProps));
1022
-
1023
- act(() => {
1024
- result.current.handleTapActionChange(ANDROID, TAP_ACTION_APP);
1025
- });
1026
-
1027
- expect(mockSetAndroidContent).not.toHaveBeenCalled();
1028
- });
1029
-
1030
- it('syncs to the other platform when sync is enabled', () => {
1031
- const { result } = renderHook(() => usePlatformSync({ ...defaultProps, sameContent: true }));
1032
-
1033
- act(() => {
1034
- result.current.handleTapActionChange(ANDROID, DEEP_LINK);
1035
- });
1036
-
1037
- expect(mockSetIosContent).toHaveBeenCalledWith(expect.objectContaining({
1038
- actionOnClick: true,
1039
- linkType: DEEP_LINK,
1040
- }));
1041
- });
1042
- });
1043
-
1044
982
  describe('handleLinkTypeChange', () => {
1045
983
  it('should update Android linkType when sync is disabled', () => {
1046
984
  const { result } = renderHook(() => usePlatformSync(defaultProps));
@@ -602,32 +602,6 @@ describe('useUpload Hook', () => {
602
602
  });
603
603
  });
604
604
 
605
- it('should clear only the iOS image when re-upload handlers kept from the ticked render run after untick', () => {
606
- const { result, rerender } = renderHook(
607
- ({ sameContent }) => useUpload(
608
- mockMobilePushActions, {}, {}, {}, false, sameContent,
609
- mockSetAndroidContent, mockSetIosContent, IOS, androidContent, iosContent, mockFormatMessage,
610
- ),
611
- { initialProps: { sameContent: true } },
612
- );
613
- // Handlers as the uploader keeps them from its first render
614
- const { setUpdateMpushImageSrc, updateOnMpushImageReUpload } = result.current;
615
-
616
- act(() => {
617
- setUpdateMpushImageSrc('img.png', 1);
618
- });
619
- rerender({ sameContent: false });
620
- act(() => {
621
- setUpdateMpushImageSrc('', 1);
622
- updateOnMpushImageReUpload();
623
- });
624
-
625
- expect(result.current.imageSrc).toEqual({
626
- androidImageSrc: 'img.png',
627
- iosImageSrc: '',
628
- });
629
- });
630
-
631
605
  it('should handle image source update with sync enabled', () => {
632
606
  const { result } = createHook({ sameContent: true });
633
607
 
@@ -1147,19 +1121,6 @@ describe('useUpload Hook', () => {
1147
1121
  });
1148
1122
  });
1149
1123
 
1150
- it('clears the platform it is given, not the visible tab', () => {
1151
- const { result } = createHook({ sameContent: false, activeTab: ANDROID });
1152
- act(() => {
1153
- result.current.setImageSrc({ androidImageSrc: 'a.jpg', iosImageSrc: 'b.jpg' });
1154
- });
1155
-
1156
- act(() => {
1157
- result.current.clearImageDataByMediaType(IMAGE, IOS);
1158
- });
1159
-
1160
- expect(result.current.imageSrc).toEqual({ androidImageSrc: 'a.jpg', iosImageSrc: '' });
1161
- });
1162
-
1163
1124
  it('should clear video data with sync enabled', () => {
1164
1125
  const { result } = createHook({ sameContent: true });
1165
1126
 
@@ -1495,43 +1456,4 @@ describe('useUpload Hook', () => {
1495
1456
  });
1496
1457
  });
1497
1458
  });
1498
-
1499
- describe('Ticking same content', () => {
1500
- // Android has image A, iOS has video V; then tick on the given tab
1501
- const renderAndTick = (activeTab) => {
1502
- const hook = renderHook(({ sameContent }) => useUpload(
1503
- mockMobilePushActions, {}, {}, {}, false, sameContent,
1504
- mockSetAndroidContent, mockSetIosContent, activeTab, androidContent, iosContent, mockFormatMessage,
1505
- ), { initialProps: { sameContent: false } });
1506
- act(() => {
1507
- hook.result.current.setImageSrc({ androidImageSrc: 'A.jpg', iosImageSrc: '' });
1508
- hook.result.current.setUpdateMpushVideoSrc(1, { videoSrc: 'V.mp4', previewUrl: 'V.jpg', videoDuration: 5 });
1509
- });
1510
- hook.rerender({ sameContent: true });
1511
- return hook.result;
1512
- };
1513
-
1514
- it('wipes the iOS video when ticked on Android, which has none', () => {
1515
- const result = renderAndTick(ANDROID);
1516
- expect(result.current.videoState).toEqual({
1517
- androidVideoSrc: '',
1518
- iosVideoSrc: '',
1519
- androidVideoPreview: '',
1520
- iosVideoPreview: '',
1521
- androidVideoDuration: 0,
1522
- iosVideoDuration: 0,
1523
- });
1524
- expect(result.current.iosAssetList).toEqual([]);
1525
- expect(result.current.imageSrc).toEqual({ androidImageSrc: 'A.jpg', iosImageSrc: 'A.jpg' });
1526
- expect(androidContent.videoSrc).toBe('');
1527
- expect(iosContent.videoSrc).toBe('');
1528
- });
1529
-
1530
- it('wipes the Android image when ticked on iOS, which has none', () => {
1531
- const result = renderAndTick(IOS);
1532
- expect(result.current.imageSrc).toEqual({ androidImageSrc: '', iosImageSrc: '' });
1533
- expect(result.current.videoState.androidVideoSrc).toBe('V.mp4');
1534
- expect(result.current.androidAssetList).toMatchObject({ videoSrc: 'V.mp4' });
1535
- });
1536
- });
1537
1459
  });
@@ -1,7 +1,7 @@
1
1
  // eslint-disable-next-line jsx-a11y/href-no-hash
2
2
  import { useCallback, useEffect, useRef } from 'react';
3
3
  import {
4
- ANDROID, DEEP_LINK, GIF, IMAGE, IOS, VIDEO, TAP_ACTION_APP,
4
+ ANDROID, DEEP_LINK, GIF, IMAGE, IOS, VIDEO,
5
5
  } from '../constants';
6
6
  import { NONE } from '../../Whatsapp/constants';
7
7
 
@@ -353,44 +353,6 @@ const usePlatformSync = ({
353
353
  }
354
354
  }, [androidContent, iosContent, setAndroidContent, setIosContent, sameContent, deepSyncContent]);
355
355
 
356
- // "When tapped, open" dropdown: TAP_ACTION_APP turns the tap action off, DEEP_LINK / EXTERNAL_LINK
357
- // turn it on with that link type. One update, so actionOnClick and linkType can't overwrite each other.
358
- const handleTapActionChange = useCallback((platform, value) => {
359
- const {
360
- setContent,
361
- otherSetContent,
362
- otherContent,
363
- currentContent,
364
- targetPlatform,
365
- } = getPlatformContent(platform, {
366
- androidContent,
367
- iosContent,
368
- setAndroidContent,
369
- setIosContent,
370
- });
371
-
372
- const isApp = value === TAP_ACTION_APP;
373
- const currentValue = currentContent?.actionOnClick ? (currentContent?.linkType || DEEP_LINK) : TAP_ACTION_APP;
374
- if (value === currentValue) return;
375
-
376
- const newContent = {
377
- ...currentContent,
378
- actionOnClick: !isApp,
379
- linkType: isApp ? DEEP_LINK : value,
380
- deepLinkValue: "",
381
- deepLinkKeysValue: [],
382
- externalLinkValue: "",
383
- // A new link stays open until its Save is clicked
384
- tapLinkSaved: isApp ? undefined : false,
385
- };
386
- setContent(newContent);
387
-
388
- if (sameContent) {
389
- const synced = deepSyncContent(newContent, otherContent, targetPlatform);
390
- otherSetContent(synced);
391
- }
392
- }, [androidContent, iosContent, setAndroidContent, setIosContent, sameContent, deepSyncContent]);
393
-
394
356
  return {
395
357
  handleTitleChange,
396
358
  handleMessageChange,
@@ -399,7 +361,6 @@ const usePlatformSync = ({
399
361
  handleButtonChange,
400
362
  handleActionOnClickChange,
401
363
  handleLinkTypeChange,
402
- handleTapActionChange,
403
364
  };
404
365
  };
405
366