@capillarytech/creatives-library 8.0.345-alpha.13 → 8.0.345-alpha.15

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 (138) hide show
  1. package/constants/unified.js +29 -0
  2. package/package.json +1 -1
  3. package/services/api.js +0 -20
  4. package/services/tests/api.test.js +13 -59
  5. package/utils/commonUtils.js +19 -1
  6. package/utils/rcsPayloadUtils.js +92 -0
  7. package/utils/templateVarUtils.js +201 -0
  8. package/utils/tests/templateVarUtils.test.js +204 -0
  9. package/v2Components/CapActionButton/constants.js +7 -0
  10. package/v2Components/CapActionButton/index.js +167 -109
  11. package/v2Components/CapActionButton/index.scss +157 -6
  12. package/v2Components/CapActionButton/messages.js +19 -3
  13. package/v2Components/CapActionButton/tests/index.test.js +41 -17
  14. package/v2Components/CapCustomSkeleton/index.js +1 -1
  15. package/v2Components/CapCustomSkeleton/tests/__snapshots__/index.test.js.snap +12 -12
  16. package/v2Components/CapTagList/index.js +10 -0
  17. package/v2Components/CommonTestAndPreview/CustomValuesEditor.js +70 -49
  18. package/v2Components/CommonTestAndPreview/DeliverySettings/DeliverySettings.scss +8 -2
  19. package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +207 -21
  20. package/v2Components/CommonTestAndPreview/DeliverySettings/constants.js +16 -0
  21. package/v2Components/CommonTestAndPreview/DeliverySettings/index.js +85 -10
  22. package/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +30 -0
  23. package/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js +79 -11
  24. package/v2Components/CommonTestAndPreview/SendTestMessage.js +10 -5
  25. package/v2Components/CommonTestAndPreview/UnifiedPreview/RcsPreviewContent.js +160 -15
  26. package/v2Components/CommonTestAndPreview/UnifiedPreview/RcsPreviewContent.js.rej +18 -0
  27. package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +341 -76
  28. package/v2Components/CommonTestAndPreview/UnifiedPreview/index.js +133 -4
  29. package/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +11 -0
  30. package/v2Components/CommonTestAndPreview/constants.js +38 -2
  31. package/v2Components/CommonTestAndPreview/index.js +676 -186
  32. package/v2Components/CommonTestAndPreview/messages.js +49 -3
  33. package/v2Components/CommonTestAndPreview/previewApiUtils.js +59 -0
  34. package/v2Components/CommonTestAndPreview/sagas.js +15 -6
  35. package/v2Components/CommonTestAndPreview/tests/CustomValuesEditor.test.js +308 -284
  36. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +231 -65
  37. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +118 -5
  38. package/v2Components/CommonTestAndPreview/tests/DeliverySettings/utils/parseSenderDetailsResponse.test.js +341 -0
  39. package/v2Components/CommonTestAndPreview/tests/PreviewSection.test.js +8 -1
  40. package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +34 -13
  41. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/RcsPreviewContent.test.js +281 -283
  42. package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/index.test.js +199 -1
  43. package/v2Components/CommonTestAndPreview/tests/index.test.js +132 -4
  44. package/v2Components/CommonTestAndPreview/tests/previewApiUtils.test.js +67 -0
  45. package/v2Components/CommonTestAndPreview/tests/sagas.test.js +2 -2
  46. package/v2Components/FormBuilder/index.js +8 -10
  47. package/v2Components/SmsFallback/SmsFallbackLocalSelector.js +87 -0
  48. package/v2Components/SmsFallback/constants.js +73 -0
  49. package/v2Components/SmsFallback/index.js +955 -0
  50. package/v2Components/SmsFallback/index.scss +265 -0
  51. package/v2Components/SmsFallback/messages.js +78 -0
  52. package/v2Components/SmsFallback/smsFallbackUtils.js +118 -0
  53. package/v2Components/SmsFallback/tests/SmsFallbackLocalSelector.test.js +50 -0
  54. package/v2Components/SmsFallback/tests/rcsSmsFallback.acceptance.test.js +147 -0
  55. package/v2Components/SmsFallback/tests/smsFallbackHandlers.test.js +304 -0
  56. package/v2Components/SmsFallback/tests/smsFallbackUi.test.js +197 -0
  57. package/v2Components/SmsFallback/tests/smsFallbackUtils.test.js +277 -0
  58. package/v2Components/SmsFallback/tests/useLocalTemplateList.test.js +422 -0
  59. package/v2Components/SmsFallback/useLocalTemplateList.js +92 -0
  60. package/v2Components/TemplatePreview/_templatePreview.scss +33 -23
  61. package/v2Components/TemplatePreview/constants.js +2 -0
  62. package/v2Components/TemplatePreview/index.js +143 -28
  63. package/v2Components/TemplatePreview/tests/index.test.js +142 -0
  64. package/v2Components/TestAndPreviewSlidebox/index.js +13 -1
  65. package/v2Components/TestAndPreviewSlidebox/sagas.js +11 -4
  66. package/v2Components/TestAndPreviewSlidebox/tests/saga.test.js +3 -1
  67. package/v2Components/VarSegmentMessageEditor/constants.js +2 -0
  68. package/v2Components/VarSegmentMessageEditor/index.js +125 -0
  69. package/v2Components/VarSegmentMessageEditor/index.scss +46 -0
  70. package/v2Containers/CreativesContainer/CreativesSlideBoxWrapper.js +43 -0
  71. package/v2Containers/CreativesContainer/SlideBoxContent.js +36 -4
  72. package/v2Containers/CreativesContainer/SlideBoxFooter.js +11 -4
  73. package/v2Containers/CreativesContainer/SlideBoxHeader.js +29 -4
  74. package/v2Containers/CreativesContainer/constants.js +9 -0
  75. package/v2Containers/CreativesContainer/embeddedSlideboxUtils.js +67 -0
  76. package/v2Containers/CreativesContainer/index.js +300 -108
  77. package/v2Containers/CreativesContainer/index.scss +51 -1
  78. package/v2Containers/CreativesContainer/messages.js +0 -4
  79. package/v2Containers/CreativesContainer/tests/SlideBoxContent.localTemplates.test.js +90 -0
  80. package/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +78 -34
  81. package/v2Containers/CreativesContainer/tests/SlideBoxHeader.test.js +79 -16
  82. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +8 -0
  83. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxHeader.test.js.snap +357 -98
  84. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +20 -18
  85. package/v2Containers/CreativesContainer/tests/embeddedSlideboxUtils.test.js +258 -0
  86. package/v2Containers/CreativesContainer/tests/index.test.js +71 -9
  87. package/v2Containers/CreativesContainer/tests/useLocalTemplatesProp.test.js +125 -0
  88. package/v2Containers/Rcs/constants.js +119 -8
  89. package/v2Containers/Rcs/index.js +2379 -807
  90. package/v2Containers/Rcs/index.js.rej +1336 -0
  91. package/v2Containers/Rcs/index.scss +276 -6
  92. package/v2Containers/Rcs/index.scss.rej +74 -0
  93. package/v2Containers/Rcs/messages.js +38 -3
  94. package/v2Containers/Rcs/rcsLibraryHydrationUtils.js +225 -0
  95. package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +98018 -70073
  96. package/v2Containers/Rcs/tests/__snapshots__/utils.test.js.snap +0 -5
  97. package/v2Containers/Rcs/tests/__snapshots__/utils.test.js.snap.rej +128 -0
  98. package/v2Containers/Rcs/tests/index.test.js +152 -121
  99. package/v2Containers/Rcs/tests/mockData.js +38 -0
  100. package/v2Containers/Rcs/tests/rcsLibraryHydrationUtils.test.js +318 -0
  101. package/v2Containers/Rcs/tests/utils.test.js +646 -30
  102. package/v2Containers/Rcs/utils.js +478 -11
  103. package/v2Containers/Sms/Create/index.js +100 -40
  104. package/v2Containers/Sms/smsFormDataHelpers.js +67 -0
  105. package/v2Containers/Sms/tests/smsFormDataHelpers.test.js +253 -0
  106. package/v2Containers/SmsTrai/Create/index.js +9 -4
  107. package/v2Containers/SmsTrai/Edit/constants.js +2 -0
  108. package/v2Containers/SmsTrai/Edit/index.js +636 -130
  109. package/v2Containers/SmsTrai/Edit/index.scss +121 -0
  110. package/v2Containers/SmsTrai/Edit/messages.js +14 -4
  111. package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +4328 -2375
  112. package/v2Containers/SmsWrapper/index.js +37 -8
  113. package/v2Containers/TagList/index.js +6 -0
  114. package/v2Containers/Templates/ChannelTypeIllustration.js +6 -23
  115. package/v2Containers/Templates/TemplatesActionBar.js +101 -0
  116. package/v2Containers/Templates/_templates.scss +181 -126
  117. package/v2Containers/Templates/actions.js +11 -36
  118. package/v2Containers/Templates/constants.js +2 -23
  119. package/v2Containers/Templates/index.js +142 -333
  120. package/v2Containers/Templates/messages.js +0 -68
  121. package/v2Containers/Templates/reducer.js +0 -68
  122. package/v2Containers/Templates/sagas.js +55 -98
  123. package/v2Containers/Templates/selectors.js +0 -12
  124. package/v2Containers/Templates/tests/ChannelTypeIllustration.test.js +0 -12
  125. package/v2Containers/Templates/tests/TemplatesActionBar.test.js +120 -0
  126. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +1042 -1256
  127. package/v2Containers/Templates/tests/index.test.js +0 -6
  128. package/v2Containers/Templates/tests/reducer.test.js +0 -178
  129. package/v2Containers/Templates/tests/sagas.test.js +200 -436
  130. package/v2Containers/Templates/tests/selector.test.js +0 -32
  131. package/v2Containers/Templates/tests/smsTemplatesListApi.test.js +180 -0
  132. package/v2Containers/Templates/utils/smsTemplatesListApi.js +79 -0
  133. package/v2Containers/TemplatesV2/TemplatesV2.style.js +72 -1
  134. package/v2Containers/TemplatesV2/index.js +86 -23
  135. package/v2Containers/TemplatesV2/tests/TemplatesV2.localTemplates.test.js +131 -0
  136. package/v2Containers/Whatsapp/index.js +3 -20
  137. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +578 -34
  138. package/v2Containers/Assets/images/archive_Empty_Illustration.svg +0 -9
