@capillarytech/creatives-library 9.2.2-alpha.sprint-cap-214249.44 → 9.2.2
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 +1 -3
- package/package.json +1 -1
- package/translations/en.json +0 -1
- package/translations/ja-JP.json +0 -1
- package/translations/zh.json +0 -1
- package/utils/common.js +6 -0
- package/utils/createMobilePushPayload.js +56 -50
- package/utils/tagValidations.js +4 -35
- package/utils/tests/createMobilePushPayload.test.js +168 -177
- package/utils/tests/tagValidations.test.js +0 -48
- package/v2Components/CapMpushCTA/index.js +57 -47
- package/v2Components/CapMpushCTA/index.scss +5 -43
- package/v2Components/CapTagList/index.js +7 -46
- package/v2Components/CapTagList/messages.js +0 -44
- package/v2Components/CapTagList/style.scss +1 -113
- package/v2Components/CommonTestAndPreview/UnifiedPreview/MobilePushPreviewContent.js +8 -11
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +1 -13
- package/v2Components/CommonTestAndPreview/constants.js +0 -2
- package/v2Components/CommonTestAndPreview/index.js +12 -51
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/MobilePushPreviewContent.test.js +5 -83
- package/v2Components/CommonTestAndPreview/tests/index.test.js +0 -100
- package/v2Components/FormBuilder/Classic.js +14 -24
- package/v2Components/FormBuilder/Functional/channels/mobilepush/config.js +0 -1
- package/v2Components/FormBuilder/Functional/channels/mobilepush/getEditorErrorDescriptor.js +1 -1
- package/v2Components/FormBuilder/Functional/channels/mobilepush/tests/validate.test.js +0 -57
- package/v2Components/FormBuilder/Functional/channels/mobilepush/validate.js +4 -4
- package/v2Components/FormBuilder/Functional/channels/sms/getEditorErrorDescriptor.js +0 -3
- package/v2Components/FormBuilder/Functional/channels/sms/tests/getEditorErrorDescriptor.test.js +0 -5
- package/v2Components/FormBuilder/Functional/channels/sms/tests/validate.test.js +0 -6
- package/v2Components/FormBuilder/Functional/channels/sms/validate.js +1 -3
- package/v2Components/FormBuilder/Functional/renderers/mpushRenderers.js +0 -3
- package/v2Components/FormBuilder/Functional/tests/mpushRenderers.test.js +0 -22
- package/v2Components/MobilePushPreviewV2/index.js +9 -22
- package/v2Components/TemplatePreview/_templatePreview.scss +2 -18
- package/v2Components/TemplatePreview/index.js +18 -20
- package/v2Components/TemplatePreview/tests/index.test.js +0 -69
- package/v2Containers/Cap/messages.js +0 -4
- package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +0 -1
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/extractContentForPreview.js +2 -12
- 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 +1 -4
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/content.test.js.snap +0 -3
- package/v2Containers/Line/Container/ImageCarousel/tests/__snapshots__/index.test.js.snap +0 -2
- package/v2Containers/Line/Container/Text/index.js +1 -3
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +0 -16
- package/v2Containers/Line/Container/tests/__snapshots__/index.test.js.snap +0 -18
- package/v2Containers/MobilePushNew/components/CtaButtons.js +47 -52
- package/v2Containers/MobilePushNew/components/MediaUploaders.js +345 -105
- package/v2Containers/MobilePushNew/components/PlatformContentFields.js +105 -127
- package/v2Containers/MobilePushNew/components/tests/CtaButtons.test.js +208 -30
- package/v2Containers/MobilePushNew/components/tests/MediaUploaders.test.js +1484 -307
- package/v2Containers/MobilePushNew/components/tests/PlatformContentFields.test.js +59 -165
- package/v2Containers/MobilePushNew/constants.js +0 -12
- package/v2Containers/MobilePushNew/hooks/tests/usePlatformSync.test.js +1 -63
- package/v2Containers/MobilePushNew/hooks/tests/useUpload.test.js +0 -78
- package/v2Containers/MobilePushNew/hooks/usePlatformSync.js +1 -40
- package/v2Containers/MobilePushNew/hooks/useUpload.js +46 -42
- package/v2Containers/MobilePushNew/index.js +290 -502
- package/v2Containers/MobilePushNew/index.scss +4 -151
- package/v2Containers/MobilePushNew/messages.js +6 -106
- package/v2Containers/MobilePushNew/tests/index.test.js +1 -483
- package/v2Containers/MobilePushNew/tests/utils.test.js +0 -110
- package/v2Containers/MobilePushNew/utils.js +0 -83
- package/v2Containers/Rcs/index.js +1 -8
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +0 -59
- package/v2Containers/SmsTrai/Create/tests/__snapshots__/index.test.js.snap +0 -4
- package/v2Containers/SmsTrai/Edit/index.js +5 -13
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +0 -15
- package/v2Containers/Templates/_templates.scss +2 -10
- package/v2Containers/Templates/index.js +81 -86
- package/v2Containers/Templates/tests/index.test.js +0 -81
- package/v2Containers/Viber/index.js +1 -3
- package/v2Containers/WebPush/Create/utils/validation.js +0 -6
- package/v2Containers/WebPush/Create/utils/validation.test.js +0 -50
- package/v2Containers/Whatsapp/index.js +5 -9
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +2 -2
- package/v2Containers/Zalo/index.js +1 -4
- package/v2Components/CapMpushCTA/tests/index.test.js +0 -150
- package/v2Components/CapTagList/TagFallbackPanel.js +0 -124
- package/v2Components/CapTagList/constants.js +0 -5
- package/v2Components/CapTagList/tests/TagFallback.test.js +0 -222
- package/v2Components/CapTagList/utils.js +0 -17
- package/v2Components/MobilePushPreviewV2/_mobilePushPreviewV2.scss +0 -7
- package/v2Components/MobilePushPreviewV2/tests/index.test.js +0 -55
- package/v2Components/TemplatePreview/_mobilePushPhone.scss +0 -72
- package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/Tests/extractContentForPreview.test.js +0 -45
- package/v2Containers/MobilePushNew/components/TapLinkActions.js +0 -76
|
@@ -16,7 +16,6 @@ export const ERROR = {
|
|
|
16
16
|
MISSING_TAG: 'missingTagsError',
|
|
17
17
|
GENERIC: 'genericValidationError',
|
|
18
18
|
BRACKET: 'tagBracketCountMismatchError',
|
|
19
|
-
DEFAULT_QUOTE: 'tagDefaultQuoteError',
|
|
20
19
|
};
|
|
21
20
|
|
|
22
21
|
/**
|
|
@@ -58,11 +57,10 @@ export default function validateSms(formData = {}, options = {}) {
|
|
|
58
57
|
if (tagValidation.valid) {
|
|
59
58
|
tabErrors[EDITOR_FIELD] = false;
|
|
60
59
|
} else {
|
|
61
|
-
const { missingTags, isBraceError
|
|
60
|
+
const { missingTags, isBraceError } = tagValidation;
|
|
62
61
|
let editorError = ERROR.GENERIC;
|
|
63
62
|
if (missingTags?.length) editorError = ERROR.MISSING_TAG;
|
|
64
63
|
else if (isBraceError) editorError = ERROR.BRACKET;
|
|
65
|
-
else if (isDefaultQuoteError) editorError = ERROR.DEFAULT_QUOTE;
|
|
66
64
|
tabErrors[EDITOR_FIELD] = editorError;
|
|
67
65
|
tabErrors['bracket-error'] = isBraceError && ERROR.BRACKET;
|
|
68
66
|
isValid = false;
|
|
@@ -72,9 +72,6 @@ const resolveInputMessage = (field, value, error, renderContext) => {
|
|
|
72
72
|
if (error === ERROR_VALUE.BRACKET) {
|
|
73
73
|
return formatSafe(intl, globalMessages.unbalanacedCurlyBraces);
|
|
74
74
|
}
|
|
75
|
-
if (error === ERROR_VALUE.DEFAULT_QUOTE) {
|
|
76
|
-
return formatSafe(intl, globalMessages.unquotedTagDefaultValue);
|
|
77
|
-
}
|
|
78
75
|
return field.errorMessage || '';
|
|
79
76
|
};
|
|
80
77
|
|
|
@@ -43,28 +43,6 @@ describe('MpushInputField', () => {
|
|
|
43
43
|
}))[0].props.errorMessage).toBe('');
|
|
44
44
|
});
|
|
45
45
|
|
|
46
|
-
it('unquoted default error shows its own message; personalization still wins over it', () => {
|
|
47
|
-
const base = { field, onChange: () => {}, renderContext: { checkValidation: true, intl } };
|
|
48
|
-
expect(kids(MpushInputField({ ...base, value: '{{a | default: x}}', error: ERROR_VALUE.DEFAULT_QUOTE }))[0].props.errorMessage)
|
|
49
|
-
.toBe('Invalid label, default value must be within quotes');
|
|
50
|
-
expect(kids(MpushInputField({
|
|
51
|
-
...base, value: '{{a | default: x}}', error: ERROR_VALUE.DEFAULT_QUOTE, renderContext: { checkValidation: false, intl },
|
|
52
|
-
}))[0].props.errorMessage).toBe('Invalid label, default value must be within quotes');
|
|
53
|
-
expect(kids(MpushInputField({
|
|
54
|
-
...base,
|
|
55
|
-
value: 'hi {{first_name | default: x}}',
|
|
56
|
-
error: ERROR_VALUE.DEFAULT_QUOTE,
|
|
57
|
-
renderContext: { checkValidation: true, intl, restrictPersonalization: true },
|
|
58
|
-
}))[0].props.errorMessage).toContain('Personalization');
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('falls back to empty message when error is not brace/quote and field has no errorMessage', () => {
|
|
62
|
-
const el = MpushInputField({
|
|
63
|
-
field: { id: 'x', width: 18 }, value: 'abc', error: 'someOtherError', onChange: () => {}, renderContext: { checkValidation: true, intl },
|
|
64
|
-
});
|
|
65
|
-
expect(kids(el)[0].props.errorMessage).toBe('');
|
|
66
|
-
});
|
|
67
|
-
|
|
68
46
|
it('shows brace/tag errors live, before checkValidation (Save/Update/Done) is set', () => {
|
|
69
47
|
const el = MpushInputField({
|
|
70
48
|
field, value: 'a {{b', error: ERROR_VALUE.BRACKET, onChange: () => {}, renderContext: { checkValidation: false, intl },
|
|
@@ -7,27 +7,17 @@
|
|
|
7
7
|
import PropTypes from 'prop-types';
|
|
8
8
|
|
|
9
9
|
import React from 'react';
|
|
10
|
-
import { CapTab, CapIcon
|
|
10
|
+
import { CapTab, CapIcon } from '@capillarytech/cap-ui-library';
|
|
11
11
|
import { get, isEmpty} from 'lodash';
|
|
12
12
|
import TemplatePreview from '../TemplatePreview';
|
|
13
13
|
import '../PreviewSideBar/_previewsidebar.scss';
|
|
14
|
-
import './_mobilePushPreviewV2.scss';
|
|
15
14
|
import { MOBILE_PUSH } from '../../v2Containers/CreativesContainer/constants';
|
|
16
15
|
import { INAPP } from '../../v2Containers/App/constants';
|
|
17
16
|
import { ANDROID, IOS } from '../../v2Containers/InApp/constants';
|
|
18
17
|
import { getCtaObject } from '../../v2Containers/InApp/utils';
|
|
19
|
-
import {
|
|
20
|
-
CAROUSEL, IMAGE, MANUAL_CAROUSEL, VIDEO,
|
|
21
|
-
} from '../../v2Containers/MobilePushNew/constants';
|
|
18
|
+
import { CAROUSEL, VIDEO } from '../../v2Containers/MobilePushNew/constants';
|
|
22
19
|
import { DEVICE_TYPES, IPHONE } from './constants';
|
|
23
20
|
|
|
24
|
-
// Saved media item -> carousel card in the shape TemplatePreview renders
|
|
25
|
-
const toCarouselCard = ({ type, url } = {}) => ({
|
|
26
|
-
mediaType: type,
|
|
27
|
-
imageUrl: type === IMAGE ? url : '',
|
|
28
|
-
videoSrc: type === VIDEO ? url : '',
|
|
29
|
-
});
|
|
30
|
-
|
|
31
21
|
class MobilePushPreviewV2 extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
32
22
|
constructor(props) {
|
|
33
23
|
super(props);
|
|
@@ -102,18 +92,16 @@ class MobilePushPreviewV2 extends React.Component { // eslint-disable-line react
|
|
|
102
92
|
const data = device?.toLowerCase() === "android" ? androidContent : iosContent;
|
|
103
93
|
const {
|
|
104
94
|
title = '', message = '', type = '', expandableDetails: {
|
|
105
|
-
ctas = [], image = '', media = [], carouselData = [],
|
|
95
|
+
ctas = [], image = '', media = [], carouselData = [],
|
|
106
96
|
} = {},
|
|
107
97
|
} = data || {};
|
|
108
|
-
const isCarousel = style === MANUAL_CAROUSEL || type === CAROUSEL;
|
|
109
98
|
|
|
110
99
|
// Handle video/GIF content from expandableDetails.media array (new format)
|
|
111
100
|
let bodyVideo = {};
|
|
112
101
|
let bodyGif = '';
|
|
113
102
|
let bodyImage = image;
|
|
114
103
|
|
|
115
|
-
|
|
116
|
-
if (!isCarousel && media?.length > 0) {
|
|
104
|
+
if (media?.length > 0) {
|
|
117
105
|
const mediaItem = media[0];
|
|
118
106
|
const { type: mediaType, url } = mediaItem;
|
|
119
107
|
if (mediaType === VIDEO) {
|
|
@@ -139,8 +127,7 @@ class MobilePushPreviewV2 extends React.Component { // eslint-disable-line react
|
|
|
139
127
|
bodyGif,
|
|
140
128
|
actions: [],
|
|
141
129
|
appName: templateData?.appName,
|
|
142
|
-
|
|
143
|
-
carouselData: (carouselData?.length || !isCarousel) ? carouselData : (media || []).map(toCarouselCard),
|
|
130
|
+
carouselData,
|
|
144
131
|
};
|
|
145
132
|
|
|
146
133
|
// Map CTAs consistently for both Android and iOS
|
|
@@ -203,8 +190,8 @@ class MobilePushPreviewV2 extends React.Component { // eslint-disable-line react
|
|
|
203
190
|
}
|
|
204
191
|
const hasBothAndroidAndIos = hasAndroid && hasIos;
|
|
205
192
|
return (
|
|
206
|
-
<
|
|
207
|
-
<
|
|
193
|
+
<div>
|
|
194
|
+
<div className="devices">
|
|
208
195
|
{!isEmpty(templateData)
|
|
209
196
|
&& ( hasBothAndroidAndIos ? (
|
|
210
197
|
<CapTab
|
|
@@ -227,8 +214,8 @@ class MobilePushPreviewV2 extends React.Component { // eslint-disable-line react
|
|
|
227
214
|
(hasAndroid || hasIos) && this.getPreview(hasAndroid ? 'android' : 'ios')
|
|
228
215
|
))
|
|
229
216
|
}
|
|
230
|
-
</
|
|
231
|
-
</
|
|
217
|
+
</div>
|
|
218
|
+
</div>
|
|
232
219
|
);
|
|
233
220
|
}
|
|
234
221
|
}
|
|
@@ -627,12 +627,6 @@
|
|
|
627
627
|
margin-left: 1.571rem;
|
|
628
628
|
display: block;
|
|
629
629
|
}
|
|
630
|
-
// Width leaves room for the left inset, so the video stays inside the card
|
|
631
|
-
.mpush-body-video{
|
|
632
|
-
max-width: calc(100% - 1.5rem);
|
|
633
|
-
max-height: 7.5rem;
|
|
634
|
-
margin-left: 1.5rem;
|
|
635
|
-
}
|
|
636
630
|
}
|
|
637
631
|
}
|
|
638
632
|
.mobile-push-carousel-card {
|
|
@@ -751,23 +745,13 @@
|
|
|
751
745
|
justify-content: space-between;
|
|
752
746
|
flex-direction: row;
|
|
753
747
|
gap: $CAP_SPACE_08;
|
|
754
|
-
width: 100%;
|
|
755
|
-
// One button: centred. Two: equal halves, each centred, split by a divider.
|
|
756
748
|
.action{
|
|
757
|
-
flex: 1 1 0;
|
|
758
|
-
min-width: 0;
|
|
759
|
-
text-align: center;
|
|
760
|
-
white-space: nowrap;
|
|
761
|
-
overflow: hidden;
|
|
762
|
-
text-overflow: ellipsis;
|
|
763
749
|
font-size: $FONT_SIZE_S;
|
|
764
750
|
font-weight: 600;
|
|
765
|
-
color:
|
|
751
|
+
color: #1970DA;
|
|
766
752
|
height: 1.25rem;
|
|
753
|
+
text-transform: uppercase;
|
|
767
754
|
cursor: pointer;
|
|
768
|
-
& + .action {
|
|
769
|
-
border-left: 1px solid $CAP_G07;
|
|
770
|
-
}
|
|
771
755
|
&:hover {
|
|
772
756
|
text-decoration: underline;
|
|
773
757
|
}
|
|
@@ -168,15 +168,14 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
168
168
|
};
|
|
169
169
|
|
|
170
170
|
renderMobilePushCarousel = (content) => {
|
|
171
|
-
// Every card shows, even before its media is uploaded (an empty card keeps its place)
|
|
172
171
|
if (!content?.carouselData || content?.carouselData?.length === 0) {
|
|
173
172
|
return null;
|
|
174
173
|
}
|
|
175
174
|
|
|
176
175
|
return (
|
|
177
176
|
<CapRow type="flex" vertical noWrap className="msg-container-carousel mobile-push-carousel-container">
|
|
178
|
-
<CapRow
|
|
179
|
-
{content
|
|
177
|
+
<CapRow className="scroll-container mobile-push-scroll-container">
|
|
178
|
+
{content?.carouselData?.map((item, idx) => (
|
|
180
179
|
<CapColumn
|
|
181
180
|
key={`carousel-card-${idx}`}
|
|
182
181
|
className="mobile-push-carousel-card message-pop align-left message-pop-carousel"
|
|
@@ -188,11 +187,10 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
188
187
|
className="carousel-image"
|
|
189
188
|
/>
|
|
190
189
|
)}
|
|
191
|
-
{item?.mediaType?.toLowerCase() === VIDEO &&
|
|
190
|
+
{item?.mediaType?.toLowerCase() === VIDEO && item?.videoPreviewImg && (
|
|
192
191
|
<CapRow className="video-preview">
|
|
193
|
-
{/* No thumbnail from the upload: same placeholder as WhatsApp/RCS */}
|
|
194
192
|
<CapImage
|
|
195
|
-
src={item?.videoPreviewImg ||
|
|
193
|
+
src={item?.videoPreviewImg || item?.url}
|
|
196
194
|
alt="carousel-video-preview"
|
|
197
195
|
className="carousel-video-preview"
|
|
198
196
|
/>
|
|
@@ -881,10 +879,10 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
881
879
|
{(() => {
|
|
882
880
|
if (content?.bodyVideo?.videoSrc && !content?.bodyImage && !content?.bodyGif) {
|
|
883
881
|
return (
|
|
884
|
-
<video
|
|
882
|
+
<video
|
|
885
883
|
key={`android-video-${content.bodyVideo.videoSrc}`}
|
|
886
|
-
controls
|
|
887
|
-
|
|
884
|
+
controls
|
|
885
|
+
style={{ maxWidth: '100%', maxHeight: '120px', marginLeft: '24px' }}
|
|
888
886
|
poster={content?.bodyVideo?.videoPreview || undefined}
|
|
889
887
|
>
|
|
890
888
|
<source src={content.bodyVideo.videoSrc} type="video/mp4" />
|
|
@@ -909,17 +907,17 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
909
907
|
)}
|
|
910
908
|
{(content?.actions || []).filter((action) => action?.label)
|
|
911
909
|
.length && content?.carouselData?.length === 0 ? (
|
|
912
|
-
<CapRow
|
|
910
|
+
<CapRow className="actions">
|
|
913
911
|
{_.map(
|
|
914
912
|
content?.actions || [],
|
|
915
|
-
(action
|
|
913
|
+
(action) =>
|
|
916
914
|
!!action?.label && (
|
|
917
915
|
<span
|
|
918
916
|
className="action"
|
|
919
|
-
key={`action-${
|
|
917
|
+
key={`action-${action?.label}`}
|
|
920
918
|
title={action?.url || ''}
|
|
921
919
|
>
|
|
922
|
-
{action?.label}
|
|
920
|
+
{action?.label?.toUpperCase()}
|
|
923
921
|
</span>
|
|
924
922
|
)
|
|
925
923
|
)}
|
|
@@ -945,10 +943,10 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
945
943
|
{(() => {
|
|
946
944
|
if (content?.bodyVideo?.videoSrc && !content?.bodyImage && !content?.bodyGif) {
|
|
947
945
|
return (
|
|
948
|
-
<video
|
|
946
|
+
<video
|
|
949
947
|
key={`ios-video-${content?.bodyVideo?.videoSrc}`}
|
|
950
|
-
controls
|
|
951
|
-
|
|
948
|
+
controls
|
|
949
|
+
style={{ maxWidth: '100%', maxHeight: '120px', marginLeft: '24px' }}
|
|
952
950
|
poster={content?.bodyVideo?.videoPreview || undefined}
|
|
953
951
|
>
|
|
954
952
|
<source src={content?.bodyVideo?.videoSrc} type="video/mp4" />
|
|
@@ -973,17 +971,17 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
973
971
|
)}
|
|
974
972
|
{(content?.actions || []).filter((action) => action?.label)
|
|
975
973
|
.length && content?.carouselData?.length === 0 ? (
|
|
976
|
-
<CapRow
|
|
974
|
+
<CapRow className="actions">
|
|
977
975
|
{_.map(
|
|
978
976
|
content?.actions || [],
|
|
979
|
-
(action
|
|
977
|
+
(action) =>
|
|
980
978
|
!!action?.label && (
|
|
981
979
|
<span
|
|
982
980
|
className="action"
|
|
983
|
-
key={`action-${
|
|
981
|
+
key={`action-${action?.label}`}
|
|
984
982
|
title={action?.url || ''}
|
|
985
983
|
>
|
|
986
|
-
{action?.label}
|
|
984
|
+
{action?.label?.toUpperCase()}
|
|
987
985
|
</span>
|
|
988
986
|
)
|
|
989
987
|
)}
|
|
@@ -73,75 +73,6 @@ describe('Test Templates container', () => {
|
|
|
73
73
|
expect(renderedComponent).toMatchSnapshot();
|
|
74
74
|
});
|
|
75
75
|
|
|
76
|
-
describe('Mobile push action buttons', () => {
|
|
77
|
-
const renderMobilePush = (device, actions) => {
|
|
78
|
-
renderedComponent = shallowWithIntl(
|
|
79
|
-
<TemplatePreview
|
|
80
|
-
channel="MOBILEPUSH"
|
|
81
|
-
device={device}
|
|
82
|
-
content={{ header: 'Title', bodyText: 'Body', actions, carouselData: [] }}
|
|
83
|
-
/>,
|
|
84
|
-
);
|
|
85
|
-
return renderedComponent.find('.actions');
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
it.each(['android', 'ios'])('renders labels as typed on one flex row with index keys (%s)', (device) => {
|
|
89
|
-
const row = renderMobilePush(device, [
|
|
90
|
-
{ label: 'Shop', url: 'https://a.com' },
|
|
91
|
-
{ label: 'Shop' },
|
|
92
|
-
{ label: '' },
|
|
93
|
-
]);
|
|
94
|
-
const buttons = row.find('.action');
|
|
95
|
-
|
|
96
|
-
expect(row.props()).toEqual(expect.objectContaining({ type: 'flex', noWrap: true }));
|
|
97
|
-
expect(buttons).toHaveLength(2);
|
|
98
|
-
expect(buttons.map((button) => button.key())).toEqual(['action-0', 'action-1']);
|
|
99
|
-
expect(buttons.map((button) => button.text())).toEqual(['Shop', 'Shop']);
|
|
100
|
-
expect(buttons.at(0).prop('title')).toBe('https://a.com');
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
const renderCarousel = (device, carouselData) => {
|
|
104
|
-
renderedComponent = shallowWithIntl(
|
|
105
|
-
<TemplatePreview
|
|
106
|
-
channel="MOBILEPUSH"
|
|
107
|
-
device={device}
|
|
108
|
-
content={{ header: 'Title', carouselData }}
|
|
109
|
-
/>,
|
|
110
|
-
);
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
it.each(['android', 'ios'])('shows every card, with or without media, in one horizontal row (%s)', (device) => {
|
|
114
|
-
renderCarousel(device, [
|
|
115
|
-
{ mediaType: 'IMAGE', imageUrl: 'https://a.url' },
|
|
116
|
-
{ mediaType: 'IMAGE' },
|
|
117
|
-
{ mediaType: 'VIDEO', videoPreviewImg: 'https://b.url' },
|
|
118
|
-
]);
|
|
119
|
-
const scrollRow = renderedComponent.find('.scroll-container');
|
|
120
|
-
|
|
121
|
-
expect(scrollRow.props()).toEqual(expect.objectContaining({ type: 'flex', noWrap: true }));
|
|
122
|
-
expect(renderedComponent.find('.mobile-push-carousel-card')).toHaveLength(3);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
it.each(['android', 'ios'])('shows a video card with no thumbnail as the video placeholder (%s)', (device) => {
|
|
126
|
-
renderCarousel(device, [{ mediaType: 'video', videoSrc: 'https://v.mp4' }]);
|
|
127
|
-
expect(renderedComponent.find('.mobile-push-carousel-card')).toHaveLength(1);
|
|
128
|
-
expect(renderedComponent.find('video')).toHaveLength(0);
|
|
129
|
-
expect(renderedComponent.find('.carousel-video-preview').prop('src')).toBe('test-file-stub');
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it.each(['android', 'ios'])('shows an empty card while no media is uploaded (%s)', (device) => {
|
|
133
|
-
renderCarousel(device, [{ mediaType: 'IMAGE' }]);
|
|
134
|
-
expect(renderedComponent.find('.mobile-push-carousel-container')).toHaveLength(1);
|
|
135
|
-
expect(renderedComponent.find('.mobile-push-carousel-card')).toHaveLength(1);
|
|
136
|
-
expect(renderedComponent.find('.carousel-image')).toHaveLength(0);
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it.each(['android', 'ios'])('shows no carousel when there are no cards (%s)', (device) => {
|
|
140
|
-
renderCarousel(device, []);
|
|
141
|
-
expect(renderedComponent.find('.mobile-push-carousel-container')).toHaveLength(0);
|
|
142
|
-
});
|
|
143
|
-
});
|
|
144
|
-
|
|
145
76
|
describe('RCS carousel preview branches', () => {
|
|
146
77
|
const buildRcsContent = (cards) => ({
|
|
147
78
|
rcsPreviewContent: {
|
|
@@ -201,10 +201,6 @@ export default defineMessages({
|
|
|
201
201
|
id: `creatives.componentsV2.unbalanacedCurlyBraces`,
|
|
202
202
|
defaultMessage: 'Invalid label, please close all curly braces'
|
|
203
203
|
},
|
|
204
|
-
"unquotedTagDefaultValue": {
|
|
205
|
-
id: `creatives.componentsV2.unquotedTagDefaultValue`,
|
|
206
|
-
defaultMessage: 'Invalid label, default value must be within quotes'
|
|
207
|
-
},
|
|
208
204
|
"copyOf": {
|
|
209
205
|
id: 'creatives.componentsV2.copyOf',
|
|
210
206
|
defaultMessage: 'Copy of',
|
|
@@ -395,7 +395,6 @@ exports[`<Cap /> should render correct component 1`] = `
|
|
|
395
395
|
"creatives.componentsV2.TopBar.profile": "Profile",
|
|
396
396
|
"creatives.componentsV2.TopBar.settings": "Settings",
|
|
397
397
|
"creatives.componentsV2.unbalanacedCurlyBraces": "Invalid label, please close all curly braces",
|
|
398
|
-
"creatives.componentsV2.unquotedTagDefaultValue": "Invalid label, default value must be within quotes",
|
|
399
398
|
"creatives.componentsv2.MobilePushPreviewV2.header": "This is the MobilePushPreviewV2 component !",
|
|
400
399
|
"creatives.containers.Assets.Gallery.alphabetically": "Alphabetically",
|
|
401
400
|
"creatives.containers.Assets.Gallery.assetDeleteFailed": "Image deletion failed.",
|
package/v2Containers/CommunicationFlow/steps/ChannelSelectionStep/extractContentForPreview.js
CHANGED
|
@@ -3,7 +3,6 @@ import {
|
|
|
3
3
|
TEXT, IMAGE, VIDEO, DOCUMENT, CTA, QUICK_REPLY,
|
|
4
4
|
} from '../../../CreativesContainer/constants';
|
|
5
5
|
import { getWhatsappDocPreview } from '../../../Whatsapp/utils';
|
|
6
|
-
import { MANUAL_CAROUSEL } from '../../../MobilePushNew/constants';
|
|
7
6
|
|
|
8
7
|
const extractSmsContent = (templateData) => {
|
|
9
8
|
const smsBody = templateData.messageBody || templateData.smsBody || '';
|
|
@@ -21,28 +20,19 @@ const extractEmailContent = (templateData) => {
|
|
|
21
20
|
return { content: emailContent, formData };
|
|
22
21
|
};
|
|
23
22
|
|
|
24
|
-
// Saved media[0] is { url, type }; the test send reads { videoSrc, videoPreview }. A carousel's media are its cards
|
|
25
|
-
const toPreviewVideo = (style, media) => {
|
|
26
|
-
const { type, url, videoPreviewUrl } = media[0] || {};
|
|
27
|
-
return style !== MANUAL_CAROUSEL && type === VIDEO && url ? { videoSrc: url, videoPreview: videoPreviewUrl || '' } : {};
|
|
28
|
-
};
|
|
29
|
-
|
|
30
23
|
const extractMobilePushDevice = ({
|
|
31
24
|
title = '',
|
|
32
25
|
message = '',
|
|
33
|
-
cta,
|
|
34
26
|
expandableDetails: {
|
|
35
|
-
|
|
27
|
+
image = '', media = [], ctas = [], carouselData = [],
|
|
36
28
|
} = {},
|
|
37
29
|
} = {}) => ({
|
|
38
30
|
header: title,
|
|
39
31
|
bodyText: message,
|
|
40
32
|
bodyImage: image,
|
|
41
|
-
bodyVideo:
|
|
33
|
+
bodyVideo: media[0] || null,
|
|
42
34
|
bodyGif: '',
|
|
43
35
|
actions: ctas,
|
|
44
|
-
// Notification tap, read by the test send
|
|
45
|
-
cta,
|
|
46
36
|
carouselData,
|
|
47
37
|
});
|
|
48
38
|
|
|
@@ -848,7 +848,9 @@ export function SlideBoxContent(props) {
|
|
|
848
848
|
})()
|
|
849
849
|
)}
|
|
850
850
|
{isEditMPush && (
|
|
851
|
-
|
|
851
|
+
(isFullMode && !commonUtil.hasNewMobilePushFeatureEnabled()) ||
|
|
852
|
+
(!isFullMode && isLoyaltyModule) ||
|
|
853
|
+
(!isFullMode && !isLoyaltyModule && !commonUtil.hasNewMobilePushFeatureEnabled()) ? (
|
|
852
854
|
<MobliPushEdit
|
|
853
855
|
getFormLibraryData={getFormData}
|
|
854
856
|
setIsLoadingContent={setIsLoadingContent}
|
|
@@ -910,8 +912,6 @@ export function SlideBoxContent(props) {
|
|
|
910
912
|
waitEventContextTags={waitEventContextTags}
|
|
911
913
|
showLiquidErrorInFooter={showLiquidErrorInFooter}
|
|
912
914
|
handleClose={handleClose}
|
|
913
|
-
showTestAndPreviewSlidebox={showTestAndPreviewSlidebox}
|
|
914
|
-
handleCloseTestAndPreview={handleCloseTestAndPreview}
|
|
915
915
|
restrictPersonalization={restrictPersonalization}
|
|
916
916
|
isAnonymousType={isAnonymousType}
|
|
917
917
|
onPersonalizationTokensChange={onPersonalizationTokensChange}
|
|
@@ -920,7 +920,9 @@ export function SlideBoxContent(props) {
|
|
|
920
920
|
)
|
|
921
921
|
)}
|
|
922
922
|
{isCreateMPush && (
|
|
923
|
-
|
|
923
|
+
(isFullMode && !commonUtil.hasNewMobilePushFeatureEnabled()) ||
|
|
924
|
+
(!isFullMode && isLoyaltyModule) ||
|
|
925
|
+
(!isFullMode && !isLoyaltyModule && !commonUtil.hasNewMobilePushFeatureEnabled()) ? (
|
|
924
926
|
<MobilepushWrapper
|
|
925
927
|
key="creatives-mobilepush-wrapper"
|
|
926
928
|
date={new Date().getMilliseconds()}
|
|
@@ -1042,8 +1042,7 @@ export class Creatives extends React.Component {
|
|
|
1042
1042
|
newExpandableDetails.message = expandableDetails.message || '';
|
|
1043
1043
|
newExpandableDetails.ctas = expandableDetails.ctas || [];
|
|
1044
1044
|
newExpandableDetails.media = expandableDetails.carouselData.map((carousel) => ({
|
|
1045
|
-
|
|
1046
|
-
url: carousel?.mediaType?.toUpperCase() === VIDEO ? carousel.videoSrc : carousel.imageUrl,
|
|
1045
|
+
url: carousel.imageUrl,
|
|
1047
1046
|
type: carousel?.mediaType?.toUpperCase(),
|
|
1048
1047
|
text: '',
|
|
1049
1048
|
}));
|
|
@@ -4,9 +4,6 @@ import { SlideBoxContent } from '../SlideBoxContent';
|
|
|
4
4
|
import mockdata from '../../mockdata';
|
|
5
5
|
import { templateDetailsImage, templateDetailsVideo, templateDetailsText, templateDetails_ } from '../../Viber/tests/mockData';
|
|
6
6
|
import { CREATE, RICH_MEDIA } from '../../WeChat/Wrapper/constants';
|
|
7
|
-
import MobilePushNew from '../../MobilePushNew';
|
|
8
|
-
import MobilepushWrapper from '../../MobilepushWrapper';
|
|
9
|
-
import MobliPushEdit from '../../MobilePush/Edit';
|
|
10
7
|
|
|
11
8
|
const {
|
|
12
9
|
whatsappEditTemplateData,
|
|
@@ -1018,44 +1015,4 @@ describe('Test SlideBoxContent container', () => {
|
|
|
1018
1015
|
});
|
|
1019
1016
|
|
|
1020
1017
|
});
|
|
1021
|
-
|
|
1022
|
-
describe('Mobile push editor choice', () => {
|
|
1023
|
-
const editTemplateData = { _id: 'mp-1', type: 'MOBILEPUSH' };
|
|
1024
|
-
|
|
1025
|
-
it.each([
|
|
1026
|
-
['full mode', { isFullMode: true }],
|
|
1027
|
-
['embedded outside Loyalty', { isFullMode: false, isLoyaltyModule: false }],
|
|
1028
|
-
])('opens the new editor for create and edit in %s', (_, modeProps) => {
|
|
1029
|
-
renderFunction('MOBILEPUSH', 'createTemplate', { mode: 'create' }, modeProps);
|
|
1030
|
-
expect(renderedComponent.find(MobilePushNew).exists()).toBe(true);
|
|
1031
|
-
expect(renderedComponent.find(MobilepushWrapper).exists()).toBe(false);
|
|
1032
|
-
|
|
1033
|
-
renderFunction('MOBILEPUSH', 'editTemplate', editTemplateData, modeProps);
|
|
1034
|
-
expect(renderedComponent.find(MobilePushNew).exists()).toBe(true);
|
|
1035
|
-
expect(renderedComponent.find(MobliPushEdit).exists()).toBe(false);
|
|
1036
|
-
});
|
|
1037
|
-
|
|
1038
|
-
it('passes the footer Test & Preview state to the new editor in edit', () => {
|
|
1039
|
-
const handleCloseTestAndPreview = jest.fn();
|
|
1040
|
-
renderFunction('MOBILEPUSH', 'editTemplate', editTemplateData, {
|
|
1041
|
-
isFullMode: true,
|
|
1042
|
-
showTestAndPreviewSlidebox: true,
|
|
1043
|
-
handleCloseTestAndPreview,
|
|
1044
|
-
});
|
|
1045
|
-
const editor = renderedComponent.find(MobilePushNew);
|
|
1046
|
-
expect(editor.prop('showTestAndPreviewSlidebox')).toBe(true);
|
|
1047
|
-
expect(editor.prop('handleCloseTestAndPreview')).toBe(handleCloseTestAndPreview);
|
|
1048
|
-
});
|
|
1049
|
-
|
|
1050
|
-
it('keeps the old editor when embedded in Loyalty', () => {
|
|
1051
|
-
const loyaltyProps = { isFullMode: false, isLoyaltyModule: true };
|
|
1052
|
-
renderFunction('MOBILEPUSH', 'createTemplate', { mode: 'create' }, loyaltyProps);
|
|
1053
|
-
expect(renderedComponent.find(MobilepushWrapper).exists()).toBe(true);
|
|
1054
|
-
expect(renderedComponent.find(MobilePushNew).exists()).toBe(false);
|
|
1055
|
-
|
|
1056
|
-
renderFunction('MOBILEPUSH', 'editTemplate', editTemplateData, loyaltyProps);
|
|
1057
|
-
expect(renderedComponent.find(MobliPushEdit).exists()).toBe(true);
|
|
1058
|
-
expect(renderedComponent.find(MobilePushNew).exists()).toBe(false);
|
|
1059
|
-
});
|
|
1060
|
-
});
|
|
1061
1018
|
});
|
|
@@ -1269,7 +1269,7 @@ export const InApp = (props) => {
|
|
|
1269
1269
|
}, [clearDeviceErrors]);
|
|
1270
1270
|
|
|
1271
1271
|
const templateDescErrorHandler = (value) => {
|
|
1272
|
-
const { unsupportedTags, isBraceError
|
|
1272
|
+
const { unsupportedTags, isBraceError } = validateTags({
|
|
1273
1273
|
content: value,
|
|
1274
1274
|
tagsParam: tags,
|
|
1275
1275
|
injectedTagsParams: injectedTags,
|
|
@@ -1283,9 +1283,6 @@ export const InApp = (props) => {
|
|
|
1283
1283
|
if (isBraceError) {
|
|
1284
1284
|
return formatMessage(globalMessages.unbalanacedCurlyBraces);
|
|
1285
1285
|
}
|
|
1286
|
-
if (isDefaultQuoteError) {
|
|
1287
|
-
return formatMessage(globalMessages.unquotedTagDefaultValue);
|
|
1288
|
-
}
|
|
1289
1286
|
return '';
|
|
1290
1287
|
};
|
|
1291
1288
|
|
|
@@ -341,7 +341,6 @@ exports[`Creatives line image carousel test/> should render 1`] = `
|
|
|
341
341
|
"creatives.componentsV2.TopBar.profile": "Profile",
|
|
342
342
|
"creatives.componentsV2.TopBar.settings": "Settings",
|
|
343
343
|
"creatives.componentsV2.unbalanacedCurlyBraces": "Invalid label, please close all curly braces",
|
|
344
|
-
"creatives.componentsV2.unquotedTagDefaultValue": "Invalid label, default value must be within quotes",
|
|
345
344
|
"creatives.componentsv2.MobilePushPreviewV2.header": "This is the MobilePushPreviewV2 component !",
|
|
346
345
|
"creatives.containers.Assets.Gallery.alphabetically": "Alphabetically",
|
|
347
346
|
"creatives.containers.Assets.Gallery.assetDeleteFailed": "Image deletion failed.",
|
|
@@ -4483,7 +4482,6 @@ exports[`Creatives line image carousel test/> should render 2`] = `
|
|
|
4483
4482
|
"creatives.componentsV2.TopBar.profile": "Profile",
|
|
4484
4483
|
"creatives.componentsV2.TopBar.settings": "Settings",
|
|
4485
4484
|
"creatives.componentsV2.unbalanacedCurlyBraces": "Invalid label, please close all curly braces",
|
|
4486
|
-
"creatives.componentsV2.unquotedTagDefaultValue": "Invalid label, default value must be within quotes",
|
|
4487
4485
|
"creatives.componentsv2.MobilePushPreviewV2.header": "This is the MobilePushPreviewV2 component !",
|
|
4488
4486
|
"creatives.containers.Assets.Gallery.alphabetically": "Alphabetically",
|
|
4489
4487
|
"creatives.containers.Assets.Gallery.assetDeleteFailed": "Image deletion failed.",
|
|
@@ -8764,7 +8762,6 @@ exports[`Creatives line image carousel test/> should render 3`] = `
|
|
|
8764
8762
|
"creatives.componentsV2.TopBar.profile": "Profile",
|
|
8765
8763
|
"creatives.componentsV2.TopBar.settings": "Settings",
|
|
8766
8764
|
"creatives.componentsV2.unbalanacedCurlyBraces": "Invalid label, please close all curly braces",
|
|
8767
|
-
"creatives.componentsV2.unquotedTagDefaultValue": "Invalid label, default value must be within quotes",
|
|
8768
8765
|
"creatives.componentsv2.MobilePushPreviewV2.header": "This is the MobilePushPreviewV2 component !",
|
|
8769
8766
|
"creatives.containers.Assets.Gallery.alphabetically": "Alphabetically",
|
|
8770
8767
|
"creatives.containers.Assets.Gallery.assetDeleteFailed": "Image deletion failed.",
|
|
@@ -341,7 +341,6 @@ exports[`line wrapper test/> should render line component new 1`] = `
|
|
|
341
341
|
"creatives.componentsV2.TopBar.profile": "Profile",
|
|
342
342
|
"creatives.componentsV2.TopBar.settings": "Settings",
|
|
343
343
|
"creatives.componentsV2.unbalanacedCurlyBraces": "Invalid label, please close all curly braces",
|
|
344
|
-
"creatives.componentsV2.unquotedTagDefaultValue": "Invalid label, default value must be within quotes",
|
|
345
344
|
"creatives.componentsv2.MobilePushPreviewV2.header": "This is the MobilePushPreviewV2 component !",
|
|
346
345
|
"creatives.containers.Assets.Gallery.alphabetically": "Alphabetically",
|
|
347
346
|
"creatives.containers.Assets.Gallery.assetDeleteFailed": "Image deletion failed.",
|
|
@@ -15393,7 +15392,6 @@ exports[`line wrapper test/> should render line component old 1`] = `
|
|
|
15393
15392
|
"creatives.componentsV2.TopBar.profile": "Profile",
|
|
15394
15393
|
"creatives.componentsV2.TopBar.settings": "Settings",
|
|
15395
15394
|
"creatives.componentsV2.unbalanacedCurlyBraces": "Invalid label, please close all curly braces",
|
|
15396
|
-
"creatives.componentsV2.unquotedTagDefaultValue": "Invalid label, default value must be within quotes",
|
|
15397
15395
|
"creatives.componentsv2.MobilePushPreviewV2.header": "This is the MobilePushPreviewV2 component !",
|
|
15398
15396
|
"creatives.containers.Assets.Gallery.alphabetically": "Alphabetically",
|
|
15399
15397
|
"creatives.containers.Assets.Gallery.assetDeleteFailed": "Image deletion failed.",
|
|
@@ -135,7 +135,7 @@ export const LineText = ({
|
|
|
135
135
|
|
|
136
136
|
const updateTextContentError = (value) => {
|
|
137
137
|
let errorMessage = false;
|
|
138
|
-
const { valid, isBraceError
|
|
138
|
+
const { valid, isBraceError } = validateTags({
|
|
139
139
|
content: value,
|
|
140
140
|
tagsParam: tags,
|
|
141
141
|
location,
|
|
@@ -148,8 +148,6 @@ export const LineText = ({
|
|
|
148
148
|
errorMessage = formatMessage(messages.limitExceededContentErrorMessage);
|
|
149
149
|
} else if (isBraceError) {
|
|
150
150
|
errorMessage = formatMessage(globalMessages.unbalanacedCurlyBraces);
|
|
151
|
-
} else if (isDefaultQuoteError) {
|
|
152
|
-
errorMessage = formatMessage(globalMessages.unquotedTagDefaultValue);
|
|
153
151
|
} else if (!valid && !isFullMode) {
|
|
154
152
|
errorMessage = formatMessage(messages.invalidTagError);
|
|
155
153
|
}
|