@capillarytech/creatives-library 9.2.1-alpha.sprint-cap-214249.42 → 9.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/AppRoot.js +4 -7
- package/constants/unified.js +1 -0
- package/package.json +1 -1
- package/utils/beePluginLoader.js +106 -0
- package/utils/common.js +6 -0
- package/utils/createMobilePushPayload.js +51 -56
- package/utils/tests/beePluginLoader.test.js +199 -0
- package/utils/tests/createMobilePushPayload.test.js +10 -162
- package/v2Components/CapMpushCTA/index.js +57 -47
- package/v2Components/CapMpushCTA/index.scss +5 -43
- package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +8 -11
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -13
- package/v2Components/CommonTestAndPreview/constants.js +0 -2
- package/v2Components/CommonTestAndPreview/index.js +10 -48
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +5 -83
- package/v2Components/CommonTestAndPreview/tests/index.test.js +0 -86
- package/v2Components/TemplatePreview/_templatePreview.scss +2 -12
- package/v2Components/TemplatePreview/index.js +12 -14
- package/v2Components/TemplatePreview/tests/index.test.js +0 -69
- package/v2Containers/BeeEditor/index.js +49 -22
- package/v2Containers/BeeEditor/index.scss +12 -0
- package/v2Containers/BeeEditor/messages.js +8 -0
- package/v2Containers/BeeEditor/test/index.test.js +78 -0
- package/v2Containers/BeePopupEditor/index.js +22 -11
- package/v2Containers/CreativesContainer/SlideBoxContent.js +9 -5
- package/v2Containers/CreativesContainer/index.js +1 -2
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +0 -43
- package/v2Containers/Email/index.js +2 -2
- package/v2Containers/EmailWrapper/hooks/useEmailWrapper.js +25 -23
- package/v2Containers/MobilePushNew/components/CtaButtons.js +47 -52
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +222 -314
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +130 -161
- package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +208 -30
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +123 -484
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +46 -152
- package/v2Containers/MobilePushNew/constants.js +0 -12
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +1 -63
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +0 -78
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +1 -40
- package/v2Containers/MobilePushNew/hooks/useUpload.js +46 -42
- package/v2Containers/MobilePushNew/index.js +273 -503
- package/v2Containers/MobilePushNew/index.scss +4 -215
- package/v2Containers/MobilePushNew/messages.js +6 -106
- package/v2Containers/MobilePushNew/tests/index.test.js +1 -482
- package/v2Containers/MobilePushNew/tests/utils.test.js +0 -122
- package/v2Containers/MobilePushNew/utils.js +0 -107
- package/v2Containers/Templates/_templates.scss +2 -10
- package/v2Containers/Templates/index.js +81 -83
- package/v2Containers/Templates/tests/index.test.js +0 -68
- package/v2Components/CapMpushCTA/tests/index.test.js +0 -150
- package/v2Containers/MobilePushNew/components/TapLinkActions.js +0 -76
|
@@ -7,7 +7,7 @@ import { configureStore } from '@capillarytech/vulcan-react-sdk/utils';
|
|
|
7
7
|
import { initialReducer } from '../../../../initialReducer';
|
|
8
8
|
import history from '../../../../utils/history';
|
|
9
9
|
import MediaUploaders from '../MediaUploaders';
|
|
10
|
-
import { ANDROID, IOS
|
|
10
|
+
import { ANDROID, IOS } from '../../constants';
|
|
11
11
|
import { act } from 'react';
|
|
12
12
|
import messages from '../../messages';
|
|
13
13
|
|
|
@@ -202,27 +202,11 @@ jest.mock('../../../../v2Components/CapVideoUpload', () =>
|
|
|
202
202
|
<div data-testid="cap-video-upload">
|
|
203
203
|
<button
|
|
204
204
|
type="button"
|
|
205
|
-
|
|
206
|
-
onClick={() => props.onVideoUploadUpdateAssestList(0, { videoSrc: 'mock-video-url', previewUrl: 'mock-preview-url' })}
|
|
205
|
+
onClick={() => props.onVideoUploadUpdateAssestList('mock-video-url')}
|
|
207
206
|
data-testid="video-upload-button"
|
|
208
207
|
>
|
|
209
208
|
Upload Video
|
|
210
209
|
</button>
|
|
211
|
-
<button
|
|
212
|
-
type="button"
|
|
213
|
-
// Real Re upload clears the video, then opens the file picker
|
|
214
|
-
onClick={() => props.onVideoUploadUpdateAssestList(0, { videoSrc: '', previewUrl: '' })}
|
|
215
|
-
data-testid="video-reupload-button"
|
|
216
|
-
>
|
|
217
|
-
Re upload Video
|
|
218
|
-
</button>
|
|
219
|
-
<button
|
|
220
|
-
type="button"
|
|
221
|
-
onClick={() => props.uploadAsset({ name: 'test.mp4' }, 'video', {}, props.index)}
|
|
222
|
-
data-testid="video-file-upload-button"
|
|
223
|
-
>
|
|
224
|
-
Pick Video File
|
|
225
|
-
</button>
|
|
226
210
|
</div>
|
|
227
211
|
);
|
|
228
212
|
}
|
|
@@ -367,8 +351,8 @@ jest.mock('@capillarytech/cap-ui-library/CapRow', () =>
|
|
|
367
351
|
);
|
|
368
352
|
|
|
369
353
|
jest.mock('@capillarytech/cap-ui-library/CapColumn', () =>
|
|
370
|
-
function MockCapColumn({ children, className, span
|
|
371
|
-
return <div className={className} data-span={span}
|
|
354
|
+
function MockCapColumn({ children, className, span }) {
|
|
355
|
+
return <div className={className} data-span={span}>{children}</div>;
|
|
372
356
|
}
|
|
373
357
|
);
|
|
374
358
|
|
|
@@ -408,7 +392,6 @@ jest.mock('../../constants', () => ({
|
|
|
408
392
|
|
|
409
393
|
// Mock the utils
|
|
410
394
|
jest.mock('../../utils', () => ({
|
|
411
|
-
...jest.requireActual('../../utils'),
|
|
412
395
|
validateExternalLink: jest.fn(),
|
|
413
396
|
validateDeepLink: jest.fn(),
|
|
414
397
|
}));
|
|
@@ -505,62 +488,6 @@ jest.mock('../../messages', () => ({
|
|
|
505
488
|
id: 'creatives.containersV2.MobilePushNew.actionOnClickBody',
|
|
506
489
|
defaultMessage: 'Action on click of notification body',
|
|
507
490
|
},
|
|
508
|
-
tapLinkSaveDisabled: {
|
|
509
|
-
id: 'creatives.containersV2.MobilePushNew.tapLinkSaveDisabled',
|
|
510
|
-
defaultMessage: 'Please complete the above fields to enable Save',
|
|
511
|
-
},
|
|
512
|
-
cardTap: {
|
|
513
|
-
id: 'creatives.containersV2.MobilePushNew.cardTap',
|
|
514
|
-
defaultMessage: 'Card tap',
|
|
515
|
-
},
|
|
516
|
-
deepLinkRequired: {
|
|
517
|
-
id: 'creatives.containersV2.MobilePushNew.deepLinkRequired',
|
|
518
|
-
defaultMessage: 'Select a deep link',
|
|
519
|
-
},
|
|
520
|
-
urlNotValid: {
|
|
521
|
-
id: 'creatives.containersV2.MobilePushNew.urlNotValid',
|
|
522
|
-
defaultMessage: 'URL is not valid',
|
|
523
|
-
},
|
|
524
|
-
completeCardToAdd: {
|
|
525
|
-
id: 'creatives.containersV2.MobilePushNew.completeCardToAdd',
|
|
526
|
-
defaultMessage: 'Please set-up the first card before creating the next ones',
|
|
527
|
-
},
|
|
528
|
-
carouselMaxCardTooltip: {
|
|
529
|
-
id: 'creatives.containersV2.MobilePushNew.carouselMaxCardTooltip',
|
|
530
|
-
defaultMessage: 'Mobile push carousel cannot contain more than {max} content cards.',
|
|
531
|
-
},
|
|
532
|
-
cardTapDescription: {
|
|
533
|
-
id: 'creatives.containersV2.MobilePushNew.cardTapDescription',
|
|
534
|
-
defaultMessage: 'What happens when someone taps this card.',
|
|
535
|
-
},
|
|
536
|
-
cardTapAppHelp: {
|
|
537
|
-
id: 'creatives.containersV2.MobilePushNew.cardTapAppHelp',
|
|
538
|
-
defaultMessage: 'Opens your app. Choose a link to send people to a specific page from this card instead.',
|
|
539
|
-
},
|
|
540
|
-
whenTappedOpen: {
|
|
541
|
-
id: 'creatives.containersV2.MobilePushNew.whenTappedOpen',
|
|
542
|
-
defaultMessage: 'When tapped, open',
|
|
543
|
-
},
|
|
544
|
-
tapActionApp: {
|
|
545
|
-
id: 'creatives.containersV2.MobilePushNew.tapActionApp',
|
|
546
|
-
defaultMessage: 'App (default)',
|
|
547
|
-
},
|
|
548
|
-
tapActionDeepLink: {
|
|
549
|
-
id: 'creatives.containersV2.MobilePushNew.tapActionDeepLink',
|
|
550
|
-
defaultMessage: 'Deep link',
|
|
551
|
-
},
|
|
552
|
-
tapActionExternalLink: {
|
|
553
|
-
id: 'creatives.containersV2.MobilePushNew.tapActionExternalLink',
|
|
554
|
-
defaultMessage: 'External link',
|
|
555
|
-
},
|
|
556
|
-
url: {
|
|
557
|
-
id: 'creatives.containersV2.MobilePushNew.url',
|
|
558
|
-
defaultMessage: 'URL',
|
|
559
|
-
},
|
|
560
|
-
enterUrl: {
|
|
561
|
-
id: 'creatives.containersV2.MobilePushNew.enterUrl',
|
|
562
|
-
defaultMessage: 'Enter URL',
|
|
563
|
-
},
|
|
564
491
|
},
|
|
565
492
|
}));
|
|
566
493
|
|
|
@@ -692,7 +619,7 @@ describe('MediaUploaders', () => {
|
|
|
692
619
|
});
|
|
693
620
|
|
|
694
621
|
fireEvent.click(screen.getByTestId('video-upload-button'));
|
|
695
|
-
expect(setUpdateMpushVideoSrc).toHaveBeenCalledWith(
|
|
622
|
+
expect(setUpdateMpushVideoSrc).toHaveBeenCalledWith('mock-video-url');
|
|
696
623
|
});
|
|
697
624
|
});
|
|
698
625
|
|
|
@@ -710,7 +637,7 @@ describe('MediaUploaders', () => {
|
|
|
710
637
|
});
|
|
711
638
|
|
|
712
639
|
fireEvent.click(screen.getByTestId('video-upload-button'));
|
|
713
|
-
expect(setUpdateMpushVideoSrc).toHaveBeenCalledWith(
|
|
640
|
+
expect(setUpdateMpushVideoSrc).toHaveBeenCalledWith('mock-video-url');
|
|
714
641
|
});
|
|
715
642
|
});
|
|
716
643
|
|
|
@@ -725,7 +652,7 @@ describe('MediaUploaders', () => {
|
|
|
725
652
|
mediaType: 'image',
|
|
726
653
|
imageUrl: 'test.jpg',
|
|
727
654
|
buttons: [{
|
|
728
|
-
actionOnClick: true,
|
|
655
|
+
actionOnClick: true,
|
|
729
656
|
linkType: 'EXTERNAL_LINK',
|
|
730
657
|
deepLinkValue: '',
|
|
731
658
|
deepLinkKeys: [],
|
|
@@ -747,8 +674,9 @@ describe('MediaUploaders', () => {
|
|
|
747
674
|
const carouselCard = screen.getByText('Card 1');
|
|
748
675
|
expect(carouselCard).toBeInTheDocument();
|
|
749
676
|
|
|
750
|
-
|
|
751
|
-
|
|
677
|
+
// Check if the buttons and links section is rendered
|
|
678
|
+
const buttonsAndLinks = screen.getByText('Buttons and links');
|
|
679
|
+
expect(buttonsAndLinks).toBeInTheDocument();
|
|
752
680
|
});
|
|
753
681
|
|
|
754
682
|
it('should initialize carousel data when empty', () => {
|
|
@@ -810,7 +738,7 @@ describe('MediaUploaders', () => {
|
|
|
810
738
|
mediaType: 'image',
|
|
811
739
|
imageUrl: 'test.jpg',
|
|
812
740
|
buttons: [{
|
|
813
|
-
actionOnClick: true,
|
|
741
|
+
actionOnClick: true,
|
|
814
742
|
linkType: 'EXTERNAL_LINK',
|
|
815
743
|
deepLinkValue: '',
|
|
816
744
|
deepLinkKeys: [],
|
|
@@ -824,8 +752,15 @@ describe('MediaUploaders', () => {
|
|
|
824
752
|
formatMessage: mockFormatMessage,
|
|
825
753
|
});
|
|
826
754
|
|
|
827
|
-
|
|
755
|
+
// First check if the checkbox is checked
|
|
756
|
+
const actionOnClickCheckbox = screen.getByTestId('cap-checkbox');
|
|
757
|
+
expect(actionOnClickCheckbox).toBeChecked();
|
|
758
|
+
|
|
759
|
+
// First select the external link type
|
|
760
|
+
const linkTypeSelect = screen.getAllByTestId('cap-custom-select')[0];
|
|
761
|
+
fireEvent.change(linkTypeSelect, { target: { value: 'EXTERNAL_LINK' } });
|
|
828
762
|
|
|
763
|
+
// Wait for the external link input to be rendered
|
|
829
764
|
const externalLinkInput = screen.getByTestId('cap-input-mobile-push-external-link-input-ANDROID-0');
|
|
830
765
|
expect(externalLinkInput).toBeInTheDocument();
|
|
831
766
|
expect(externalLinkInput.value).toBe('https://example.com');
|
|
@@ -896,7 +831,7 @@ describe('MediaUploaders', () => {
|
|
|
896
831
|
</Provider>
|
|
897
832
|
);
|
|
898
833
|
|
|
899
|
-
expect(clearImageDataByMediaType).toHaveBeenCalledWith('IMAGE'
|
|
834
|
+
expect(clearImageDataByMediaType).toHaveBeenCalledWith('IMAGE');
|
|
900
835
|
});
|
|
901
836
|
|
|
902
837
|
it('should clear image data when switching from CAROUSEL to IMAGE', () => {
|
|
@@ -918,36 +853,7 @@ describe('MediaUploaders', () => {
|
|
|
918
853
|
</Provider>
|
|
919
854
|
);
|
|
920
855
|
|
|
921
|
-
expect(clearImageDataByMediaType).toHaveBeenCalledWith('IMAGE'
|
|
922
|
-
});
|
|
923
|
-
|
|
924
|
-
// A tab switch gives the hidden pane a new clearImageDataByMediaType; that alone must not clear anything
|
|
925
|
-
it('does not clear when only the callbacks change (tab switch), and clears its own platform on a real change', () => {
|
|
926
|
-
const firstClear = jest.fn();
|
|
927
|
-
const onCarouselDataChange = jest.fn();
|
|
928
|
-
const renderPane = (mediaType, clearImageDataByMediaType) => (
|
|
929
|
-
<Provider store={mockStore}>
|
|
930
|
-
<IntlProvider messages={messages} locale="en">
|
|
931
|
-
<MediaUploaders
|
|
932
|
-
{...defaultProps}
|
|
933
|
-
activeTab={IOS}
|
|
934
|
-
mediaType={mediaType}
|
|
935
|
-
clearImageDataByMediaType={clearImageDataByMediaType}
|
|
936
|
-
onCarouselDataChange={onCarouselDataChange}
|
|
937
|
-
/>
|
|
938
|
-
</IntlProvider>
|
|
939
|
-
</Provider>
|
|
940
|
-
);
|
|
941
|
-
const { rerender } = render(renderPane('VIDEO', firstClear));
|
|
942
|
-
|
|
943
|
-
const clearAfterTabSwitch = jest.fn();
|
|
944
|
-
rerender(renderPane('VIDEO', clearAfterTabSwitch));
|
|
945
|
-
expect(firstClear).not.toHaveBeenCalled();
|
|
946
|
-
expect(clearAfterTabSwitch).not.toHaveBeenCalled();
|
|
947
|
-
expect(onCarouselDataChange).not.toHaveBeenCalled();
|
|
948
|
-
|
|
949
|
-
rerender(renderPane('NONE', clearAfterTabSwitch));
|
|
950
|
-
expect(clearAfterTabSwitch).toHaveBeenCalledWith('IMAGE', IOS);
|
|
856
|
+
expect(clearImageDataByMediaType).toHaveBeenCalledWith('IMAGE');
|
|
951
857
|
});
|
|
952
858
|
});
|
|
953
859
|
|
|
@@ -1071,135 +977,6 @@ describe('MediaUploaders', () => {
|
|
|
1071
977
|
});
|
|
1072
978
|
|
|
1073
979
|
describe('Carousel card management', () => {
|
|
1074
|
-
const doneCard = (mediaType, media) => ({
|
|
1075
|
-
mediaType,
|
|
1076
|
-
imageUrl: mediaType === 'image' ? media : '',
|
|
1077
|
-
videoSrc: mediaType === 'video' ? media : '',
|
|
1078
|
-
buttons: [{ actionOnClick: false, linkType: 'DEEP_LINK', deepLinkValue: '', externalLinkValue: '' }],
|
|
1079
|
-
});
|
|
1080
|
-
|
|
1081
|
-
it('opens the new card after adding it', () => {
|
|
1082
|
-
const onCarouselDataChange = jest.fn();
|
|
1083
|
-
const setCarouselActiveTabIndex = jest.fn();
|
|
1084
|
-
renderComponent({
|
|
1085
|
-
mediaType: 'CAROUSEL',
|
|
1086
|
-
carouselData: [doneCard('image', 'a.jpg'), doneCard('image', 'b.jpg')],
|
|
1087
|
-
onCarouselDataChange,
|
|
1088
|
-
setCarouselActiveTabIndex,
|
|
1089
|
-
});
|
|
1090
|
-
setCarouselActiveTabIndex.mockClear();
|
|
1091
|
-
|
|
1092
|
-
fireEvent.click(document.querySelector('.add-carousel-content-button'));
|
|
1093
|
-
|
|
1094
|
-
expect(onCarouselDataChange).toHaveBeenCalledWith(ANDROID, expect.any(Array));
|
|
1095
|
-
expect(onCarouselDataChange.mock.calls.pop()[1]).toHaveLength(3);
|
|
1096
|
-
expect(setCarouselActiveTabIndex).toHaveBeenCalledWith(2);
|
|
1097
|
-
});
|
|
1098
|
-
|
|
1099
|
-
it.each([
|
|
1100
|
-
['an image card has no image', [doneCard('image', 'a.jpg'), doneCard('image', '')]],
|
|
1101
|
-
['a video card has no video', [doneCard('video', 'a.mp4'), doneCard('video', '')]],
|
|
1102
|
-
])('disables add while %s', (_label, carouselData) => {
|
|
1103
|
-
renderComponent({ mediaType: 'CAROUSEL', carouselData });
|
|
1104
|
-
expect(document.querySelector('.add-carousel-content-button')).toBeDisabled();
|
|
1105
|
-
});
|
|
1106
|
-
|
|
1107
|
-
it('enables add once every video card has its video', () => {
|
|
1108
|
-
renderComponent({ mediaType: 'CAROUSEL', carouselData: [doneCard('video', 'a.mp4'), doneCard('video', 'b.mp4')] });
|
|
1109
|
-
expect(document.querySelector('.add-carousel-content-button')).not.toBeDisabled();
|
|
1110
|
-
});
|
|
1111
|
-
|
|
1112
|
-
const cardWithTap = (button) => ({
|
|
1113
|
-
...doneCard('image', 'a.jpg'),
|
|
1114
|
-
buttons: [{
|
|
1115
|
-
actionOnClick: true, isSaved: false, deepLinkValue: '', deepLinkKeys: [], externalLinkValue: '', ...button,
|
|
1116
|
-
}],
|
|
1117
|
-
});
|
|
1118
|
-
|
|
1119
|
-
it.each([
|
|
1120
|
-
['Deep link is chosen with none picked', { linkType: 'DEEP_LINK' }, 'Select a deep link'],
|
|
1121
|
-
['External link is chosen with no URL', { linkType: 'EXTERNAL_LINK' }, 'URL is not valid'],
|
|
1122
|
-
])('disables add and the link Save, without an inline message, when %s', (_label, button, message) => {
|
|
1123
|
-
renderComponent({ mediaType: 'CAROUSEL', carouselData: [cardWithTap(button)], formatMessage: mockFormatMessage });
|
|
1124
|
-
expect(document.querySelector('.add-carousel-content-button')).toBeDisabled();
|
|
1125
|
-
expect(document.querySelector('.mpush-tap-save-btn')).toBeDisabled();
|
|
1126
|
-
expect(screen.queryByText(message)).not.toBeInTheDocument();
|
|
1127
|
-
});
|
|
1128
|
-
|
|
1129
|
-
it('disables add until a deep link with keys has its keys', () => {
|
|
1130
|
-
const linkProps = { deepLink: [{ value: 'app://offer', label: 'Offer', keys: ['offerId'] }] };
|
|
1131
|
-
const { unmount } = renderComponent({
|
|
1132
|
-
mediaType: 'CAROUSEL',
|
|
1133
|
-
carouselData: [cardWithTap({ linkType: 'DEEP_LINK', deepLinkValue: 'app://offer' })],
|
|
1134
|
-
linkProps,
|
|
1135
|
-
});
|
|
1136
|
-
expect(document.querySelector('.add-carousel-content-button')).toBeDisabled();
|
|
1137
|
-
unmount();
|
|
1138
|
-
|
|
1139
|
-
renderComponent({
|
|
1140
|
-
mediaType: 'CAROUSEL',
|
|
1141
|
-
carouselData: [cardWithTap({ linkType: 'DEEP_LINK', deepLinkValue: 'app://offer', deepLinkKeys: ['offerId'], isSaved: true })],
|
|
1142
|
-
linkProps,
|
|
1143
|
-
});
|
|
1144
|
-
expect(document.querySelector('.add-carousel-content-button')).not.toBeDisabled();
|
|
1145
|
-
});
|
|
1146
|
-
|
|
1147
|
-
it('enables add once the card tap link is filled', () => {
|
|
1148
|
-
renderComponent({
|
|
1149
|
-
mediaType: 'CAROUSEL',
|
|
1150
|
-
carouselData: [cardWithTap({ linkType: 'EXTERNAL_LINK', externalLinkValue: 'https://example.com', isSaved: true })],
|
|
1151
|
-
formatMessage: mockFormatMessage,
|
|
1152
|
-
});
|
|
1153
|
-
expect(document.querySelector('.add-carousel-content-button')).not.toBeDisabled();
|
|
1154
|
-
expect(screen.queryByText('URL is not valid')).not.toBeInTheDocument();
|
|
1155
|
-
});
|
|
1156
|
-
|
|
1157
|
-
it('keeps "+" off while a filled card link is not saved, and its Save saves it', () => {
|
|
1158
|
-
const onCarouselDataChange = jest.fn();
|
|
1159
|
-
renderComponent({
|
|
1160
|
-
mediaType: 'CAROUSEL',
|
|
1161
|
-
carouselData: [cardWithTap({ linkType: 'EXTERNAL_LINK', externalLinkValue: 'https://example.com' })],
|
|
1162
|
-
onCarouselDataChange,
|
|
1163
|
-
formatMessage: mockFormatMessage,
|
|
1164
|
-
});
|
|
1165
|
-
expect(document.querySelector('.add-carousel-content-button')).toBeDisabled();
|
|
1166
|
-
|
|
1167
|
-
const saveButton = document.querySelector('.mpush-tap-save-btn');
|
|
1168
|
-
expect(saveButton).not.toBeDisabled();
|
|
1169
|
-
fireEvent.click(saveButton);
|
|
1170
|
-
expect(onCarouselDataChange.mock.calls.pop()[1][0].buttons[0]).toEqual(expect.objectContaining({ isSaved: true }));
|
|
1171
|
-
});
|
|
1172
|
-
|
|
1173
|
-
it('keeps the card link Save off while the link is empty', () => {
|
|
1174
|
-
renderComponent({
|
|
1175
|
-
mediaType: 'CAROUSEL',
|
|
1176
|
-
carouselData: [cardWithTap({ linkType: 'DEEP_LINK' })],
|
|
1177
|
-
formatMessage: mockFormatMessage,
|
|
1178
|
-
});
|
|
1179
|
-
expect(document.querySelector('.mpush-tap-save-btn')).toBeDisabled();
|
|
1180
|
-
});
|
|
1181
|
-
|
|
1182
|
-
it('shows a saved card link as one row; edit reopens it, delete sets App', () => {
|
|
1183
|
-
const onCarouselDataChange = jest.fn();
|
|
1184
|
-
renderComponent({
|
|
1185
|
-
mediaType: 'CAROUSEL',
|
|
1186
|
-
carouselData: [cardWithTap({ linkType: 'EXTERNAL_LINK', externalLinkValue: 'https://example.com', isSaved: undefined })],
|
|
1187
|
-
onCarouselDataChange,
|
|
1188
|
-
formatMessage: mockFormatMessage,
|
|
1189
|
-
});
|
|
1190
|
-
expect(document.querySelector('.mpush-saved-tap-link')).toBeInTheDocument();
|
|
1191
|
-
expect(screen.getByText('https://example.com')).toBeInTheDocument();
|
|
1192
|
-
expect(document.querySelector('.mpush-tap-save-btn')).toBeNull();
|
|
1193
|
-
|
|
1194
|
-
fireEvent.click(document.querySelector('.mpush-saved-tap-link-edit-icon'));
|
|
1195
|
-
expect(onCarouselDataChange.mock.calls.pop()[1][0].buttons[0]).toEqual(expect.objectContaining({ isSaved: false }));
|
|
1196
|
-
|
|
1197
|
-
fireEvent.click(document.querySelector('.mpush-saved-tap-link-delete-icon'));
|
|
1198
|
-
expect(onCarouselDataChange.mock.calls.pop()[1][0].buttons[0]).toEqual(
|
|
1199
|
-
expect.objectContaining({ actionOnClick: false, externalLinkValue: '' })
|
|
1200
|
-
);
|
|
1201
|
-
});
|
|
1202
|
-
|
|
1203
980
|
it('should add new carousel card when add button is clicked', () => {
|
|
1204
981
|
const onCarouselDataChange = jest.fn();
|
|
1205
982
|
renderComponent({
|
|
@@ -1207,7 +984,7 @@ describe('MediaUploaders', () => {
|
|
|
1207
984
|
carouselData: [
|
|
1208
985
|
{
|
|
1209
986
|
mediaType: 'image',
|
|
1210
|
-
imageUrl: '
|
|
987
|
+
imageUrl: '',
|
|
1211
988
|
buttons: [{
|
|
1212
989
|
actionOnClick: false,
|
|
1213
990
|
linkType: 'DEEP_LINK',
|
|
@@ -1374,62 +1151,26 @@ describe('MediaUploaders', () => {
|
|
|
1374
1151
|
onCarouselDataChange,
|
|
1375
1152
|
});
|
|
1376
1153
|
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
renderComponent({
|
|
1398
|
-
mediaType: 'CAROUSEL',
|
|
1399
|
-
carouselData: [
|
|
1400
|
-
{
|
|
1401
|
-
mediaType: 'image',
|
|
1402
|
-
imageUrl: '',
|
|
1403
|
-
buttons: [{
|
|
1404
|
-
actionOnClick: true, isSaved: false,
|
|
1405
|
-
linkType: 'EXTERNAL_LINK',
|
|
1406
|
-
deepLinkValue: '',
|
|
1407
|
-
deepLinkKeys: [],
|
|
1408
|
-
externalLinkValue: 'https://example.com',
|
|
1409
|
-
}],
|
|
1410
|
-
}
|
|
1411
|
-
],
|
|
1412
|
-
onCarouselDataChange,
|
|
1413
|
-
updateCarouselLinkError,
|
|
1414
|
-
});
|
|
1415
|
-
|
|
1416
|
-
fireEvent.change(screen.getAllByTestId('cap-custom-select')[0], { target: { value: 'APP' } });
|
|
1417
|
-
expect(onCarouselDataChange).toHaveBeenCalledWith(
|
|
1418
|
-
ANDROID,
|
|
1419
|
-
expect.arrayContaining([
|
|
1420
|
-
expect.objectContaining({
|
|
1421
|
-
buttons: expect.arrayContaining([
|
|
1422
|
-
expect.objectContaining({
|
|
1423
|
-
actionOnClick: false,
|
|
1424
|
-
linkType: 'DEEP_LINK',
|
|
1425
|
-
externalLinkValue: '',
|
|
1426
|
-
deepLinkValue: '',
|
|
1427
|
-
}),
|
|
1428
|
-
]),
|
|
1429
|
-
}),
|
|
1430
|
-
])
|
|
1431
|
-
);
|
|
1432
|
-
expect(updateCarouselLinkError).toHaveBeenCalledWith(0, 'externalLink', null);
|
|
1154
|
+
// Find checkbox by class name since it renders with cap-checkbox-v2
|
|
1155
|
+
const checkbox = document.querySelector('.cap-checkbox-v2 input[type="checkbox"]');
|
|
1156
|
+
if (checkbox) {
|
|
1157
|
+
fireEvent.click(checkbox);
|
|
1158
|
+
expect(onCarouselDataChange).toHaveBeenCalledWith(
|
|
1159
|
+
ANDROID,
|
|
1160
|
+
expect.arrayContaining([
|
|
1161
|
+
expect.objectContaining({
|
|
1162
|
+
buttons: expect.arrayContaining([
|
|
1163
|
+
expect.objectContaining({
|
|
1164
|
+
actionOnClick: true,
|
|
1165
|
+
})
|
|
1166
|
+
])
|
|
1167
|
+
})
|
|
1168
|
+
])
|
|
1169
|
+
);
|
|
1170
|
+
} else {
|
|
1171
|
+
// If checkbox not found, just verify component renders
|
|
1172
|
+
expect(screen.getByTestId('cap-image-upload')).toBeInTheDocument();
|
|
1173
|
+
}
|
|
1433
1174
|
});
|
|
1434
1175
|
|
|
1435
1176
|
it('should handle carousel link type change', () => {
|
|
@@ -1442,7 +1183,7 @@ describe('MediaUploaders', () => {
|
|
|
1442
1183
|
mediaType: 'image',
|
|
1443
1184
|
imageUrl: '',
|
|
1444
1185
|
buttons: [{
|
|
1445
|
-
actionOnClick: true,
|
|
1186
|
+
actionOnClick: true, // Enable action links
|
|
1446
1187
|
linkType: 'DEEP_LINK',
|
|
1447
1188
|
deepLinkValue: '',
|
|
1448
1189
|
externalLinkValue: '',
|
|
@@ -1453,7 +1194,18 @@ describe('MediaUploaders', () => {
|
|
|
1453
1194
|
updateCarouselLinkError,
|
|
1454
1195
|
});
|
|
1455
1196
|
|
|
1456
|
-
|
|
1197
|
+
// Should show action checkbox and description when carousel is rendered
|
|
1198
|
+
const checkbox = document.querySelector('.cap-checkbox-v2');
|
|
1199
|
+
if (checkbox) {
|
|
1200
|
+
expect(checkbox).toBeInTheDocument();
|
|
1201
|
+
|
|
1202
|
+
// The checkbox should be checked since actionOnClick is true
|
|
1203
|
+
const checkboxInput = checkbox.querySelector('input[type="checkbox"]');
|
|
1204
|
+
expect(checkboxInput.checked).toBe(true);
|
|
1205
|
+
} else {
|
|
1206
|
+
// If checkbox not found, just verify component renders
|
|
1207
|
+
expect(screen.getByTestId('cap-image-upload')).toBeInTheDocument();
|
|
1208
|
+
}
|
|
1457
1209
|
});
|
|
1458
1210
|
|
|
1459
1211
|
it('should validate deep link when value changes', () => {
|
|
@@ -1466,7 +1218,7 @@ describe('MediaUploaders', () => {
|
|
|
1466
1218
|
mediaType: 'image',
|
|
1467
1219
|
imageUrl: '',
|
|
1468
1220
|
buttons: [{
|
|
1469
|
-
actionOnClick: true,
|
|
1221
|
+
actionOnClick: true,
|
|
1470
1222
|
linkType: 'DEEP_LINK',
|
|
1471
1223
|
deepLinkValue: '',
|
|
1472
1224
|
externalLinkValue: '',
|
|
@@ -1482,7 +1234,16 @@ describe('MediaUploaders', () => {
|
|
|
1482
1234
|
}
|
|
1483
1235
|
});
|
|
1484
1236
|
|
|
1485
|
-
|
|
1237
|
+
// Should render carousel component with action checkbox
|
|
1238
|
+
const checkbox = document.querySelector('.cap-checkbox-v2');
|
|
1239
|
+
if (checkbox) {
|
|
1240
|
+
expect(checkbox).toBeInTheDocument();
|
|
1241
|
+
} else {
|
|
1242
|
+
// If checkbox not found, just verify component renders
|
|
1243
|
+
expect(screen.getByTestId('cap-image-upload')).toBeInTheDocument();
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
// Verify deep link props are available and component renders correctly
|
|
1486
1247
|
expect(screen.getByTestId('cap-image-upload')).toBeInTheDocument();
|
|
1487
1248
|
});
|
|
1488
1249
|
|
|
@@ -1496,7 +1257,7 @@ describe('MediaUploaders', () => {
|
|
|
1496
1257
|
mediaType: 'image',
|
|
1497
1258
|
imageUrl: '',
|
|
1498
1259
|
buttons: [{
|
|
1499
|
-
actionOnClick: true,
|
|
1260
|
+
actionOnClick: true,
|
|
1500
1261
|
linkType: 'EXTERNAL_LINK',
|
|
1501
1262
|
deepLinkValue: '',
|
|
1502
1263
|
externalLinkValue: '',
|
|
@@ -1568,7 +1329,7 @@ describe('MediaUploaders', () => {
|
|
|
1568
1329
|
mediaType: 'image',
|
|
1569
1330
|
imageUrl: '',
|
|
1570
1331
|
buttons: [{
|
|
1571
|
-
actionOnClick: true,
|
|
1332
|
+
actionOnClick: true,
|
|
1572
1333
|
linkType: 'DEEP_LINK',
|
|
1573
1334
|
deepLinkValue: 'invalid-deep-link',
|
|
1574
1335
|
externalLinkValue: '',
|
|
@@ -1597,7 +1358,7 @@ describe('MediaUploaders', () => {
|
|
|
1597
1358
|
mediaType: 'image',
|
|
1598
1359
|
imageUrl: '',
|
|
1599
1360
|
buttons: [{
|
|
1600
|
-
actionOnClick: true,
|
|
1361
|
+
actionOnClick: true,
|
|
1601
1362
|
linkType: 'EXTERNAL_LINK',
|
|
1602
1363
|
deepLinkValue: '',
|
|
1603
1364
|
externalLinkValue: 'invalid-url',
|
|
@@ -1714,9 +1475,8 @@ describe('MediaUploaders', () => {
|
|
|
1714
1475
|
onCarouselDataChange,
|
|
1715
1476
|
});
|
|
1716
1477
|
|
|
1717
|
-
//
|
|
1718
|
-
expect(screen.getByTestId('cap-
|
|
1719
|
-
expect(screen.queryByTestId('cap-image-upload')).toBeNull();
|
|
1478
|
+
// Should render carousel component
|
|
1479
|
+
expect(screen.getByTestId('cap-image-upload')).toBeInTheDocument();
|
|
1720
1480
|
});
|
|
1721
1481
|
|
|
1722
1482
|
it('should handle carousel video upload when video component is used', () => {
|
|
@@ -1763,8 +1523,7 @@ describe('MediaUploaders', () => {
|
|
|
1763
1523
|
</Provider>
|
|
1764
1524
|
);
|
|
1765
1525
|
|
|
1766
|
-
expect(screen.getByTestId('cap-
|
|
1767
|
-
expect(screen.queryByTestId('cap-image-upload')).toBeNull();
|
|
1526
|
+
expect(screen.getByTestId('cap-image-upload')).toBeInTheDocument();
|
|
1768
1527
|
});
|
|
1769
1528
|
});
|
|
1770
1529
|
|
|
@@ -1908,7 +1667,7 @@ describe('MediaUploaders', () => {
|
|
|
1908
1667
|
mediaType: 'image',
|
|
1909
1668
|
imageUrl: '',
|
|
1910
1669
|
buttons: [{
|
|
1911
|
-
actionOnClick: true,
|
|
1670
|
+
actionOnClick: true,
|
|
1912
1671
|
linkType: 'DEEP_LINK',
|
|
1913
1672
|
deepLinkValue: 'test',
|
|
1914
1673
|
externalLinkValue: '',
|
|
@@ -1940,7 +1699,7 @@ describe('MediaUploaders', () => {
|
|
|
1940
1699
|
mediaType: 'image',
|
|
1941
1700
|
imageUrl: '',
|
|
1942
1701
|
buttons: [{
|
|
1943
|
-
actionOnClick: true,
|
|
1702
|
+
actionOnClick: true,
|
|
1944
1703
|
linkType: 'EXTERNAL_LINK',
|
|
1945
1704
|
deepLinkValue: '',
|
|
1946
1705
|
externalLinkValue: 'invalid-url',
|
|
@@ -1970,7 +1729,7 @@ describe('MediaUploaders', () => {
|
|
|
1970
1729
|
mediaType: 'image',
|
|
1971
1730
|
imageUrl: '',
|
|
1972
1731
|
buttons: [{
|
|
1973
|
-
actionOnClick: true,
|
|
1732
|
+
actionOnClick: true,
|
|
1974
1733
|
linkType: 'DEEP_LINK',
|
|
1975
1734
|
deepLinkValue: 'invalid-link',
|
|
1976
1735
|
externalLinkValue: '',
|
|
@@ -2093,7 +1852,7 @@ describe('MediaUploaders', () => {
|
|
|
2093
1852
|
mediaType: 'image',
|
|
2094
1853
|
imageUrl: 'test.jpg',
|
|
2095
1854
|
buttons: [{
|
|
2096
|
-
actionOnClick: true,
|
|
1855
|
+
actionOnClick: true,
|
|
2097
1856
|
linkType: 'EXTERNAL_LINK',
|
|
2098
1857
|
deepLinkValue: '',
|
|
2099
1858
|
externalLinkValue: 'https://example.com',
|
|
@@ -2208,7 +1967,11 @@ describe('MediaUploaders', () => {
|
|
|
2208
1967
|
carouselActiveTabIndex: 0,
|
|
2209
1968
|
});
|
|
2210
1969
|
|
|
2211
|
-
|
|
1970
|
+
// Should render carousel with buttons
|
|
1971
|
+
const checkbox = screen.getByTestId('cap-checkbox');
|
|
1972
|
+
fireEvent.click(checkbox);
|
|
1973
|
+
|
|
1974
|
+
// Should call onCarouselDataChange when checkbox changes
|
|
2212
1975
|
expect(onCarouselDataChange).toHaveBeenCalled();
|
|
2213
1976
|
});
|
|
2214
1977
|
|
|
@@ -2220,7 +1983,7 @@ describe('MediaUploaders', () => {
|
|
|
2220
1983
|
mediaType: 'image',
|
|
2221
1984
|
imageUrl: 'test.jpg',
|
|
2222
1985
|
buttons: [{
|
|
2223
|
-
actionOnClick: true,
|
|
1986
|
+
actionOnClick: true, // This triggers action links rendering
|
|
2224
1987
|
linkType: 'DEEP_LINK',
|
|
2225
1988
|
deepLinkValue: '',
|
|
2226
1989
|
externalLinkValue: '',
|
|
@@ -2235,7 +1998,9 @@ describe('MediaUploaders', () => {
|
|
|
2235
1998
|
}
|
|
2236
1999
|
});
|
|
2237
2000
|
|
|
2238
|
-
|
|
2001
|
+
// Should render action links components
|
|
2002
|
+
expect(screen.getByTestId('cap-checkbox')).toBeInTheDocument();
|
|
2003
|
+
expect(screen.getAllByTestId('cap-custom-select')).toHaveLength(2); // Link type and deep link selects
|
|
2239
2004
|
});
|
|
2240
2005
|
|
|
2241
2006
|
it('should show carousel link errors when present', () => {
|
|
@@ -2246,7 +2011,7 @@ describe('MediaUploaders', () => {
|
|
|
2246
2011
|
mediaType: 'image',
|
|
2247
2012
|
imageUrl: 'test.jpg',
|
|
2248
2013
|
buttons: [{
|
|
2249
|
-
actionOnClick: true,
|
|
2014
|
+
actionOnClick: true,
|
|
2250
2015
|
linkType: 'DEEP_LINK',
|
|
2251
2016
|
deepLinkValue: 'invalid-link',
|
|
2252
2017
|
externalLinkValue: '',
|
|
@@ -2276,7 +2041,7 @@ describe('MediaUploaders', () => {
|
|
|
2276
2041
|
mediaType: 'image',
|
|
2277
2042
|
imageUrl: 'test.jpg',
|
|
2278
2043
|
buttons: [{
|
|
2279
|
-
actionOnClick: true,
|
|
2044
|
+
actionOnClick: true,
|
|
2280
2045
|
linkType: 'EXTERNAL_LINK',
|
|
2281
2046
|
deepLinkValue: '',
|
|
2282
2047
|
externalLinkValue: 'invalid-url',
|
|
@@ -2308,7 +2073,7 @@ describe('MediaUploaders', () => {
|
|
|
2308
2073
|
|
|
2309
2074
|
// Should render carousel without action links section
|
|
2310
2075
|
expect(screen.getByTestId('cap-tab')).toBeInTheDocument();
|
|
2311
|
-
expect(screen.
|
|
2076
|
+
expect(screen.queryByTestId('cap-checkbox')).not.toBeInTheDocument();
|
|
2312
2077
|
});
|
|
2313
2078
|
|
|
2314
2079
|
it('should handle multiple carousel cards with tab operations', () => {
|
|
@@ -2539,7 +2304,6 @@ describe('MediaUploaders', () => {
|
|
|
2539
2304
|
expect.arrayContaining([
|
|
2540
2305
|
expect.objectContaining({
|
|
2541
2306
|
videoSrc: 'mock-video-url',
|
|
2542
|
-
videoPreviewImg: 'mock-preview-url',
|
|
2543
2307
|
})
|
|
2544
2308
|
])
|
|
2545
2309
|
);
|
|
@@ -2555,7 +2319,7 @@ describe('MediaUploaders', () => {
|
|
|
2555
2319
|
mediaType: 'image',
|
|
2556
2320
|
imageUrl: 'test.jpg',
|
|
2557
2321
|
buttons: [{
|
|
2558
|
-
actionOnClick: true,
|
|
2322
|
+
actionOnClick: true,
|
|
2559
2323
|
linkType: 'DEEP_LINK',
|
|
2560
2324
|
deepLinkValue: '',
|
|
2561
2325
|
externalLinkValue: '',
|
|
@@ -2584,7 +2348,7 @@ describe('MediaUploaders', () => {
|
|
|
2584
2348
|
mediaType: 'image',
|
|
2585
2349
|
imageUrl: 'test.jpg',
|
|
2586
2350
|
buttons: [{
|
|
2587
|
-
actionOnClick: true,
|
|
2351
|
+
actionOnClick: true,
|
|
2588
2352
|
linkType: 'DEEP_LINK',
|
|
2589
2353
|
deepLinkValue: '',
|
|
2590
2354
|
externalLinkValue: '',
|
|
@@ -2618,10 +2382,10 @@ describe('MediaUploaders', () => {
|
|
|
2618
2382
|
mediaType: 'image',
|
|
2619
2383
|
imageUrl: 'test-image.jpg',
|
|
2620
2384
|
buttons: [{
|
|
2621
|
-
actionOnClick: true,
|
|
2385
|
+
actionOnClick: true,
|
|
2622
2386
|
linkType: 'DEEP_LINK',
|
|
2623
2387
|
deepLinkValue: 'test-deep-link',
|
|
2624
|
-
deepLinkKeys: ['key1
|
|
2388
|
+
deepLinkKeys: ['key1', 'key2'],
|
|
2625
2389
|
externalLinkValue: '',
|
|
2626
2390
|
}]
|
|
2627
2391
|
}];
|
|
@@ -2658,10 +2422,8 @@ describe('MediaUploaders', () => {
|
|
|
2658
2422
|
);
|
|
2659
2423
|
|
|
2660
2424
|
// Check that deep link keys are displayed correctly
|
|
2661
|
-
expect(getByText('key1')).toBeInTheDocument();
|
|
2662
|
-
expect(
|
|
2663
|
-
expect(getByDisplayValue('value1')).toBeInTheDocument();
|
|
2664
|
-
expect(getByDisplayValue('value2')).toBeInTheDocument();
|
|
2425
|
+
expect(getByText('key1, key2')).toBeInTheDocument();
|
|
2426
|
+
expect(getByDisplayValue('key1, key2')).toBeInTheDocument();
|
|
2665
2427
|
});
|
|
2666
2428
|
|
|
2667
2429
|
it('should handle carousel deep link keys with single key from selection', () => {
|
|
@@ -2672,7 +2434,7 @@ describe('MediaUploaders', () => {
|
|
|
2672
2434
|
mediaType: 'image',
|
|
2673
2435
|
imageUrl: 'test-image.jpg',
|
|
2674
2436
|
buttons: [{
|
|
2675
|
-
actionOnClick: true,
|
|
2437
|
+
actionOnClick: true,
|
|
2676
2438
|
linkType: 'DEEP_LINK',
|
|
2677
2439
|
deepLinkValue: 'test-deep-link',
|
|
2678
2440
|
deepLinkKeys: ['single-key'],
|
|
@@ -2724,10 +2486,10 @@ describe('MediaUploaders', () => {
|
|
|
2724
2486
|
mediaType: 'image',
|
|
2725
2487
|
imageUrl: 'test-image.jpg',
|
|
2726
2488
|
buttons: [{
|
|
2727
|
-
actionOnClick: true,
|
|
2489
|
+
actionOnClick: true,
|
|
2728
2490
|
linkType: 'DEEP_LINK',
|
|
2729
2491
|
deepLinkValue: 'test-deep-link',
|
|
2730
|
-
deepLinkKeys: ['
|
|
2492
|
+
deepLinkKeys: ['existing-key1', 'existing-key2'],
|
|
2731
2493
|
externalLinkValue: '',
|
|
2732
2494
|
}]
|
|
2733
2495
|
}];
|
|
@@ -2764,9 +2526,8 @@ describe('MediaUploaders', () => {
|
|
|
2764
2526
|
);
|
|
2765
2527
|
|
|
2766
2528
|
// Check that existing keys are displayed correctly (should show keys from selection first)
|
|
2767
|
-
expect(getByText('key1')).toBeInTheDocument();
|
|
2768
|
-
expect(getByDisplayValue('existing-
|
|
2769
|
-
expect(getByDisplayValue('existing-value2')).toBeInTheDocument();
|
|
2529
|
+
expect(getByText('key1, key2')).toBeInTheDocument();
|
|
2530
|
+
expect(getByDisplayValue('existing-key1, existing-key2')).toBeInTheDocument();
|
|
2770
2531
|
});
|
|
2771
2532
|
|
|
2772
2533
|
it('should handle carousel deep link keys with no keys at all', () => {
|
|
@@ -2777,7 +2538,7 @@ describe('MediaUploaders', () => {
|
|
|
2777
2538
|
mediaType: 'image',
|
|
2778
2539
|
imageUrl: 'test-image.jpg',
|
|
2779
2540
|
buttons: [{
|
|
2780
|
-
actionOnClick: true,
|
|
2541
|
+
actionOnClick: true,
|
|
2781
2542
|
linkType: 'DEEP_LINK',
|
|
2782
2543
|
deepLinkValue: 'test-deep-link',
|
|
2783
2544
|
deepLinkKeys: [],
|
|
@@ -2828,10 +2589,10 @@ describe('MediaUploaders', () => {
|
|
|
2828
2589
|
mediaType: 'image',
|
|
2829
2590
|
imageUrl: 'test-image.jpg',
|
|
2830
2591
|
buttons: [{
|
|
2831
|
-
actionOnClick: true,
|
|
2592
|
+
actionOnClick: true,
|
|
2832
2593
|
linkType: 'DEEP_LINK',
|
|
2833
2594
|
deepLinkValue: 'test-deep-link',
|
|
2834
|
-
deepLinkKeys: '
|
|
2595
|
+
deepLinkKeys: 'string-key-value',
|
|
2835
2596
|
externalLinkValue: '',
|
|
2836
2597
|
}]
|
|
2837
2598
|
}];
|
|
@@ -2879,7 +2640,7 @@ describe('MediaUploaders', () => {
|
|
|
2879
2640
|
mediaType: 'image',
|
|
2880
2641
|
imageUrl: 'test-image.jpg',
|
|
2881
2642
|
buttons: [{
|
|
2882
|
-
actionOnClick: true,
|
|
2643
|
+
actionOnClick: true,
|
|
2883
2644
|
linkType: 'DEEP_LINK',
|
|
2884
2645
|
deepLinkValue: 'test-deep-link',
|
|
2885
2646
|
deepLinkKeys: undefined,
|
|
@@ -2931,7 +2692,7 @@ describe('MediaUploaders', () => {
|
|
|
2931
2692
|
mediaType: 'image',
|
|
2932
2693
|
imageUrl: 'test-image.jpg',
|
|
2933
2694
|
buttons: [{
|
|
2934
|
-
actionOnClick: true,
|
|
2695
|
+
actionOnClick: true,
|
|
2935
2696
|
linkType: 'DEEP_LINK',
|
|
2936
2697
|
deepLinkValue: 'test-deep-link',
|
|
2937
2698
|
deepLinkKeys: [],
|
|
@@ -3196,7 +2957,7 @@ describe('MediaUploaders', () => {
|
|
|
3196
2957
|
mediaType: 'image',
|
|
3197
2958
|
imageUrl: 'test.jpg',
|
|
3198
2959
|
buttons: [{
|
|
3199
|
-
actionOnClick: true,
|
|
2960
|
+
actionOnClick: true,
|
|
3200
2961
|
linkType: 'DEEP_LINK',
|
|
3201
2962
|
deepLinkValue: 'test-deep-link',
|
|
3202
2963
|
deepLinkKeys: ['key1', 'key2'],
|
|
@@ -3230,12 +2991,11 @@ describe('MediaUploaders', () => {
|
|
|
3230
2991
|
// Wait for the deep link keys input to be rendered
|
|
3231
2992
|
const deepLinkKeysInput = await screen.findByTestId('cap-input-mobile-push-carousel-deep-link-keys-input-ANDROID-0');
|
|
3232
2993
|
expect(deepLinkKeysInput).toBeInTheDocument();
|
|
3233
|
-
|
|
3234
|
-
expect(deepLinkKeysInput.value).toBe('key1');
|
|
2994
|
+
expect(deepLinkKeysInput.value).toBe('key1, key2');
|
|
3235
2995
|
|
|
3236
|
-
//
|
|
2996
|
+
// Change deep link keys
|
|
3237
2997
|
await act(async () => {
|
|
3238
|
-
fireEvent.change(deepLinkKeysInput, { target: { value: '
|
|
2998
|
+
fireEvent.change(deepLinkKeysInput, { target: { value: 'key3, key4' } });
|
|
3239
2999
|
});
|
|
3240
3000
|
|
|
3241
3001
|
expect(mockOnCarouselDataChange).toHaveBeenCalledWith(
|
|
@@ -3244,7 +3004,7 @@ describe('MediaUploaders', () => {
|
|
|
3244
3004
|
expect.objectContaining({
|
|
3245
3005
|
buttons: expect.arrayContaining([
|
|
3246
3006
|
expect.objectContaining({
|
|
3247
|
-
deepLinkKeys: ['
|
|
3007
|
+
deepLinkKeys: ['key3', 'key4'],
|
|
3248
3008
|
}),
|
|
3249
3009
|
]),
|
|
3250
3010
|
}),
|
|
@@ -3262,10 +3022,10 @@ describe('MediaUploaders', () => {
|
|
|
3262
3022
|
mediaType: 'image',
|
|
3263
3023
|
imageUrl: 'test.jpg',
|
|
3264
3024
|
buttons: [{
|
|
3265
|
-
actionOnClick: true,
|
|
3025
|
+
actionOnClick: true,
|
|
3266
3026
|
linkType: 'DEEP_LINK',
|
|
3267
3027
|
deepLinkValue: 'test-deep-link',
|
|
3268
|
-
deepLinkKeys: ['key1
|
|
3028
|
+
deepLinkKeys: ['key1', 'key2'],
|
|
3269
3029
|
externalLinkValue: '',
|
|
3270
3030
|
}],
|
|
3271
3031
|
}
|
|
@@ -3282,7 +3042,7 @@ describe('MediaUploaders', () => {
|
|
|
3282
3042
|
});
|
|
3283
3043
|
|
|
3284
3044
|
// Find and interact with the deep link keys input
|
|
3285
|
-
const deepLinkKeysInput = screen.getByDisplayValue('
|
|
3045
|
+
const deepLinkKeysInput = screen.getByDisplayValue('key1, key2');
|
|
3286
3046
|
expect(deepLinkKeysInput).toBeInTheDocument();
|
|
3287
3047
|
|
|
3288
3048
|
// Simulate user clearing the deep link keys
|
|
@@ -3472,7 +3232,7 @@ describe('MediaUploaders', () => {
|
|
|
3472
3232
|
mediaType: 'image',
|
|
3473
3233
|
imageUrl: 'test.jpg',
|
|
3474
3234
|
buttons: [{
|
|
3475
|
-
actionOnClick: true,
|
|
3235
|
+
actionOnClick: true,
|
|
3476
3236
|
linkType: 'DEEP_LINK',
|
|
3477
3237
|
deepLinkValue: 'test-deep-link',
|
|
3478
3238
|
deepLinkKeys: [],
|
|
@@ -3537,7 +3297,7 @@ describe('MediaUploaders', () => {
|
|
|
3537
3297
|
mediaType: 'image',
|
|
3538
3298
|
imageUrl: 'test.jpg',
|
|
3539
3299
|
buttons: [{
|
|
3540
|
-
actionOnClick: true,
|
|
3300
|
+
actionOnClick: true,
|
|
3541
3301
|
linkType: 'DEEP_LINK',
|
|
3542
3302
|
deepLinkValue: 'test-deep-link',
|
|
3543
3303
|
deepLinkKeys: ['key1'],
|
|
@@ -3592,7 +3352,7 @@ describe('MediaUploaders', () => {
|
|
|
3592
3352
|
mediaType: 'image',
|
|
3593
3353
|
imageUrl: 'test.jpg',
|
|
3594
3354
|
buttons: [{
|
|
3595
|
-
actionOnClick: true,
|
|
3355
|
+
actionOnClick: true,
|
|
3596
3356
|
linkType: 'DEEP_LINK',
|
|
3597
3357
|
deepLinkValue: '',
|
|
3598
3358
|
externalLinkValue: '',
|
|
@@ -3619,7 +3379,7 @@ describe('MediaUploaders', () => {
|
|
|
3619
3379
|
mediaType: 'image',
|
|
3620
3380
|
imageUrl: 'test.jpg',
|
|
3621
3381
|
buttons: [{
|
|
3622
|
-
actionOnClick: true,
|
|
3382
|
+
actionOnClick: true,
|
|
3623
3383
|
linkType: 'DEEP_LINK',
|
|
3624
3384
|
deepLinkValue: '',
|
|
3625
3385
|
externalLinkValue: '',
|
|
@@ -3647,7 +3407,7 @@ describe('MediaUploaders', () => {
|
|
|
3647
3407
|
mediaType: 'image',
|
|
3648
3408
|
imageUrl: 'test-image.jpg',
|
|
3649
3409
|
buttons: [{
|
|
3650
|
-
actionOnClick: true,
|
|
3410
|
+
actionOnClick: true,
|
|
3651
3411
|
linkType: 'DEEP_LINK',
|
|
3652
3412
|
deepLinkValue: 'myapp://page?param1=value1', // Has query parameters
|
|
3653
3413
|
deepLinkKeys: ['param1'],
|
|
@@ -3700,7 +3460,7 @@ describe('MediaUploaders', () => {
|
|
|
3700
3460
|
mediaType: 'image',
|
|
3701
3461
|
imageUrl: 'test-image.jpg',
|
|
3702
3462
|
buttons: [{
|
|
3703
|
-
actionOnClick: true,
|
|
3463
|
+
actionOnClick: true,
|
|
3704
3464
|
linkType: 'DEEP_LINK',
|
|
3705
3465
|
deepLinkValue: 'myapp://home?userId=123&sessionId=abc', // Has query parameters
|
|
3706
3466
|
deepLinkKeys: ['userId', 'sessionId'],
|
|
@@ -3741,9 +3501,8 @@ describe('MediaUploaders', () => {
|
|
|
3741
3501
|
</Provider>
|
|
3742
3502
|
);
|
|
3743
3503
|
|
|
3744
|
-
//
|
|
3745
|
-
expect(getByText('userId')).toBeInTheDocument();
|
|
3746
|
-
expect(getByText('sessionId')).toBeInTheDocument();
|
|
3504
|
+
// Should find the base deep link and display keys
|
|
3505
|
+
expect(getByText('userId, sessionId')).toBeInTheDocument();
|
|
3747
3506
|
});
|
|
3748
3507
|
|
|
3749
3508
|
it('should match deep link with query parameters in carousel placeholder', () => {
|
|
@@ -3754,7 +3513,7 @@ describe('MediaUploaders', () => {
|
|
|
3754
3513
|
mediaType: 'image',
|
|
3755
3514
|
imageUrl: 'test-image.jpg',
|
|
3756
3515
|
buttons: [{
|
|
3757
|
-
actionOnClick: true,
|
|
3516
|
+
actionOnClick: true,
|
|
3758
3517
|
linkType: 'DEEP_LINK',
|
|
3759
3518
|
deepLinkValue: 'testapp://screen?itemId=456', // Has query parameters
|
|
3760
3519
|
deepLinkKeys: [],
|
|
@@ -3807,7 +3566,7 @@ describe('MediaUploaders', () => {
|
|
|
3807
3566
|
mediaType: 'image',
|
|
3808
3567
|
imageUrl: 'test-image.jpg',
|
|
3809
3568
|
buttons: [{
|
|
3810
|
-
actionOnClick: true,
|
|
3569
|
+
actionOnClick: true,
|
|
3811
3570
|
linkType: 'DEEP_LINK',
|
|
3812
3571
|
deepLinkValue: 'myapp://nomatch?param1=value1', // Base doesn't match any deepLink
|
|
3813
3572
|
deepLinkKeys: [],
|
|
@@ -4425,7 +4184,7 @@ describe('MediaUploaders', () => {
|
|
|
4425
4184
|
mediaType: 'image',
|
|
4426
4185
|
imageUrl: 'test.jpg',
|
|
4427
4186
|
buttons: [{
|
|
4428
|
-
actionOnClick: true,
|
|
4187
|
+
actionOnClick: true,
|
|
4429
4188
|
linkType: 'EXTERNAL_LINK',
|
|
4430
4189
|
deepLinkValue: '',
|
|
4431
4190
|
deepLinkKeys: [],
|
|
@@ -4462,124 +4221,4 @@ describe('MediaUploaders', () => {
|
|
|
4462
4221
|
);
|
|
4463
4222
|
});
|
|
4464
4223
|
});
|
|
4465
|
-
|
|
4466
|
-
describe('Carousel media switch and video uploads', () => {
|
|
4467
|
-
const button = { actionOnClick: false, linkType: DEEP_LINK, deepLinkValue: '', externalLinkValue: '' };
|
|
4468
|
-
const videoCard = (src) => ({
|
|
4469
|
-
mediaType: 'video', imageUrl: '', videoSrc: src, videoPreviewImg: src ? `${src}.png` : '', buttons: [button],
|
|
4470
|
-
});
|
|
4471
|
-
const uploaded = (metaInfo) => ({ uploadedAssetData0: { metaInfo } });
|
|
4472
|
-
const lastCards = (fn) => fn.mock.calls[fn.mock.calls.length - 1][1];
|
|
4473
|
-
|
|
4474
|
-
const renderCarousel = (props) => {
|
|
4475
|
-
const allProps = { ...defaultProps, mediaType: 'CAROUSEL', activeTab: ANDROID, ...props };
|
|
4476
|
-
const ui = (extra = {}) => (
|
|
4477
|
-
<Provider store={mockStore}>
|
|
4478
|
-
<IntlProvider messages={messages} locale="en">
|
|
4479
|
-
<MediaUploaders {...allProps} {...extra} />
|
|
4480
|
-
</IntlProvider>
|
|
4481
|
-
</Provider>
|
|
4482
|
-
);
|
|
4483
|
-
const utils = render(ui());
|
|
4484
|
-
return { ...utils, rerenderWith: (extra) => utils.rerender(ui(extra)) };
|
|
4485
|
-
};
|
|
4486
|
-
|
|
4487
|
-
it('switching to video keeps video fields, clears images and adds default buttons', () => {
|
|
4488
|
-
const onCarouselDataChange = jest.fn();
|
|
4489
|
-
renderCarousel({
|
|
4490
|
-
onCarouselDataChange,
|
|
4491
|
-
carouselData: [
|
|
4492
|
-
{ mediaType: 'image', imageUrl: 'a.jpg', videoSrc: 'a.mp4', videoPreviewImg: 'a.png', buttons: [button] },
|
|
4493
|
-
{ mediaType: 'image', imageUrl: 'b.jpg', videoSrc: '', videoPreviewImg: '' },
|
|
4494
|
-
],
|
|
4495
|
-
});
|
|
4496
|
-
|
|
4497
|
-
fireEvent.click(screen.getByTestId('radio-video'));
|
|
4498
|
-
|
|
4499
|
-
expect(lastCards(onCarouselDataChange)).toEqual([
|
|
4500
|
-
{ mediaType: 'video', imageUrl: '', videoSrc: 'a.mp4', videoPreviewImg: 'a.png', buttons: [button] },
|
|
4501
|
-
{
|
|
4502
|
-
mediaType: 'video',
|
|
4503
|
-
imageUrl: '',
|
|
4504
|
-
videoSrc: '',
|
|
4505
|
-
videoPreviewImg: '',
|
|
4506
|
-
buttons: [{ actionOnClick: false, linkType: DEEP_LINK, deepLinkValue: '', externalLinkValue: '' }],
|
|
4507
|
-
},
|
|
4508
|
-
]);
|
|
4509
|
-
expect(screen.getAllByTestId('cap-video-upload')).toHaveLength(2);
|
|
4510
|
-
});
|
|
4511
|
-
|
|
4512
|
-
it('switching to image keeps the image and clears the video and its thumbnail', () => {
|
|
4513
|
-
const onCarouselDataChange = jest.fn();
|
|
4514
|
-
renderCarousel({
|
|
4515
|
-
onCarouselDataChange,
|
|
4516
|
-
carouselData: [{ mediaType: 'video', imageUrl: 'a.jpg', videoSrc: 'a.mp4', videoPreviewImg: 'a.png', buttons: [button] }],
|
|
4517
|
-
});
|
|
4518
|
-
|
|
4519
|
-
fireEvent.click(screen.getByTestId('radio-image'));
|
|
4520
|
-
|
|
4521
|
-
expect(lastCards(onCarouselDataChange)).toEqual([
|
|
4522
|
-
{ mediaType: 'image', imageUrl: 'a.jpg', videoSrc: '', videoPreviewImg: '', buttons: [button] },
|
|
4523
|
-
]);
|
|
4524
|
-
expect(screen.getByTestId('cap-image-upload')).toBeInTheDocument();
|
|
4525
|
-
});
|
|
4526
|
-
|
|
4527
|
-
it('re upload on card 2 clears it, and the file picked through card 1\'s input lands on card 2', () => {
|
|
4528
|
-
const onCarouselDataChange = jest.fn();
|
|
4529
|
-
const uploadMpushAsset = jest.fn();
|
|
4530
|
-
const carouselData = [videoCard('a.mp4'), videoCard('b.mp4')];
|
|
4531
|
-
const { rerenderWith } = renderCarousel({ onCarouselDataChange, uploadMpushAsset, carouselData });
|
|
4532
|
-
|
|
4533
|
-
fireEvent.click(screen.getAllByTestId('video-reupload-button')[1]);
|
|
4534
|
-
expect(lastCards(onCarouselDataChange)).toEqual([
|
|
4535
|
-
carouselData[0],
|
|
4536
|
-
{ ...carouselData[1], videoSrc: '', videoPreviewImg: '' },
|
|
4537
|
-
]);
|
|
4538
|
-
|
|
4539
|
-
// Re upload clicks the page's first file input, which belongs to card 1
|
|
4540
|
-
fireEvent.click(screen.getAllByTestId('video-file-upload-button')[0]);
|
|
4541
|
-
expect(uploadMpushAsset).toHaveBeenCalledWith({ name: 'test.mp4' }, 'video', {}, 0);
|
|
4542
|
-
|
|
4543
|
-
onCarouselDataChange.mockClear();
|
|
4544
|
-
rerenderWith({ imageData: uploaded({ secure_file_path: 'c.mp4', file_name: 'c.mp4', video_file_path_preview: 'c.png' }) });
|
|
4545
|
-
|
|
4546
|
-
expect(lastCards(onCarouselDataChange)).toEqual([
|
|
4547
|
-
carouselData[0],
|
|
4548
|
-
{ ...carouselData[1], videoSrc: 'c.mp4', videoPreviewImg: 'c.png' },
|
|
4549
|
-
]);
|
|
4550
|
-
});
|
|
4551
|
-
|
|
4552
|
-
it.each([
|
|
4553
|
-
['the video preview', { video_file_path_preview: 'p.png', preview_image_url: 'i.png' }, 'p.png'],
|
|
4554
|
-
['the preview image when there is no video preview', { preview_image_url: 'i.png' }, 'i.png'],
|
|
4555
|
-
['no thumbnail when neither is sent', {}, ''],
|
|
4556
|
-
])('an uploaded video card gets %s', (_label, previews, expectedThumb) => {
|
|
4557
|
-
const onCarouselDataChange = jest.fn();
|
|
4558
|
-
const carouselData = [videoCard('')];
|
|
4559
|
-
const { rerenderWith } = renderCarousel({ onCarouselDataChange, carouselData });
|
|
4560
|
-
|
|
4561
|
-
fireEvent.click(screen.getByTestId('video-file-upload-button'));
|
|
4562
|
-
onCarouselDataChange.mockClear();
|
|
4563
|
-
rerenderWith({ imageData: uploaded({ secure_file_path: 'v.mp4', ...previews }) });
|
|
4564
|
-
|
|
4565
|
-
expect(lastCards(onCarouselDataChange)).toEqual([
|
|
4566
|
-
{ ...carouselData[0], videoSrc: 'v.mp4', videoPreviewImg: expectedThumb },
|
|
4567
|
-
]);
|
|
4568
|
-
});
|
|
4569
|
-
|
|
4570
|
-
it('a new upload does not reapply the previous upload\'s result', () => {
|
|
4571
|
-
const onCarouselDataChange = jest.fn();
|
|
4572
|
-
const imageData = uploaded({ secure_file_path: 'v.mp4', file_name: 'v.mp4' });
|
|
4573
|
-
const { rerenderWith } = renderCarousel({ onCarouselDataChange, carouselData: [videoCard('')] });
|
|
4574
|
-
|
|
4575
|
-
fireEvent.click(screen.getByTestId('video-file-upload-button'));
|
|
4576
|
-
rerenderWith({ imageData });
|
|
4577
|
-
expect(onCarouselDataChange).toHaveBeenCalled();
|
|
4578
|
-
|
|
4579
|
-
onCarouselDataChange.mockClear();
|
|
4580
|
-
fireEvent.click(screen.getByTestId('video-file-upload-button'));
|
|
4581
|
-
|
|
4582
|
-
expect(onCarouselDataChange).not.toHaveBeenCalled();
|
|
4583
|
-
});
|
|
4584
|
-
});
|
|
4585
4224
|
});
|