@@ -2,6 +2,43 @@
2
2
 
3
3
  $classPrefix: add-creatives-section;
4
4
 
5
+ /* Local SMS template picker: fill slidebox height; global .v2-pagination-container uses 100vh-20rem and leaves a dead zone inside slideboxes */
6
+ .#{$classPrefix}.creatives-slidebox--local-sms-templates {
7
+ .cap-slide-box-v2-container {
8
+ display: flex;
9
+ flex-direction: column;
10
+ min-height: 0;
11
+ max-height: 100vh;
12
+ }
13
+
14
+ .slidebox-content-container {
15
+ flex: 1;
16
+ min-height: 0;
17
+ display: flex;
18
+ flex-direction: column;
19
+ overflow: hidden;
20
+ }
21
+
22
+ .slidebox-content-container > div {
23
+ flex: 1;
24
+ min-height: 0;
25
+ display: flex;
26
+ flex-direction: column;
27
+ overflow: hidden;
28
+ }
29
+
30
+ /* TemplatesV2 root: fill slidebox so the template grid can flex instead of using 100vh-based pagination height */
31
+ .slidebox-content-container .creatives-templates-container--local-sms.library-mode {
32
+ flex: 1;
33
+ min-height: 0;
34
+ display: flex;
35
+ flex-direction: column;
36
+ overflow: hidden;
37
+ height: auto;
38
+ max-height: 100%;
39
+ }
40
+ }
41
+
5
42
  .#{$classPrefix} {
