@capillarytech/creatives-library 8.0.353-alpha.5 → 8.0.353-alpha.6
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.
- package/constants/unified.js +29 -0
- package/package.json +1 -1
- package/services/tests/api.test.js +35 -20
- package/utils/commonUtils.js +19 -1
- package/utils/rcsPayloadUtils.js +92 -0
- package/utils/templateVarUtils.js +201 -0
- package/utils/tests/rcsPayloadUtils.test.js +226 -0
- package/utils/tests/templateVarUtils.test.js +204 -0
- package/v2Components/CapActionButton/constants.js +7 -0
- package/v2Components/CapActionButton/index.js +166 -108
- package/v2Components/CapActionButton/index.scss +157 -6
- package/v2Components/CapActionButton/messages.js +19 -3
- package/v2Components/CapActionButton/tests/index.test.js +41 -17
- package/v2Components/CapTagList/index.js +10 -0
- package/v2Components/CommonTestAndPreview/CustomValuesEditor.js +72 -49
- package/v2Components/CommonTestAndPreview/DeliverySettings/DeliverySettings.scss +8 -2
- package/v2Components/CommonTestAndPreview/DeliverySettings/ModifyDeliverySettings.js +213 -21
- package/v2Components/CommonTestAndPreview/DeliverySettings/constants.js +16 -0
- package/v2Components/CommonTestAndPreview/DeliverySettings/index.js +85 -10
- package/v2Components/CommonTestAndPreview/DeliverySettings/messages.js +30 -0
- package/v2Components/CommonTestAndPreview/DeliverySettings/utils/parseSenderDetailsResponse.js +79 -11
- package/v2Components/CommonTestAndPreview/SendTestMessage.js +10 -5
- package/v2Components/CommonTestAndPreview/UnifiedPreview/PreviewHeader.js +0 -17
- package/v2Components/CommonTestAndPreview/UnifiedPreview/RcsPreviewContent.js +157 -15
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +346 -146
- package/v2Components/CommonTestAndPreview/UnifiedPreview/index.js +138 -48
- package/v2Components/CommonTestAndPreview/_commonTestAndPreview.scss +11 -0
- package/v2Components/CommonTestAndPreview/constants.js +38 -4
- package/v2Components/CommonTestAndPreview/index.js +691 -235
- package/v2Components/CommonTestAndPreview/messages.js +45 -3
- package/v2Components/CommonTestAndPreview/previewApiUtils.js +59 -0
- package/v2Components/CommonTestAndPreview/sagas.js +25 -6
- package/v2Components/CommonTestAndPreview/tests/CustomValuesEditor.test.js +308 -284
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/ModifyDeliverySettings.test.js +231 -65
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/index.test.js +118 -5
- package/v2Components/CommonTestAndPreview/tests/DeliverySettings/utils/parseSenderDetailsResponse.test.js +341 -0
- package/v2Components/CommonTestAndPreview/tests/PreviewSection.test.js +8 -1
- package/v2Components/CommonTestAndPreview/tests/SendTestMessage.test.js +34 -13
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/PreviewHeader.test.js +0 -159
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/RcsPreviewContent.test.js +281 -283
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/index.test.js +199 -256
- package/v2Components/CommonTestAndPreview/tests/constants.test.js +1 -2
- package/v2Components/CommonTestAndPreview/tests/index.test.js +132 -198
- package/v2Components/CommonTestAndPreview/tests/previewApiUtils.test.js +67 -0
- package/v2Components/CommonTestAndPreview/tests/sagas.test.js +36 -26
- package/v2Components/FormBuilder/index.js +11 -6
- package/v2Components/SmsFallback/SmsFallbackLocalSelector.js +91 -0
- package/v2Components/SmsFallback/constants.js +73 -0
- package/v2Components/SmsFallback/index.js +956 -0
- package/v2Components/SmsFallback/index.scss +265 -0
- package/v2Components/SmsFallback/messages.js +78 -0
- package/v2Components/SmsFallback/smsFallbackUtils.js +119 -0
- package/v2Components/SmsFallback/tests/SmsFallbackLocalSelector.test.js +50 -0
- package/v2Components/SmsFallback/tests/rcsSmsFallback.acceptance.test.js +147 -0
- package/v2Components/SmsFallback/tests/smsFallbackHandlers.test.js +304 -0
- package/v2Components/SmsFallback/tests/smsFallbackUi.test.js +223 -0
- package/v2Components/SmsFallback/tests/smsFallbackUtils.test.js +309 -0
- package/v2Components/SmsFallback/tests/useLocalTemplateList.test.js +422 -0
- package/v2Components/SmsFallback/useLocalTemplateList.js +92 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +38 -23
- package/v2Components/TemplatePreview/constants.js +2 -0
- package/v2Components/TemplatePreview/index.js +143 -31
- package/v2Components/TemplatePreview/tests/index.test.js +142 -0
- package/v2Components/TestAndPreviewSlidebox/index.js +15 -3
- package/v2Components/TestAndPreviewSlidebox/sagas.js +11 -4
- package/v2Components/TestAndPreviewSlidebox/tests/saga.test.js +3 -1
- package/v2Components/VarSegmentMessageEditor/constants.js +2 -0
- package/v2Components/VarSegmentMessageEditor/index.js +125 -0
- package/v2Components/VarSegmentMessageEditor/index.scss +46 -0
- package/v2Containers/App/constants.js +0 -3
- package/v2Containers/CreativesContainer/CreativesSlideBoxWrapper.js +43 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +36 -4
- package/v2Containers/CreativesContainer/SlideBoxFooter.js +10 -1
- package/v2Containers/CreativesContainer/SlideBoxHeader.js +29 -4
- package/v2Containers/CreativesContainer/constants.js +9 -0
- package/v2Containers/CreativesContainer/embeddedSlideboxUtils.js +79 -0
- package/v2Containers/CreativesContainer/index.js +322 -103
- package/v2Containers/CreativesContainer/index.scss +51 -1
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.localTemplates.test.js +90 -0
- package/v2Containers/CreativesContainer/tests/SlideBoxFooter.test.js +78 -34
- package/v2Containers/CreativesContainer/tests/SlideBoxHeader.test.js +79 -16
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +8 -0
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxHeader.test.js.snap +357 -98
- package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +20 -15
- package/v2Containers/CreativesContainer/tests/embeddedSlideboxUtils.test.js +258 -0
- package/v2Containers/CreativesContainer/tests/index.test.js +71 -9
- package/v2Containers/CreativesContainer/tests/useLocalTemplatesProp.test.js +125 -0
- package/v2Containers/MobilePush/Create/test/saga.test.js +2 -2
- package/v2Containers/Rcs/constants.js +119 -10
- package/v2Containers/Rcs/index.js +2445 -813
- package/v2Containers/Rcs/index.scss +280 -8
- package/v2Containers/Rcs/messages.js +34 -3
- package/v2Containers/Rcs/rcsLibraryHydrationUtils.js +225 -0
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +98018 -70073
- package/v2Containers/Rcs/tests/__snapshots__/utils.test.js.snap +0 -5
- package/v2Containers/Rcs/tests/index.test.js +152 -121
- package/v2Containers/Rcs/tests/mockData.js +38 -0
- package/v2Containers/Rcs/tests/rcsLibraryHydrationUtils.test.js +318 -0
- package/v2Containers/Rcs/tests/utils.test.js +646 -30
- package/v2Containers/Rcs/utils.js +478 -11
- package/v2Containers/Sms/Create/index.js +106 -40
- package/v2Containers/Sms/smsFormDataHelpers.js +67 -0
- package/v2Containers/Sms/tests/smsFormDataHelpers.test.js +253 -0
- package/v2Containers/SmsTrai/Create/index.js +9 -4
- package/v2Containers/SmsTrai/Edit/constants.js +2 -0
- package/v2Containers/SmsTrai/Edit/index.js +640 -130
- package/v2Containers/SmsTrai/Edit/index.scss +121 -0
- package/v2Containers/SmsTrai/Edit/messages.js +14 -4
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +4328 -2375
- package/v2Containers/SmsWrapper/index.js +37 -8
- package/v2Containers/TagList/index.js +6 -0
- package/v2Containers/Templates/TemplatesActionBar.js +101 -0
- package/v2Containers/Templates/_templates.scss +166 -9
- package/v2Containers/Templates/actions.js +11 -0
- package/v2Containers/Templates/constants.js +2 -0
- package/v2Containers/Templates/index.js +122 -120
- package/v2Containers/Templates/sagas.js +56 -12
- package/v2Containers/Templates/tests/TemplatesActionBar.test.js +120 -0
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +1062 -1017
- package/v2Containers/Templates/tests/sagas.test.js +199 -16
- package/v2Containers/Templates/tests/smsTemplatesListApi.test.js +180 -0
- package/v2Containers/Templates/utils/smsTemplatesListApi.js +79 -0
- package/v2Containers/TemplatesV2/TemplatesV2.style.js +72 -1
- package/v2Containers/TemplatesV2/index.js +86 -23
- package/v2Containers/TemplatesV2/tests/TemplatesV2.localTemplates.test.js +131 -0
- package/v2Containers/WeChat/MapTemplates/test/saga.test.js +9 -9
- package/v2Containers/WebPush/Create/index.js +8 -91
- package/v2Containers/WebPush/Create/index.scss +0 -7
- package/v2Containers/Whatsapp/index.js +3 -20
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +578 -34
- package/v2Components/CommonTestAndPreview/UnifiedPreview/WebPushPreviewContent.js +0 -169
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/WebPushPreviewContent.test.js +0 -522
- package/v2Containers/App/tests/constants.test.js +0 -61
- package/v2Containers/Templates/tests/webpush.test.js +0 -375
- package/v2Containers/WebPush/Create/tests/getTemplateContent.test.js +0 -338
- package/v2Containers/WebPush/Create/tests/testAndPreviewIntegration.test.js +0 -325
|
@@ -9,7 +9,16 @@ import { render, screen } from '@testing-library/react';
|
|
|
9
9
|
import '@testing-library/jest-dom';
|
|
10
10
|
import { injectIntl, IntlProvider } from 'react-intl';
|
|
11
11
|
import UnifiedPreview from '../../UnifiedPreview';
|
|
12
|
-
import {
|
|
12
|
+
import {
|
|
13
|
+
CHANNELS,
|
|
14
|
+
DESKTOP,
|
|
15
|
+
TABLET,
|
|
16
|
+
MOBILE,
|
|
17
|
+
ANDROID,
|
|
18
|
+
IOS,
|
|
19
|
+
PREVIEW_TAB_RCS,
|
|
20
|
+
PREVIEW_TAB_SMS_FALLBACK,
|
|
21
|
+
} from '../../constants';
|
|
13
22
|
import messages from '../../messages';
|
|
14
23
|
|
|
15
24
|
// Convert messages object to format expected by IntlProvider
|
|
@@ -119,21 +128,6 @@ jest.mock('../../UnifiedPreview/ZaloPreviewContent', () => ({
|
|
|
119
128
|
),
|
|
120
129
|
}));
|
|
121
130
|
|
|
122
|
-
jest.mock('../../UnifiedPreview/WebPushPreviewContent', () => ({
|
|
123
|
-
__esModule: true,
|
|
124
|
-
default: (props) => (
|
|
125
|
-
<div data-testid="webpush-preview">
|
|
126
|
-
<div data-testid="webpush-title">{props.notificationTitle}</div>
|
|
127
|
-
<div data-testid="webpush-body">{props.notificationBody}</div>
|
|
128
|
-
<div data-testid="webpush-image">{props.imageSrc}</div>
|
|
129
|
-
<div data-testid="webpush-icon">{props.brandIconSrc}</div>
|
|
130
|
-
<div data-testid="webpush-url">{props.url}</div>
|
|
131
|
-
<div data-testid="webpush-buttons">{JSON.stringify(props.buttons)}</div>
|
|
132
|
-
<div data-testid="webpush-fullscreen">{props.isFullscreenOpen ? 'true' : 'false'}</div>
|
|
133
|
-
</div>
|
|
134
|
-
),
|
|
135
|
-
}));
|
|
136
|
-
|
|
137
131
|
jest.mock('../../UnifiedPreview/PreviewHeader', () => ({
|
|
138
132
|
__esModule: true,
|
|
139
133
|
default: (props) => (
|
|
@@ -562,6 +556,195 @@ describe('UnifiedPreview', () => {
|
|
|
562
556
|
|
|
563
557
|
expect(screen.getByTestId('rcs-sender-id')).toHaveTextContent('RCS_SENDER');
|
|
564
558
|
});
|
|
559
|
+
|
|
560
|
+
describe('RCS SMS fallback — Test & Preview tabs', () => {
|
|
561
|
+
it('without SMS fallback selected, shows only RCS preview (no RCS+SMS tab layout)', () => {
|
|
562
|
+
const props = {
|
|
563
|
+
...defaultProps,
|
|
564
|
+
channel: CHANNELS.RCS,
|
|
565
|
+
content: { rcsTitle: 'Hello RCS' },
|
|
566
|
+
smsFallbackContent: undefined,
|
|
567
|
+
};
|
|
568
|
+
|
|
569
|
+
const { container } = render(
|
|
570
|
+
<TestWrapper>
|
|
571
|
+
<ComponentToRender {...props} />
|
|
572
|
+
</TestWrapper>
|
|
573
|
+
);
|
|
574
|
+
|
|
575
|
+
expect(container.querySelector('.unified-preview-rcs-tabs')).toBeNull();
|
|
576
|
+
expect(screen.getByTestId('rcs-preview')).toBeInTheDocument();
|
|
577
|
+
expect(screen.queryByTestId('sms-preview')).not.toBeInTheDocument();
|
|
578
|
+
});
|
|
579
|
+
|
|
580
|
+
it('with SMS fallback template body, shows RCS and Fallback SMS tabs', () => {
|
|
581
|
+
const props = {
|
|
582
|
+
...defaultProps,
|
|
583
|
+
channel: CHANNELS.RCS,
|
|
584
|
+
content: { rcsTitle: 'Hello RCS' },
|
|
585
|
+
smsFallbackContent: {
|
|
586
|
+
content: 'SMS fallback body',
|
|
587
|
+
templateContent: 'SMS fallback body',
|
|
588
|
+
},
|
|
589
|
+
};
|
|
590
|
+
|
|
591
|
+
const { container } = render(
|
|
592
|
+
<TestWrapper>
|
|
593
|
+
<ComponentToRender {...props} />
|
|
594
|
+
</TestWrapper>
|
|
595
|
+
);
|
|
596
|
+
|
|
597
|
+
expect(container.querySelector('.unified-preview-rcs-tabs')).toBeInTheDocument();
|
|
598
|
+
expect(
|
|
599
|
+
screen.getByRole('tab', { name: messages.rcsTab.defaultMessage })
|
|
600
|
+
).toBeInTheDocument();
|
|
601
|
+
expect(
|
|
602
|
+
screen.getByRole('tab', { name: messages.smsFallbackTab.defaultMessage })
|
|
603
|
+
).toBeInTheDocument();
|
|
604
|
+
});
|
|
605
|
+
|
|
606
|
+
it('on SMS fallback tab, renders SMS preview with resolved fallback text when smsFallbackResolvedText is set', () => {
|
|
607
|
+
const props = {
|
|
608
|
+
...defaultProps,
|
|
609
|
+
channel: CHANNELS.RCS,
|
|
610
|
+
content: { rcsTitle: 'Hello RCS' },
|
|
611
|
+
smsFallbackContent: {
|
|
612
|
+
content: '{{var}}',
|
|
613
|
+
templateContent: '{{var}}',
|
|
614
|
+
},
|
|
615
|
+
smsFallbackResolvedText: 'Resolved SMS for preview',
|
|
616
|
+
activePreviewTab: PREVIEW_TAB_SMS_FALLBACK,
|
|
617
|
+
onPreviewTabChange: jest.fn(),
|
|
618
|
+
};
|
|
619
|
+
|
|
620
|
+
render(
|
|
621
|
+
<TestWrapper>
|
|
622
|
+
<ComponentToRender {...props} />
|
|
623
|
+
</TestWrapper>
|
|
624
|
+
);
|
|
625
|
+
|
|
626
|
+
expect(screen.getByTestId('sms-content')).toHaveTextContent('Resolved SMS for preview');
|
|
627
|
+
});
|
|
628
|
+
|
|
629
|
+
it('on RCS tab (default), renders RCS preview when dual tabs are shown', () => {
|
|
630
|
+
const props = {
|
|
631
|
+
...defaultProps,
|
|
632
|
+
channel: CHANNELS.RCS,
|
|
633
|
+
content: { rcsTitle: 'Only RCS pane' },
|
|
634
|
+
smsFallbackContent: { content: 'SMS', templateContent: 'SMS' },
|
|
635
|
+
activePreviewTab: PREVIEW_TAB_RCS,
|
|
636
|
+
onPreviewTabChange: jest.fn(),
|
|
637
|
+
};
|
|
638
|
+
|
|
639
|
+
render(
|
|
640
|
+
<TestWrapper>
|
|
641
|
+
<ComponentToRender {...props} />
|
|
642
|
+
</TestWrapper>
|
|
643
|
+
);
|
|
644
|
+
|
|
645
|
+
expect(screen.getByTestId('rcs-preview')).toBeInTheDocument();
|
|
646
|
+
expect(screen.getByTestId('rcs-content')).toHaveTextContent(/Only RCS pane/);
|
|
647
|
+
});
|
|
648
|
+
|
|
649
|
+
it('on SMS fallback tab, shows raw template when no varmap and no resolved text', () => {
|
|
650
|
+
const props = {
|
|
651
|
+
...defaultProps,
|
|
652
|
+
channel: CHANNELS.RCS,
|
|
653
|
+
content: { rcsTitle: 'Hello RCS' },
|
|
654
|
+
smsFallbackContent: {
|
|
655
|
+
content: 'Hello {{name}}',
|
|
656
|
+
templateContent: 'Hello {{name}}',
|
|
657
|
+
// no rcsSmsFallbackVarMapped
|
|
658
|
+
},
|
|
659
|
+
smsFallbackResolvedText: undefined,
|
|
660
|
+
activePreviewTab: PREVIEW_TAB_SMS_FALLBACK,
|
|
661
|
+
onPreviewTabChange: jest.fn(),
|
|
662
|
+
};
|
|
663
|
+
|
|
664
|
+
render(
|
|
665
|
+
<TestWrapper>
|
|
666
|
+
<ComponentToRender {...props} />
|
|
667
|
+
</TestWrapper>
|
|
668
|
+
);
|
|
669
|
+
|
|
670
|
+
// rawFallbackTemplate is shown directly — {{tags}} remain visible
|
|
671
|
+
expect(screen.getByTestId('sms-content')).toHaveTextContent('Hello {{name}}');
|
|
672
|
+
});
|
|
673
|
+
|
|
674
|
+
it('on SMS fallback tab, treats empty resolved text as absent and shows raw template', () => {
|
|
675
|
+
const props = {
|
|
676
|
+
...defaultProps,
|
|
677
|
+
channel: CHANNELS.RCS,
|
|
678
|
+
content: { rcsTitle: 'Hello RCS' },
|
|
679
|
+
smsFallbackContent: {
|
|
680
|
+
content: 'Raw {{var}} template',
|
|
681
|
+
templateContent: 'Raw {{var}} template',
|
|
682
|
+
},
|
|
683
|
+
smsFallbackResolvedText: '',
|
|
684
|
+
activePreviewTab: PREVIEW_TAB_SMS_FALLBACK,
|
|
685
|
+
onPreviewTabChange: jest.fn(),
|
|
686
|
+
};
|
|
687
|
+
|
|
688
|
+
render(
|
|
689
|
+
<TestWrapper>
|
|
690
|
+
<ComponentToRender {...props} />
|
|
691
|
+
</TestWrapper>
|
|
692
|
+
);
|
|
693
|
+
|
|
694
|
+
expect(screen.getByTestId('sms-content')).toHaveTextContent('Raw {{var}} template');
|
|
695
|
+
});
|
|
696
|
+
|
|
697
|
+
it('on SMS fallback tab, applies varmap slot substitution when varmap entries exist and no resolved text', () => {
|
|
698
|
+
// getFallbackResolvedContent key format: `${fullToken}_${segmentIndex}`
|
|
699
|
+
// 'Hello {{name}}' → segments ['Hello ', '{{name}}'], so {{name}} is at index 1 → key '{{name}}_1'
|
|
700
|
+
const props = {
|
|
701
|
+
...defaultProps,
|
|
702
|
+
channel: CHANNELS.RCS,
|
|
703
|
+
content: { rcsTitle: 'Hello RCS' },
|
|
704
|
+
smsFallbackContent: {
|
|
705
|
+
content: 'Hello {{name}}',
|
|
706
|
+
templateContent: 'Hello {{name}}',
|
|
707
|
+
rcsSmsFallbackVarMapped: { '{{name}}_1': 'World' },
|
|
708
|
+
},
|
|
709
|
+
smsFallbackResolvedText: undefined,
|
|
710
|
+
activePreviewTab: PREVIEW_TAB_SMS_FALLBACK,
|
|
711
|
+
onPreviewTabChange: jest.fn(),
|
|
712
|
+
};
|
|
713
|
+
|
|
714
|
+
render(
|
|
715
|
+
<TestWrapper>
|
|
716
|
+
<ComponentToRender {...props} />
|
|
717
|
+
</TestWrapper>
|
|
718
|
+
);
|
|
719
|
+
|
|
720
|
+
expect(screen.getByTestId('sms-content')).toHaveTextContent('Hello World');
|
|
721
|
+
});
|
|
722
|
+
|
|
723
|
+
it('on SMS fallback tab, resolved text takes priority over varmap entries', () => {
|
|
724
|
+
const props = {
|
|
725
|
+
...defaultProps,
|
|
726
|
+
channel: CHANNELS.RCS,
|
|
727
|
+
content: { rcsTitle: 'Hello RCS' },
|
|
728
|
+
smsFallbackContent: {
|
|
729
|
+
content: 'Hello {{name}}',
|
|
730
|
+
templateContent: 'Hello {{name}}',
|
|
731
|
+
rcsSmsFallbackVarMapped: { '{{name}}_1': 'World' },
|
|
732
|
+
},
|
|
733
|
+
smsFallbackResolvedText: 'Hello John',
|
|
734
|
+
activePreviewTab: PREVIEW_TAB_SMS_FALLBACK,
|
|
735
|
+
onPreviewTabChange: jest.fn(),
|
|
736
|
+
};
|
|
737
|
+
|
|
738
|
+
render(
|
|
739
|
+
<TestWrapper>
|
|
740
|
+
<ComponentToRender {...props} />
|
|
741
|
+
</TestWrapper>
|
|
742
|
+
);
|
|
743
|
+
|
|
744
|
+
// resolvedText wins over varmap substitution
|
|
745
|
+
expect(screen.getByTestId('sms-content')).toHaveTextContent('Hello John');
|
|
746
|
+
});
|
|
747
|
+
});
|
|
565
748
|
});
|
|
566
749
|
|
|
567
750
|
describe('Channel Routing - INAPP', () => {
|
|
@@ -991,244 +1174,4 @@ describe('UnifiedPreview', () => {
|
|
|
991
1174
|
consoleSpy.mockRestore();
|
|
992
1175
|
});
|
|
993
1176
|
});
|
|
994
|
-
|
|
995
|
-
describe('Channel Routing - WEBPUSH', () => {
|
|
996
|
-
it('should render WebPushPreviewContent for WEBPUSH channel with object content', () => {
|
|
997
|
-
const content = {
|
|
998
|
-
content: {
|
|
999
|
-
title: 'Hello World',
|
|
1000
|
-
message: 'This is a notification',
|
|
1001
|
-
iconImageUrl: 'https://example.com/icon.png',
|
|
1002
|
-
cta: { actionLink: 'https://example.com' },
|
|
1003
|
-
expandableDetails: {
|
|
1004
|
-
media: [{ url: 'https://example.com/image.jpg' }],
|
|
1005
|
-
ctas: [{ title: 'Click me', actionLink: 'https://example.com/btn', type: 'EXTERNAL_URL' }],
|
|
1006
|
-
},
|
|
1007
|
-
},
|
|
1008
|
-
};
|
|
1009
|
-
const props = { ...defaultProps, channel: CHANNELS.WEBPUSH, content };
|
|
1010
|
-
|
|
1011
|
-
render(
|
|
1012
|
-
<TestWrapper>
|
|
1013
|
-
<ComponentToRender {...props} />
|
|
1014
|
-
</TestWrapper>
|
|
1015
|
-
);
|
|
1016
|
-
|
|
1017
|
-
expect(screen.getByTestId('webpush-preview')).toBeTruthy();
|
|
1018
|
-
expect(screen.getByTestId('webpush-title')).toHaveTextContent('Hello World');
|
|
1019
|
-
expect(screen.getByTestId('webpush-body')).toHaveTextContent('This is a notification');
|
|
1020
|
-
expect(screen.getByTestId('webpush-icon')).toHaveTextContent('https://example.com/icon.png');
|
|
1021
|
-
expect(screen.getByTestId('webpush-url')).toHaveTextContent('https://example.com');
|
|
1022
|
-
});
|
|
1023
|
-
|
|
1024
|
-
it('should render WebPushPreviewContent for WEBPUSH channel with JSON string content', () => {
|
|
1025
|
-
const contentObj = {
|
|
1026
|
-
content: {
|
|
1027
|
-
title: 'Push Title',
|
|
1028
|
-
message: 'Push message body',
|
|
1029
|
-
iconImageUrl: 'https://example.com/brand.png',
|
|
1030
|
-
},
|
|
1031
|
-
};
|
|
1032
|
-
const props = {
|
|
1033
|
-
...defaultProps,
|
|
1034
|
-
channel: CHANNELS.WEBPUSH,
|
|
1035
|
-
content: JSON.stringify(contentObj),
|
|
1036
|
-
};
|
|
1037
|
-
|
|
1038
|
-
render(
|
|
1039
|
-
<TestWrapper>
|
|
1040
|
-
<ComponentToRender {...props} />
|
|
1041
|
-
</TestWrapper>
|
|
1042
|
-
);
|
|
1043
|
-
|
|
1044
|
-
expect(screen.getByTestId('webpush-preview')).toBeTruthy();
|
|
1045
|
-
expect(screen.getByTestId('webpush-title')).toHaveTextContent('Push Title');
|
|
1046
|
-
expect(screen.getByTestId('webpush-body')).toHaveTextContent('Push message body');
|
|
1047
|
-
expect(screen.getByTestId('webpush-icon')).toHaveTextContent('https://example.com/brand.png');
|
|
1048
|
-
});
|
|
1049
|
-
|
|
1050
|
-
it('should fallback to empty object when JSON parse fails', () => {
|
|
1051
|
-
const props = {
|
|
1052
|
-
...defaultProps,
|
|
1053
|
-
channel: CHANNELS.WEBPUSH,
|
|
1054
|
-
content: 'INVALID_JSON{{{{',
|
|
1055
|
-
};
|
|
1056
|
-
|
|
1057
|
-
render(
|
|
1058
|
-
<TestWrapper>
|
|
1059
|
-
<ComponentToRender {...props} />
|
|
1060
|
-
</TestWrapper>
|
|
1061
|
-
);
|
|
1062
|
-
|
|
1063
|
-
expect(screen.getByTestId('webpush-preview')).toBeTruthy();
|
|
1064
|
-
expect(screen.getByTestId('webpush-title')).toHaveTextContent('');
|
|
1065
|
-
expect(screen.getByTestId('webpush-body')).toHaveTextContent('');
|
|
1066
|
-
});
|
|
1067
|
-
|
|
1068
|
-
it('should fallback to empty object when content is null', () => {
|
|
1069
|
-
const props = { ...defaultProps, channel: CHANNELS.WEBPUSH, content: null };
|
|
1070
|
-
|
|
1071
|
-
render(
|
|
1072
|
-
<TestWrapper>
|
|
1073
|
-
<ComponentToRender {...props} />
|
|
1074
|
-
</TestWrapper>
|
|
1075
|
-
);
|
|
1076
|
-
|
|
1077
|
-
expect(screen.getByTestId('webpush-preview')).toBeTruthy();
|
|
1078
|
-
expect(screen.getByTestId('webpush-title')).toHaveTextContent('');
|
|
1079
|
-
});
|
|
1080
|
-
|
|
1081
|
-
it('should extract imageSrc from expandableDetails.media[0].url', () => {
|
|
1082
|
-
const content = {
|
|
1083
|
-
content: {
|
|
1084
|
-
title: 'T',
|
|
1085
|
-
message: 'M',
|
|
1086
|
-
expandableDetails: {
|
|
1087
|
-
media: [{ url: 'https://example.com/media.jpg' }],
|
|
1088
|
-
ctas: [],
|
|
1089
|
-
},
|
|
1090
|
-
},
|
|
1091
|
-
};
|
|
1092
|
-
const props = { ...defaultProps, channel: CHANNELS.WEBPUSH, content };
|
|
1093
|
-
|
|
1094
|
-
render(
|
|
1095
|
-
<TestWrapper>
|
|
1096
|
-
<ComponentToRender {...props} />
|
|
1097
|
-
</TestWrapper>
|
|
1098
|
-
);
|
|
1099
|
-
|
|
1100
|
-
expect(screen.getByTestId('webpush-image')).toHaveTextContent('https://example.com/media.jpg');
|
|
1101
|
-
});
|
|
1102
|
-
|
|
1103
|
-
it('should pass empty imageSrc when media array is empty', () => {
|
|
1104
|
-
const content = {
|
|
1105
|
-
content: {
|
|
1106
|
-
title: 'T',
|
|
1107
|
-
message: 'M',
|
|
1108
|
-
expandableDetails: { media: [], ctas: [] },
|
|
1109
|
-
},
|
|
1110
|
-
};
|
|
1111
|
-
const props = { ...defaultProps, channel: CHANNELS.WEBPUSH, content };
|
|
1112
|
-
|
|
1113
|
-
render(
|
|
1114
|
-
<TestWrapper>
|
|
1115
|
-
<ComponentToRender {...props} />
|
|
1116
|
-
</TestWrapper>
|
|
1117
|
-
);
|
|
1118
|
-
|
|
1119
|
-
expect(screen.getByTestId('webpush-image')).toHaveTextContent('');
|
|
1120
|
-
});
|
|
1121
|
-
|
|
1122
|
-
it('should map CTA buttons from expandableDetails.ctas', () => {
|
|
1123
|
-
const content = {
|
|
1124
|
-
content: {
|
|
1125
|
-
title: 'T',
|
|
1126
|
-
message: 'M',
|
|
1127
|
-
expandableDetails: {
|
|
1128
|
-
media: [],
|
|
1129
|
-
ctas: [
|
|
1130
|
-
{ title: 'Btn1', actionLink: 'https://a.com', type: 'EXTERNAL_URL' },
|
|
1131
|
-
{ title: 'Btn2', actionLink: 'https://b.com', type: 'SITE_URL' },
|
|
1132
|
-
],
|
|
1133
|
-
},
|
|
1134
|
-
},
|
|
1135
|
-
};
|
|
1136
|
-
const props = { ...defaultProps, channel: CHANNELS.WEBPUSH, content };
|
|
1137
|
-
|
|
1138
|
-
render(
|
|
1139
|
-
<TestWrapper>
|
|
1140
|
-
<ComponentToRender {...props} />
|
|
1141
|
-
</TestWrapper>
|
|
1142
|
-
);
|
|
1143
|
-
|
|
1144
|
-
const buttons = JSON.parse(screen.getByTestId('webpush-buttons').textContent);
|
|
1145
|
-
expect(buttons).toHaveLength(2);
|
|
1146
|
-
expect(buttons[0]).toEqual({ text: 'Btn1', url: 'https://a.com', type: 'EXTERNAL_URL' });
|
|
1147
|
-
expect(buttons[1]).toEqual({ text: 'Btn2', url: 'https://b.com', type: 'SITE_URL' });
|
|
1148
|
-
});
|
|
1149
|
-
|
|
1150
|
-
it('should pass empty buttons array when no ctas', () => {
|
|
1151
|
-
const content = { content: { title: 'T', message: 'M' } };
|
|
1152
|
-
const props = { ...defaultProps, channel: CHANNELS.WEBPUSH, content };
|
|
1153
|
-
|
|
1154
|
-
render(
|
|
1155
|
-
<TestWrapper>
|
|
1156
|
-
<ComponentToRender {...props} />
|
|
1157
|
-
</TestWrapper>
|
|
1158
|
-
);
|
|
1159
|
-
|
|
1160
|
-
const buttons = JSON.parse(screen.getByTestId('webpush-buttons').textContent);
|
|
1161
|
-
expect(buttons).toEqual([]);
|
|
1162
|
-
});
|
|
1163
|
-
|
|
1164
|
-
it('should NOT show device toggle for WEBPUSH channel', () => {
|
|
1165
|
-
const props = {
|
|
1166
|
-
...defaultProps,
|
|
1167
|
-
channel: CHANNELS.WEBPUSH,
|
|
1168
|
-
showDeviceToggle: true,
|
|
1169
|
-
showHeader: true,
|
|
1170
|
-
selectedCustomer: { name: 'Alice' },
|
|
1171
|
-
};
|
|
1172
|
-
|
|
1173
|
-
render(
|
|
1174
|
-
<TestWrapper>
|
|
1175
|
-
<ComponentToRender {...props} />
|
|
1176
|
-
</TestWrapper>
|
|
1177
|
-
);
|
|
1178
|
-
|
|
1179
|
-
// PreviewHeader is mocked - verify it receives showDeviceToggle=false for WEBPUSH
|
|
1180
|
-
const header = screen.getByTestId('preview-header');
|
|
1181
|
-
expect(header).toBeTruthy();
|
|
1182
|
-
});
|
|
1183
|
-
|
|
1184
|
-
it('should include WEBPUSH in supported channels list', () => {
|
|
1185
|
-
const props = { ...defaultProps, channel: CHANNELS.WEBPUSH, content: {} };
|
|
1186
|
-
|
|
1187
|
-
render(
|
|
1188
|
-
<TestWrapper>
|
|
1189
|
-
<ComponentToRender {...props} />
|
|
1190
|
-
</TestWrapper>
|
|
1191
|
-
);
|
|
1192
|
-
|
|
1193
|
-
// WEBPUSH should render WebPushPreviewContent, not the unsupported placeholder
|
|
1194
|
-
expect(screen.getByTestId('webpush-preview')).toBeTruthy();
|
|
1195
|
-
expect(screen.queryByText(/Coming Soon/)).toBeNull();
|
|
1196
|
-
});
|
|
1197
|
-
|
|
1198
|
-
it('should pass isUpdating to WebPushPreviewContent in loading state', () => {
|
|
1199
|
-
const props = {
|
|
1200
|
-
...defaultProps,
|
|
1201
|
-
channel: CHANNELS.WEBPUSH,
|
|
1202
|
-
content: { content: { title: 'T', message: 'M' } },
|
|
1203
|
-
isUpdating: true,
|
|
1204
|
-
};
|
|
1205
|
-
|
|
1206
|
-
render(
|
|
1207
|
-
<TestWrapper>
|
|
1208
|
-
<ComponentToRender {...props} />
|
|
1209
|
-
</TestWrapper>
|
|
1210
|
-
);
|
|
1211
|
-
|
|
1212
|
-
// When isUpdating, component shows loading spinner, not WebPushPreviewContent
|
|
1213
|
-
expect(screen.queryByTestId('webpush-preview')).toBeNull();
|
|
1214
|
-
});
|
|
1215
|
-
|
|
1216
|
-
it('should pass error to WebPushPreviewContent in error state', () => {
|
|
1217
|
-
const props = {
|
|
1218
|
-
...defaultProps,
|
|
1219
|
-
channel: CHANNELS.WEBPUSH,
|
|
1220
|
-
content: { content: { title: 'T', message: 'M' } },
|
|
1221
|
-
error: 'Network error',
|
|
1222
|
-
};
|
|
1223
|
-
|
|
1224
|
-
render(
|
|
1225
|
-
<TestWrapper>
|
|
1226
|
-
<ComponentToRender {...props} />
|
|
1227
|
-
</TestWrapper>
|
|
1228
|
-
);
|
|
1229
|
-
|
|
1230
|
-
// When error, component shows error state, not WebPushPreviewContent
|
|
1231
|
-
expect(screen.queryByTestId('webpush-preview')).toBeNull();
|
|
1232
|
-
});
|
|
1233
|
-
});
|
|
1234
1177
|
});
|
|
@@ -179,11 +179,10 @@ describe('CommonTestAndPreview Constants', () => {
|
|
|
179
179
|
expect(CHANNELS.MOBILEPUSH).toBe('MOBILEPUSH');
|
|
180
180
|
expect(CHANNELS.VIBER).toBe('VIBER');
|
|
181
181
|
expect(CHANNELS.ZALO).toBe('ZALO');
|
|
182
|
-
expect(CHANNELS.WEBPUSH).toBe('WEBPUSH');
|
|
183
182
|
});
|
|
184
183
|
|
|
185
184
|
it('should have all required channel keys', () => {
|
|
186
|
-
const expectedChannels = ['EMAIL', 'SMS', 'RCS', 'WHATSAPP', 'INAPP', 'MOBILEPUSH', 'VIBER', 'ZALO'
|
|
185
|
+
const expectedChannels = ['EMAIL', 'SMS', 'RCS', 'WHATSAPP', 'INAPP', 'MOBILEPUSH', 'VIBER', 'ZALO'];
|
|
187
186
|
expect(Object.keys(CHANNELS)).toEqual(expect.arrayContaining(expectedChannels));
|
|
188
187
|
expect(Object.keys(CHANNELS).length).toBe(expectedChannels.length);
|
|
189
188
|
});
|