@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
@@ -498,72 +498,4 @@ describe('Test Templates container', () => {
498
498
  expect(renderedComponent.instance().getCreativesParams()).not.toHaveProperty('openTestAndPreview');
499
499
  });
500
500
  });
501
-
502
- describe('Mobile push grid tile buttons', () => {
503
- it('renders button labels as typed with index keys, so duplicate labels do not clash', () => {
504
- RenderFunctionFor('whatsapp', true);
505
-
506
- const cardDataList = renderedComponent.instance().getTemplateDataForGrid({
507
- templates: [{
508
- _id: 'mpush_1',
509
- name: 'Push Template',
510
- versions: {
511
- base: {
512
- ANDROID: {
513
- title: 'Title',
514
- message: 'Body',
515
- expandableDetails: { ctas: [{ actionText: 'Shop' }, { actionText: 'Shop' }] },
516
- },
517
- },
518
- },
519
- }],
520
- handlers: { handlePreviewClick: jest.fn(), handleEditClick: jest.fn() },
521
- filterContent: null,
522
- channel: 'mobilepush',
523
- isLoading: false,
524
- isInitialLoading: false,
525
- loadingTip: '',
526
- previewTemplateId: null,
527
- });
528
-
529
- const buttons = findByClassName(cardDataList, 'mobilepush-container').props.children
530
- .find((child) => child?.props?.className === 'actions').props.children;
531
- expect(buttons.map((button) => button.key)).toEqual(['action-0', 'action-1']);
532
- expect(buttons.map((button) => button.props.children)).toEqual(['Shop', 'Shop']);
533
- });
534
- });
535
-
536
- describe('Mobile push Test & Preview content from the list', () => {
537
- it('maps each saved video to the { videoSrc, videoPreview } shape the preview reads', () => {
538
- RenderFunctionFor('whatsapp', true);
539
-
540
- const result = renderedComponent.instance().extractTemplateContentForPreview({
541
- versions: {
542
- base: {
543
- ANDROID: {
544
- title: 'A',
545
- expandableDetails: { media: [{ url: 'https://a.mp4', type: 'VIDEO', videoPreviewUrl: 'https://a.jpg' }] },
546
- },
547
- IOS: {
548
- title: 'I',
549
- expandableDetails: { media: [{ url: 'https://i.mp4', type: 'VIDEO' }] },
550
- },
551
- },
552
- },
553
- }, 'MOBILEPUSH');
554
-
555
- expect(result.androidContent.bodyVideo).toEqual({ videoSrc: 'https://a.mp4', videoPreview: 'https://a.jpg' });
556
- expect(result.iosContent.bodyVideo).toEqual({ videoSrc: 'https://i.mp4', videoPreview: '' });
557
- });
558
-
559
- it('gives no video for a text template', () => {
560
- RenderFunctionFor('whatsapp', true);
561
-
562
- const result = renderedComponent.instance().extractTemplateContentForPreview({
563
- versions: { base: { ANDROID: { title: 'A', expandableDetails: { style: 'BIG_TEXT' } } } },
564
- }, 'MOBILEPUSH');
565
-
566
- expect(result.androidContent.bodyVideo).toEqual({});
567
- });
568
- });
569
501
  });
