@capillarytech/creatives-library 9.1.7 → 9.1.8-alpha.sprint-cap-214249.38
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/constants/unified.js +0 -1
- package/index.js +0 -13
- package/package.json +1 -1
- package/services/getSchema.js +1 -4
- package/services/tests/getSchema.test.js +2 -2
- package/utils/common.js +0 -6
- package/utils/createMobilePushPayload.js +47 -33
- package/utils/tests/createMobilePushPayload.test.js +102 -8
- package/v2Components/CapMpushCTA/index.js +10 -9
- package/v2Components/CapMpushCTA/index.scss +29 -3
- package/v2Components/CapMpushCTA/tests/index.test.js +89 -0
- package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +26 -13
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +13 -1
- package/v2Components/CommonTestAndPreview/constants.js +2 -0
- package/v2Components/CommonTestAndPreview/index.js +49 -11
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +79 -5
- package/v2Components/CommonTestAndPreview/tests/index.test.js +86 -0
- package/v2Components/FormBuilder/Functional/tests/mpush.crossFlowParity.test.js +1 -1
- package/v2Components/FormBuilder/Functional/tests/mpush.shellEvents.test.js +1 -1
- package/v2Components/FormBuilder/Functional/tests/mpush.singlePlatform.test.js +1 -1
- package/v2Components/FormBuilder/tests/mpush.characterization.test.js +2 -2
- package/v2Components/TemplatePreview/_templatePreview.scss +12 -2
- package/v2Components/TemplatePreview/index.js +30 -17
- package/v2Components/TemplatePreview/tests/index.test.js +61 -0
- package/v2Containers/Cap/index.js +0 -3
- package/v2Containers/CreativesContainer/SlideBoxContent.js +70 -151
- package/v2Containers/CreativesContainer/index.js +3 -6
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +29 -0
- package/v2Containers/MobilePushNew/components/CtaButtons.js +52 -47
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +207 -192
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +116 -121
- package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +30 -208
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +316 -72
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +45 -16
- package/v2Containers/MobilePushNew/constants.js +5 -0
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +63 -1
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +52 -0
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +38 -1
- package/v2Containers/MobilePushNew/hooks/useUpload.js +29 -39
- package/v2Containers/MobilePushNew/index.js +453 -188
- package/v2Containers/MobilePushNew/index.scss +188 -4
- package/v2Containers/MobilePushNew/messages.js +86 -6
- package/v2Containers/MobilePushNew/tests/index.test.js +450 -1
- package/v2Containers/MobilePushNew/tests/utils.test.js +25 -0
- package/v2Containers/MobilePushNew/utils.js +8 -0
- package/v2Containers/Templates/_templates.scss +10 -2
- package/v2Containers/Templates/index.js +84 -90
- package/v2Containers/Templates/tests/index.test.js +68 -0
- package/v2Components/FormBuilder/Functional/tests/manual.typingPerf.test.js +0 -135
- package/v2Components/FormBuilder/Functional/tests/mpush.ctaFlows.parity.test.js +0 -320
- package/v2Components/FormBuilder/Functional/tests/mpush.editContainer.parity.test.js +0 -148
- package/v2Components/FormBuilder/Functional/tests/mpush.libraryValidity.parity.test.js +0 -152
- package/v2Containers/MobilePush/Create/_mobilePushCreate.scss +0 -70
- package/v2Containers/MobilePush/Create/actions.js +0 -52
- package/v2Containers/MobilePush/Create/constants.js +0 -26
- package/v2Containers/MobilePush/Create/index.js +0 -2149
- package/v2Containers/MobilePush/Create/messages.js +0 -349
- package/v2Containers/MobilePush/Create/reducer.js +0 -72
- package/v2Containers/MobilePush/Create/sagas.js +0 -79
- package/v2Containers/MobilePush/Create/selectors.js +0 -29
- package/v2Containers/MobilePush/Create/test/contentValidity.test.js +0 -154
- package/v2Containers/MobilePush/Create/test/saga.test.js +0 -19
- package/v2Containers/MobilePush/Create/test/stayOpenOnSave.test.js +0 -80
- package/v2Containers/MobilePush/Edit/_mobilePushCreate.scss +0 -65
- package/v2Containers/MobilePush/Edit/actions.js +0 -94
- package/v2Containers/MobilePush/Edit/constants.js +0 -37
- package/v2Containers/MobilePush/Edit/index.js +0 -2407
- package/v2Containers/MobilePush/Edit/messages.js +0 -341
- package/v2Containers/MobilePush/Edit/reducer.js +0 -113
- package/v2Containers/MobilePush/Edit/sagas.js +0 -113
- package/v2Containers/MobilePush/Edit/selectors.js +0 -33
- package/v2Containers/MobilePush/Edit/test/contentValidity.test.js +0 -149
- package/v2Containers/MobilePush/Edit/test/saga.test.js +0 -255
- package/v2Containers/MobilePush/Edit/test/stayOpenOnSave.test.js +0 -60
- package/v2Containers/MobilePush/commonMethods.js +0 -333
- package/v2Containers/MobilePush/eventsMap.js +0 -130
- package/v2Containers/MobilePush/tests/commonMethods.test.js +0 -401
- package/v2Containers/MobilepushWrapper/_mobilepushWrapper.scss +0 -22
- package/v2Containers/MobilepushWrapper/index.js +0 -178
- package/v2Containers/MobilepushWrapper/messages.js +0 -29
- /package/{v2Containers/MobilePush/initialSchema.js → v2Components/FormBuilder/Functional/tests/fixtures/mpushInitialSchema.js} +0 -0
|
@@ -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 } from '../../constants';
|
|
10
|
+
import { ANDROID, IOS, DEEP_LINK } from '../../constants';
|
|
11
11
|
import { act } from 'react';
|
|
12
12
|
import messages from '../../messages';
|
|
13
13
|
|
|
@@ -202,11 +202,27 @@ jest.mock('../../../../v2Components/CapVideoUpload', () =>
|
|
|
202
202
|
<div data-testid="cap-video-upload">
|
|
203
203
|
<button
|
|
204
204
|
type="button"
|
|
205
|
-
|
|
205
|
+
// Real CapVideoUpload calls back with (index, data)
|
|
206
|
+
onClick={() => props.onVideoUploadUpdateAssestList(0, { videoSrc: 'mock-video-url', previewUrl: 'mock-preview-url' })}
|
|
206
207
|
data-testid="video-upload-button"
|
|
207
208
|
>
|
|
208
209
|
Upload Video
|
|
209
210
|
</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>
|
|
210
226
|
</div>
|
|
211
227
|
);
|
|
212
228
|
}
|
|
@@ -488,6 +504,42 @@ jest.mock('../../messages', () => ({
|
|
|
488
504
|
id: 'creatives.containersV2.MobilePushNew.actionOnClickBody',
|
|
489
505
|
defaultMessage: 'Action on click of notification body',
|
|
490
506
|
},
|
|
507
|
+
cardTap: {
|
|
508
|
+
id: 'creatives.containersV2.MobilePushNew.cardTap',
|
|
509
|
+
defaultMessage: 'Card tap',
|
|
510
|
+
},
|
|
511
|
+
cardTapDescription: {
|
|
512
|
+
id: 'creatives.containersV2.MobilePushNew.cardTapDescription',
|
|
513
|
+
defaultMessage: 'What happens when someone taps this card.',
|
|
514
|
+
},
|
|
515
|
+
cardTapAppHelp: {
|
|
516
|
+
id: 'creatives.containersV2.MobilePushNew.cardTapAppHelp',
|
|
517
|
+
defaultMessage: 'Opens your app. Choose a link to send people to a specific page from this card instead.',
|
|
518
|
+
},
|
|
519
|
+
whenTappedOpen: {
|
|
520
|
+
id: 'creatives.containersV2.MobilePushNew.whenTappedOpen',
|
|
521
|
+
defaultMessage: 'When tapped, open',
|
|
522
|
+
},
|
|
523
|
+
tapActionApp: {
|
|
524
|
+
id: 'creatives.containersV2.MobilePushNew.tapActionApp',
|
|
525
|
+
defaultMessage: 'App (default)',
|
|
526
|
+
},
|
|
527
|
+
tapActionDeepLink: {
|
|
528
|
+
id: 'creatives.containersV2.MobilePushNew.tapActionDeepLink',
|
|
529
|
+
defaultMessage: 'Deep link',
|
|
530
|
+
},
|
|
531
|
+
tapActionExternalLink: {
|
|
532
|
+
id: 'creatives.containersV2.MobilePushNew.tapActionExternalLink',
|
|
533
|
+
defaultMessage: 'External link',
|
|
534
|
+
},
|
|
535
|
+
url: {
|
|
536
|
+
id: 'creatives.containersV2.MobilePushNew.url',
|
|
537
|
+
defaultMessage: 'URL',
|
|
538
|
+
},
|
|
539
|
+
enterUrl: {
|
|
540
|
+
id: 'creatives.containersV2.MobilePushNew.enterUrl',
|
|
541
|
+
defaultMessage: 'Enter URL',
|
|
542
|
+
},
|
|
491
543
|
},
|
|
492
544
|
}));
|
|
493
545
|
|
|
@@ -619,7 +671,7 @@ describe('MediaUploaders', () => {
|
|
|
619
671
|
});
|
|
620
672
|
|
|
621
673
|
fireEvent.click(screen.getByTestId('video-upload-button'));
|
|
622
|
-
expect(setUpdateMpushVideoSrc).toHaveBeenCalledWith('mock-video-url');
|
|
674
|
+
expect(setUpdateMpushVideoSrc).toHaveBeenCalledWith(0, { videoSrc: 'mock-video-url', previewUrl: 'mock-preview-url' });
|
|
623
675
|
});
|
|
624
676
|
});
|
|
625
677
|
|
|
@@ -637,7 +689,7 @@ describe('MediaUploaders', () => {
|
|
|
637
689
|
});
|
|
638
690
|
|
|
639
691
|
fireEvent.click(screen.getByTestId('video-upload-button'));
|
|
640
|
-
expect(setUpdateMpushVideoSrc).toHaveBeenCalledWith('mock-video-url');
|
|
692
|
+
expect(setUpdateMpushVideoSrc).toHaveBeenCalledWith(0, { videoSrc: 'mock-video-url', previewUrl: 'mock-preview-url' });
|
|
641
693
|
});
|
|
642
694
|
});
|
|
643
695
|
|
|
@@ -674,9 +726,8 @@ describe('MediaUploaders', () => {
|
|
|
674
726
|
const carouselCard = screen.getByText('Card 1');
|
|
675
727
|
expect(carouselCard).toBeInTheDocument();
|
|
676
728
|
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
expect(buttonsAndLinks).toBeInTheDocument();
|
|
729
|
+
expect(screen.getByText('Card tap')).toBeInTheDocument();
|
|
730
|
+
expect(screen.getByText('When tapped, open')).toBeInTheDocument();
|
|
680
731
|
});
|
|
681
732
|
|
|
682
733
|
it('should initialize carousel data when empty', () => {
|
|
@@ -752,15 +803,8 @@ describe('MediaUploaders', () => {
|
|
|
752
803
|
formatMessage: mockFormatMessage,
|
|
753
804
|
});
|
|
754
805
|
|
|
755
|
-
|
|
756
|
-
const actionOnClickCheckbox = screen.getByTestId('cap-checkbox');
|
|
757
|
-
expect(actionOnClickCheckbox).toBeChecked();
|
|
806
|
+
expect(screen.getAllByTestId('cap-custom-select')[0]).toHaveValue('EXTERNAL_LINK');
|
|
758
807
|
|
|
759
|
-
// First select the external link type
|
|
760
|
-
const linkTypeSelect = screen.getAllByTestId('cap-custom-select')[0];
|
|
761
|
-
fireEvent.change(linkTypeSelect, { target: { value: 'EXTERNAL_LINK' } });
|
|
762
|
-
|
|
763
|
-
// Wait for the external link input to be rendered
|
|
764
808
|
const externalLinkInput = screen.getByTestId('cap-input-mobile-push-external-link-input-ANDROID-0');
|
|
765
809
|
expect(externalLinkInput).toBeInTheDocument();
|
|
766
810
|
expect(externalLinkInput.value).toBe('https://example.com');
|
|
@@ -831,7 +875,7 @@ describe('MediaUploaders', () => {
|
|
|
831
875
|
</Provider>
|
|
832
876
|
);
|
|
833
877
|
|
|
834
|
-
expect(clearImageDataByMediaType).toHaveBeenCalledWith('IMAGE');
|
|
878
|
+
expect(clearImageDataByMediaType).toHaveBeenCalledWith('IMAGE', ANDROID);
|
|
835
879
|
});
|
|
836
880
|
|
|
837
881
|
it('should clear image data when switching from CAROUSEL to IMAGE', () => {
|
|
@@ -853,7 +897,36 @@ describe('MediaUploaders', () => {
|
|
|
853
897
|
</Provider>
|
|
854
898
|
);
|
|
855
899
|
|
|
856
|
-
expect(clearImageDataByMediaType).toHaveBeenCalledWith('IMAGE');
|
|
900
|
+
expect(clearImageDataByMediaType).toHaveBeenCalledWith('IMAGE', ANDROID);
|
|
901
|
+
});
|
|
902
|
+
|
|
903
|
+
// A tab switch gives the hidden pane a new clearImageDataByMediaType; that alone must not clear anything
|
|
904
|
+
it('does not clear when only the callbacks change (tab switch), and clears its own platform on a real change', () => {
|
|
905
|
+
const firstClear = jest.fn();
|
|
906
|
+
const onCarouselDataChange = jest.fn();
|
|
907
|
+
const renderPane = (mediaType, clearImageDataByMediaType) => (
|
|
908
|
+
<Provider store={mockStore}>
|
|
909
|
+
<IntlProvider messages={messages} locale="en">
|
|
910
|
+
<MediaUploaders
|
|
911
|
+
{...defaultProps}
|
|
912
|
+
activeTab={IOS}
|
|
913
|
+
mediaType={mediaType}
|
|
914
|
+
clearImageDataByMediaType={clearImageDataByMediaType}
|
|
915
|
+
onCarouselDataChange={onCarouselDataChange}
|
|
916
|
+
/>
|
|
917
|
+
</IntlProvider>
|
|
918
|
+
</Provider>
|
|
919
|
+
);
|
|
920
|
+
const { rerender } = render(renderPane('VIDEO', firstClear));
|
|
921
|
+
|
|
922
|
+
const clearAfterTabSwitch = jest.fn();
|
|
923
|
+
rerender(renderPane('VIDEO', clearAfterTabSwitch));
|
|
924
|
+
expect(firstClear).not.toHaveBeenCalled();
|
|
925
|
+
expect(clearAfterTabSwitch).not.toHaveBeenCalled();
|
|
926
|
+
expect(onCarouselDataChange).not.toHaveBeenCalled();
|
|
927
|
+
|
|
928
|
+
rerender(renderPane('NONE', clearAfterTabSwitch));
|
|
929
|
+
expect(clearAfterTabSwitch).toHaveBeenCalledWith('IMAGE', IOS);
|
|
857
930
|
});
|
|
858
931
|
});
|
|
859
932
|
|
|
@@ -977,6 +1050,44 @@ describe('MediaUploaders', () => {
|
|
|
977
1050
|
});
|
|
978
1051
|
|
|
979
1052
|
describe('Carousel card management', () => {
|
|
1053
|
+
const doneCard = (mediaType, media) => ({
|
|
1054
|
+
mediaType,
|
|
1055
|
+
imageUrl: mediaType === 'image' ? media : '',
|
|
1056
|
+
videoSrc: mediaType === 'video' ? media : '',
|
|
1057
|
+
buttons: [{ actionOnClick: false, linkType: 'DEEP_LINK', deepLinkValue: '', externalLinkValue: '' }],
|
|
1058
|
+
});
|
|
1059
|
+
|
|
1060
|
+
it('opens the new card after adding it', () => {
|
|
1061
|
+
const onCarouselDataChange = jest.fn();
|
|
1062
|
+
const setCarouselActiveTabIndex = jest.fn();
|
|
1063
|
+
renderComponent({
|
|
1064
|
+
mediaType: 'CAROUSEL',
|
|
1065
|
+
carouselData: [doneCard('image', 'a.jpg'), doneCard('image', 'b.jpg')],
|
|
1066
|
+
onCarouselDataChange,
|
|
1067
|
+
setCarouselActiveTabIndex,
|
|
1068
|
+
});
|
|
1069
|
+
setCarouselActiveTabIndex.mockClear();
|
|
1070
|
+
|
|
1071
|
+
fireEvent.click(document.querySelector('.add-carousel-content-button'));
|
|
1072
|
+
|
|
1073
|
+
expect(onCarouselDataChange).toHaveBeenCalledWith(ANDROID, expect.any(Array));
|
|
1074
|
+
expect(onCarouselDataChange.mock.calls.pop()[1]).toHaveLength(3);
|
|
1075
|
+
expect(setCarouselActiveTabIndex).toHaveBeenCalledWith(2);
|
|
1076
|
+
});
|
|
1077
|
+
|
|
1078
|
+
it.each([
|
|
1079
|
+
['an image card has no image', [doneCard('image', 'a.jpg'), doneCard('image', '')]],
|
|
1080
|
+
['a video card has no video', [doneCard('video', 'a.mp4'), doneCard('video', '')]],
|
|
1081
|
+
])('disables add while %s', (_label, carouselData) => {
|
|
1082
|
+
renderComponent({ mediaType: 'CAROUSEL', carouselData });
|
|
1083
|
+
expect(document.querySelector('.add-carousel-content-button')).toBeDisabled();
|
|
1084
|
+
});
|
|
1085
|
+
|
|
1086
|
+
it('enables add once every video card has its video', () => {
|
|
1087
|
+
renderComponent({ mediaType: 'CAROUSEL', carouselData: [doneCard('video', 'a.mp4'), doneCard('video', 'b.mp4')] });
|
|
1088
|
+
expect(document.querySelector('.add-carousel-content-button')).not.toBeDisabled();
|
|
1089
|
+
});
|
|
1090
|
+
|
|
980
1091
|
it('should add new carousel card when add button is clicked', () => {
|
|
981
1092
|
const onCarouselDataChange = jest.fn();
|
|
982
1093
|
renderComponent({
|
|
@@ -984,7 +1095,7 @@ describe('MediaUploaders', () => {
|
|
|
984
1095
|
carouselData: [
|
|
985
1096
|
{
|
|
986
1097
|
mediaType: 'image',
|
|
987
|
-
imageUrl: '',
|
|
1098
|
+
imageUrl: 'card1.jpg',
|
|
988
1099
|
buttons: [{
|
|
989
1100
|
actionOnClick: false,
|
|
990
1101
|
linkType: 'DEEP_LINK',
|
|
@@ -1151,26 +1262,62 @@ describe('MediaUploaders', () => {
|
|
|
1151
1262
|
onCarouselDataChange,
|
|
1152
1263
|
});
|
|
1153
1264
|
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1265
|
+
const tapSelect = screen.getAllByTestId('cap-custom-select')[0];
|
|
1266
|
+
expect(tapSelect).toHaveValue('APP');
|
|
1267
|
+
expect(screen.getByText('Opens your app. Choose a link to send people to a specific page from this card instead.')).toBeInTheDocument();
|
|
1268
|
+
|
|
1269
|
+
fireEvent.change(tapSelect, { target: { value: 'EXTERNAL_LINK' } });
|
|
1270
|
+
expect(onCarouselDataChange).toHaveBeenCalledWith(
|
|
1271
|
+
ANDROID,
|
|
1272
|
+
expect.arrayContaining([
|
|
1273
|
+
expect.objectContaining({
|
|
1274
|
+
buttons: expect.arrayContaining([
|
|
1275
|
+
expect.objectContaining({ actionOnClick: true, linkType: 'EXTERNAL_LINK' }),
|
|
1276
|
+
]),
|
|
1277
|
+
}),
|
|
1278
|
+
])
|
|
1279
|
+
);
|
|
1280
|
+
});
|
|
1281
|
+
|
|
1282
|
+
it('should turn the card action off and clear links when App is chosen', () => {
|
|
1283
|
+
const onCarouselDataChange = jest.fn();
|
|
1284
|
+
const updateCarouselLinkError = jest.fn();
|
|
1285
|
+
renderComponent({
|
|
1286
|
+
mediaType: 'CAROUSEL',
|
|
1287
|
+
carouselData: [
|
|
1288
|
+
{
|
|
1289
|
+
mediaType: 'image',
|
|
1290
|
+
imageUrl: '',
|
|
1291
|
+
buttons: [{
|
|
1292
|
+
actionOnClick: true,
|
|
1293
|
+
linkType: 'EXTERNAL_LINK',
|
|
1294
|
+
deepLinkValue: '',
|
|
1295
|
+
deepLinkKeys: [],
|
|
1296
|
+
externalLinkValue: 'https://example.com',
|
|
1297
|
+
}],
|
|
1298
|
+
}
|
|
1299
|
+
],
|
|
1300
|
+
onCarouselDataChange,
|
|
1301
|
+
updateCarouselLinkError,
|
|
1302
|
+
});
|
|
1303
|
+
|
|
1304
|
+
fireEvent.change(screen.getAllByTestId('cap-custom-select')[0], { target: { value: 'APP' } });
|
|
1305
|
+
expect(onCarouselDataChange).toHaveBeenCalledWith(
|
|
1306
|
+
ANDROID,
|
|
1307
|
+
expect.arrayContaining([
|
|
1308
|
+
expect.objectContaining({
|
|
1309
|
+
buttons: expect.arrayContaining([
|
|
1310
|
+
expect.objectContaining({
|
|
1311
|
+
actionOnClick: false,
|
|
1312
|
+
linkType: 'DEEP_LINK',
|
|
1313
|
+
externalLinkValue: '',
|
|
1314
|
+
deepLinkValue: '',
|
|
1315
|
+
}),
|
|
1316
|
+
]),
|
|
1317
|
+
}),
|
|
1318
|
+
])
|
|
1319
|
+
);
|
|
1320
|
+
expect(updateCarouselLinkError).toHaveBeenCalledWith(0, 'externalLink', null);
|
|
1174
1321
|
});
|
|
1175
1322
|
|
|
1176
1323
|
it('should handle carousel link type change', () => {
|
|
@@ -1194,18 +1341,7 @@ describe('MediaUploaders', () => {
|
|
|
1194
1341
|
updateCarouselLinkError,
|
|
1195
1342
|
});
|
|
1196
1343
|
|
|
1197
|
-
|
|
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
|
-
}
|
|
1344
|
+
expect(screen.getAllByTestId('cap-custom-select')[0]).toHaveValue('DEEP_LINK');
|
|
1209
1345
|
});
|
|
1210
1346
|
|
|
1211
1347
|
it('should validate deep link when value changes', () => {
|
|
@@ -1234,16 +1370,7 @@ describe('MediaUploaders', () => {
|
|
|
1234
1370
|
}
|
|
1235
1371
|
});
|
|
1236
1372
|
|
|
1237
|
-
|
|
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
|
|
1373
|
+
expect(screen.getAllByTestId('cap-custom-select')[0]).toHaveValue('DEEP_LINK');
|
|
1247
1374
|
expect(screen.getByTestId('cap-image-upload')).toBeInTheDocument();
|
|
1248
1375
|
});
|
|
1249
1376
|
|
|
@@ -1475,8 +1602,9 @@ describe('MediaUploaders', () => {
|
|
|
1475
1602
|
onCarouselDataChange,
|
|
1476
1603
|
});
|
|
1477
1604
|
|
|
1478
|
-
//
|
|
1479
|
-
expect(screen.getByTestId('cap-
|
|
1605
|
+
// Saved video cards open with video boxes, not the default image ones
|
|
1606
|
+
expect(screen.getByTestId('cap-video-upload')).toBeInTheDocument();
|
|
1607
|
+
expect(screen.queryByTestId('cap-image-upload')).toBeNull();
|
|
1480
1608
|
});
|
|
1481
1609
|
|
|
1482
1610
|
it('should handle carousel video upload when video component is used', () => {
|
|
@@ -1523,7 +1651,8 @@ describe('MediaUploaders', () => {
|
|
|
1523
1651
|
</Provider>
|
|
1524
1652
|
);
|
|
1525
1653
|
|
|
1526
|
-
expect(screen.getByTestId('cap-
|
|
1654
|
+
expect(screen.getByTestId('cap-video-upload')).toBeInTheDocument();
|
|
1655
|
+
expect(screen.queryByTestId('cap-image-upload')).toBeNull();
|
|
1527
1656
|
});
|
|
1528
1657
|
});
|
|
1529
1658
|
|
|
@@ -1967,11 +2096,7 @@ describe('MediaUploaders', () => {
|
|
|
1967
2096
|
carouselActiveTabIndex: 0,
|
|
1968
2097
|
});
|
|
1969
2098
|
|
|
1970
|
-
|
|
1971
|
-
const checkbox = screen.getByTestId('cap-checkbox');
|
|
1972
|
-
fireEvent.click(checkbox);
|
|
1973
|
-
|
|
1974
|
-
// Should call onCarouselDataChange when checkbox changes
|
|
2099
|
+
fireEvent.change(screen.getAllByTestId('cap-custom-select')[0], { target: { value: 'DEEP_LINK' } });
|
|
1975
2100
|
expect(onCarouselDataChange).toHaveBeenCalled();
|
|
1976
2101
|
});
|
|
1977
2102
|
|
|
@@ -1998,9 +2123,7 @@ describe('MediaUploaders', () => {
|
|
|
1998
2123
|
}
|
|
1999
2124
|
});
|
|
2000
2125
|
|
|
2001
|
-
//
|
|
2002
|
-
expect(screen.getByTestId('cap-checkbox')).toBeInTheDocument();
|
|
2003
|
-
expect(screen.getAllByTestId('cap-custom-select')).toHaveLength(2); // Link type and deep link selects
|
|
2126
|
+
expect(screen.getAllByTestId('cap-custom-select')).toHaveLength(2); // Tap action and deep link selects
|
|
2004
2127
|
});
|
|
2005
2128
|
|
|
2006
2129
|
it('should show carousel link errors when present', () => {
|
|
@@ -2073,7 +2196,7 @@ describe('MediaUploaders', () => {
|
|
|
2073
2196
|
|
|
2074
2197
|
// Should render carousel without action links section
|
|
2075
2198
|
expect(screen.getByTestId('cap-tab')).toBeInTheDocument();
|
|
2076
|
-
expect(screen.
|
|
2199
|
+
expect(screen.queryByText('When tapped, open')).not.toBeInTheDocument();
|
|
2077
2200
|
});
|
|
2078
2201
|
|
|
2079
2202
|
it('should handle multiple carousel cards with tab operations', () => {
|
|
@@ -2304,6 +2427,7 @@ describe('MediaUploaders', () => {
|
|
|
2304
2427
|
expect.arrayContaining([
|
|
2305
2428
|
expect.objectContaining({
|
|
2306
2429
|
videoSrc: 'mock-video-url',
|
|
2430
|
+
videoPreviewImg: 'mock-preview-url',
|
|
2307
2431
|
})
|
|
2308
2432
|
])
|
|
2309
2433
|
);
|
|
@@ -4221,4 +4345,124 @@ describe('MediaUploaders', () => {
|
|
|
4221
4345
|
);
|
|
4222
4346
|
});
|
|
4223
4347
|
});
|
|
4348
|
+
|
|
4349
|
+
describe('Carousel media switch and video uploads', () => {
|
|
4350
|
+
const button = { actionOnClick: false, linkType: DEEP_LINK, deepLinkValue: '', externalLinkValue: '' };
|
|
4351
|
+
const videoCard = (src) => ({
|
|
4352
|
+
mediaType: 'video', imageUrl: '', videoSrc: src, videoPreviewImg: src ? `${src}.png` : '', buttons: [button],
|
|
4353
|
+
});
|
|
4354
|
+
const uploaded = (metaInfo) => ({ uploadedAssetData0: { metaInfo } });
|
|
4355
|
+
const lastCards = (fn) => fn.mock.calls[fn.mock.calls.length - 1][1];
|
|
4356
|
+
|
|
4357
|
+
const renderCarousel = (props) => {
|
|
4358
|
+
const allProps = { ...defaultProps, mediaType: 'CAROUSEL', activeTab: ANDROID, ...props };
|
|
4359
|
+
const ui = (extra = {}) => (
|
|
4360
|
+
<Provider store={mockStore}>
|
|
4361
|
+
<IntlProvider messages={messages} locale="en">
|
|
4362
|
+
<MediaUploaders {...allProps} {...extra} />
|
|
4363
|
+
</IntlProvider>
|
|
4364
|
+
</Provider>
|
|
4365
|
+
);
|
|
4366
|
+
const utils = render(ui());
|
|
4367
|
+
return { ...utils, rerenderWith: (extra) => utils.rerender(ui(extra)) };
|
|
4368
|
+
};
|
|
4369
|
+
|
|
4370
|
+
it('switching to video keeps video fields, clears images and adds default buttons', () => {
|
|
4371
|
+
const onCarouselDataChange = jest.fn();
|
|
4372
|
+
renderCarousel({
|
|
4373
|
+
onCarouselDataChange,
|
|
4374
|
+
carouselData: [
|
|
4375
|
+
{ mediaType: 'image', imageUrl: 'a.jpg', videoSrc: 'a.mp4', videoPreviewImg: 'a.png', buttons: [button] },
|
|
4376
|
+
{ mediaType: 'image', imageUrl: 'b.jpg', videoSrc: '', videoPreviewImg: '' },
|
|
4377
|
+
],
|
|
4378
|
+
});
|
|
4379
|
+
|
|
4380
|
+
fireEvent.click(screen.getByTestId('radio-video'));
|
|
4381
|
+
|
|
4382
|
+
expect(lastCards(onCarouselDataChange)).toEqual([
|
|
4383
|
+
{ mediaType: 'video', imageUrl: '', videoSrc: 'a.mp4', videoPreviewImg: 'a.png', buttons: [button] },
|
|
4384
|
+
{
|
|
4385
|
+
mediaType: 'video',
|
|
4386
|
+
imageUrl: '',
|
|
4387
|
+
videoSrc: '',
|
|
4388
|
+
videoPreviewImg: '',
|
|
4389
|
+
buttons: [{ actionOnClick: false, linkType: DEEP_LINK, deepLinkValue: '', externalLinkValue: '' }],
|
|
4390
|
+
},
|
|
4391
|
+
]);
|
|
4392
|
+
expect(screen.getAllByTestId('cap-video-upload')).toHaveLength(2);
|
|
4393
|
+
});
|
|
4394
|
+
|
|
4395
|
+
it('switching to image keeps the image and clears the video and its thumbnail', () => {
|
|
4396
|
+
const onCarouselDataChange = jest.fn();
|
|
4397
|
+
renderCarousel({
|
|
4398
|
+
onCarouselDataChange,
|
|
4399
|
+
carouselData: [{ mediaType: 'video', imageUrl: 'a.jpg', videoSrc: 'a.mp4', videoPreviewImg: 'a.png', buttons: [button] }],
|
|
4400
|
+
});
|
|
4401
|
+
|
|
4402
|
+
fireEvent.click(screen.getByTestId('radio-image'));
|
|
4403
|
+
|
|
4404
|
+
expect(lastCards(onCarouselDataChange)).toEqual([
|
|
4405
|
+
{ mediaType: 'image', imageUrl: 'a.jpg', videoSrc: '', videoPreviewImg: '', buttons: [button] },
|
|
4406
|
+
]);
|
|
4407
|
+
expect(screen.getByTestId('cap-image-upload')).toBeInTheDocument();
|
|
4408
|
+
});
|
|
4409
|
+
|
|
4410
|
+
it('re upload on card 2 clears it, and the file picked through card 1\'s input lands on card 2', () => {
|
|
4411
|
+
const onCarouselDataChange = jest.fn();
|
|
4412
|
+
const uploadMpushAsset = jest.fn();
|
|
4413
|
+
const carouselData = [videoCard('a.mp4'), videoCard('b.mp4')];
|
|
4414
|
+
const { rerenderWith } = renderCarousel({ onCarouselDataChange, uploadMpushAsset, carouselData });
|
|
4415
|
+
|
|
4416
|
+
fireEvent.click(screen.getAllByTestId('video-reupload-button')[1]);
|
|
4417
|
+
expect(lastCards(onCarouselDataChange)).toEqual([
|
|
4418
|
+
carouselData[0],
|
|
4419
|
+
{ ...carouselData[1], videoSrc: '', videoPreviewImg: '' },
|
|
4420
|
+
]);
|
|
4421
|
+
|
|
4422
|
+
// Re upload clicks the page's first file input, which belongs to card 1
|
|
4423
|
+
fireEvent.click(screen.getAllByTestId('video-file-upload-button')[0]);
|
|
4424
|
+
expect(uploadMpushAsset).toHaveBeenCalledWith({ name: 'test.mp4' }, 'video', {}, 0);
|
|
4425
|
+
|
|
4426
|
+
onCarouselDataChange.mockClear();
|
|
4427
|
+
rerenderWith({ imageData: uploaded({ secure_file_path: 'c.mp4', file_name: 'c.mp4', video_file_path_preview: 'c.png' }) });
|
|
4428
|
+
|
|
4429
|
+
expect(lastCards(onCarouselDataChange)).toEqual([
|
|
4430
|
+
carouselData[0],
|
|
4431
|
+
{ ...carouselData[1], videoSrc: 'c.mp4', videoPreviewImg: 'c.png' },
|
|
4432
|
+
]);
|
|
4433
|
+
});
|
|
4434
|
+
|
|
4435
|
+
it.each([
|
|
4436
|
+
['the video preview', { video_file_path_preview: 'p.png', preview_image_url: 'i.png' }, 'p.png'],
|
|
4437
|
+
['the preview image when there is no video preview', { preview_image_url: 'i.png' }, 'i.png'],
|
|
4438
|
+
['no thumbnail when neither is sent', {}, ''],
|
|
4439
|
+
])('an uploaded video card gets %s', (_label, previews, expectedThumb) => {
|
|
4440
|
+
const onCarouselDataChange = jest.fn();
|
|
4441
|
+
const carouselData = [videoCard('')];
|
|
4442
|
+
const { rerenderWith } = renderCarousel({ onCarouselDataChange, carouselData });
|
|
4443
|
+
|
|
4444
|
+
fireEvent.click(screen.getByTestId('video-file-upload-button'));
|
|
4445
|
+
onCarouselDataChange.mockClear();
|
|
4446
|
+
rerenderWith({ imageData: uploaded({ secure_file_path: 'v.mp4', ...previews }) });
|
|
4447
|
+
|
|
4448
|
+
expect(lastCards(onCarouselDataChange)).toEqual([
|
|
4449
|
+
{ ...carouselData[0], videoSrc: 'v.mp4', videoPreviewImg: expectedThumb },
|
|
4450
|
+
]);
|
|
4451
|
+
});
|
|
4452
|
+
|
|
4453
|
+
it('a new upload does not reapply the previous upload\'s result', () => {
|
|
4454
|
+
const onCarouselDataChange = jest.fn();
|
|
4455
|
+
const imageData = uploaded({ secure_file_path: 'v.mp4', file_name: 'v.mp4' });
|
|
4456
|
+
const { rerenderWith } = renderCarousel({ onCarouselDataChange, carouselData: [videoCard('')] });
|
|
4457
|
+
|
|
4458
|
+
fireEvent.click(screen.getByTestId('video-file-upload-button'));
|
|
4459
|
+
rerenderWith({ imageData });
|
|
4460
|
+
expect(onCarouselDataChange).toHaveBeenCalled();
|
|
4461
|
+
|
|
4462
|
+
onCarouselDataChange.mockClear();
|
|
4463
|
+
fireEvent.click(screen.getByTestId('video-file-upload-button'));
|
|
4464
|
+
|
|
4465
|
+
expect(onCarouselDataChange).not.toHaveBeenCalled();
|
|
4466
|
+
});
|
|
4467
|
+
});
|
|
4224
4468
|
});
|
|
@@ -101,6 +101,15 @@ jest.mock("../../messages", () => ({
|
|
|
101
101
|
deepLink: { id: "deepLink", defaultMessage: "Deep Link" },
|
|
102
102
|
externalLink: { id: "externalLink", defaultMessage: "External Link" },
|
|
103
103
|
enterExternalLink: { id: "enterExternalLink", defaultMessage: "Enter external link" },
|
|
104
|
+
notificationTap: { id: "notificationTap", defaultMessage: "Notification tap" },
|
|
105
|
+
notificationTapDescription: { id: "notificationTapDescription", defaultMessage: "What happens when someone taps the notification itself." },
|
|
106
|
+
whenTappedOpen: { id: "whenTappedOpen", defaultMessage: "When tapped, open" },
|
|
107
|
+
tapActionApp: { id: "tapActionApp", defaultMessage: "App (default)" },
|
|
108
|
+
tapActionAppHelp: { id: "tapActionAppHelp", defaultMessage: "Opens your app. Choose a link to send people to a specific page instead." },
|
|
109
|
+
tapActionDeepLink: { id: "tapActionDeepLink", defaultMessage: "Deep link" },
|
|
110
|
+
tapActionExternalLink: { id: "tapActionExternalLink", defaultMessage: "External link" },
|
|
111
|
+
url: { id: "url", defaultMessage: "URL" },
|
|
112
|
+
enterUrl: { id: "enterUrl", defaultMessage: "Enter URL" },
|
|
104
113
|
deepLinkKeys: { id: "deepLinkKeys", defaultMessage: "Deep Link Keys" },
|
|
105
114
|
deepLinkKeysPlaceholder: { id: "deepLinkKeysPlaceholder", defaultMessage: "Enter {key}" },
|
|
106
115
|
deepLinkKeysRequired: { id: "deepLinkKeysRequired", defaultMessage: "Deep link keys are required" },
|
|
@@ -125,6 +134,7 @@ jest.mock("../../constants", () => ({
|
|
|
125
134
|
],
|
|
126
135
|
DEEP_LINK: "DEEP_LINK",
|
|
127
136
|
EXTERNAL_LINK: "EXTERNAL_LINK",
|
|
137
|
+
TAP_ACTION_APP: "APP",
|
|
128
138
|
}));
|
|
129
139
|
|
|
130
140
|
describe("PlatformContentFields", () => {
|
|
@@ -147,8 +157,7 @@ describe("PlatformContentFields", () => {
|
|
|
147
157
|
handleTitleChange: jest.fn(),
|
|
148
158
|
handleMessageChange: jest.fn(),
|
|
149
159
|
handleMediaTypeChange: jest.fn(),
|
|
150
|
-
|
|
151
|
-
handleLinkTypeChange: jest.fn(),
|
|
160
|
+
handleTapActionChange: jest.fn(),
|
|
152
161
|
handleDeepLinkChange: jest.fn(),
|
|
153
162
|
handleDeepLinkKeysChange: jest.fn(),
|
|
154
163
|
handleExternalLinkChange: jest.fn(),
|
|
@@ -309,30 +318,50 @@ describe("PlatformContentFields", () => {
|
|
|
309
318
|
});
|
|
310
319
|
});
|
|
311
320
|
|
|
312
|
-
describe("
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
321
|
+
describe("Notification tap", () => {
|
|
322
|
+
// Second select: the first one is Media type
|
|
323
|
+
const getTapSelect = (container) => container.querySelectorAll("select")[1];
|
|
324
|
+
|
|
325
|
+
it("shows App (default) with its help text when there is no tap action", () => {
|
|
326
|
+
const { container } = renderComponent({
|
|
327
|
+
content: { ...defaultProps.content, actionOnClick: false },
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
expect(container.textContent).toContain("Notification tap");
|
|
331
|
+
expect(container.textContent).toContain("When tapped, open");
|
|
332
|
+
expect(getTapSelect(container)).toHaveValue("APP");
|
|
333
|
+
expect(container.textContent).toContain("Opens your app. Choose a link to send people to a specific page instead.");
|
|
334
|
+
expect(container.textContent).not.toContain("Buttons and Links");
|
|
335
|
+
});
|
|
336
|
+
|
|
337
|
+
it("calls the tap action handler with the chosen option", () => {
|
|
338
|
+
const { container } = renderComponent();
|
|
316
339
|
|
|
317
|
-
fireEvent.
|
|
340
|
+
fireEvent.change(getTapSelect(container), { target: { value: EXTERNAL_LINK } });
|
|
318
341
|
|
|
319
|
-
expect(defaultProps.handlers.
|
|
342
|
+
expect(defaultProps.handlers.handleTapActionChange).toHaveBeenCalledWith(EXTERNAL_LINK);
|
|
320
343
|
});
|
|
321
344
|
|
|
322
|
-
it("
|
|
345
|
+
it("shows the deep link select, without the App help text, for Deep link", () => {
|
|
323
346
|
const { container } = renderComponent({
|
|
324
|
-
content: { ...defaultProps.content, actionOnClick: true },
|
|
347
|
+
content: { ...defaultProps.content, actionOnClick: true, linkType: DEEP_LINK },
|
|
325
348
|
});
|
|
326
349
|
|
|
327
|
-
expect(container
|
|
350
|
+
expect(getTapSelect(container)).toHaveValue(DEEP_LINK);
|
|
351
|
+
expect(container.querySelectorAll("select")).toHaveLength(3);
|
|
352
|
+
expect(container.textContent).not.toContain("Opens your app.");
|
|
328
353
|
});
|
|
329
354
|
|
|
330
|
-
it("
|
|
355
|
+
it("shows the URL input for External link", () => {
|
|
331
356
|
const { container } = renderComponent({
|
|
332
|
-
content: { ...defaultProps.content, actionOnClick:
|
|
357
|
+
content: { ...defaultProps.content, actionOnClick: true, linkType: EXTERNAL_LINK },
|
|
358
|
+
// plain fn: resetMocks wipes jest.fn implementations
|
|
359
|
+
formatMessage: (msg) => msg?.defaultMessage ?? "",
|
|
333
360
|
});
|
|
334
361
|
|
|
335
|
-
expect(container
|
|
362
|
+
expect(getTapSelect(container)).toHaveValue(EXTERNAL_LINK);
|
|
363
|
+
expect(container.textContent).toContain("URL");
|
|
364
|
+
expect(container.querySelector("#mobile-push-external-link-input")).toHaveAttribute("placeholder", "Enter URL");
|
|
336
365
|
});
|
|
337
366
|
});
|
|
338
367
|
|
|
@@ -380,7 +409,7 @@ describe("PlatformContentFields", () => {
|
|
|
380
409
|
content: { ...defaultProps.content, mediaType: "CAROUSEL" },
|
|
381
410
|
});
|
|
382
411
|
|
|
383
|
-
expect(container.textContent).not.toContain("
|
|
412
|
+
expect(container.textContent).not.toContain("Notification tap");
|
|
384
413
|
expect(container.textContent).not.toContain("CtaButtons");
|
|
385
414
|
});
|
|
386
415
|
|
|
@@ -389,7 +418,7 @@ describe("PlatformContentFields", () => {
|
|
|
389
418
|
content: { ...defaultProps.content, mediaType: "IMAGE" },
|
|
390
419
|
});
|
|
391
420
|
|
|
392
|
-
expect(container.textContent).toContain("
|
|
421
|
+
expect(container.textContent).toContain("Notification tap");
|
|
393
422
|
});
|
|
394
423
|
});
|
|
395
424
|
|
|
@@ -50,6 +50,8 @@ export const MEDIA_TYPES_OPTIONS = [
|
|
|
50
50
|
export const MOBILE_PUSH_CHANNEL = "MOBILEPUSH";
|
|
51
51
|
export const ANDROID = "ANDROID";
|
|
52
52
|
export const IOS = "IOS";
|
|
53
|
+
// Platforms dropdown value for Android and iOS together
|
|
54
|
+
export const BOTH_PLATFORMS = "BOTH";
|
|
53
55
|
export const ALLOWED_IMAGE_EXTENSIONS_REGEX = /\.(jpe?g|png)$/i;
|
|
54
56
|
export const MPUSH_IMG_SIZE = 2000000; // 2MB
|
|
55
57
|
export const MPUSH_VIDEO_SIZE = 209715200; // 200MB (200 * 1024 * 1024)
|
|
@@ -73,6 +75,9 @@ export const LINK_TYPE_OPTIONS = [
|
|
|
73
75
|
{ label: 'External Link', value: EXTERNAL_LINK },
|
|
74
76
|
];
|
|
75
77
|
|
|
78
|
+
// "When tapped, open" dropdown value for opening the app (no link); the other values are DEEP_LINK / EXTERNAL_LINK
|
|
79
|
+
export const TAP_ACTION_APP = 'APP';
|
|
80
|
+
|
|
76
81
|
export const EXTERNAL_LINK_LOWERCASE = 'external link';
|
|
77
82
|
export const PRIMARY = 'PRIMARY';
|
|
78
83
|
export const SECONDARY = 'SECONDARY';
|