6
43
  &.creatives-library-mode{
7
44
  .sms-create-container, .sms-email-container{
@@ -80,5 +117,18 @@ $classPrefix: add-creatives-section;
80
117
  }
81
118
 
82
119
  .template-footer-width {
83
- width: 100%;;
120
+ width: 100%;
121
+ }
122
+
123
+ .slidebox-footer-actions {
124
+ display: flex;
125
+ flex-wrap: nowrap;
126
+ align-items: center;
127
+ gap: 0.75rem;
128
+ min-width: 0;
129
+
130
+ .ant-btn,
131
+ button {
132
+ flex-shrink: 0;
133
+ }
84
134
  }
@@ -390,8 +390,4 @@ export default defineMessages({
390
390
  id: `${scope}.personalizationTokensErrorMessage`,
391
391
  defaultMessage: `Personalization tags are not supported for anonymous customers, please remove the tags.`,
392
392
  },
393
- "cannotEditArchivedTemplate": {
394
- id: `${scope}.cannotEditArchivedTemplate`,
395
- defaultMessage: 'Cannot edit an archived template. Please unarchive it first.',
396
- },
397
393
  });
@@ -0,0 +1,90 @@
1
+ /**
2
+ * Covers `localTemplatesConfig` / `useLocalTemplates` branch in SlideBoxContent → TemplatesV2
3
+ * (embedded SMS template list / RCS SMS fallback).
4
+ */
5
+ import React from 'react';
6
+ import { mountWithIntl, shallowWithIntl } from '../../../helpers/intl-enzym-test-helpers';
7
+ import { SlideBoxContent } from '../SlideBoxContent';
8
+
9
+ const mockTemplatesV2 = jest.fn(() => <div data-testid="templates-v2-mock" />);
10
+ jest.mock('../../TemplatesV2', () => ({
11
+ __esModule: true,
12
+ default: (props) => mockTemplatesV2(props),
13
+ }));
14
+
15
+ const baseProps = {
16
+ slidBoxContent: 'templates',
17
+ currentChannel: 'SMS',
18
+ onSelectTemplate: jest.fn(),
19
+ onPreviewTemplate: jest.fn(),
20
+ onCreateNew: jest.fn(),
21
+ onChannelChange: jest.fn(),
22
+ location: { pathname: '/sms', query: {}, search: '' },
23
+ cap: {},
24
+ channelsToHide: [],
25
+ channelsToDisable: [],
26
+ handleClose: jest.fn(),
27
+ messageDetails: {},
28
+ onCreateComplete: jest.fn(),
29
+ };
30
+
31
+ describe('SlideBoxContent local templates (TemplatesV2)', () => {
32
+ beforeEach(() => {
33
+ mockTemplatesV2.mockClear();
34
+ });
35
+
36
+ // Use mount when asserting TemplatesV2 mock calls: shallow does not invoke children under styled CreativesWrapper.
37
+ it('renders TemplatesV2 in full mode when useLocalTemplates is true', () => {
38
+ mountWithIntl(
39
+ <SlideBoxContent
40
+ {...baseProps}
41
+ isFullMode
42
+ localTemplatesConfig={{
43
+ useLocalTemplates: true,
44
+ localTemplates: [],
45
+ localTemplatesLoading: false,
46
+ }}
47
+ />,
48
+ );
49
+ expect(mockTemplatesV2).toHaveBeenCalled();
50
+ const passed = mockTemplatesV2.mock.calls[mockTemplatesV2.mock.calls.length - 1][0];
51
+ expect(passed.localTemplatesConfig.useLocalTemplates).toBe(true);
52
+ });
53
+
54
+ it('does not render TemplatesV2 in full mode when useLocalTemplates is false', () => {
55
+ shallowWithIntl(
56
+ <SlideBoxContent
57
+ {...baseProps}
58
+ isFullMode
59
+ localTemplatesConfig={{ useLocalTemplates: false }}
60
+ />,
61
+ );
62
+ expect(mockTemplatesV2).not.toHaveBeenCalled();
63
+ });
64
+
65
+ it('renders TemplatesV2 in library mode without localTemplates flag', () => {
66
+ mountWithIntl(
67
+ <SlideBoxContent
68
+ {...baseProps}
69
+ isFullMode={false}
70
+ />,
71
+ );
72
+ expect(mockTemplatesV2).toHaveBeenCalled();
73
+ });
74
+
75
+ it('merges top-level local template props via pick when localTemplatesConfig is omitted', () => {
76
+ mountWithIntl(
77
+ <SlideBoxContent
78
+ {...baseProps}
79
+ isFullMode
80
+ useLocalTemplates
81
+ localTemplates={[{ _id: '1' }]}
82
+ localTemplatesLoading={false}
83
+ />,
84
+ );
85
+ expect(mockTemplatesV2).toHaveBeenCalled();
86
+ const passed = mockTemplatesV2.mock.calls[mockTemplatesV2.mock.calls.length - 1][0];
87
+ expect(passed.localTemplatesConfig.useLocalTemplates).toBe(true);
88
+ expect(passed.localTemplatesConfig.localTemplates).toEqual([{ _id: '1' }]);
89
+ });
90
+ });
@@ -531,62 +531,106 @@ describe('shouldCheckValidation (line 79)', () => {
531
531
  });
