@capillarytech/creatives-library 9.2.0 → 9.2.1-alpha.sprint-cap-214249.42
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 +0 -1
- package/package.json +1 -1
- package/utils/common.js +0 -6
- package/utils/createMobilePushPayload.js +56 -51
- package/utils/tests/createMobilePushPayload.test.js +162 -10
- package/v2Components/CapMpushCTA/index.js +47 -57
- package/v2Components/CapMpushCTA/index.scss +43 -5
- package/v2Components/CapMpushCTA/tests/index.test.js +150 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +11 -8
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +13 -1
- package/v2Components/CommonTestAndPreview/constants.js +2 -0
- package/v2Components/CommonTestAndPreview/index.js +48 -10
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +83 -5
- package/v2Components/CommonTestAndPreview/tests/index.test.js +86 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +12 -2
- package/v2Components/TemplatePreview/index.js +14 -12
- package/v2Components/TemplatePreview/tests/index.test.js +69 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +4 -6
- package/v2Containers/CreativesContainer/index.js +2 -1
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +43 -0
- package/v2Containers/MobilePushNew/components/CtaButtons.js +52 -47
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +314 -222
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +161 -130
- package/v2Containers/MobilePushNew/components/TapLinkActions.js +76 -0
- package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +30 -208
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +484 -123
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +152 -46
- package/v2Containers/MobilePushNew/constants.js +12 -0
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +63 -1
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +78 -0
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +40 -1
- package/v2Containers/MobilePushNew/hooks/useUpload.js +42 -46
- package/v2Containers/MobilePushNew/index.js +503 -273
- package/v2Containers/MobilePushNew/index.scss +215 -4
- package/v2Containers/MobilePushNew/messages.js +106 -6
- package/v2Containers/MobilePushNew/tests/index.test.js +482 -1
- package/v2Containers/MobilePushNew/tests/utils.test.js +122 -0
- package/v2Containers/MobilePushNew/utils.js +107 -0
- package/v2Containers/Templates/_templates.scss +10 -2
- package/v2Containers/Templates/index.js +83 -81
- package/v2Containers/Templates/tests/index.test.js +68 -0
|
@@ -602,6 +602,92 @@ describe('CommonTestAndPreview', () => {
|
|
|
602
602
|
});
|
|
603
603
|
});
|
|
604
604
|
|
|
605
|
+
describe('Mobile push video payload - handleSendTestMessage', () => {
|
|
606
|
+
// resetMocks in the jest config wipes the module mock's implementation before each test
|
|
607
|
+
beforeEach(() => {
|
|
608
|
+
// eslint-disable-next-line global-require
|
|
609
|
+
require('../../../utils/cdnTransformation').getCdnUrl.mockImplementation(({ url }) => `cdn_${url}`);
|
|
610
|
+
});
|
|
611
|
+
|
|
612
|
+
const sendAndGetContent = async (props) => {
|
|
613
|
+
render(
|
|
614
|
+
<TestWrapper>
|
|
615
|
+
<CommonTestAndPreview {...defaultProps} channel={CHANNELS.MOBILEPUSH} {...props} />
|
|
616
|
+
</TestWrapper>
|
|
617
|
+
);
|
|
618
|
+
await waitFor(() => expect(lastSendTestMessageProps).toBeTruthy());
|
|
619
|
+
lastSendTestMessageProps.handleSendTestMessage();
|
|
620
|
+
const [payload] = mockActions.createMessageMetaRequested.mock.calls[0];
|
|
621
|
+
return payload.mpushMessageContent;
|
|
622
|
+
};
|
|
623
|
+
|
|
624
|
+
it('sends a VIDEO style with the raw video url from the edit flow form data', async () => {
|
|
625
|
+
const { androidContent, iosContent } = await sendAndGetContent({
|
|
626
|
+
formData: [
|
|
627
|
+
{ 'message-title': 'T', 'message-editor': 'M', image: 'old.jpg', video: 'https://s3/a.mp4' },
|
|
628
|
+
{ 'message-title2': 'T2', 'message-editor2': 'M2', image: 'ios.jpg', video: '' },
|
|
629
|
+
],
|
|
630
|
+
});
|
|
631
|
+
expect(androidContent.type).toBe('VIDEO');
|
|
632
|
+
expect(androidContent.expandableDetails.style).toBe('VIDEO');
|
|
633
|
+
expect(androidContent.expandableDetails.media).toEqual([{ url: 'https://s3/a.mp4', text: '', type: 'VIDEO' }]);
|
|
634
|
+
expect(androidContent.expandableDetails.image).toBeUndefined();
|
|
635
|
+
expect(iosContent.type).toBe('IMAGE');
|
|
636
|
+
expect(iosContent.expandableDetails.style).toBe('BIG_PICTURE');
|
|
637
|
+
expect(iosContent.expandableDetails.image).toBe('cdn_ios.jpg');
|
|
638
|
+
expect(iosContent.expandableDetails.media).toBeUndefined();
|
|
639
|
+
});
|
|
640
|
+
|
|
641
|
+
it('reads bodyVideo from the list (three-dots) content, but not for a GIF', async () => {
|
|
642
|
+
const { androidContent, iosContent } = await sendAndGetContent({
|
|
643
|
+
formData: undefined,
|
|
644
|
+
content: {
|
|
645
|
+
androidContent: { header: 'T', bodyText: 'M', bodyVideo: { videoSrc: 'https://s3/a.mp4' } },
|
|
646
|
+
iosContent: { header: 'T2', bodyText: 'M2', bodyVideo: { videoSrc: 'https://s3/b.gif' }, bodyGif: 'https://s3/b.gif' },
|
|
647
|
+
},
|
|
648
|
+
});
|
|
649
|
+
expect(androidContent.expandableDetails.media).toEqual([{ url: 'https://s3/a.mp4', text: '', type: 'VIDEO' }]);
|
|
650
|
+
expect(androidContent.type).toBe('VIDEO');
|
|
651
|
+
expect(iosContent.type).toBe('TEXT');
|
|
652
|
+
expect(iosContent.expandableDetails.style).toBe('BIG_TEXT');
|
|
653
|
+
expect(iosContent.expandableDetails.media).toBeUndefined();
|
|
654
|
+
});
|
|
655
|
+
|
|
656
|
+
const imageCard = { mediaType: 'image', imageUrl: 'https://s3/1.png', videoSrc: '', buttons: [] };
|
|
657
|
+
const videoCard = { mediaType: 'video', imageUrl: '', videoSrc: 'https://s3/2.mp4', buttons: [] };
|
|
658
|
+
|
|
659
|
+
it('sends carousel cards and the media list from the edit flow form data', async () => {
|
|
660
|
+
const { androidContent, iosContent } = await sendAndGetContent({
|
|
661
|
+
formData: [
|
|
662
|
+
{ 'message-title': 'T', 'message-editor': 'M', image: '', video: '', carouselData: [imageCard, videoCard] },
|
|
663
|
+
{ 'message-title2': 'T2', 'message-editor2': 'M2', image: '', video: '', carouselData: [] },
|
|
664
|
+
],
|
|
665
|
+
});
|
|
666
|
+
expect(androidContent.type).toBe('CAROUSEL');
|
|
667
|
+
expect(androidContent.expandableDetails.style).toBe('MANUAL_CAROUSEL');
|
|
668
|
+
expect(androidContent.expandableDetails.carouselData).toEqual([imageCard, videoCard]);
|
|
669
|
+
expect(androidContent.expandableDetails.media).toEqual([
|
|
670
|
+
{ url: 'https://s3/1.png', type: 'IMAGE', text: '' },
|
|
671
|
+
{ url: 'https://s3/2.mp4', type: 'VIDEO', text: '' },
|
|
672
|
+
]);
|
|
673
|
+
expect(iosContent.type).toBe('TEXT');
|
|
674
|
+
expect(iosContent.expandableDetails.carouselData).toBeUndefined();
|
|
675
|
+
});
|
|
676
|
+
|
|
677
|
+
it('sends saved carousel cards from the list (three-dots) content', async () => {
|
|
678
|
+
const { iosContent } = await sendAndGetContent({
|
|
679
|
+
formData: undefined,
|
|
680
|
+
content: {
|
|
681
|
+
androidContent: { header: 'T', bodyText: 'M' },
|
|
682
|
+
iosContent: { header: 'T2', bodyText: 'M2', carouselData: [videoCard] },
|
|
683
|
+
},
|
|
684
|
+
});
|
|
685
|
+
expect(iosContent.type).toBe('CAROUSEL');
|
|
686
|
+
expect(iosContent.expandableDetails.style).toBe('MANUAL_CAROUSEL');
|
|
687
|
+
expect(iosContent.expandableDetails.media).toEqual([{ url: 'https://s3/2.mp4', type: 'VIDEO', text: '' }]);
|
|
688
|
+
});
|
|
689
|
+
});
|
|
690
|
+
|
|
605
691
|
describe('Carousel payload (getCarouselMappedData) - handleSendTestMessage', () => {
|
|
606
692
|
it('should map empty carouselData to empty cards when mediaType is CAROUSEL', async () => {
|
|
607
693
|
const props = {
|
|
@@ -745,13 +745,23 @@
|
|
|
745
745
|
justify-content: space-between;
|
|
746
746
|
flex-direction: row;
|
|
747
747
|
gap: $CAP_SPACE_08;
|
|
748
|
+
width: 100%;
|
|
749
|
+
// One button: centred. Two: equal halves, each centred, split by a divider.
|
|
748
750
|
.action{
|
|
751
|
+
flex: 1 1 0;
|
|
752
|
+
min-width: 0;
|
|
753
|
+
text-align: center;
|
|
754
|
+
white-space: nowrap;
|
|
755
|
+
overflow: hidden;
|
|
756
|
+
text-overflow: ellipsis;
|
|
749
757
|
font-size: $FONT_SIZE_S;
|
|
750
758
|
font-weight: 600;
|
|
751
|
-
color:
|
|
759
|
+
color: $FONT_COLOR_01;
|
|
752
760
|
height: 1.25rem;
|
|
753
|
-
text-transform: uppercase;
|
|
754
761
|
cursor: pointer;
|
|
762
|
+
& + .action {
|
|
763
|
+
border-left: 1px solid $CAP_G07;
|
|
764
|
+
}
|
|
755
765
|
&:hover {
|
|
756
766
|
text-decoration: underline;
|
|
757
767
|
}
|
|
@@ -168,14 +168,15 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
168
168
|
};
|
|
169
169
|
|
|
170
170
|
renderMobilePushCarousel = (content) => {
|
|
171
|
+
// Every card shows, even before its media is uploaded (an empty card keeps its place)
|
|
171
172
|
if (!content?.carouselData || content?.carouselData?.length === 0) {
|
|
172
173
|
return null;
|
|
173
174
|
}
|
|
174
175
|
|
|
175
176
|
return (
|
|
176
177
|
<CapRow type="flex" vertical noWrap className="msg-container-carousel mobile-push-carousel-container">
|
|
177
|
-
<CapRow className="scroll-container mobile-push-scroll-container">
|
|
178
|
-
{content
|
|
178
|
+
<CapRow type="flex" noWrap className="scroll-container mobile-push-scroll-container">
|
|
179
|
+
{content.carouselData.map((item, idx) => (
|
|
179
180
|
<CapColumn
|
|
180
181
|
key={`carousel-card-${idx}`}
|
|
181
182
|
className="mobile-push-carousel-card message-pop align-left message-pop-carousel"
|
|
@@ -187,10 +188,11 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
187
188
|
className="carousel-image"
|
|
188
189
|
/>
|
|
189
190
|
)}
|
|
190
|
-
{item?.mediaType?.toLowerCase() === VIDEO && item?.videoPreviewImg && (
|
|
191
|
+
{item?.mediaType?.toLowerCase() === VIDEO && (item?.videoPreviewImg || item?.videoSrc) && (
|
|
191
192
|
<CapRow className="video-preview">
|
|
193
|
+
{/* No thumbnail from the upload: same placeholder as WhatsApp/RCS */}
|
|
192
194
|
<CapImage
|
|
193
|
-
src={item?.videoPreviewImg ||
|
|
195
|
+
src={item?.videoPreviewImg || whatsappVideoEmptyPreview}
|
|
194
196
|
alt="carousel-video-preview"
|
|
195
197
|
className="carousel-video-preview"
|
|
196
198
|
/>
|
|
@@ -907,17 +909,17 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
907
909
|
)}
|
|
908
910
|
{(content?.actions || []).filter((action) => action?.label)
|
|
909
911
|
.length && content?.carouselData?.length === 0 ? (
|
|
910
|
-
<CapRow className="actions">
|
|
912
|
+
<CapRow type="flex" noWrap className="actions">
|
|
911
913
|
{_.map(
|
|
912
914
|
content?.actions || [],
|
|
913
|
-
(action) =>
|
|
915
|
+
(action, index) =>
|
|
914
916
|
!!action?.label && (
|
|
915
917
|
<span
|
|
916
918
|
className="action"
|
|
917
|
-
key={`action-${
|
|
919
|
+
key={`action-${index}`}
|
|
918
920
|
title={action?.url || ''}
|
|
919
921
|
>
|
|
920
|
-
{action?.label
|
|
922
|
+
{action?.label}
|
|
921
923
|
</span>
|
|
922
924
|
)
|
|
923
925
|
)}
|
|
@@ -971,17 +973,17 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
971
973
|
)}
|
|
972
974
|
{(content?.actions || []).filter((action) => action?.label)
|
|
973
975
|
.length && content?.carouselData?.length === 0 ? (
|
|
974
|
-
<CapRow className="actions">
|
|
976
|
+
<CapRow type="flex" noWrap className="actions">
|
|
975
977
|
{_.map(
|
|
976
978
|
content?.actions || [],
|
|
977
|
-
(action) =>
|
|
979
|
+
(action, index) =>
|
|
978
980
|
!!action?.label && (
|
|
979
981
|
<span
|
|
980
982
|
className="action"
|
|
981
|
-
key={`action-${
|
|
983
|
+
key={`action-${index}`}
|
|
982
984
|
title={action?.url || ''}
|
|
983
985
|
>
|
|
984
|
-
{action?.label
|
|
986
|
+
{action?.label}
|
|
985
987
|
</span>
|
|
986
988
|
)
|
|
987
989
|
)}
|
|
@@ -73,6 +73,75 @@ describe('Test Templates container', () => {
|
|
|
73
73
|
expect(renderedComponent).toMatchSnapshot();
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
+
describe('Mobile push action buttons', () => {
|
|
77
|
+
const renderMobilePush = (device, actions) => {
|
|
78
|
+
renderedComponent = shallowWithIntl(
|
|
79
|
+
<TemplatePreview
|
|
80
|
+
channel="MOBILEPUSH"
|
|
81
|
+
device={device}
|
|
82
|
+
content={{ header: 'Title', bodyText: 'Body', actions, carouselData: [] }}
|
|
83
|
+
/>,
|
|
84
|
+
);
|
|
85
|
+
return renderedComponent.find('.actions');
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
it.each(['android', 'ios'])('renders labels as typed on one flex row with index keys (%s)', (device) => {
|
|
89
|
+
const row = renderMobilePush(device, [
|
|
90
|
+
{ label: 'Shop', url: 'https://a.com' },
|
|
91
|
+
{ label: 'Shop' },
|
|
92
|
+
{ label: '' },
|
|
93
|
+
]);
|
|
94
|
+
const buttons = row.find('.action');
|
|
95
|
+
|
|
96
|
+
expect(row.props()).toEqual(expect.objectContaining({ type: 'flex', noWrap: true }));
|
|
97
|
+
expect(buttons).toHaveLength(2);
|
|
98
|
+
expect(buttons.map((button) => button.key())).toEqual(['action-0', 'action-1']);
|
|
99
|
+
expect(buttons.map((button) => button.text())).toEqual(['Shop', 'Shop']);
|
|
100
|
+
expect(buttons.at(0).prop('title')).toBe('https://a.com');
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
const renderCarousel = (device, carouselData) => {
|
|
104
|
+
renderedComponent = shallowWithIntl(
|
|
105
|
+
<TemplatePreview
|
|
106
|
+
channel="MOBILEPUSH"
|
|
107
|
+
device={device}
|
|
108
|
+
content={{ header: 'Title', carouselData }}
|
|
109
|
+
/>,
|
|
110
|
+
);
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
it.each(['android', 'ios'])('shows every card, with or without media, in one horizontal row (%s)', (device) => {
|
|
114
|
+
renderCarousel(device, [
|
|
115
|
+
{ mediaType: 'IMAGE', imageUrl: 'https://a.url' },
|
|
116
|
+
{ mediaType: 'IMAGE' },
|
|
117
|
+
{ mediaType: 'VIDEO', videoPreviewImg: 'https://b.url' },
|
|
118
|
+
]);
|
|
119
|
+
const scrollRow = renderedComponent.find('.scroll-container');
|
|
120
|
+
|
|
121
|
+
expect(scrollRow.props()).toEqual(expect.objectContaining({ type: 'flex', noWrap: true }));
|
|
122
|
+
expect(renderedComponent.find('.mobile-push-carousel-card')).toHaveLength(3);
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
it.each(['android', 'ios'])('shows a video card with no thumbnail as the video placeholder (%s)', (device) => {
|
|
126
|
+
renderCarousel(device, [{ mediaType: 'video', videoSrc: 'https://v.mp4' }]);
|
|
127
|
+
expect(renderedComponent.find('.mobile-push-carousel-card')).toHaveLength(1);
|
|
128
|
+
expect(renderedComponent.find('video')).toHaveLength(0);
|
|
129
|
+
expect(renderedComponent.find('.carousel-video-preview').prop('src')).toBe('test-file-stub');
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it.each(['android', 'ios'])('shows an empty card while no media is uploaded (%s)', (device) => {
|
|
133
|
+
renderCarousel(device, [{ mediaType: 'IMAGE' }]);
|
|
134
|
+
expect(renderedComponent.find('.mobile-push-carousel-container')).toHaveLength(1);
|
|
135
|
+
expect(renderedComponent.find('.mobile-push-carousel-card')).toHaveLength(1);
|
|
136
|
+
expect(renderedComponent.find('.carousel-image')).toHaveLength(0);
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
it.each(['android', 'ios'])('shows no carousel when there are no cards (%s)', (device) => {
|
|
140
|
+
renderCarousel(device, []);
|
|
141
|
+
expect(renderedComponent.find('.mobile-push-carousel-container')).toHaveLength(0);
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
|
|
76
145
|
describe('RCS carousel preview branches', () => {
|
|
77
146
|
const buildRcsContent = (cards) => ({
|
|
78
147
|
rcsPreviewContent: {
|
|
@@ -846,9 +846,7 @@ export function SlideBoxContent(props) {
|
|
|
846
846
|
})()
|
|
847
847
|
)}
|
|
848
848
|
{isEditMPush && (
|
|
849
|
-
|
|
850
|
-
(!isFullMode && isLoyaltyModule) ||
|
|
851
|
-
(!isFullMode && !isLoyaltyModule && !commonUtil.hasNewMobilePushFeatureEnabled()) ? (
|
|
849
|
+
!isFullMode && isLoyaltyModule ? (
|
|
852
850
|
<MobliPushEdit
|
|
853
851
|
getFormLibraryData={getFormData}
|
|
854
852
|
setIsLoadingContent={setIsLoadingContent}
|
|
@@ -910,6 +908,8 @@ export function SlideBoxContent(props) {
|
|
|
910
908
|
waitEventContextTags={waitEventContextTags}
|
|
911
909
|
showLiquidErrorInFooter={showLiquidErrorInFooter}
|
|
912
910
|
handleClose={handleClose}
|
|
911
|
+
showTestAndPreviewSlidebox={showTestAndPreviewSlidebox}
|
|
912
|
+
handleCloseTestAndPreview={handleCloseTestAndPreview}
|
|
913
913
|
restrictPersonalization={restrictPersonalization}
|
|
914
914
|
isAnonymousType={isAnonymousType}
|
|
915
915
|
onPersonalizationTokensChange={onPersonalizationTokensChange}
|
|
@@ -918,9 +918,7 @@ export function SlideBoxContent(props) {
|
|
|
918
918
|
)
|
|
919
919
|
)}
|
|
920
920
|
{isCreateMPush && (
|
|
921
|
-
|
|
922
|
-
(!isFullMode && isLoyaltyModule) ||
|
|
923
|
-
(!isFullMode && !isLoyaltyModule && !commonUtil.hasNewMobilePushFeatureEnabled()) ? (
|
|
921
|
+
!isFullMode && isLoyaltyModule ? (
|
|
924
922
|
<MobilepushWrapper
|
|
925
923
|
key="creatives-mobilepush-wrapper"
|
|
926
924
|
date={new Date().getMilliseconds()}
|
|
@@ -1042,7 +1042,8 @@ export class Creatives extends React.Component {
|
|
|
1042
1042
|
newExpandableDetails.message = expandableDetails.message || '';
|
|
1043
1043
|
newExpandableDetails.ctas = expandableDetails.ctas || [];
|
|
1044
1044
|
newExpandableDetails.media = expandableDetails.carouselData.map((carousel) => ({
|
|
1045
|
-
url
|
|
1045
|
+
// Video cards keep their url in videoSrc
|
|
1046
|
+
url: carousel?.mediaType?.toUpperCase() === VIDEO ? carousel.videoSrc : carousel.imageUrl,
|
|
1046
1047
|
type: carousel?.mediaType?.toUpperCase(),
|
|
1047
1048
|
text: '',
|
|
1048
1049
|
}));
|
|
@@ -4,6 +4,9 @@ import { SlideBoxContent } from '../SlideBoxContent';
|
|
|
4
4
|
import mockdata from '../../mockdata';
|
|
5
5
|
import { templateDetailsImage, templateDetailsVideo, templateDetailsText, templateDetails_ } from '../../Viber/tests/mockData';
|
|
6
6
|
import { CREATE, RICH_MEDIA } from '../../WeChat/Wrapper/constants';
|
|
7
|
+
import MobilePushNew from '../../MobilePushNew';
|
|
8
|
+
import MobilepushWrapper from '../../MobilepushWrapper';
|
|
9
|
+
import MobliPushEdit from '../../MobilePush/Edit';
|
|
7
10
|
|
|
8
11
|
const {
|
|
9
12
|
whatsappEditTemplateData,
|
|
@@ -1015,4 +1018,44 @@ describe('Test SlideBoxContent container', () => {
|
|
|
1015
1018
|
});
|
|
1016
1019
|
|
|
1017
1020
|
});
|
|
1021
|
+
|
|
1022
|
+
describe('Mobile push editor choice', () => {
|
|
1023
|
+
const editTemplateData = { _id: 'mp-1', type: 'MOBILEPUSH' };
|
|
1024
|
+
|
|
1025
|
+
it.each([
|
|
1026
|
+
['full mode', { isFullMode: true }],
|
|
1027
|
+
['embedded outside Loyalty', { isFullMode: false, isLoyaltyModule: false }],
|
|
1028
|
+
])('opens the new editor for create and edit in %s', (_, modeProps) => {
|
|
1029
|
+
renderFunction('MOBILEPUSH', 'createTemplate', { mode: 'create' }, modeProps);
|
|
1030
|
+
expect(renderedComponent.find(MobilePushNew).exists()).toBe(true);
|
|
1031
|
+
expect(renderedComponent.find(MobilepushWrapper).exists()).toBe(false);
|
|
1032
|
+
|
|
1033
|
+
renderFunction('MOBILEPUSH', 'editTemplate', editTemplateData, modeProps);
|
|
1034
|
+
expect(renderedComponent.find(MobilePushNew).exists()).toBe(true);
|
|
1035
|
+
expect(renderedComponent.find(MobliPushEdit).exists()).toBe(false);
|
|
1036
|
+
});
|
|
1037
|
+
|
|
1038
|
+
it('passes the footer Test & Preview state to the new editor in edit', () => {
|
|
1039
|
+
const handleCloseTestAndPreview = jest.fn();
|
|
1040
|
+
renderFunction('MOBILEPUSH', 'editTemplate', editTemplateData, {
|
|
1041
|
+
isFullMode: true,
|
|
1042
|
+
showTestAndPreviewSlidebox: true,
|
|
1043
|
+
handleCloseTestAndPreview,
|
|
1044
|
+
});
|
|
1045
|
+
const editor = renderedComponent.find(MobilePushNew);
|
|
1046
|
+
expect(editor.prop('showTestAndPreviewSlidebox')).toBe(true);
|
|
1047
|
+
expect(editor.prop('handleCloseTestAndPreview')).toBe(handleCloseTestAndPreview);
|
|
1048
|
+
});
|
|
1049
|
+
|
|
1050
|
+
it('keeps the old editor when embedded in Loyalty', () => {
|
|
1051
|
+
const loyaltyProps = { isFullMode: false, isLoyaltyModule: true };
|
|
1052
|
+
renderFunction('MOBILEPUSH', 'createTemplate', { mode: 'create' }, loyaltyProps);
|
|
1053
|
+
expect(renderedComponent.find(MobilepushWrapper).exists()).toBe(true);
|
|
1054
|
+
expect(renderedComponent.find(MobilePushNew).exists()).toBe(false);
|
|
1055
|
+
|
|
1056
|
+
renderFunction('MOBILEPUSH', 'editTemplate', editTemplateData, loyaltyProps);
|
|
1057
|
+
expect(renderedComponent.find(MobliPushEdit).exists()).toBe(true);
|
|
1058
|
+
expect(renderedComponent.find(MobilePushNew).exists()).toBe(false);
|
|
1059
|
+
});
|
|
1060
|
+
});
|
|
1018
1061
|
});
|
|
@@ -5,16 +5,20 @@ import CapRow from "@capillarytech/cap-ui-library/CapRow";
|
|
|
5
5
|
import CapButton from "@capillarytech/cap-ui-library/CapButton";
|
|
6
6
|
import CapIcon from "@capillarytech/cap-ui-library/CapIcon";
|
|
7
7
|
import CapHeading from "@capillarytech/cap-ui-library/CapHeading";
|
|
8
|
-
import
|
|
8
|
+
import CapLabel from "@capillarytech/cap-ui-library/CapLabel";
|
|
9
|
+
// import CapTooltip from "@capillarytech/cap-ui-library/CapTooltip";
|
|
9
10
|
import CapMpushCTA from "../../../v2Components/CapMpushCTA";
|
|
10
|
-
import { PRIMARY,
|
|
11
|
+
import { PRIMARY, DEEP_LINK } from "../constants";
|
|
12
|
+
// import { SECONDARY } from "../constants";
|
|
11
13
|
import messages from "../messages";
|
|
12
14
|
|
|
15
|
+
// Secondary button is commented out below: it needs backend support, so it is being revamped.
|
|
16
|
+
// Restore the commented secondaryButton / setSecondaryButton props, state, handler and JSX together.
|
|
13
17
|
const CtaButtons = ({
|
|
14
18
|
primaryButton,
|
|
15
|
-
secondaryButton,
|
|
19
|
+
// secondaryButton,
|
|
16
20
|
setPrimaryButton,
|
|
17
|
-
setSecondaryButton,
|
|
21
|
+
// setSecondaryButton,
|
|
18
22
|
ctaData,
|
|
19
23
|
updateHandler,
|
|
20
24
|
deleteHandler,
|
|
@@ -27,7 +31,7 @@ const CtaButtons = ({
|
|
|
27
31
|
}) => {
|
|
28
32
|
// Local state to control CTA form visibility
|
|
29
33
|
const [showPrimaryCTA, setShowPrimaryCTA] = useState(false);
|
|
30
|
-
const [showSecondaryCTA, setShowSecondaryCTA] = useState(false);
|
|
34
|
+
// const [showSecondaryCTA, setShowSecondaryCTA] = useState(false);
|
|
31
35
|
|
|
32
36
|
const handleAddPrimary = () => {
|
|
33
37
|
// Prevent multiple clicks if primary button is already being added or form is already showing
|
|
@@ -53,68 +57,67 @@ const CtaButtons = ({
|
|
|
53
57
|
setShowPrimaryCTA(true);
|
|
54
58
|
};
|
|
55
59
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
isSaved: false,
|
|
77
|
-
};
|
|
78
|
-
updateHandler(newSecondaryButton, 1);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// setSecondaryButton(true);
|
|
82
|
-
// setShowSecondaryCTA(true);
|
|
83
|
-
};
|
|
60
|
+
// Secondary button: needs backend support, revamped
|
|
61
|
+
// const handleAddSecondary = () => {
|
|
62
|
+
// if (secondaryButton && showSecondaryCTA) {
|
|
63
|
+
// return;
|
|
64
|
+
// }
|
|
65
|
+
// if (ctaData?.length < 2 || !ctaData?.find((cta) => cta?.index === 1)) {
|
|
66
|
+
// const newSecondaryButton = {
|
|
67
|
+
// index: 1,
|
|
68
|
+
// ctaType: SECONDARY,
|
|
69
|
+
// text: "",
|
|
70
|
+
// urlType: DEEP_LINK,
|
|
71
|
+
// url: "",
|
|
72
|
+
// deepLinkKeys: "",
|
|
73
|
+
// isSaved: false,
|
|
74
|
+
// };
|
|
75
|
+
// updateHandler(newSecondaryButton, 1);
|
|
76
|
+
// }
|
|
77
|
+
// setSecondaryButton(true);
|
|
78
|
+
// setShowSecondaryCTA(true);
|
|
79
|
+
// };
|
|
84
80
|
|
|
85
81
|
// Check if primary button exists (saved or being edited)
|
|
86
82
|
const primaryButtonExists = ctaData?.length > 0 && ctaData[0]?.text;
|
|
87
83
|
const isPrimaryButtonSaved = primaryButtonExists && ctaData[0]?.isSaved;
|
|
88
84
|
|
|
89
|
-
//
|
|
90
|
-
const secondaryButtonExists = ctaData?.length > 1 && ctaData[1]?.text;
|
|
91
|
-
const isSecondaryButtonSaved = secondaryButtonExists && ctaData[1]?.isSaved;
|
|
85
|
+
// Secondary button: needs backend support, revamped
|
|
86
|
+
// const secondaryButtonExists = ctaData?.length > 1 && ctaData[1]?.text;
|
|
87
|
+
// const isSecondaryButtonSaved = secondaryButtonExists && ctaData[1]?.isSaved;
|
|
92
88
|
|
|
93
89
|
// Show primary CTA if button is active and (form is showing OR button exists)
|
|
94
90
|
const shouldShowPrimaryCTA = primaryButton && (showPrimaryCTA || primaryButtonExists);
|
|
95
91
|
|
|
96
|
-
//
|
|
97
|
-
const shouldShowSecondaryCTA = secondaryButton && (showSecondaryCTA || secondaryButtonExists);
|
|
92
|
+
// Secondary button: needs backend support, revamped
|
|
93
|
+
// const shouldShowSecondaryCTA = secondaryButton && (showSecondaryCTA || secondaryButtonExists);
|
|
98
94
|
|
|
99
95
|
// Enhanced delete handler to hide forms when buttons are deleted
|
|
100
96
|
const handleDelete = (index) => {
|
|
101
97
|
if (index === 0) {
|
|
102
98
|
setShowPrimaryCTA(false);
|
|
103
99
|
setPrimaryButton(false);
|
|
104
|
-
} else if (index === 1) {
|
|
105
|
-
//cooment until supported from BE & Hydra
|
|
106
|
-
// setShowSecondaryCTA(false);
|
|
107
|
-
// setSecondaryButton(false);
|
|
108
100
|
}
|
|
101
|
+
// Secondary button: needs backend support, revamped
|
|
102
|
+
// else if (index === 1) {
|
|
103
|
+
// setShowSecondaryCTA(false);
|
|
104
|
+
// setSecondaryButton(false);
|
|
105
|
+
// }
|
|
109
106
|
deleteHandler(index);
|
|
110
107
|
};
|
|
111
108
|
|
|
112
109
|
return (
|
|
113
110
|
<>
|
|
114
111
|
<CapRow className="mpush-cta-buttons">
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
112
|
+
{/* Heading with "(Optional)" on the same line */}
|
|
113
|
+
<CapRow type="flex" align="middle" noWrap className="mpush-section-heading">
|
|
114
|
+
<CapHeading type="h3">
|
|
115
|
+
<FormattedMessage {...messages.buttons} />
|
|
116
|
+
</CapHeading>
|
|
117
|
+
<CapLabel className="optional-text">
|
|
118
|
+
<FormattedMessage {...messages.optionalText} />
|
|
119
|
+
</CapLabel>
|
|
120
|
+
</CapRow>
|
|
118
121
|
{!isPrimaryButtonSaved && !shouldShowPrimaryCTA && (
|
|
119
122
|
<CapButton
|
|
120
123
|
type="link"
|
|
@@ -142,6 +145,7 @@ const CtaButtons = ({
|
|
|
142
145
|
handleOnTagsContextChange={handleOnTagsContextChange}
|
|
143
146
|
/>
|
|
144
147
|
)}
|
|
148
|
+
{/* Secondary button: needs backend support, so it is being revamped. Hidden until then.
|
|
145
149
|
{isPrimaryButtonSaved && !isSecondaryButtonSaved && !shouldShowSecondaryCTA && (
|
|
146
150
|
<CapTooltip
|
|
147
151
|
overlay={<FormattedMessage {...messages.secondaryButtonTooltip} />}
|
|
@@ -171,15 +175,16 @@ const CtaButtons = ({
|
|
|
171
175
|
buttonType={SECONDARY}
|
|
172
176
|
/>
|
|
173
177
|
)}
|
|
178
|
+
*/}
|
|
174
179
|
</>
|
|
175
180
|
);
|
|
176
181
|
};
|
|
177
182
|
|
|
178
183
|
CtaButtons.propTypes = {
|
|
179
184
|
primaryButton: PropTypes.bool.isRequired,
|
|
180
|
-
secondaryButton: PropTypes.bool.isRequired,
|
|
185
|
+
// secondaryButton: PropTypes.bool.isRequired,
|
|
181
186
|
setPrimaryButton: PropTypes.func.isRequired,
|
|
182
|
-
setSecondaryButton: PropTypes.func.isRequired,
|
|
187
|
+
// setSecondaryButton: PropTypes.func.isRequired,
|
|
183
188
|
ctaData: PropTypes.array.isRequired,
|
|
184
189
|
updateHandler: PropTypes.func.isRequired,
|
|
185
190
|
deleteHandler: PropTypes.func.isRequired,
|