@capillarytech/creatives-library 7.12.40 → 7.12.41
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/package.json +1 -1
- package/v2Components/CapWhatsappCTA/constants.js +0 -5
- package/v2Components/CapWhatsappCTA/index.js +13 -12
- package/v2Components/CapWhatsappCTA/index.scss +15 -0
- package/v2Components/CapWhatsappCTA/messages.js +0 -4
- package/v2Components/CapWhatsappCTA/tests/index.test.js +152 -0
- package/v2Components/TemplatePreview/tests/__snapshots__/index.test.js.snap +191 -19
- package/v2Components/TemplatePreview/tests/index.test.js +52 -5
- package/v2Containers/CreativesContainer/index.js +7 -2
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +29 -0
- package/v2Containers/CreativesContainer/tests/index.test.js +47 -14
- package/v2Containers/Whatsapp/constants.js +10 -7
- package/v2Containers/Whatsapp/index.js +52 -47
- package/v2Containers/Whatsapp/messages.js +6 -2
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +84338 -18311
- package/v2Containers/Whatsapp/tests/__snapshots__/utils.test.js.snap +100 -0
- package/v2Containers/Whatsapp/tests/index.test.js +159 -18
- package/v2Containers/Whatsapp/tests/mockData.js +150 -89
- package/v2Containers/Whatsapp/tests/utils.test.js +8 -0
- package/v2Containers/Whatsapp/utils.js +16 -14
- package/v2Containers/mockdata.js +177 -5
|
@@ -4,11 +4,22 @@ import { shallowWithIntl } from '../../../helpers/intl-enzym-test-helpers';
|
|
|
4
4
|
import { Creatives } from '../index';
|
|
5
5
|
import mockdata from '../../mockdata';
|
|
6
6
|
|
|
7
|
-
const {
|
|
7
|
+
const {
|
|
8
|
+
whatsappTemplates,
|
|
9
|
+
rcsTemplates,
|
|
10
|
+
whatsappGetCreativeData,
|
|
11
|
+
whatsappGetTemplateData,
|
|
12
|
+
rcsEditTemplateData,
|
|
13
|
+
whatsappGetCreativeData2,
|
|
14
|
+
} = mockdata;
|
|
8
15
|
|
|
9
|
-
jest.mock(
|
|
16
|
+
jest.mock('../../../v2Components/FormBuilder', () => ({
|
|
10
17
|
__esModule: true,
|
|
11
|
-
default: (props) =>
|
|
18
|
+
default: (props) => (
|
|
19
|
+
<div className="FormBuilder-mock" {...props}>
|
|
20
|
+
FormBuilder
|
|
21
|
+
</div>
|
|
22
|
+
),
|
|
12
23
|
}));
|
|
13
24
|
|
|
14
25
|
describe('Test SlideBoxContent container', () => {
|
|
@@ -29,17 +40,24 @@ describe('Test SlideBoxContent container', () => {
|
|
|
29
40
|
templateData={templateData}
|
|
30
41
|
handleCloseCreatives={handleCloseCreatives}
|
|
31
42
|
getCreativesData={getCreativesData}
|
|
32
|
-
|
|
43
|
+
/>,
|
|
33
44
|
);
|
|
34
45
|
};
|
|
35
46
|
|
|
36
47
|
it('Should render correct component for whatsapp channel create mode', () => {
|
|
37
|
-
renderFunction(
|
|
48
|
+
renderFunction('WHATSAPP', 'createTemplate', whatsappTemplates, {
|
|
49
|
+
mode: 'create',
|
|
50
|
+
});
|
|
38
51
|
expect(renderedComponent).toMatchSnapshot();
|
|
39
52
|
});
|
|
40
53
|
|
|
41
54
|
it('Should render correct component for whatsapp channel edit mode', () => {
|
|
42
|
-
renderFunction(
|
|
55
|
+
renderFunction(
|
|
56
|
+
'WHATSAPP',
|
|
57
|
+
'editTemplate',
|
|
58
|
+
whatsappTemplates,
|
|
59
|
+
whatsappGetTemplateData,
|
|
60
|
+
);
|
|
43
61
|
renderedComponent.instance().onEditTemplate();
|
|
44
62
|
renderedComponent.find('CapSlideBox').props().content.props.handleClose();
|
|
45
63
|
expect(renderedComponent).toMatchSnapshot();
|
|
@@ -48,23 +66,38 @@ describe('Test SlideBoxContent container', () => {
|
|
|
48
66
|
});
|
|
49
67
|
|
|
50
68
|
it('Text getCreatives data for whatsapp', () => {
|
|
51
|
-
|
|
69
|
+
console.log('abcRcb');
|
|
70
|
+
renderFunction(
|
|
71
|
+
'WHATSAPP',
|
|
72
|
+
'editTemplate',
|
|
73
|
+
whatsappTemplates,
|
|
74
|
+
whatsappGetCreativeData,
|
|
75
|
+
);
|
|
52
76
|
renderedComponent.instance().onEditTemplate();
|
|
53
|
-
renderedComponent
|
|
54
|
-
|
|
55
|
-
|
|
77
|
+
renderedComponent
|
|
78
|
+
.find('CapSlideBox')
|
|
79
|
+
.props()
|
|
80
|
+
.content.props.getFormData(whatsappGetCreativeData);
|
|
81
|
+
renderedComponent
|
|
82
|
+
.find('CapSlideBox')
|
|
83
|
+
.props()
|
|
84
|
+
.content.props.getFormData(whatsappGetCreativeData2);
|
|
85
|
+
expect(getCreativesData).toHaveBeenCalledTimes(2);
|
|
56
86
|
});
|
|
57
87
|
|
|
58
88
|
it('Should render correct component for rcs channel create mode', () => {
|
|
59
|
-
renderFunction(
|
|
89
|
+
renderFunction('RCS', 'createTemplate', rcsTemplates, { mode: 'create' });
|
|
60
90
|
expect(renderedComponent).toMatchSnapshot();
|
|
61
91
|
});
|
|
62
92
|
|
|
63
93
|
it('Text getCreatives data for rcs', () => {
|
|
64
|
-
renderFunction(
|
|
94
|
+
renderFunction('RCS', 'editTemplate', rcsTemplates, rcsEditTemplateData);
|
|
65
95
|
renderedComponent.instance().onEditTemplate();
|
|
66
|
-
renderedComponent
|
|
96
|
+
renderedComponent
|
|
97
|
+
.find('CapSlideBox')
|
|
98
|
+
.props()
|
|
99
|
+
.content.props.getFormData(rcsEditTemplateData);
|
|
67
100
|
expect(getCreativesData).toHaveBeenCalledTimes(1);
|
|
68
|
-
expect(getCreativesData).toHaveBeenCalledWith({ channel:
|
|
101
|
+
expect(getCreativesData).toHaveBeenCalledWith({ channel: 'RCS' });
|
|
69
102
|
});
|
|
70
103
|
});
|
|
@@ -128,20 +128,23 @@ export const WHATSAPP_MEDIA_TYPES = {
|
|
|
128
128
|
IMAGE: 'IMAGE',
|
|
129
129
|
VIDEO: 'VIDEO',
|
|
130
130
|
};
|
|
131
|
-
|
|
131
|
+
export const NONE = 'NONE';
|
|
132
|
+
export const CTA = 'CTA';
|
|
133
|
+
export const QUICK_REPLY = 'QUICK_REPLY';
|
|
132
134
|
export const WHATSAPP_BUTTON_TYPES = {
|
|
133
|
-
NONE
|
|
134
|
-
CTA
|
|
135
|
-
QUICK_REPLY
|
|
135
|
+
NONE,
|
|
136
|
+
CTA,
|
|
137
|
+
QUICK_REPLY,
|
|
136
138
|
};
|
|
137
|
-
|
|
139
|
+
export const PHONE_NUMBER = 'PHONE_NUMBER';
|
|
140
|
+
export const STATIC_URL = 'STATIC_URL';
|
|
138
141
|
export const INITIAL_CTA_DATA = [
|
|
139
142
|
{
|
|
140
143
|
index: 0,
|
|
141
|
-
ctaType:
|
|
144
|
+
ctaType: PHONE_NUMBER,
|
|
142
145
|
text: '',
|
|
143
146
|
phone_number: '',
|
|
144
|
-
urlType:
|
|
147
|
+
urlType: STATIC_URL,
|
|
145
148
|
url: '',
|
|
146
149
|
isSaved: false,
|
|
147
150
|
},
|
|
@@ -203,13 +203,7 @@ export const Whatsapp = (props) => {
|
|
|
203
203
|
if (btnType === WHATSAPP_BUTTON_TYPES.CTA && buttons.length > 0) {
|
|
204
204
|
setCtadata(
|
|
205
205
|
buttons.map((cta) => {
|
|
206
|
-
const {
|
|
207
|
-
index,
|
|
208
|
-
type,
|
|
209
|
-
text,
|
|
210
|
-
phone_number = '',
|
|
211
|
-
url = '',
|
|
212
|
-
} = cta || {};
|
|
206
|
+
const { index, type, text, phone_number = '', url = '' } = cta;
|
|
213
207
|
const obj = {
|
|
214
208
|
index,
|
|
215
209
|
text,
|
|
@@ -239,17 +233,23 @@ export const Whatsapp = (props) => {
|
|
|
239
233
|
const computeTempMsgArray = () => {
|
|
240
234
|
let msg = get(editContent, `languages[0].content`, '');
|
|
241
235
|
const validVarArr = msg.match(validVarRegex) || [];
|
|
242
|
-
const
|
|
236
|
+
const unsubscribeRegex1 = /Click {{([1-9]|1[0-9])}} to unsubscribe/g;
|
|
237
|
+
const unsubscribeRegex2 = /Click {{unsubscribe}} to unsubscribe/g;
|
|
243
238
|
const templateMessageArray = [];
|
|
244
239
|
//removing $'' which was added for twilio enter handling
|
|
245
240
|
// msg = msg.slice(2, -1);
|
|
246
|
-
if (
|
|
247
|
-
|
|
241
|
+
if (
|
|
242
|
+
msg.match(unsubscribeRegex1)?.length > 0 ||
|
|
243
|
+
msg.match(unsubscribeRegex2)?.length > 0
|
|
244
|
+
) {
|
|
245
|
+
//removing Click {{([1-9]|1[0-9])}} to unsubscribe
|
|
248
246
|
msg = msg.replace(
|
|
249
247
|
`\nClick ${validVarArr[validVarArr.length - 1]} to unsubscribe`,
|
|
250
248
|
'',
|
|
251
249
|
);
|
|
252
|
-
//removing
|
|
250
|
+
//removing Click {{unsubscribe}} to unsubscribe
|
|
251
|
+
msg = msg.replace(`\nClick {{unsubscribe}} to unsubscribe`, '');
|
|
252
|
+
//removing last var added for Click {{([1-9]|1[0-9])}} to unsubscribe
|
|
253
253
|
if (isFullMode) {
|
|
254
254
|
validVarArr.pop();
|
|
255
255
|
}
|
|
@@ -532,41 +532,46 @@ export const Whatsapp = (props) => {
|
|
|
532
532
|
setTemplateMessageError(error);
|
|
533
533
|
};
|
|
534
534
|
|
|
535
|
-
const renderUnsubscribeText = () =>
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
<CapTooltip
|
|
554
|
-
placement="bottom"
|
|
555
|
-
title={
|
|
556
|
-
!isEditFlow && formatMessage(messages.unsubscribeTextTooltip)
|
|
557
|
-
}
|
|
535
|
+
const renderUnsubscribeText = () => {
|
|
536
|
+
const isDisabled =
|
|
537
|
+
isEditFlow ||
|
|
538
|
+
templateMessage.length + UNSUBSCRIBE_TEXT_LENGTH >
|
|
539
|
+
TEMPLATE_MESSAGE_MAX_LENGTH;
|
|
540
|
+
return (
|
|
541
|
+
<>
|
|
542
|
+
<CapColumn span={12}>
|
|
543
|
+
<CapCheckbox
|
|
544
|
+
className={`whatsapp-unsubscribe-checkbox ${
|
|
545
|
+
isEditFlow
|
|
546
|
+
? 'whatsapp-edit-unsubscribe-checkbox'
|
|
547
|
+
: 'whatsapp-create-unsubscribe-checkbox'
|
|
548
|
+
}`}
|
|
549
|
+
onChange={unsubscribeHandler}
|
|
550
|
+
checked={unsubscribeRequired}
|
|
551
|
+
disabled={isDisabled}
|
|
552
|
+
autoFocus={true}
|
|
558
553
|
>
|
|
559
|
-
<
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
554
|
+
<CapTooltip
|
|
555
|
+
placement="bottom"
|
|
556
|
+
title={
|
|
557
|
+
isDisabled &&
|
|
558
|
+
(isEditFlow
|
|
559
|
+
? formatMessage(messages.unsubscribeTextTooltipEditFlow)
|
|
560
|
+
: formatMessage(messages.unsubscribeTextTooltipCreateFlow))
|
|
561
|
+
}
|
|
562
|
+
>
|
|
563
|
+
<span className="whatsapp-render-unsubscribe-text">
|
|
564
|
+
{formatMessage(messages.templateMessageUnsubscribeText)}
|
|
565
|
+
</span>
|
|
566
|
+
</CapTooltip>
|
|
567
|
+
</CapCheckbox>
|
|
568
|
+
</CapColumn>
|
|
569
|
+
<CapColumn span={12}></CapColumn>
|
|
570
|
+
</>
|
|
571
|
+
);
|
|
572
|
+
};
|
|
568
573
|
|
|
569
|
-
const
|
|
574
|
+
const computeTextLength = () => {
|
|
570
575
|
let whatsappContentLen = 0;
|
|
571
576
|
whatsappContentLen = isEditFlow
|
|
572
577
|
? updatedSmsEditor.join('').length
|
|
@@ -579,7 +584,7 @@ export const Whatsapp = (props) => {
|
|
|
579
584
|
const renderMessageLength = () => (
|
|
580
585
|
<CapHeading type="label1" className="whatsapp-render-message-length">
|
|
581
586
|
{formatMessage(messages.templateMessageLength, {
|
|
582
|
-
currentLength:
|
|
587
|
+
currentLength: computeTextLength(),
|
|
583
588
|
maxLength: TEMPLATE_MESSAGE_MAX_LENGTH,
|
|
584
589
|
})}
|
|
585
590
|
</CapHeading>
|
|
@@ -729,7 +734,7 @@ export const Whatsapp = (props) => {
|
|
|
729
734
|
|
|
730
735
|
const getCtaPayload = () =>
|
|
731
736
|
ctaData.map((cta) => {
|
|
732
|
-
const { index, ctaType, text, phone_number, urlType, url } = cta
|
|
737
|
+
const { index, ctaType, text, phone_number, urlType, url } = cta;
|
|
733
738
|
if (ctaType === PHONE_NUMBER) {
|
|
734
739
|
return {
|
|
735
740
|
index,
|
|
@@ -1189,7 +1194,7 @@ export const Whatsapp = (props) => {
|
|
|
1189
1194
|
ctaData,
|
|
1190
1195
|
}),
|
|
1191
1196
|
}}
|
|
1192
|
-
whatsappContentLen={
|
|
1197
|
+
whatsappContentLen={computeTextLength()}
|
|
1193
1198
|
whatsappAccountName={accountName}
|
|
1194
1199
|
/>
|
|
1195
1200
|
);
|
|
@@ -127,10 +127,14 @@ export default defineMessages({
|
|
|
127
127
|
id: `${prefix}.modifiedUnsubscribeText`,
|
|
128
128
|
defaultMessage: 'Click {value} to unsubscribe',
|
|
129
129
|
},
|
|
130
|
-
|
|
131
|
-
id: `${prefix}.
|
|
130
|
+
unsubscribeTextTooltipEditFlow: {
|
|
131
|
+
id: `${prefix}.unsubscribeTextTooltipEditFlow`,
|
|
132
132
|
defaultMessage: 'This is non-editable',
|
|
133
133
|
},
|
|
134
|
+
unsubscribeTextTooltipCreateFlow: {
|
|
135
|
+
id: `${prefix}.unsubscribeTextTooltipCreateFlow`,
|
|
136
|
+
defaultMessage: 'To enable the checkbox, reduce the message character count to 988',
|
|
137
|
+
},
|
|
134
138
|
repetativeVars: {
|
|
135
139
|
id: `${prefix}.repetativeVars`,
|
|
136
140
|
defaultMessage: 'Variables cannot be repeated',
|