@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
package/constants/unified.js
CHANGED
|
@@ -46,7 +46,6 @@ export const HOSPITALITY_BASED_SCOPE = 'HOSPITALITY_BASED_SCOPE';
|
|
|
46
46
|
export const REGISTRATION_CUSTOM_FIELD = 'Registration custom fields';
|
|
47
47
|
export const GIFT_CARDS = 'GIFT_CARDS';
|
|
48
48
|
export const PROMO_ENGINE = 'PROMO_ENGINE';
|
|
49
|
-
export const ENABLE_NEW_MPUSH = 'ENABLE_NEW_MPUSH';
|
|
50
49
|
export const ENABLE_NEW_EDITOR_FLOW_INAPP = 'ENABLE_NEW_EDITOR_FLOW_INAPP';
|
|
51
50
|
// Per-channel flags for the FormBuilder V3 migration. Each routes its channel to
|
|
52
51
|
// the new functional FormBuilder; later channels get their own flags (…_EMAIL).
|
package/index.js
CHANGED
|
@@ -52,19 +52,10 @@ import Gallery from './v2Containers/Assets/Gallery';
|
|
|
52
52
|
import galleryReducer from './v2Containers/Assets/Gallery/reducer';
|
|
53
53
|
import gallerySagas from './v2Containers/Assets/Gallery/sagas';
|
|
54
54
|
|
|
55
|
-
import MobilepushCreate from './v2Containers/MobilePush/Create';
|
|
56
|
-
import mobilepushCreateReducer from './v2Containers/MobilePush/Create/reducer';
|
|
57
|
-
import mobilepushCreateSaga from './v2Containers/MobilePush/Create/sagas';
|
|
58
|
-
|
|
59
55
|
import FTP from './v2Containers/FTP';
|
|
60
56
|
import FTPReducer from './v2Containers/FTP/reducer';
|
|
61
57
|
import FTPSagas from './v2Containers/FTP/sagas';
|
|
62
58
|
|
|
63
|
-
import MobilepushEdit from './v2Containers/MobilePush/Edit';
|
|
64
|
-
import mobilepushEditReducer from './v2Containers/MobilePush/Edit/reducer';
|
|
65
|
-
import mobilepushEditSaga from './v2Containers/MobilePush/Edit/sagas';
|
|
66
|
-
|
|
67
|
-
|
|
68
59
|
import LineCreate from './v2Containers/Line/Container';
|
|
69
60
|
import lineCreateReducer from './v2Containers/Line/Container/reducer';
|
|
70
61
|
import lineCreateSaga from './v2Containers/Line/Container/sagas';
|
|
@@ -128,8 +119,6 @@ const CallTaskContainer = {CallTask, callTaskReducer, callTaskSaga};
|
|
|
128
119
|
const WeChatMapTemplateContainer = {WeChatMapTemplate, weChatMapTemplateReducer, weChatMapTemplateSaga};
|
|
129
120
|
const WeChatRichMediaCreateContainer = {WeChatRichMediaCreate, weChatRichMediaCreateReducer, weChatRichMediaCreateSaga};
|
|
130
121
|
const WeChatRichMediaEditContainer = {WeChatRichMediaEdit, weChatRichMediaEditReducer, weChatRichMediaEditSaga};
|
|
131
|
-
const MobilePushCreateContainer = {MobilepushCreate, mobilepushCreateReducer, mobilepushCreateSaga};
|
|
132
|
-
const MobilePushEditContainer = {MobilepushEdit, mobilepushEditReducer, mobilepushEditSaga};
|
|
133
122
|
const LineCreateContainer = {LineCreate, lineCreateReducer, lineCreateSaga};
|
|
134
123
|
const TemplatesV2Container = {TemplatesV2, templateReducer, templateSaga};
|
|
135
124
|
const FacebookContainer = {Facebook, facebookReducer, facebookSaga};
|
|
@@ -177,8 +166,6 @@ export { CapContainer,
|
|
|
177
166
|
SmsEdit,
|
|
178
167
|
Email,
|
|
179
168
|
LineCreateContainer,
|
|
180
|
-
MobilePushCreateContainer,
|
|
181
|
-
MobilePushEditContainer,
|
|
182
169
|
TemplatesV2Container,
|
|
183
170
|
CreativesContainer,
|
|
184
171
|
updateCharCount,
|
package/package.json
CHANGED
package/services/getSchema.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { SMS, EMAIL,
|
|
1
|
+
import { SMS, EMAIL, WECHAT } from '../v2Containers/CreativesContainer/constants';
|
|
2
2
|
export default function getSchema(channel) {
|
|
3
3
|
let schemaPath = '../containers/';
|
|
4
4
|
switch (channel.toUpperCase()) {
|
|
@@ -8,9 +8,6 @@ export default function getSchema(channel) {
|
|
|
8
8
|
case EMAIL:
|
|
9
9
|
schemaPath = import(`../v2Containers/Email/initialSchema`);
|
|
10
10
|
break;
|
|
11
|
-
case MOBILE_PUSH:
|
|
12
|
-
schemaPath = import(`../v2Containers/MobilePush/initialSchema`);
|
|
13
|
-
break;
|
|
14
11
|
case WECHAT:
|
|
15
12
|
schemaPath = import(`../v2Containers/WeChat/MapTemplates/initialSchema`);
|
|
16
13
|
break;
|
|
@@ -37,14 +37,14 @@ describe('getSchema', () => {
|
|
|
37
37
|
});
|
|
38
38
|
});
|
|
39
39
|
|
|
40
|
-
it('should return
|
|
40
|
+
it('should return SMS schema (default) when channel is "mobile_push"', () => {
|
|
41
41
|
const result = getSchema('mobile_push');
|
|
42
42
|
return result.then((module) => {
|
|
43
43
|
expect(module).toBeDefined();
|
|
44
44
|
});
|
|
45
45
|
});
|
|
46
46
|
|
|
47
|
-
it('should return
|
|
47
|
+
it('should return SMS schema (default) when channel is "MOBILE_PUSH"', () => {
|
|
48
48
|
const result = getSchema('MOBILE_PUSH');
|
|
49
49
|
return result.then((module) => {
|
|
50
50
|
expect(module).toBeDefined();
|
package/utils/common.js
CHANGED
|
@@ -24,7 +24,6 @@ import {
|
|
|
24
24
|
ENABLE_WECHAT,
|
|
25
25
|
ENABLE_WEBPUSH,
|
|
26
26
|
SUPPORT_CK_EDITOR,
|
|
27
|
-
ENABLE_NEW_MPUSH,
|
|
28
27
|
ENABLE_NEW_EDITOR_FLOW_INAPP,
|
|
29
28
|
ENABLE_NEW_FORMBUILDER_SMS,
|
|
30
29
|
ENABLE_NEW_FORMBUILDER_MPUSH,
|
|
@@ -144,11 +143,6 @@ export const isEmailUnsubscribeTagOptional = Auth.hasFeatureAccess.bind(
|
|
|
144
143
|
EMAIL_UNSUBSCRIBE_TAG_MANDATORY,
|
|
145
144
|
);
|
|
146
145
|
|
|
147
|
-
export const hasNewMobilePushFeatureEnabled = Auth.hasFeatureAccess.bind(
|
|
148
|
-
null,
|
|
149
|
-
ENABLE_NEW_MPUSH,
|
|
150
|
-
);
|
|
151
|
-
|
|
152
146
|
export const hasNewEditorFlowInAppEnabled = Auth.hasFeatureAccess.bind(
|
|
153
147
|
null,
|
|
154
148
|
ENABLE_NEW_EDITOR_FLOW_INAPP,
|
|
@@ -27,6 +27,7 @@ import messages from '../v2Containers/MobilePushNew/messages';
|
|
|
27
27
|
* @param {Object} params.accountData - Account data for the payload
|
|
28
28
|
* @param {boolean} params.sameContent - Whether content is shared between platforms
|
|
29
29
|
* @param {Object} params.options - Additional options
|
|
30
|
+
* @param {string} [params.options.skipPlatform] - ANDROID or IOS: leave out a supported platform the user chose not to configure
|
|
30
31
|
* @param {Object} params.intl - Internationalization object for messages
|
|
31
32
|
*/
|
|
32
33
|
const createMobilePushPayload = ({
|
|
@@ -41,8 +42,8 @@ const createMobilePushPayload = ({
|
|
|
41
42
|
intl,
|
|
42
43
|
}) => {
|
|
43
44
|
// Platform support checks must be at the top
|
|
44
|
-
const isAndroidSupported = accountData?.configs?.android === '1';
|
|
45
|
-
const isIosSupported = accountData?.configs?.ios === '1';
|
|
45
|
+
const isAndroidSupported = accountData?.configs?.android === '1' && options?.skipPlatform !== ANDROID;
|
|
46
|
+
const isIosSupported = accountData?.configs?.ios === '1' && options?.skipPlatform !== IOS;
|
|
46
47
|
|
|
47
48
|
const {
|
|
48
49
|
accountId: accountIdFromAccountData, id, licenseCode: licenseCodeFromAccountData, sourceAccountIdentifier, sourceType: sourceTypeFromAccountData, sourceTypeName,
|
|
@@ -121,6 +122,44 @@ const createMobilePushPayload = ({
|
|
|
121
122
|
return payload;
|
|
122
123
|
};
|
|
123
124
|
|
|
125
|
+
/**
|
|
126
|
+
* Carousel cards as Save sends them (also used by the Test & Preview payload)
|
|
127
|
+
* @param {Array} carouselData - Editor carousel cards
|
|
128
|
+
* @returns {Array} Cards with deep link keys appended to button links
|
|
129
|
+
*/
|
|
130
|
+
export function buildCarouselCards(carouselData = []) {
|
|
131
|
+
return (carouselData || []).map((card) => {
|
|
132
|
+
const {
|
|
133
|
+
mediaType,
|
|
134
|
+
imageUrl,
|
|
135
|
+
videoSrc,
|
|
136
|
+
videoPreviewImg,
|
|
137
|
+
buttons,
|
|
138
|
+
} = card || {};
|
|
139
|
+
|
|
140
|
+
return {
|
|
141
|
+
mediaType: mediaType || IMAGE.toLowerCase(),
|
|
142
|
+
imageUrl: imageUrl || '',
|
|
143
|
+
videoSrc: videoSrc || '',
|
|
144
|
+
// Thumbnail, so the phone preview can show the video card when editing
|
|
145
|
+
...(videoPreviewImg && { videoPreviewImg }),
|
|
146
|
+
buttons: buttons ? buttons.map((button) => {
|
|
147
|
+
const { linkType: buttonLinkType, deepLinkKeys, deepLinkValue: buttonDeepLinkValue } = button || {};
|
|
148
|
+
if (buttonLinkType === DEEP_LINK && deepLinkKeys && buttonDeepLinkValue) {
|
|
149
|
+
const deepLinkKeysArray = Array.isArray(deepLinkKeys) ? deepLinkKeys : [deepLinkKeys];
|
|
150
|
+
const updatedDeepLinkValue = appendDeepLinkKeysToUrl(buttonDeepLinkValue, deepLinkKeysArray);
|
|
151
|
+
|
|
152
|
+
return {
|
|
153
|
+
...button,
|
|
154
|
+
deepLinkValue: updatedDeepLinkValue,
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
return button;
|
|
158
|
+
}) : [],
|
|
159
|
+
};
|
|
160
|
+
});
|
|
161
|
+
}
|
|
162
|
+
|
|
124
163
|
/**
|
|
125
164
|
* Builds platform-specific content for the payload
|
|
126
165
|
* @param {Object} content - Platform content (Android/iOS)
|
|
@@ -129,7 +168,7 @@ const createMobilePushPayload = ({
|
|
|
129
168
|
* @param {string} platform - Platform (ANDROID/IOS)
|
|
130
169
|
* @returns {Object} Platform-specific content
|
|
131
170
|
*/
|
|
132
|
-
function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview, platform) {
|
|
171
|
+
export function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview, platform) {
|
|
133
172
|
const {
|
|
134
173
|
title = '',
|
|
135
174
|
message = '',
|
|
@@ -184,7 +223,8 @@ function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview, platfo
|
|
|
184
223
|
platformContent.expandableDetails.style = VIDEO;
|
|
185
224
|
platformContent.expandableDetails.message = message;
|
|
186
225
|
platformContent.expandableDetails.media = [{
|
|
187
|
-
|
|
226
|
+
// This platform's own video; mpushVideoSrcAndPreview is shared by both tabs
|
|
227
|
+
url: content?.videoSrc || content?.mediaList?.[0]?.url || '',
|
|
188
228
|
text: content?.mediaList?.[0]?.text || '',
|
|
189
229
|
type: VIDEO,
|
|
190
230
|
}];
|
|
@@ -201,11 +241,11 @@ function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview, platfo
|
|
|
201
241
|
type: type.toLowerCase(),
|
|
202
242
|
}];
|
|
203
243
|
} else {
|
|
204
|
-
//
|
|
244
|
+
// No mediaList: use this platform's own GIF
|
|
205
245
|
platformContent.expandableDetails.style = GIF;
|
|
206
246
|
platformContent.expandableDetails.message = message;
|
|
207
247
|
platformContent.expandableDetails.media = [{
|
|
208
|
-
url:
|
|
248
|
+
url: content?.videoSrc || '',
|
|
209
249
|
text: '',
|
|
210
250
|
type: GIF, // Backend expects GIF type for GIFs
|
|
211
251
|
}];
|
|
@@ -218,33 +258,7 @@ function buildPlatformContent(content, imageSrc, mpushVideoSrcAndPreview, platfo
|
|
|
218
258
|
|
|
219
259
|
// Handle carouselData
|
|
220
260
|
if (content?.carouselData?.length > 0) {
|
|
221
|
-
platformContent.expandableDetails.carouselData = content.carouselData
|
|
222
|
-
const {
|
|
223
|
-
mediaType,
|
|
224
|
-
imageUrl,
|
|
225
|
-
videoSrc,
|
|
226
|
-
buttons,
|
|
227
|
-
} = card || {};
|
|
228
|
-
|
|
229
|
-
return {
|
|
230
|
-
mediaType: mediaType || IMAGE.toLowerCase(),
|
|
231
|
-
imageUrl: imageUrl || '',
|
|
232
|
-
videoSrc: videoSrc || '',
|
|
233
|
-
buttons: buttons ? buttons.map((button) => {
|
|
234
|
-
const { linkType: buttonLinkType, deepLinkKeys, deepLinkValue: buttonDeepLinkValue } = button || {};
|
|
235
|
-
if (buttonLinkType === DEEP_LINK && deepLinkKeys && buttonDeepLinkValue) {
|
|
236
|
-
const deepLinkKeysArray = Array.isArray(deepLinkKeys) ? deepLinkKeys : [deepLinkKeys];
|
|
237
|
-
const updatedDeepLinkValue = appendDeepLinkKeysToUrl(buttonDeepLinkValue, deepLinkKeysArray);
|
|
238
|
-
|
|
239
|
-
return {
|
|
240
|
-
...button,
|
|
241
|
-
deepLinkValue: updatedDeepLinkValue,
|
|
242
|
-
};
|
|
243
|
-
}
|
|
244
|
-
return button;
|
|
245
|
-
}) : [],
|
|
246
|
-
};
|
|
247
|
-
});
|
|
261
|
+
platformContent.expandableDetails.carouselData = buildCarouselCards(content.carouselData);
|
|
248
262
|
}
|
|
249
263
|
|
|
250
264
|
// Handle mediaList
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { IntlProvider } from 'react-intl';
|
|
2
|
-
import createMobilePushPayload from '../createMobilePushPayload';
|
|
2
|
+
import createMobilePushPayload, { buildCarouselCards } from '../createMobilePushPayload';
|
|
3
3
|
import messages from '../../v2Containers/MobilePushNew/messages';
|
|
4
4
|
|
|
5
5
|
// Create a mock intl object
|
|
@@ -48,6 +48,7 @@ jest.mock('../createMobilePushPayload', () => {
|
|
|
48
48
|
__esModule: true,
|
|
49
49
|
default: mockCreateMobilePushPayload,
|
|
50
50
|
appendDeepLinkKeysToUrl: originalModule.appendDeepLinkKeysToUrl,
|
|
51
|
+
buildCarouselCards: originalModule.buildCarouselCards,
|
|
51
52
|
};
|
|
52
53
|
});
|
|
53
54
|
|
|
@@ -261,6 +262,21 @@ describe('createMobilePushPayload', () => {
|
|
|
261
262
|
accountData: unsupportedAccountData,
|
|
262
263
|
})).not.toThrow();
|
|
263
264
|
});
|
|
265
|
+
|
|
266
|
+
it.each([
|
|
267
|
+
['IOS', 'ANDROID', { androidContent: { title: 'Title', message: 'Message' }, iosContent: { title: '', message: '' } }],
|
|
268
|
+
['ANDROID', 'IOS', { androidContent: { title: '', message: '' }, iosContent: { title: 'Title', message: 'Message' } }],
|
|
269
|
+
])('leaves out a supported platform passed as skipPlatform (%s)', (skipPlatform, keptPlatform, content) => {
|
|
270
|
+
const result = callWithIntl({
|
|
271
|
+
templateName: 'Test',
|
|
272
|
+
...content,
|
|
273
|
+
accountData: mockAccountData,
|
|
274
|
+
options: { skipPlatform },
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
expect(result.versions.base[skipPlatform]).toBeUndefined();
|
|
278
|
+
expect(result.versions.base[keptPlatform]).toBeDefined();
|
|
279
|
+
});
|
|
264
280
|
});
|
|
265
281
|
|
|
266
282
|
// Account Data Validation Tests
|
|
@@ -335,33 +351,67 @@ describe('createMobilePushPayload', () => {
|
|
|
335
351
|
expect(result.versions.base.ANDROID.expandableDetails.image).toBe('test-image.jpg');
|
|
336
352
|
});
|
|
337
353
|
|
|
338
|
-
it('should handle VIDEO media type with
|
|
354
|
+
it('should handle VIDEO media type with the platform videoSrc', () => {
|
|
339
355
|
const result = callWithIntl({
|
|
340
356
|
templateName: 'Test',
|
|
341
357
|
androidContent: {
|
|
342
358
|
title: 'Title',
|
|
343
359
|
message: 'Message',
|
|
344
360
|
mediaType: 'VIDEO',
|
|
361
|
+
videoSrc: 'test-video.mp4',
|
|
345
362
|
},
|
|
346
363
|
iosContent: { title: 'Title', message: 'Message' },
|
|
347
364
|
accountData: mockAccountData,
|
|
348
|
-
|
|
365
|
+
// The shared slot is ignored; it can hold the other tab's video
|
|
366
|
+
mpushVideoSrcAndPreview: { mpushVideoSrc: 'other-tab.mp4' },
|
|
349
367
|
});
|
|
350
368
|
expect(result.versions.base.ANDROID.expandableDetails.media[0].url).toBe('test-video.mp4');
|
|
351
369
|
expect(result.versions.base.ANDROID.expandableDetails.media[0].type).toBe('VIDEO');
|
|
352
370
|
});
|
|
353
371
|
|
|
354
|
-
it('should
|
|
372
|
+
it('should fall back to mediaList for a VIDEO with no videoSrc', () => {
|
|
373
|
+
const result = callWithIntl({
|
|
374
|
+
templateName: 'Test',
|
|
375
|
+
androidContent: {
|
|
376
|
+
title: 'Title',
|
|
377
|
+
message: 'Message',
|
|
378
|
+
mediaType: 'VIDEO',
|
|
379
|
+
mediaList: [{ url: 'saved.mp4', text: 'Saved' }],
|
|
380
|
+
},
|
|
381
|
+
iosContent: { title: 'Title', message: 'Message' },
|
|
382
|
+
accountData: mockAccountData,
|
|
383
|
+
});
|
|
384
|
+
expect(result.versions.base.ANDROID.expandableDetails.media[0]).toEqual({ url: 'saved.mp4', text: 'Saved', type: 'VIDEO' });
|
|
385
|
+
});
|
|
386
|
+
|
|
387
|
+
it('saves each platform its own video', () => {
|
|
388
|
+
const result = callWithIntl({
|
|
389
|
+
templateName: 'Test',
|
|
390
|
+
androidContent: {
|
|
391
|
+
title: 'Title', message: 'Message', mediaType: 'VIDEO', videoSrc: 'a.mp4',
|
|
392
|
+
},
|
|
393
|
+
iosContent: {
|
|
394
|
+
title: 'Title', message: 'Message', mediaType: 'VIDEO', videoSrc: 'b.mp4',
|
|
395
|
+
},
|
|
396
|
+
accountData: mockAccountData,
|
|
397
|
+
mpushVideoSrcAndPreview: { mpushVideoSrc: 'b.mp4' },
|
|
398
|
+
});
|
|
399
|
+
expect(result.versions.base.ANDROID.expandableDetails.media[0].url).toBe('a.mp4');
|
|
400
|
+
expect(result.versions.base.IOS.expandableDetails.media[0].url).toBe('b.mp4');
|
|
401
|
+
});
|
|
402
|
+
|
|
403
|
+
it('should handle GIF media type with the platform videoSrc', () => {
|
|
355
404
|
const result = callWithIntl({
|
|
356
405
|
templateName: 'Test',
|
|
357
406
|
androidContent: {
|
|
358
407
|
title: 'Title',
|
|
359
408
|
message: 'Message',
|
|
360
409
|
mediaType: 'GIF',
|
|
410
|
+
videoSrc: 'test-gif.gif',
|
|
361
411
|
},
|
|
362
412
|
iosContent: { title: 'Title', message: 'Message' },
|
|
363
413
|
accountData: mockAccountData,
|
|
364
|
-
mpushVideoSrcAndPreview: { mpushVideoSrc: '
|
|
414
|
+
mpushVideoSrcAndPreview: { mpushVideoSrc: 'other-tab.gif' },
|
|
365
415
|
});
|
|
366
416
|
expect(result.versions.base.ANDROID.expandableDetails.media[0].url).toBe('test-gif.gif');
|
|
367
417
|
expect(result.versions.base.ANDROID.expandableDetails.media[0].type).toBe('GIF');
|
|
@@ -860,13 +910,12 @@ describe('createMobilePushPayload', () => {
|
|
|
860
910
|
title: 'Title',
|
|
861
911
|
message: 'Message',
|
|
862
912
|
mediaType: 'GIF',
|
|
913
|
+
videoSrc: 'test-gif.gif',
|
|
863
914
|
},
|
|
864
915
|
iosContent: { title: 'Title', message: 'Message' },
|
|
865
916
|
accountData: mockAccountData,
|
|
866
|
-
mpushVideoSrcAndPreview: { mpushVideoSrc: 'test-gif.gif' },
|
|
867
917
|
});
|
|
868
|
-
|
|
869
|
-
expect(result.versions.base.ANDROID.expandableDetails.media[0].type).toBe('GIF');
|
|
918
|
+
expect(result.versions.base.ANDROID.expandableDetails.media[0]).toEqual({ url: 'test-gif.gif', text: '', type: 'GIF' });
|
|
870
919
|
});
|
|
871
920
|
|
|
872
921
|
it('should handle options with custom mode', () => {
|
|
@@ -1322,3 +1371,48 @@ describe('createMobilePushPayload', () => {
|
|
|
1322
1371
|
});
|
|
1323
1372
|
});
|
|
1324
1373
|
});
|
|
1374
|
+
|
|
1375
|
+
describe('buildCarouselCards', () => {
|
|
1376
|
+
it.each([
|
|
1377
|
+
['no argument', undefined],
|
|
1378
|
+
['null', null],
|
|
1379
|
+
['an empty array', []],
|
|
1380
|
+
])('returns [] for %s', (_label, input) => {
|
|
1381
|
+
expect(buildCarouselCards(input)).toEqual([]);
|
|
1382
|
+
});
|
|
1383
|
+
|
|
1384
|
+
it('fills defaults for a missing card', () => {
|
|
1385
|
+
expect(buildCarouselCards([null])).toEqual([
|
|
1386
|
+
{ mediaType: 'image', imageUrl: '', videoSrc: '', buttons: [] },
|
|
1387
|
+
]);
|
|
1388
|
+
});
|
|
1389
|
+
|
|
1390
|
+
it('keeps the video thumbnail only when there is one', () => {
|
|
1391
|
+
const [withThumb, withoutThumb] = buildCarouselCards([
|
|
1392
|
+
{ mediaType: 'video', videoSrc: 'a.mp4', videoPreviewImg: 'a.png' },
|
|
1393
|
+
{ mediaType: 'video', videoSrc: 'b.mp4', videoPreviewImg: '' },
|
|
1394
|
+
]);
|
|
1395
|
+
|
|
1396
|
+
expect(withThumb).toEqual({ mediaType: 'video', imageUrl: '', videoSrc: 'a.mp4', videoPreviewImg: 'a.png', buttons: [] });
|
|
1397
|
+
expect(withoutThumb).toEqual({ mediaType: 'video', imageUrl: '', videoSrc: 'b.mp4', buttons: [] });
|
|
1398
|
+
});
|
|
1399
|
+
|
|
1400
|
+
it('appends deep link keys and leaves other buttons as they are', () => {
|
|
1401
|
+
const externalButton = { linkType: 'EXTERNAL_LINK', externalLinkValue: 'https://x.com' };
|
|
1402
|
+
const [card] = buildCarouselCards([{
|
|
1403
|
+
mediaType: 'image',
|
|
1404
|
+
imageUrl: 'a.jpg',
|
|
1405
|
+
buttons: [
|
|
1406
|
+
{ linkType: 'DEEP_LINK', deepLinkValue: 'app://home', deepLinkKeys: 'id' },
|
|
1407
|
+
externalButton,
|
|
1408
|
+
null,
|
|
1409
|
+
],
|
|
1410
|
+
}]);
|
|
1411
|
+
|
|
1412
|
+
expect(card.buttons).toEqual([
|
|
1413
|
+
{ linkType: 'DEEP_LINK', deepLinkValue: 'app://home?id=id', deepLinkKeys: 'id' },
|
|
1414
|
+
externalButton,
|
|
1415
|
+
null,
|
|
1416
|
+
]);
|
|
1417
|
+
});
|
|
1418
|
+
});
|
|
@@ -235,9 +235,10 @@ export const CapMpushCTA = (props) => {
|
|
|
235
235
|
type="flex"
|
|
236
236
|
>
|
|
237
237
|
<CapColumn>
|
|
238
|
-
<CapRow className="mpush-cta-row">
|
|
238
|
+
<CapRow type="flex" align="middle" className="mpush-cta-row">
|
|
239
239
|
<CapColumn>
|
|
240
|
-
|
|
240
|
+
{/* Not "launch": its SVG mask id collides with other launch icons and renders a square */}
|
|
241
|
+
<CapIcon size="s" type="open-in-new" />
|
|
241
242
|
</CapColumn>
|
|
242
243
|
<CapColumn className="btn-text">
|
|
243
244
|
<CapLabel type="label2" className="mpush-saved-cta-button-text">
|
|
@@ -251,13 +252,11 @@ export const CapMpushCTA = (props) => {
|
|
|
251
252
|
<CapTag className="cta-type-label">{formatMessage(messages.urlDeepLink)}</CapTag>
|
|
252
253
|
: <CapTag className="cta-type-label">{formatMessage(messages.urlExternalLink)}</CapTag>}
|
|
253
254
|
</CapColumn>
|
|
254
|
-
<CapColumn>
|
|
255
|
-
{urlType === DEEP_LINK ? selectedDeepLink?.label :
|
|
256
|
-
</CapColumn>
|
|
257
|
-
<CapColumn>
|
|
255
|
+
<CapColumn className="mpush-saved-cta-link" title={cta?.url}>
|
|
256
|
+
{urlType === DEEP_LINK ? selectedDeepLink?.label : cta?.url}
|
|
258
257
|
</CapColumn>
|
|
259
258
|
<CapColumn>
|
|
260
|
-
<CapRow className="cta-action-grp">
|
|
259
|
+
<CapRow type="flex" align="middle" className="cta-action-grp">
|
|
261
260
|
<CapColumn
|
|
262
261
|
className="mpush-saved-cta-edit-icon"
|
|
263
262
|
onClick={() => isSavedCta(index, false)}
|
|
@@ -320,6 +319,8 @@ export const CapMpushCTA = (props) => {
|
|
|
320
319
|
</CapRow>
|
|
321
320
|
)}
|
|
322
321
|
{urlType === EXTERNAL_URL && (
|
|
322
|
+
// Wrapper lets the stylesheet size the label row to match "Type of link"
|
|
323
|
+
<div className="mpush-cta-external-link-field">
|
|
323
324
|
<CapTagListWithInput
|
|
324
325
|
inputId="mpush-cta-external-link"
|
|
325
326
|
inputValue={localUrlValues[index] || ''}
|
|
@@ -329,8 +330,7 @@ export const CapMpushCTA = (props) => {
|
|
|
329
330
|
inputMaxLength={URL_MAX_LENGTH}
|
|
330
331
|
inputErrorMessage={urlError}
|
|
331
332
|
headingText={formatMessage(messages.urlExternalLink)}
|
|
332
|
-
headingStyle={{
|
|
333
|
-
containerStyle={{ width: '70%', marginTop: '-0.625rem' }}
|
|
333
|
+
headingStyle={{ whiteSpace: 'nowrap' }}
|
|
334
334
|
moduleFilterEnabled={location?.query?.type !== "embedded"}
|
|
335
335
|
onTagSelect={onButtonTagSelect}
|
|
336
336
|
onContextChange={handleOnTagsContextChange}
|
|
@@ -340,6 +340,7 @@ export const CapMpushCTA = (props) => {
|
|
|
340
340
|
selectedOfferDetails={selectedOfferDetails}
|
|
341
341
|
inputProps={{ 'data-index': index }}
|
|
342
342
|
/>
|
|
343
|
+
</div>
|
|
343
344
|
)}
|
|
344
345
|
</CapColumn>
|
|
345
346
|
{urlType === DEEP_LINK && ctaDeepLinkValue && deepLinkKeysFromSelectionArray.length > 0 && (
|
|
@@ -31,6 +31,18 @@
|
|
|
31
31
|
margin-top: $CAP_SPACE_12;
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
// External link column: its label row (heading + "Add label") gets the height of the
|
|
35
|
+
// "Type of link" label plus its 8px gap, so the input lines up with the dropdown
|
|
36
|
+
.mpush-cta-external-link-field {
|
|
37
|
+
width: 70%;
|
|
38
|
+
|
|
39
|
+
> .ant-col > .ant-row:first-child {
|
|
40
|
+
height: 1.449rem; // CapHeading h4 line height
|
|
41
|
+
margin-bottom: $CAP_SPACE_08;
|
|
42
|
+
justify-content: space-between;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
34
46
|
.mpush-cta-save-delete-btn {
|
|
35
47
|
margin-top: $CAP_SPACE_16;
|
|
36
48
|
|
|
@@ -55,13 +67,27 @@
|
|
|
55
67
|
padding: $CAP_SPACE_08 $CAP_SPACE_12;
|
|
56
68
|
border-radius: $CAP_SPACE_04;
|
|
57
69
|
height: $CAP_SPACE_40;
|
|
70
|
+
gap: $CAP_SPACE_12;
|
|
58
71
|
|
|
59
72
|
.mpush-saved-cta-button-text {
|
|
60
73
|
font-weight: 500;
|
|
61
74
|
}
|
|
62
75
|
|
|
63
|
-
|
|
64
|
-
|
|
76
|
+
// Inline icons sit on the text baseline (a few px high); as blocks they centre with the text
|
|
77
|
+
.cap-icon-v2 {
|
|
78
|
+
display: flex;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// URL fills the space up to the icons and ends in "..." when too long.
|
|
82
|
+
// contain: inline-size stops a long URL from widening the whole form.
|
|
83
|
+
.mpush-saved-cta-link {
|
|
84
|
+
flex: 1;
|
|
85
|
+
min-width: 0;
|
|
86
|
+
contain: inline-size;
|
|
87
|
+
white-space: nowrap;
|
|
88
|
+
overflow: hidden;
|
|
89
|
+
text-overflow: ellipsis;
|
|
90
|
+
color: $CAP_G04;
|
|
65
91
|
}
|
|
66
92
|
}
|
|
67
93
|
.cta-label {
|
|
@@ -89,5 +115,5 @@
|
|
|
89
115
|
padding-left: 1rem;
|
|
90
116
|
}
|
|
91
117
|
.btn-text {
|
|
92
|
-
margin-left: $
|
|
118
|
+
margin-left: $CAP_SPACE_08;
|
|
93
119
|
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shallow } from 'enzyme';
|
|
3
|
+
import CapIcon from '@capillarytech/cap-ui-library/CapIcon';
|
|
4
|
+
import { CapMpushCTA } from '../index';
|
|
5
|
+
import CapTagListWithInput from '../../CapTagListWithInput';
|
|
6
|
+
import { DEEP_LINK, EXTERNAL_URL } from '../constants';
|
|
7
|
+
import { PRIMARY } from '../../../v2Containers/MobilePushNew/constants';
|
|
8
|
+
|
|
9
|
+
jest.mock('../../../v2Containers/TagList', () => () => null);
|
|
10
|
+
jest.mock('../../CapTagListWithInput', () => () => null);
|
|
11
|
+
|
|
12
|
+
const intl = { formatMessage: (msg) => msg?.defaultMessage || '' };
|
|
13
|
+
|
|
14
|
+
const renderCta = (cta, extraProps = {}) => shallow(
|
|
15
|
+
<CapMpushCTA
|
|
16
|
+
intl={intl}
|
|
17
|
+
ctaData={[{ index: 0, text: 'Shop', ...cta }]}
|
|
18
|
+
buttonType={PRIMARY}
|
|
19
|
+
updateHandler={jest.fn()}
|
|
20
|
+
deleteHandler={jest.fn()}
|
|
21
|
+
deepLink={[{ value: 'app://home', label: 'Home' }]}
|
|
22
|
+
location={{ query: {} }}
|
|
23
|
+
{...extraProps}
|
|
24
|
+
/>,
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
describe('CapMpushCTA', () => {
|
|
28
|
+
describe('saved button card', () => {
|
|
29
|
+
it('uses the mask-free "open-in-new" icon, not "launch"', () => {
|
|
30
|
+
const wrapper = renderCta({ urlType: EXTERNAL_URL, url: 'https://google.com', isSaved: true });
|
|
31
|
+
const iconTypes = wrapper.find(CapIcon).map((icon) => icon.prop('type'));
|
|
32
|
+
|
|
33
|
+
expect(iconTypes).toContain('open-in-new');
|
|
34
|
+
expect(iconTypes).not.toContain('launch');
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('shows the external URL in the link column with the URL as tooltip', () => {
|
|
38
|
+
const wrapper = renderCta({ urlType: EXTERNAL_URL, url: 'https://google.com', isSaved: true });
|
|
39
|
+
const link = wrapper.find('.mpush-saved-cta-link');
|
|
40
|
+
|
|
41
|
+
expect(link.prop('children')).toBe('https://google.com');
|
|
42
|
+
expect(link.prop('title')).toBe('https://google.com');
|
|
43
|
+
expect(wrapper.find('.cta-type-label').prop('children')).toBe('External link');
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('shows the selected deep link label in the link column', () => {
|
|
47
|
+
const wrapper = renderCta({ urlType: DEEP_LINK, url: 'app://home', isSaved: true });
|
|
48
|
+
|
|
49
|
+
expect(wrapper.find('.mpush-saved-cta-link').prop('children')).toBe('Home');
|
|
50
|
+
expect(wrapper.find('.cta-type-label').prop('children')).toBe('Deep link');
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
it('lays out the card rows horizontally with vertically centred items', () => {
|
|
54
|
+
const wrapper = renderCta({ urlType: EXTERNAL_URL, url: 'https://google.com', isSaved: true });
|
|
55
|
+
|
|
56
|
+
expect(wrapper.find('.mpush-cta-row').props()).toEqual(expect.objectContaining({ type: 'flex', align: 'middle' }));
|
|
57
|
+
expect(wrapper.find('.cta-action-grp').props()).toEqual(expect.objectContaining({ type: 'flex', align: 'middle' }));
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it('reopens the button for editing and deletes it from the card icons', () => {
|
|
61
|
+
const updateHandler = jest.fn();
|
|
62
|
+
const deleteHandler = jest.fn();
|
|
63
|
+
const wrapper = renderCta(
|
|
64
|
+
{ urlType: EXTERNAL_URL, url: 'https://google.com', isSaved: true },
|
|
65
|
+
{ updateHandler, deleteHandler },
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
wrapper.find('.mpush-saved-cta-edit-icon').simulate('click');
|
|
69
|
+
expect(updateHandler).toHaveBeenCalledWith(expect.objectContaining({ isSaved: false }), 0);
|
|
70
|
+
|
|
71
|
+
wrapper.find('.cta-del-icon').simulate('click');
|
|
72
|
+
expect(deleteHandler).toHaveBeenCalledWith(0);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
it('keeps the "External link" heading on one line in the edit form', () => {
|
|
77
|
+
const wrapper = renderCta({ urlType: EXTERNAL_URL, url: '', isSaved: false });
|
|
78
|
+
|
|
79
|
+
expect(wrapper.find(CapTagListWithInput).prop('headingStyle')).toEqual(
|
|
80
|
+
expect.objectContaining({ whiteSpace: 'nowrap' }),
|
|
81
|
+
);
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it('wraps the External link field so its label row lines up with "Type of link"', () => {
|
|
85
|
+
const wrapper = renderCta({ urlType: EXTERNAL_URL, url: '', isSaved: false });
|
|
86
|
+
|
|
87
|
+
expect(wrapper.find('.mpush-cta-external-link-field').find(CapTagListWithInput).exists()).toBe(true);
|
|
88
|
+
});
|
|
89
|
+
});
|