532
532
  });
533
533
 
534
- describe('SlideBoxFooter — continue and preview states', () => {
534
+ describe('SlideBoxFooter — isHtmlEditorValidationStateActive via issueCounts', () => {
535
535
  beforeEach(() => {
536
536
  jest.clearAllMocks();
537
+ });
538
+
539
+ it('activates via issueCounts.total > 0 even when validationComplete=false and hasErrors=false', () => {
537
540
  const { hasSupportCKEditor } = require('../../../utils/common');
538
541
  hasSupportCKEditor.mockReturnValue(false);
539
- });
540
542
 
541
- it('renders the Continue button when shouldShowContinueFooter returns true', () => {
542
543
  renderComponent({
543
544
  ...baseFooterProps,
544
- shouldShowDoneFooter: jest.fn().mockReturnValue(false),
545
- shouldShowContinueFooter: jest.fn().mockReturnValue(true),
546
- isContinueButtonDisabled: false,
547
- // null lets the component fall back to messages.continue (has a valid id)
548
- // The defaultProp {} has no id, which causes FormattedMessage to throw
549
- continueButtonLabel: null,
545
+ currentChannel: 'EMAIL',
546
+ slidBoxContent: 'editTemplate',
547
+ htmlEditorValidationState: {
548
+ validationComplete: false,
549
+ hasErrors: false,
550
+ errorsAcknowledged: false,
551
+ isContentEmpty: false,
552
+ issueCounts: { html: 1, label: 0, liquid: 0, total: 1 },
553
+ },
550
554
  });
551
- const continueBtn = screen.getByRole('button', { name: /continue/i });
552
- expect(continueBtn).toBeTruthy();
553
- expect(continueBtn).toBeEnabled();
555
+ // isHtmlEditorValidationStateActive = true (via issueCounts.total > 0)
556
+ // isHTMLEditorModeInEdit = true, shouldCheckValidation = true
557
+ // hasValidationErrors = false, shouldDisableButtons = false (no hasErrors)
558
+ const updateBtn = screen.getByRole('button', { name: /update/i });
559
+ expect(updateBtn).toBeEnabled();
554
560
  });
555
561
 
556
- it('disables the Continue button when isContinueButtonDisabled is true', () => {
562
+ it('issueCounts.total=0 with validationComplete=false not activated (BEE edit mode)', () => {
563
+ const { hasSupportCKEditor } = require('../../../utils/common');
564
+ hasSupportCKEditor.mockReturnValue(false);
565
+
557
566
  renderComponent({
558
567
  ...baseFooterProps,
559
- shouldShowDoneFooter: jest.fn().mockReturnValue(false),
560
- shouldShowContinueFooter: jest.fn().mockReturnValue(true),
561
- isContinueButtonDisabled: true,
562
- continueButtonLabel: null,
568
+ currentChannel: 'EMAIL',
569
+ slidBoxContent: 'editTemplate',
570
+ htmlEditorValidationState: {
571
+ validationComplete: false,
572
+ hasErrors: false,
573
+ errorsAcknowledged: false,
574
+ isContentEmpty: false,
575
+ issueCounts: { html: 0, label: 0, liquid: 0, total: 0 },
576
+ },
563
577
  });
564
- const continueBtn = screen.getByRole('button', { name: /continue/i });
565
- expect(continueBtn).toBeDisabled();
578
+ // isHtmlEditorValidationStateActive = false isHTMLEditorModeInEdit = false
579
+ // isBEEEditor = true (isEditMode && !isHtmlEditorValidationStateActive)
580
+ // shouldCheckValidation = false → button enabled
581
+ const updateBtn = screen.getByRole('button', { name: /update/i });
582
+ expect(updateBtn).toBeEnabled();
566
583
  });
584
+ });
585
+
586
+ describe('SlideBoxFooter — isBEEEditor detection in create mode via emailCreateMode=editor', () => {
587
+ beforeEach(() => {
588
+ jest.clearAllMocks();
589
+ });
590
+
591
+ it('detects BEE editor when emailCreateMode=editor and selectedEmailCreateMode is not html_editor (create mode)', () => {
592
+ const { hasSupportCKEditor } = require('../../../utils/common');
593
+ hasSupportCKEditor.mockReturnValue(false);
567
594
 
568
- it('renders the Edit button when slidBoxContent is preview', () => {
569
595
  renderComponent({
570
596
  ...baseFooterProps,
571
- slidBoxContent: 'preview',
572
- shouldShowDoneFooter: jest.fn().mockReturnValue(false),
573
- shouldShowContinueFooter: jest.fn().mockReturnValue(false),
574
- onEditTemplate: jest.fn(),
597
+ currentChannel: 'EMAIL',
598
+ slidBoxContent: 'createTemplate',
599
+ emailCreateMode: 'editor',
600
+ selectedEmailCreateMode: 'drag_drop',
601
+ htmlEditorValidationState: {
602
+ validationComplete: false,
603
+ hasErrors: false,
604
+ isContentEmpty: false,
605
+ issueCounts: { html: 0, label: 0, liquid: 0, total: 0 },
606
+ },
575
607
  });
576
- const editBtn = screen.getByRole('button', { name: /edit/i });
577
- expect(editBtn).toBeTruthy();
608
+ // selectedEmailCreateMode=drag_drop isBEEEditor = true (DRAG_DROP branch)
609
+ // shouldCheckValidation = false → button not disabled by validation
610
+ const createBtn = screen.getByRole('button', { name: /create/i });
611
+ expect(createBtn).toBeInTheDocument();
578
612
  });
579
613
 
580
- it('calls onEditTemplate when the Edit button is clicked in preview mode', () => {
581
- const onEditTemplate = jest.fn();
614
+ it('enables primary action button when emailCreateMode=editor but mode is not HTML editor (BEE editor path)', () => {
615
+ const { hasSupportCKEditor } = require('../../../utils/common');
616
+ hasSupportCKEditor.mockReturnValue(false);
617
+
582
618
  renderComponent({
583
619
  ...baseFooterProps,
584
- slidBoxContent: 'preview',
585
- shouldShowDoneFooter: jest.fn().mockReturnValue(false),
586
- shouldShowContinueFooter: jest.fn().mockReturnValue(false),
587
- onEditTemplate,
620
+ currentChannel: 'EMAIL',
621
+ slidBoxContent: 'createTemplate',
622
+ emailCreateMode: 'editor',
623
+ selectedEmailCreateMode: undefined,
624
+ htmlEditorValidationState: {
625
+ validationComplete: false,
626
+ hasErrors: false,
627
+ isContentEmpty: false,
628
+ issueCounts: { html: 0, label: 0, liquid: 0, total: 0 },
629
+ },
588
630
  });
589
- screen.getByRole('button', { name: /edit/i }).click();
590
- expect(onEditTemplate).toHaveBeenCalled();
631
+ // isHTMLEditorModeInCreate = false (selectedEmailCreateMode is undefined, not html_editor)
632
+ // emailCreateMode === 'editor' && !isHTMLEditorMode → isBEEEditor = true
633
+ const createBtn = screen.getByRole('button', { name: /create/i });
634
+ expect(createBtn).toBeInTheDocument();
591
635
  });
592
636
  });
@@ -73,48 +73,111 @@ describe('Test SlideBoxHeader container', () => {
73
73
  expect(renderedComponent).toMatchSnapshot();
74
74
  });
75
75
 
76
- it('Should render correct component for inapp channel edit mode (non-fullmode)', () => {
76
+ it('renders templateNameRenderProp when isFullMode and shouldShowTemplateName are both true', () => {
77
+ const templateNameRenderProp = jest.fn().mockReturnValue(null);
77
78
  renderedComponent = shallowWithIntl(
78
79
  <SlideBoxHeader
79
80
  slidBoxContent="editTemplate"
80
- channel="INAPP"
81
- templateData={{ name: 'InApp Template' }}
81
+ channel="SMS"
82
+ templateData={{ name: 'My Template' }}
83
+ onCreateComplete={onCreateComplete}
84
+ isFullMode
85
+ shouldShowTemplateName
86
+ templateNameRenderProp={templateNameRenderProp}
87
+ moduleType="journey"
88
+ />
89
+ );
90
+ expect(templateNameRenderProp).toHaveBeenCalled();
91
+ expect(renderedComponent).toMatchSnapshot();
92
+ });
93
+
94
+ it('does not call templateNameRenderProp when isFullMode is false (showTemplateNameHeader=false)', () => {
95
+ const templateNameRenderProp = jest.fn().mockReturnValue(null);
96
+ renderedComponent = shallowWithIntl(
97
+ <SlideBoxHeader
98
+ slidBoxContent="editTemplate"
99
+ channel="SMS"
100
+ templateData={{ name: 'My Template' }}
82
101
  onCreateComplete={onCreateComplete}
83
102
  isFullMode={false}
103
+ shouldShowTemplateName
104
+ templateNameRenderProp={templateNameRenderProp}
84
105
  moduleType="journey"
85
106
  />
86
107
  );
108
+ expect(templateNameRenderProp).not.toHaveBeenCalled();
87
109
  expect(renderedComponent).toMatchSnapshot();
88
110
  });
89
111
 
90
- it('Should render correct component for inapp channel create mode', () => {
112
+ it('does not call templateNameRenderProp when shouldShowTemplateName is false (showTemplateNameHeader=false)', () => {
113
+ const templateNameRenderProp = jest.fn().mockReturnValue(null);
91
114
  renderedComponent = shallowWithIntl(
92
115
  <SlideBoxHeader
93
- slidBoxContent="createTemplate"
94
- channel="INAPP"
95
- templateData={{}}
116
+ slidBoxContent="editTemplate"
117
+ channel="SMS"
118
+ templateData={{ name: 'My Template' }}
119
+ onCreateComplete={onCreateComplete}
120
+ isFullMode
121
+ shouldShowTemplateName={false}
122
+ templateNameRenderProp={templateNameRenderProp}
123
+ moduleType="journey"
124
+ />
125
+ );
126
+ expect(templateNameRenderProp).not.toHaveBeenCalled();
127
+ expect(renderedComponent).toMatchSnapshot();
128
+ });
129
+
130
+ it('shows edit header for InApp edit without fullMode (shouldShowInAppEditHeader=true)', () => {
131
+ renderedComponent = shallowWithIntl(
132
+ <SlideBoxHeader
133
+ slidBoxContent="editTemplate"
134
+ channel="inapp"
135
+ templateData={{ name: 'InApp Tpl' }}
96
136
  onCreateComplete={onCreateComplete}
97
137
  isFullMode={false}
98
138
  moduleType="journey"
99
- templateStep="modeSelection"
100
139
  />
101
140
  );
102
141
  expect(renderedComponent).toMatchSnapshot();
103
142
  });
104
143
 
105
- it('Should render wechat map template create steps (mapTemplateCreate path)', () => {
144
+ it('hides edit header for InApp edit with fullMode (shouldShowInAppEditHeader=false, isInAppCreate guard)', () => {
106
145
  renderedComponent = shallowWithIntl(
107
146
  <SlideBoxHeader
108
- slidBoxContent="createTemplate"
109
- channel="WECHAT"
110
- templateData={{}}
147
+ slidBoxContent="editTemplate"
148
+ channel="inapp"
149
+ templateData={{ name: 'InApp Tpl' }}
150
+ onCreateComplete={onCreateComplete}
151
+ isFullMode
152
+ moduleType="journey"
153
+ />
154
+ );
155
+ expect(renderedComponent).toMatchSnapshot();
156
+ });
157
+
158
+ it('renders whatsappOverview=true header when WHATSAPP edit in fullMode', () => {
159
+ renderedComponent = shallowWithIntl(
160
+ <SlideBoxHeader
161
+ slidBoxContent="editTemplate"
162
+ channel="WHATSAPP"
163
+ templateData={whatsappEditTemplateData}
164
+ onCreateComplete={onCreateComplete}
165
+ isFullMode
166
+ moduleType="journey"
167
+ />
168
+ );
169
+ expect(renderedComponent).toMatchSnapshot();
170
+ });
171
+
172
+ it('renders whatsappOverview=false header when WHATSAPP edit without fullMode', () => {
173
+ renderedComponent = shallowWithIntl(
174
+ <SlideBoxHeader
175
+ slidBoxContent="editTemplate"
176
+ channel="WHATSAPP"
177
+ templateData={whatsappEditTemplateData}
111
178
  onCreateComplete={onCreateComplete}
112
179
  isFullMode={false}
113
180
  moduleType="journey"
114
- weChatTemplateType="mapTemplate"
115
- templateStep="createTemplateContent"
116
- onWeChatMaptemplateStepChange={jest.fn()}
117
- weChatMaptemplateStep={0}
118
181
  />
119
182
  );
120
183
  expect(renderedComponent).toMatchSnapshot();
@@ -870,6 +870,11 @@ exports[`Test SlideBoxContent container Should render correct component for rcs
870
870
  }
871
871
  }
872
872
  onCreateComplete={[MockFunction]}
873
+ templateData={
874
+ Object {
875
+ "mode": "create",
876
+ }
877
+ }
873
878
  waitEventContextTags={Object {}}
874
879
  />
875
880
  </SlideBoxContent__CreativesWrapper>
@@ -981,6 +986,7 @@ exports[`Test SlideBoxContent container Should render correct component for rcs
981
986
  <Connect(UserIsAuthenticated(Connect(InjectIntl(withStyles__StyledComponent))))
982
987
  FTPMode="create"
983
988
  channel="rcs"
989
+ localTemplatesConfig={Object {}}
984
990
  loyaltyMetaData={Object {}}
985
991
  messageDetails={Object {}}
986
992
  onCreateComplete={[MockFunction]}
@@ -1393,6 +1399,7 @@ exports[`Test SlideBoxContent container Should render correct component for what
1393
1399
  <Connect(UserIsAuthenticated(Connect(InjectIntl(withStyles__StyledComponent))))
1394
1400
  FTPMode="create"
1395
1401
  channel="whatsapp"
1402
+ localTemplatesConfig={Object {}}
1396
1403
  loyaltyMetaData={Object {}}
1397
1404
  messageDetails={Object {}}
1398
1405
  onCreateComplete={[MockFunction]}
@@ -3409,6 +3416,7 @@ exports[`Test SlideBoxContent container getViber utility function Should handle
3409
3416
  "name": "sms",
3410
3417
  }
3411
3418
  }
3419
+ templateData={null}
3412
3420
  waitEventContextTags={Object {}}
3413
3421
  />
3414
3422
  </SlideBoxContent__CreativesWrapper>