@capillarytech/creatives-library 7.12.39 → 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/index.js +5 -6
- package/v2Components/TemplatePreview/messages.js +0 -8
- package/v2Components/TemplatePreview/tests/__snapshots__/index.test.js.snap +190 -27
- 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 +30 -6
- package/v2Containers/CreativesContainer/tests/index.test.js +47 -14
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +40 -240
- package/v2Containers/Whatsapp/constants.js +10 -7
- package/v2Containers/Whatsapp/index.js +100 -61
- package/v2Containers/Whatsapp/index.scss +6 -2
- package/v2Containers/Whatsapp/messages.js +6 -2
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +94558 -28425
- package/v2Containers/Whatsapp/tests/__snapshots__/utils.test.js.snap +98 -8
- 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 +49 -48
- package/v2Containers/mockdata.js +177 -5
|
@@ -367,6 +367,7 @@ export class Creatives extends React.Component {
|
|
|
367
367
|
}
|
|
368
368
|
case constants.WHATSAPP: {
|
|
369
369
|
const {
|
|
370
|
+
messageBody = '',
|
|
370
371
|
templateConfigs: {
|
|
371
372
|
id,
|
|
372
373
|
name,
|
|
@@ -387,6 +388,7 @@ export class Creatives extends React.Component {
|
|
|
387
388
|
}
|
|
388
389
|
return btn;
|
|
389
390
|
});
|
|
391
|
+
const unsubscribeRegex = /Click {{unsubscribe}} to unsubscribe/g;
|
|
390
392
|
creativesTemplateData = {
|
|
391
393
|
_id: id,
|
|
392
394
|
type: constants.WHATSAPP,
|
|
@@ -401,11 +403,14 @@ export class Creatives extends React.Component {
|
|
|
401
403
|
varMapped,
|
|
402
404
|
mediaType,
|
|
403
405
|
buttonType,
|
|
404
|
-
buttons
|
|
406
|
+
buttons: modifiedButtons,
|
|
405
407
|
languages: [
|
|
406
408
|
{
|
|
407
409
|
language,
|
|
408
|
-
content:
|
|
410
|
+
content:
|
|
411
|
+
messageBody.match(unsubscribeRegex)?.length > 0
|
|
412
|
+
? `${template}\nClick {{unsubscribe}} to unsubscribe`
|
|
413
|
+
: template,
|
|
409
414
|
},
|
|
410
415
|
],
|
|
411
416
|
},
|
|
@@ -196,17 +196,26 @@ exports[`Test SlideBoxContent container Should render correct component for what
|
|
|
196
196
|
content={
|
|
197
197
|
Object {
|
|
198
198
|
"charCount": 46,
|
|
199
|
+
"ctaData": Array [
|
|
200
|
+
Object {
|
|
201
|
+
"index": 0,
|
|
202
|
+
"phone_number": "+919738752617",
|
|
203
|
+
"text": "Call",
|
|
204
|
+
"type": "PHONE_NUMBER",
|
|
205
|
+
},
|
|
206
|
+
Object {
|
|
207
|
+
"index": 1,
|
|
208
|
+
"text": "More info",
|
|
209
|
+
"type": "STATIC_URL",
|
|
210
|
+
"url": "https://fast.com/",
|
|
211
|
+
},
|
|
212
|
+
],
|
|
199
213
|
"templateMsg": <React.Fragment>
|
|
200
214
|
<CapLabel
|
|
201
215
|
type="label5"
|
|
202
216
|
>
|
|
203
217
|
1234567890
|
|
204
|
-
|
|
205
|
-
</CapLabel>
|
|
206
|
-
<CapLabel
|
|
207
|
-
type="label5"
|
|
208
|
-
>
|
|
209
|
-
Click {{unsubscribe}} to unsubscribe
|
|
218
|
+
Click {{unsubscribe}} to unsubscribe
|
|
210
219
|
</CapLabel>
|
|
211
220
|
</React.Fragment>,
|
|
212
221
|
}
|
|
@@ -234,6 +243,21 @@ exports[`Test SlideBoxContent container Should render correct component for what
|
|
|
234
243
|
"accessToken": "4676323eb5d1f975b0987070c03a8efc",
|
|
235
244
|
"accountId": "AC41030cebba9e2f1ce37c78235da0ee18",
|
|
236
245
|
"accountName": "whatsappTest",
|
|
246
|
+
"buttonType": "CTA",
|
|
247
|
+
"buttons": Array [
|
|
248
|
+
Object {
|
|
249
|
+
"index": 0,
|
|
250
|
+
"phone_number": "+919738752617",
|
|
251
|
+
"text": "Call",
|
|
252
|
+
"type": "PHONE_NUMBER",
|
|
253
|
+
},
|
|
254
|
+
Object {
|
|
255
|
+
"index": 1,
|
|
256
|
+
"text": "More info",
|
|
257
|
+
"type": "STATIC_URL",
|
|
258
|
+
"url": "https://fast.com/",
|
|
259
|
+
},
|
|
260
|
+
],
|
|
237
261
|
"category": "ALERT_UPDATE",
|
|
238
262
|
"languages": Array [
|
|
239
263
|
Object {
|
|
@@ -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
|
});
|