@@ -347,7 +347,7 @@ export const Viber = (props) => {
347
347
  // validation on Text area and tags validation
348
348
  const updateTextContentError = (value) => {
349
349
  let errorMessage = false;
350
- const { valid, isBraceError } = validateTags({
350
+ const { valid, isBraceError, isDefaultQuoteError } = validateTags({
351
351
  content: value,
352
352
  tagsParam: tags,
353
353
  location,
@@ -360,6 +360,8 @@ export const Viber = (props) => {
360
360
  errorMessage = formatMessage(messages.limitExceededContentErrorMessage);
361
361
  } else if (isBraceError) {
362
362
  errorMessage = formatMessage(globalMessages.unbalanacedCurlyBraces);
363
+ } else if (isDefaultQuoteError) {
364
+ errorMessage = formatMessage(globalMessages.unquotedTagDefaultValue);
363
365
  } else if (!valid) {
364
366
  errorMessage = formatMessage(messages.invalidTagError);
365
367
  }
@@ -37,6 +37,9 @@ export const validateTitle = (value, formatMessage, messages, restrictPersonaliz
37
37
  if (validationResponse?.isBraceError) {
38
38
  return formatMessage(globalMessages.unbalanacedCurlyBraces);
39
39
  }
40
+ if (validationResponse?.isDefaultQuoteError) {
41
+ return formatMessage(globalMessages.unquotedTagDefaultValue);
42
+ }
40
43
  }
41
44
 
42
45
  return '';
@@ -83,6 +86,9 @@ export const validateMessageContent = (value, formatMessage, messages, validatio
83
86
  if (validationResponse?.isBraceError) {
84
87
  return formatMessage(globalMessages.unbalanacedCurlyBraces);
85
88
  }
89
+ if (validationResponse?.isDefaultQuoteError) {
90
+ return formatMessage(globalMessages.unquotedTagDefaultValue);
91
+ }
86
92
 
87
93
  if (restrictPersonalization && hasPersonalizationTags(value)) {
88
94
  return formatMessage(messages.personalizationTokensErrorMessage);
@@ -24,6 +24,9 @@ jest.mock('../../../Cap/messages', () => ({
24
24
  unbalanacedCurlyBraces: {
25
25
  defaultMessage: 'Unbalanced curly braces',
26
26
  },
27
+ unquotedTagDefaultValue: {
28
+ defaultMessage: 'Default value must be within quotes',
29
+ },
27
30
  }));
28
31
 
29
32
  import { validateTags } from '../../../../utils/tagValidations';
@@ -148,6 +151,27 @@ describe('validation', () => {
148
151
  });
149
152
  });
150
153
 
154
+ it('should return default quote error when validateTags returns isDefaultQuoteError', () => {
155
+ validateTags.mockReturnValue({ isBraceError: false, isDefaultQuoteError: true });
156
+ const result = validateTitle('{{name | default: x}}', mockFormatMessage, mockMessages, false, {}, false);
157
+ expect(result).toBe('Default value must be within quotes');
158
+ expect(mockFormatMessage).toHaveBeenCalledWith(globalMessages.unquotedTagDefaultValue);
159
+ });
160
+
161
+ it('should prefer brace error over default quote error', () => {
162
+ validateTags.mockReturnValue({ isBraceError: true, isDefaultQuoteError: true });
163
+ const result = validateTitle('{{name', mockFormatMessage, mockMessages, false, {}, false);
164
+ expect(result).toBe('Unbalanced curly braces');
165
+ expect(mockFormatMessage).not.toHaveBeenCalledWith(globalMessages.unquotedTagDefaultValue);
166
+ });
167
+
168
+ it('should return empty when validateTags has no errors or returns null/undefined', () => {
169
+ [{ isBraceError: false, isDefaultQuoteError: false }, null, undefined].forEach((response) => {
170
+ validateTags.mockReturnValue(response);
171
+ expect(validateTitle('Valid Title', mockFormatMessage, mockMessages, false, {}, false)).toBe('');
172
+ });
173
+ });
174
+
151
175
  it('should not run tag validation when validationConfig is null', () => {
152
176
  validateTags.mockClear();
153
177
  const result = validateTitle('Valid Title', mockFormatMessage, mockMessages, false, null);
@@ -266,6 +290,32 @@ describe('validation', () => {
266
290
  expect(mockFormatMessage).toHaveBeenCalledWith(globalMessages.unbalanacedCurlyBraces);
267
291
  });
268
292
 
293
+ it('should return default quote error when validateTags returns isDefaultQuoteError', () => {
294
+ validateTags.mockReturnValue({ isBraceError: false, isDefaultQuoteError: true });
295
+ const result = validateMessageContent('{{name | default: x}}', mockFormatMessage, mockMessages, mockValidationConfig);
296
+ expect(result).toBe('Default value must be within quotes');
297
+ expect(mockFormatMessage).toHaveBeenCalledWith(globalMessages.unquotedTagDefaultValue);
298
+ });
299
+
300
+ it('should prefer brace error over default quote error', () => {
301
+ validateTags.mockReturnValue({ isBraceError: true, isDefaultQuoteError: true });
302
+ const result = validateMessageContent('{{name', mockFormatMessage, mockMessages, mockValidationConfig);
303
+ expect(result).toBe('Unbalanced curly braces');
304
+ expect(mockFormatMessage).not.toHaveBeenCalledWith(globalMessages.unquotedTagDefaultValue);
305
+ });
306
+
307
+ it('should return default quote error before personalization error', () => {
308
+ validateTags.mockReturnValue({ isDefaultQuoteError: true });
309
+ const result = validateMessageContent('{{first_name | default: x}}', mockFormatMessage, mockMessages, mockValidationConfig, false, true);
310
+ expect(result).toBe('Default value must be within quotes');
311
+ });
312
+
313
+ it('should return empty when isDefaultQuoteError is false', () => {
314
+ validateTags.mockReturnValue({ isBraceError: false, isDefaultQuoteError: false });
315
+ const result = validateMessageContent('Valid message', mockFormatMessage, mockMessages, mockValidationConfig);
316
+ expect(result).toBe('');
317
+ });
318
+
269
319
  it('should pass validation config to validateTags', () => {
270
320
  const customConfig = {
271
321
  tagsParam: [{ id: 1, name: 'Tag1' }],
@@ -637,17 +637,18 @@ export const Whatsapp = (props) => {
637
637
  tagModule: getDefaultTags,
638
638
  isFullMode,
639
639
  }) || {};
640
+ const hasTagSyntaxError = !!(validationResponse.isBraceError || validationResponse.isDefaultQuoteError);
640
641
  if (type === HEADER_TEXT) {
641
642
  headerTagValidationResponse = validationResponse;
642
- updateIsHeaderTagValidationError(validationResponse.isBraceError);
643
+ updateIsHeaderTagValidationError(hasTagSyntaxError);
643
644
  } else if (type === CAROUSEL_TEXT) {
644
645
  return [
645
- { fieldName: "carouselTagValidationErrMessage", value: validationResponse.isBraceError ? validationResponse : {} },
646
- { fieldName: "carouselTagValidationErr", value: validationResponse.isBraceError },
646
+ { fieldName: "carouselTagValidationErrMessage", value: hasTagSyntaxError ? validationResponse : {} },
647
+ { fieldName: "carouselTagValidationErr", value: hasTagSyntaxError },
647
648
  ];
648
649
  } else {
649
650
  tagValidationResponse = validationResponse;
650
- updateIsTagValidationError(validationResponse.isBraceError);
651
+ updateIsTagValidationError(hasTagSyntaxError);
651
652
  }
652
653
  }
653
654
  };
@@ -2837,10 +2838,13 @@ const isAuthenticationTemplate = isEqual(templateCategory, WHATSAPP_CATEGORIES.a
2837
2838
  } else {
2838
2839
  validationResponse = tagValidationResponse;
2839
2840
  }
2840
- const { isBraceError } = validationResponse || {};
2841
+ const { isBraceError, isDefaultQuoteError } = validationResponse || {};
2841
2842
  if (isBraceError) {
2842
2843
  return <CapError>{formatMessage(globalMessages.unbalanacedCurlyBraces)}</CapError>;
2843
2844
  }
2845
+ if (isDefaultQuoteError) {
2846
+ return <CapError>{formatMessage(globalMessages.unquotedTagDefaultValue)}</CapError>;
2847
+ }
2844
2848
  return null;
2845
2849
  };
2846
2850
 
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap
3
- size: 57295127 bytes
4
- sha256: 3ca4752bd0410b9d7f0e57070855228ef817cc04531f23794bf27e2647b4f7a2
3
+ size: 57312915 bytes
4
+ sha256: 297ff99f24988ebb3e7289712381c4345e1104c2184c67094070a6bf65072c26
@@ -281,10 +281,13 @@ export const Zalo = (props) => {
281
281
  tagModule: getDefaultTags,
282
282
  isFullMode,
283
283
  }) || {};
284
- const { isBraceError } = tagValidationResponse;
284
+ const { isBraceError, isDefaultQuoteError } = tagValidationResponse;
285
285
  if (isBraceError) {
286
286
  return formatMessage(globalMessages.unbalanacedCurlyBraces);
287
287
  }
288
+ if (isDefaultQuoteError) {
289
+ return formatMessage(globalMessages.unquotedTagDefaultValue);
290
+ }
288
291
  return '';
289
292
  };
290
293
 
@@ -1,89 +0,0 @@
1
- import React from 'react';
2
- import { shallow } from 'enzyme';
3
- import CapIcon from '@capillarytech/cap-ui-library/CapIcon';
4
- import { CapMpushCTA } from '../index';
5
- import CapTagListWithInput from '../../CapTagListWithInput';
6
- import { DEEP_LINK, EXTERNAL_URL } from '../constants';
7
- import { PRIMARY } from '../../../v2Containers/MobilePushNew/constants';
8
-
9
- jest.mock('../../../v2Containers/TagList', () => () => null);
10
- jest.mock('../../CapTagListWithInput', () => () => null);
11
-
12
- const intl = { formatMessage: (msg) => msg?.defaultMessage || '' };
13
-
14
- const renderCta = (cta, extraProps = {}) => shallow(
15
- <CapMpushCTA
16
- intl={intl}
17
- ctaData={[{ index: 0, text: 'Shop', ...cta }]}
18
- buttonType={PRIMARY}
19
- updateHandler={jest.fn()}
20
- deleteHandler={jest.fn()}
21
- deepLink={[{ value: 'app://home', label: 'Home' }]}
22
- location={{ query: {} }}
23
- {...extraProps}
24
- />,
25
- );
26
-
27
- describe('CapMpushCTA', () => {
28
- describe('saved button card', () => {
29
- it('uses the mask-free "open-in-new" icon, not "launch"', () => {
30
- const wrapper = renderCta({ urlType: EXTERNAL_URL, url: 'https://google.com', isSaved: true });
31
- const iconTypes = wrapper.find(CapIcon).map((icon) => icon.prop('type'));
32
-
33
- expect(iconTypes).toContain('open-in-new');
34
- expect(iconTypes).not.toContain('launch');
35
- });
36
-
37
- it('shows the external URL in the link column with the URL as tooltip', () => {
38
- const wrapper = renderCta({ urlType: EXTERNAL_URL, url: 'https://google.com', isSaved: true });
39
- const link = wrapper.find('.mpush-saved-cta-link');
40
-
41
- expect(link.prop('children')).toBe('https://google.com');
42
- expect(link.prop('title')).toBe('https://google.com');
43
- expect(wrapper.find('.cta-type-label').prop('children')).toBe('External link');
44
- });
45
-
46
- it('shows the selected deep link label in the link column', () => {
47
- const wrapper = renderCta({ urlType: DEEP_LINK, url: 'app://home', isSaved: true });
48
-
49
- expect(wrapper.find('.mpush-saved-cta-link').prop('children')).toBe('Home');
50
- expect(wrapper.find('.cta-type-label').prop('children')).toBe('Deep link');
51
- });
52
-
53
- it('lays out the card rows horizontally with vertically centred items', () => {
54
- const wrapper = renderCta({ urlType: EXTERNAL_URL, url: 'https://google.com', isSaved: true });
55
-
56
- expect(wrapper.find('.mpush-cta-row').props()).toEqual(expect.objectContaining({ type: 'flex', align: 'middle' }));
57
- expect(wrapper.find('.cta-action-grp').props()).toEqual(expect.objectContaining({ type: 'flex', align: 'middle' }));
58
- });
59
-
60
- it('reopens the button for editing and deletes it from the card icons', () => {
61
- const updateHandler = jest.fn();
62
- const deleteHandler = jest.fn();
63
- const wrapper = renderCta(
64
- { urlType: EXTERNAL_URL, url: 'https://google.com', isSaved: true },
65
- { updateHandler, deleteHandler },
66
- );
67
-
68
- wrapper.find('.mpush-saved-cta-edit-icon').simulate('click');
69
- expect(updateHandler).toHaveBeenCalledWith(expect.objectContaining({ isSaved: false }), 0);
70
-
71
- wrapper.find('.cta-del-icon').simulate('click');
72
- expect(deleteHandler).toHaveBeenCalledWith(0);
73
- });
74
- });
75
-
76
- it('keeps the "External link" heading on one line in the edit form', () => {
77
- const wrapper = renderCta({ urlType: EXTERNAL_URL, url: '', isSaved: false });
78
-
79
- expect(wrapper.find(CapTagListWithInput).prop('headingStyle')).toEqual(
80
- expect.objectContaining({ whiteSpace: 'nowrap' }),
81
- );
82
- });
83
-
84
- it('wraps the External link field so its label row lines up with "Type of link"', () => {
85
- const wrapper = renderCta({ urlType: EXTERNAL_URL, url: '', isSaved: false });
86
-
87
- expect(wrapper.find('.mpush-cta-external-link-field').find(CapTagListWithInput).exists()).toBe(true);
88
- });
89
- });