@capillarytech/creatives-library 9.1.8-alpha.sprint-cap-214249.39 → 9.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/constants/unified.js +4 -0
- package/package.json +1 -1
- package/translations/en.json +1 -0
- package/translations/ja-JP.json +1 -0
- package/translations/zh.json +1 -0
- package/utils/common.js +6 -0
- package/utils/createMobilePushPayload.js +33 -50
- package/utils/tagValidations.js +35 -4
- package/utils/templateVarUtils.js +49 -0
- package/utils/tests/createMobilePushPayload.test.js +8 -113
- package/utils/tests/tagValidations.test.js +48 -0
- package/utils/tests/templateVarUtils.test.js +89 -0
- package/v2Components/CapMpushCTA/index.js +9 -10
- package/v2Components/CapMpushCTA/index.scss +3 -29
- package/v2Components/CapTagList/TagFallbackPanel.js +124 -0
- package/v2Components/CapTagList/constants.js +5 -0
- package/v2Components/CapTagList/index.js +46 -7
- package/v2Components/CapTagList/messages.js +44 -0
- package/v2Components/CapTagList/style.scss +113 -1
- package/v2Components/CapTagList/tests/TagFallback.test.js +222 -0
- package/v2Components/CapTagList/utils.js +17 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +12 -20
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -13
- package/v2Components/CommonTestAndPreview/constants.js +3 -2
- package/v2Components/CommonTestAndPreview/index.js +61 -61
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +5 -81
- package/v2Components/CommonTestAndPreview/tests/index.test.js +0 -86
- package/v2Components/CommonTestAndPreview/tests/utils.test.js +102 -0
- package/v2Components/CommonTestAndPreview/utils.js +42 -3
- package/v2Components/FormBuilder/Classic.js +24 -14
- package/v2Components/FormBuilder/Functional/channels/mobilepush/config.js +1 -0
- package/v2Components/FormBuilder/Functional/channels/mobilepush/getEditorErrorDescriptor.js +1 -1
- package/v2Components/FormBuilder/Functional/channels/mobilepush/tests/validate.test.js +57 -0
- package/v2Components/FormBuilder/Functional/channels/mobilepush/validate.js +4 -4
- package/v2Components/FormBuilder/Functional/channels/sms/getEditorErrorDescriptor.js +3 -0
- package/v2Components/FormBuilder/Functional/channels/sms/tests/getEditorErrorDescriptor.test.js +5 -0
- package/v2Components/FormBuilder/Functional/channels/sms/tests/validate.test.js +6 -0
- package/v2Components/FormBuilder/Functional/channels/sms/validate.js +3 -1
- package/v2Components/FormBuilder/Functional/renderers/mpushRenderers.js +3 -0
- package/v2Components/FormBuilder/Functional/tests/mpushRenderers.test.js +22 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +2 -12
- package/v2Components/TemplatePreview/index.js +16 -24
- package/v2Components/TemplatePreview/tests/index.test.js +0 -68
- package/v2Containers/Cap/messages.js +4 -0
- package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +1 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +6 -4
- package/v2Containers/CreativesContainer/index.js +1 -2
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +0 -43
- package/v2Containers/InApp/index.js +4 -1
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +3 -0
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +2 -0
- package/v2Containers/Line/Container/Text/index.js +3 -1
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +16 -0
- package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +18 -0
- package/v2Containers/MobilePushNew/components/CtaButtons.js +47 -52
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +216 -297
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +125 -158
- package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +208 -30
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +108 -464
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +35 -106
- package/v2Containers/MobilePushNew/constants.js +0 -5
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +1 -63
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +0 -52
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +1 -40
- package/v2Containers/MobilePushNew/hooks/useUpload.js +39 -29
- package/v2Containers/MobilePushNew/index.js +239 -488
- package/v2Containers/MobilePushNew/index.scss +4 -205
- package/v2Containers/MobilePushNew/messages.js +6 -106
- package/v2Containers/MobilePushNew/tests/index.test.js +1 -469
- package/v2Containers/MobilePushNew/tests/utils.test.js +0 -70
- package/v2Containers/MobilePushNew/utils.js +0 -56
- package/v2Containers/Rcs/index.js +8 -1
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +59 -0
- package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +4 -0
- package/v2Containers/SmsTrai/Edit/index.js +17 -7
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +42 -0
- package/v2Containers/Templates/_templates.scss +2 -10
- package/v2Containers/Templates/index.js +81 -83
- package/v2Containers/Templates/tests/index.test.js +0 -68
- package/v2Containers/Viber/index.js +3 -1
- package/v2Containers/WebPush/Create/utils/validation.js +6 -0
- package/v2Containers/WebPush/Create/utils/validation.test.js +50 -0
- package/v2Containers/Whatsapp/index.js +9 -5
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +2 -2
- package/v2Containers/Zalo/index.js +4 -1
- package/v2Components/CapMpushCTA/tests/index.test.js +0 -89
- 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,7 +2382,7 @@ 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
2388
|
deepLinkKeys: ['key1', 'key2'],
|
|
@@ -2670,7 +2434,7 @@ describe('MediaUploaders', () => {
|
|
|
2670
2434
|
mediaType: 'image',
|
|
2671
2435
|
imageUrl: 'test-image.jpg',
|
|
2672
2436
|
buttons: [{
|
|
2673
|
-
actionOnClick: true,
|
|
2437
|
+
actionOnClick: true,
|
|
2674
2438
|
linkType: 'DEEP_LINK',
|
|
2675
2439
|
deepLinkValue: 'test-deep-link',
|
|
2676
2440
|
deepLinkKeys: ['single-key'],
|
|
@@ -2722,7 +2486,7 @@ describe('MediaUploaders', () => {
|
|
|
2722
2486
|
mediaType: 'image',
|
|
2723
2487
|
imageUrl: 'test-image.jpg',
|
|
2724
2488
|
buttons: [{
|
|
2725
|
-
actionOnClick: true,
|
|
2489
|
+
actionOnClick: true,
|
|
2726
2490
|
linkType: 'DEEP_LINK',
|
|
2727
2491
|
deepLinkValue: 'test-deep-link',
|
|
2728
2492
|
deepLinkKeys: ['existing-key1', 'existing-key2'],
|
|
@@ -2774,7 +2538,7 @@ describe('MediaUploaders', () => {
|
|
|
2774
2538
|
mediaType: 'image',
|
|
2775
2539
|
imageUrl: 'test-image.jpg',
|
|
2776
2540
|
buttons: [{
|
|
2777
|
-
actionOnClick: true,
|
|
2541
|
+
actionOnClick: true,
|
|
2778
2542
|
linkType: 'DEEP_LINK',
|
|
2779
2543
|
deepLinkValue: 'test-deep-link',
|
|
2780
2544
|
deepLinkKeys: [],
|
|
@@ -2825,7 +2589,7 @@ describe('MediaUploaders', () => {
|
|
|
2825
2589
|
mediaType: 'image',
|
|
2826
2590
|
imageUrl: 'test-image.jpg',
|
|
2827
2591
|
buttons: [{
|
|
2828
|
-
actionOnClick: true,
|
|
2592
|
+
actionOnClick: true,
|
|
2829
2593
|
linkType: 'DEEP_LINK',
|
|
2830
2594
|
deepLinkValue: 'test-deep-link',
|
|
2831
2595
|
deepLinkKeys: 'string-key-value',
|
|
@@ -2876,7 +2640,7 @@ describe('MediaUploaders', () => {
|
|
|
2876
2640
|
mediaType: 'image',
|
|
2877
2641
|
imageUrl: 'test-image.jpg',
|
|
2878
2642
|
buttons: [{
|
|
2879
|
-
actionOnClick: true,
|
|
2643
|
+
actionOnClick: true,
|
|
2880
2644
|
linkType: 'DEEP_LINK',
|
|
2881
2645
|
deepLinkValue: 'test-deep-link',
|
|
2882
2646
|
deepLinkKeys: undefined,
|
|
@@ -2928,7 +2692,7 @@ describe('MediaUploaders', () => {
|
|
|
2928
2692
|
mediaType: 'image',
|
|
2929
2693
|
imageUrl: 'test-image.jpg',
|
|
2930
2694
|
buttons: [{
|
|
2931
|
-
actionOnClick: true,
|
|
2695
|
+
actionOnClick: true,
|
|
2932
2696
|
linkType: 'DEEP_LINK',
|
|
2933
2697
|
deepLinkValue: 'test-deep-link',
|
|
2934
2698
|
deepLinkKeys: [],
|
|
@@ -3193,7 +2957,7 @@ describe('MediaUploaders', () => {
|
|
|
3193
2957
|
mediaType: 'image',
|
|
3194
2958
|
imageUrl: 'test.jpg',
|
|
3195
2959
|
buttons: [{
|
|
3196
|
-
actionOnClick: true,
|
|
2960
|
+
actionOnClick: true,
|
|
3197
2961
|
linkType: 'DEEP_LINK',
|
|
3198
2962
|
deepLinkValue: 'test-deep-link',
|
|
3199
2963
|
deepLinkKeys: ['key1', 'key2'],
|
|
@@ -3258,7 +3022,7 @@ describe('MediaUploaders', () => {
|
|
|
3258
3022
|
mediaType: 'image',
|
|
3259
3023
|
imageUrl: 'test.jpg',
|
|
3260
3024
|
buttons: [{
|
|
3261
|
-
actionOnClick: true,
|
|
3025
|
+
actionOnClick: true,
|
|
3262
3026
|
linkType: 'DEEP_LINK',
|
|
3263
3027
|
deepLinkValue: 'test-deep-link',
|
|
3264
3028
|
deepLinkKeys: ['key1', 'key2'],
|
|
@@ -3468,7 +3232,7 @@ describe('MediaUploaders', () => {
|
|
|
3468
3232
|
mediaType: 'image',
|
|
3469
3233
|
imageUrl: 'test.jpg',
|
|
3470
3234
|
buttons: [{
|
|
3471
|
-
actionOnClick: true,
|
|
3235
|
+
actionOnClick: true,
|
|
3472
3236
|
linkType: 'DEEP_LINK',
|
|
3473
3237
|
deepLinkValue: 'test-deep-link',
|
|
3474
3238
|
deepLinkKeys: [],
|
|
@@ -3533,7 +3297,7 @@ describe('MediaUploaders', () => {
|
|
|
3533
3297
|
mediaType: 'image',
|
|
3534
3298
|
imageUrl: 'test.jpg',
|
|
3535
3299
|
buttons: [{
|
|
3536
|
-
actionOnClick: true,
|
|
3300
|
+
actionOnClick: true,
|
|
3537
3301
|
linkType: 'DEEP_LINK',
|
|
3538
3302
|
deepLinkValue: 'test-deep-link',
|
|
3539
3303
|
deepLinkKeys: ['key1'],
|
|
@@ -3588,7 +3352,7 @@ describe('MediaUploaders', () => {
|
|
|
3588
3352
|
mediaType: 'image',
|
|
3589
3353
|
imageUrl: 'test.jpg',
|
|
3590
3354
|
buttons: [{
|
|
3591
|
-
actionOnClick: true,
|
|
3355
|
+
actionOnClick: true,
|
|
3592
3356
|
linkType: 'DEEP_LINK',
|
|
3593
3357
|
deepLinkValue: '',
|
|
3594
3358
|
externalLinkValue: '',
|
|
@@ -3615,7 +3379,7 @@ describe('MediaUploaders', () => {
|
|
|
3615
3379
|
mediaType: 'image',
|
|
3616
3380
|
imageUrl: 'test.jpg',
|
|
3617
3381
|
buttons: [{
|
|
3618
|
-
actionOnClick: true,
|
|
3382
|
+
actionOnClick: true,
|
|
3619
3383
|
linkType: 'DEEP_LINK',
|
|
3620
3384
|
deepLinkValue: '',
|
|
3621
3385
|
externalLinkValue: '',
|
|
@@ -3643,7 +3407,7 @@ describe('MediaUploaders', () => {
|
|
|
3643
3407
|
mediaType: 'image',
|
|
3644
3408
|
imageUrl: 'test-image.jpg',
|
|
3645
3409
|
buttons: [{
|
|
3646
|
-
actionOnClick: true,
|
|
3410
|
+
actionOnClick: true,
|
|
3647
3411
|
linkType: 'DEEP_LINK',
|
|
3648
3412
|
deepLinkValue: 'myapp://page?param1=value1', // Has query parameters
|
|
3649
3413
|
deepLinkKeys: ['param1'],
|
|
@@ -3696,7 +3460,7 @@ describe('MediaUploaders', () => {
|
|
|
3696
3460
|
mediaType: 'image',
|
|
3697
3461
|
imageUrl: 'test-image.jpg',
|
|
3698
3462
|
buttons: [{
|
|
3699
|
-
actionOnClick: true,
|
|
3463
|
+
actionOnClick: true,
|
|
3700
3464
|
linkType: 'DEEP_LINK',
|
|
3701
3465
|
deepLinkValue: 'myapp://home?userId=123&sessionId=abc', // Has query parameters
|
|
3702
3466
|
deepLinkKeys: ['userId', 'sessionId'],
|
|
@@ -3749,7 +3513,7 @@ describe('MediaUploaders', () => {
|
|
|
3749
3513
|
mediaType: 'image',
|
|
3750
3514
|
imageUrl: 'test-image.jpg',
|
|
3751
3515
|
buttons: [{
|
|
3752
|
-
actionOnClick: true,
|
|
3516
|
+
actionOnClick: true,
|
|
3753
3517
|
linkType: 'DEEP_LINK',
|
|
3754
3518
|
deepLinkValue: 'testapp://screen?itemId=456', // Has query parameters
|
|
3755
3519
|
deepLinkKeys: [],
|
|
@@ -3802,7 +3566,7 @@ describe('MediaUploaders', () => {
|
|
|
3802
3566
|
mediaType: 'image',
|
|
3803
3567
|
imageUrl: 'test-image.jpg',
|
|
3804
3568
|
buttons: [{
|
|
3805
|
-
actionOnClick: true,
|
|
3569
|
+
actionOnClick: true,
|
|
3806
3570
|
linkType: 'DEEP_LINK',
|
|
3807
3571
|
deepLinkValue: 'myapp://nomatch?param1=value1', // Base doesn't match any deepLink
|
|
3808
3572
|
deepLinkKeys: [],
|
|
@@ -4420,7 +4184,7 @@ describe('MediaUploaders', () => {
|
|
|
4420
4184
|
mediaType: 'image',
|
|
4421
4185
|
imageUrl: 'test.jpg',
|
|
4422
4186
|
buttons: [{
|
|
4423
|
-
actionOnClick: true,
|
|
4187
|
+
actionOnClick: true,
|
|
4424
4188
|
linkType: 'EXTERNAL_LINK',
|
|
4425
4189
|
deepLinkValue: '',
|
|
4426
4190
|
deepLinkKeys: [],
|
|
@@ -4457,124 +4221,4 @@ describe('MediaUploaders', () => {
|
|
|
4457
4221
|
);
|
|
4458
4222
|
});
|
|
4459
4223
|
});
|
|
4460
|
-
|
|
4461
|
-
describe('Carousel media switch and video uploads', () => {
|
|
4462
|
-
const button = { actionOnClick: false, linkType: DEEP_LINK, deepLinkValue: '', externalLinkValue: '' };
|
|
4463
|
-
const videoCard = (src) => ({
|
|
4464
|
-
mediaType: 'video', imageUrl: '', videoSrc: src, videoPreviewImg: src ? `${src}.png` : '', buttons: [button],
|
|
4465
|
-
});
|
|
4466
|
-
const uploaded = (metaInfo) => ({ uploadedAssetData0: { metaInfo } });
|
|
4467
|
-
const lastCards = (fn) => fn.mock.calls[fn.mock.calls.length - 1][1];
|
|
4468
|
-
|
|
4469
|
-
const renderCarousel = (props) => {
|
|
4470
|
-
const allProps = { ...defaultProps, mediaType: 'CAROUSEL', activeTab: ANDROID, ...props };
|
|
4471
|
-
const ui = (extra = {}) => (
|
|
4472
|
-
<Provider store={mockStore}>
|
|
4473
|
-
<IntlProvider messages={messages} locale="en">
|
|
4474
|
-
<MediaUploaders {...allProps} {...extra} />
|
|
4475
|
-
</IntlProvider>
|
|
4476
|
-
</Provider>
|
|
4477
|
-
);
|
|
4478
|
-
const utils = render(ui());
|
|
4479
|
-
return { ...utils, rerenderWith: (extra) => utils.rerender(ui(extra)) };
|
|
4480
|
-
};
|
|
4481
|
-
|
|
4482
|
-
it('switching to video keeps video fields, clears images and adds default buttons', () => {
|
|
4483
|
-
const onCarouselDataChange = jest.fn();
|
|
4484
|
-
renderCarousel({
|
|
4485
|
-
onCarouselDataChange,
|
|
4486
|
-
carouselData: [
|
|
4487
|
-
{ mediaType: 'image', imageUrl: 'a.jpg', videoSrc: 'a.mp4', videoPreviewImg: 'a.png', buttons: [button] },
|
|
4488
|
-
{ mediaType: 'image', imageUrl: 'b.jpg', videoSrc: '', videoPreviewImg: '' },
|
|
4489
|
-
],
|
|
4490
|
-
});
|
|
4491
|
-
|
|
4492
|
-
fireEvent.click(screen.getByTestId('radio-video'));
|
|
4493
|
-
|
|
4494
|
-
expect(lastCards(onCarouselDataChange)).toEqual([
|
|
4495
|
-
{ mediaType: 'video', imageUrl: '', videoSrc: 'a.mp4', videoPreviewImg: 'a.png', buttons: [button] },
|
|
4496
|
-
{
|
|
4497
|
-
mediaType: 'video',
|
|
4498
|
-
imageUrl: '',
|
|
4499
|
-
videoSrc: '',
|
|
4500
|
-
videoPreviewImg: '',
|
|
4501
|
-
buttons: [{ actionOnClick: false, linkType: DEEP_LINK, deepLinkValue: '', externalLinkValue: '' }],
|
|
4502
|
-
},
|
|
4503
|
-
]);
|
|
4504
|
-
expect(screen.getAllByTestId('cap-video-upload')).toHaveLength(2);
|
|
4505
|
-
});
|
|
4506
|
-
|
|
4507
|
-
it('switching to image keeps the image and clears the video and its thumbnail', () => {
|
|
4508
|
-
const onCarouselDataChange = jest.fn();
|
|
4509
|
-
renderCarousel({
|
|
4510
|
-
onCarouselDataChange,
|
|
4511
|
-
carouselData: [{ mediaType: 'video', imageUrl: 'a.jpg', videoSrc: 'a.mp4', videoPreviewImg: 'a.png', buttons: [button] }],
|
|
4512
|
-
});
|
|
4513
|
-
|
|
4514
|
-
fireEvent.click(screen.getByTestId('radio-image'));
|
|
4515
|
-
|
|
4516
|
-
expect(lastCards(onCarouselDataChange)).toEqual([
|
|
4517
|
-
{ mediaType: 'image', imageUrl: 'a.jpg', videoSrc: '', videoPreviewImg: '', buttons: [button] },
|
|
4518
|
-
]);
|
|
4519
|
-
expect(screen.getByTestId('cap-image-upload')).toBeInTheDocument();
|
|
4520
|
-
});
|
|
4521
|
-
|
|
4522
|
-
it('re upload on card 2 clears it, and the file picked through card 1\'s input lands on card 2', () => {
|
|
4523
|
-
const onCarouselDataChange = jest.fn();
|
|
4524
|
-
const uploadMpushAsset = jest.fn();
|
|
4525
|
-
const carouselData = [videoCard('a.mp4'), videoCard('b.mp4')];
|
|
4526
|
-
const { rerenderWith } = renderCarousel({ onCarouselDataChange, uploadMpushAsset, carouselData });
|
|
4527
|
-
|
|
4528
|
-
fireEvent.click(screen.getAllByTestId('video-reupload-button')[1]);
|
|
4529
|
-
expect(lastCards(onCarouselDataChange)).toEqual([
|
|
4530
|
-
carouselData[0],
|
|
4531
|
-
{ ...carouselData[1], videoSrc: '', videoPreviewImg: '' },
|
|
4532
|
-
]);
|
|
4533
|
-
|
|
4534
|
-
// Re upload clicks the page's first file input, which belongs to card 1
|
|
4535
|
-
fireEvent.click(screen.getAllByTestId('video-file-upload-button')[0]);
|
|
4536
|
-
expect(uploadMpushAsset).toHaveBeenCalledWith({ name: 'test.mp4' }, 'video', {}, 0);
|
|
4537
|
-
|
|
4538
|
-
onCarouselDataChange.mockClear();
|
|
4539
|
-
rerenderWith({ imageData: uploaded({ secure_file_path: 'c.mp4', file_name: 'c.mp4', video_file_path_preview: 'c.png' }) });
|
|
4540
|
-
|
|
4541
|
-
expect(lastCards(onCarouselDataChange)).toEqual([
|
|
4542
|
-
carouselData[0],
|
|
4543
|
-
{ ...carouselData[1], videoSrc: 'c.mp4', videoPreviewImg: 'c.png' },
|
|
4544
|
-
]);
|
|
4545
|
-
});
|
|
4546
|
-
|
|
4547
|
-
it.each([
|
|
4548
|
-
['the video preview', { video_file_path_preview: 'p.png', preview_image_url: 'i.png' }, 'p.png'],
|
|
4549
|
-
['the preview image when there is no video preview', { preview_image_url: 'i.png' }, 'i.png'],
|
|
4550
|
-
['no thumbnail when neither is sent', {}, ''],
|
|
4551
|
-
])('an uploaded video card gets %s', (_label, previews, expectedThumb) => {
|
|
4552
|
-
const onCarouselDataChange = jest.fn();
|
|
4553
|
-
const carouselData = [videoCard('')];
|
|
4554
|
-
const { rerenderWith } = renderCarousel({ onCarouselDataChange, carouselData });
|
|
4555
|
-
|
|
4556
|
-
fireEvent.click(screen.getByTestId('video-file-upload-button'));
|
|
4557
|
-
onCarouselDataChange.mockClear();
|
|
4558
|
-
rerenderWith({ imageData: uploaded({ secure_file_path: 'v.mp4', ...previews }) });
|
|
4559
|
-
|
|
4560
|
-
expect(lastCards(onCarouselDataChange)).toEqual([
|
|
4561
|
-
{ ...carouselData[0], videoSrc: 'v.mp4', videoPreviewImg: expectedThumb },
|
|
4562
|
-
]);
|
|
4563
|
-
});
|
|
4564
|
-
|
|
4565
|
-
it('a new upload does not reapply the previous upload\'s result', () => {
|
|
4566
|
-
const onCarouselDataChange = jest.fn();
|
|
4567
|
-
const imageData = uploaded({ secure_file_path: 'v.mp4', file_name: 'v.mp4' });
|
|
4568
|
-
const { rerenderWith } = renderCarousel({ onCarouselDataChange, carouselData: [videoCard('')] });
|
|
4569
|
-
|
|
4570
|
-
fireEvent.click(screen.getByTestId('video-file-upload-button'));
|
|
4571
|
-
rerenderWith({ imageData });
|
|
4572
|
-
expect(onCarouselDataChange).toHaveBeenCalled();
|
|
4573
|
-
|
|
4574
|
-
onCarouselDataChange.mockClear();
|
|
4575
|
-
fireEvent.click(screen.getByTestId('video-file-upload-button'));
|
|
4576
|
-
|
|
4577
|
-
expect(onCarouselDataChange).not.toHaveBeenCalled();
|
|
4578
|
-
});
|
|
4579
|
-
});
|
|
4580
4224
|
});
|