@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
package/package.json
CHANGED
|
@@ -27,11 +27,6 @@ export const CTA_URL_OPTIONS = [
|
|
|
27
27
|
value: STATIC_URL,
|
|
28
28
|
label: <FormattedMessage {...messages.ctaWebsiteTypeStatic} />,
|
|
29
29
|
},
|
|
30
|
-
// {
|
|
31
|
-
// value: DYNAMIC_URL,
|
|
32
|
-
// label: <FormattedMessage {...messages.ctaWebsiteTypeDynamic} />,
|
|
33
|
-
// disabled: true,
|
|
34
|
-
// },
|
|
35
30
|
];
|
|
36
31
|
export const BTN_MAX_LENGTH = 20;
|
|
37
32
|
export const PHONE_NUMBER_MAX_LENGTH = 15;
|
|
@@ -90,6 +90,7 @@ export const CapWhatsappCTA = (props) => {
|
|
|
90
90
|
|
|
91
91
|
const ctaOptions = CTA_OPTIONS.map((option) => {
|
|
92
92
|
const { value, label, tooltipLabel } = option;
|
|
93
|
+
//if button 1 is of type-> PHONE_NUMBER, it is disabled in second button
|
|
93
94
|
const isDisabled = ctaData.length === 2 && ctaData[0].ctaType === value;
|
|
94
95
|
return {
|
|
95
96
|
value,
|
|
@@ -132,10 +133,7 @@ export const CapWhatsappCTA = (props) => {
|
|
|
132
133
|
const { ctaType, text, phone_number, url } = ctaData[index] || {};
|
|
133
134
|
if (text === '') {
|
|
134
135
|
return true;
|
|
135
|
-
} else if (
|
|
136
|
-
ctaType === PHONE_NUMBER &&
|
|
137
|
-
(phone_number === '91' || phone_number === '' || phone_number.length < 5)
|
|
138
|
-
) {
|
|
136
|
+
} else if (ctaType === PHONE_NUMBER && phone_number.length < 5) {
|
|
139
137
|
return true;
|
|
140
138
|
} else if (ctaType === WEBSITE && (url === '' || urlError)) {
|
|
141
139
|
return true;
|
|
@@ -152,6 +150,7 @@ export const CapWhatsappCTA = (props) => {
|
|
|
152
150
|
|
|
153
151
|
const renderedContent = () => {
|
|
154
152
|
const renderArray = [];
|
|
153
|
+
const addBtnDisabled = ctaData.length === 1 && !ctaData[0].isSaved;
|
|
155
154
|
ctaData.forEach((cta) => {
|
|
156
155
|
const { index, ctaType, text, phone_number, url, isSaved } = cta || {};
|
|
157
156
|
if (isSaved) {
|
|
@@ -166,17 +165,20 @@ export const CapWhatsappCTA = (props) => {
|
|
|
166
165
|
<CapIcon
|
|
167
166
|
size="s"
|
|
168
167
|
type="drag"
|
|
169
|
-
|
|
168
|
+
className="whatsapp-saved-cta-drag-icon"
|
|
170
169
|
/>
|
|
171
170
|
</CapColumn>
|
|
172
171
|
<CapColumn
|
|
173
172
|
span={1}
|
|
174
|
-
|
|
173
|
+
className={`${ctaIsPhone ? 'whatsapp-saved-cta-phone-icon' : ''}`}
|
|
175
174
|
>
|
|
176
175
|
<CapIcon size="s" type={ctaIsPhone ? 'call' : 'launch'} />
|
|
177
176
|
</CapColumn>
|
|
178
177
|
<CapColumn span={6}>
|
|
179
|
-
<CapLabel
|
|
178
|
+
<CapLabel
|
|
179
|
+
type="label2"
|
|
180
|
+
className="whatsapp-saved-cta-button-text"
|
|
181
|
+
>
|
|
180
182
|
{text}
|
|
181
183
|
</CapLabel>
|
|
182
184
|
</CapColumn>
|
|
@@ -199,7 +201,7 @@ export const CapWhatsappCTA = (props) => {
|
|
|
199
201
|
)}
|
|
200
202
|
<CapColumn
|
|
201
203
|
span={1}
|
|
202
|
-
|
|
204
|
+
className="whatsapp-saved-cta-edit-icon"
|
|
203
205
|
onClick={() => editCta(index)}
|
|
204
206
|
>
|
|
205
207
|
<CapIcon size="s" type="edit" />
|
|
@@ -338,15 +340,14 @@ export const CapWhatsappCTA = (props) => {
|
|
|
338
340
|
});
|
|
339
341
|
// eslint-disable-next-line no-lone-blocks
|
|
340
342
|
{
|
|
343
|
+
// when first button is not saved, add button is disabled with tooltip
|
|
341
344
|
// eslint-disable-next-line no-unused-expressions
|
|
342
345
|
ctaData.length < 2 &&
|
|
343
346
|
renderArray.push(
|
|
344
347
|
<CapRow>
|
|
345
348
|
<CapTooltip
|
|
346
349
|
title={
|
|
347
|
-
|
|
348
|
-
? formatMessage(messages.ctaAddDisabled)
|
|
349
|
-
: ''
|
|
350
|
+
addBtnDisabled ? formatMessage(messages.ctaAddDisabled) : ''
|
|
350
351
|
}
|
|
351
352
|
placement={'right'}
|
|
352
353
|
>
|
|
@@ -354,7 +355,7 @@ export const CapWhatsappCTA = (props) => {
|
|
|
354
355
|
<CapButton
|
|
355
356
|
type="flat"
|
|
356
357
|
id="whatsapp-cta-add-button"
|
|
357
|
-
disabled={
|
|
358
|
+
disabled={addBtnDisabled}
|
|
358
359
|
className="margin-t-12 margin-l-24"
|
|
359
360
|
isAddBtn
|
|
360
361
|
onClick={addCta}
|
|
@@ -24,6 +24,21 @@
|
|
|
24
24
|
text-align: center;
|
|
25
25
|
background-color: #f1f1f1;
|
|
26
26
|
}
|
|
27
|
+
|
|
28
|
+
.whatsapp-saved-cta-drag-icon {
|
|
29
|
+
transform: rotate(90deg);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.whatsapp-saved-cta-phone-icon {
|
|
33
|
+
margin-bottom: -4px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.whatsapp-saved-cta-button-text {
|
|
37
|
+
font-weight: 500;
|
|
38
|
+
}
|
|
39
|
+
.whatsapp-saved-cta-edit-icon{
|
|
40
|
+
margin-left: 16px;
|
|
41
|
+
}
|
|
27
42
|
}
|
|
28
43
|
|
|
29
44
|
.cap-whatsapp-cta {
|
|
@@ -29,10 +29,6 @@ export default defineMessages({
|
|
|
29
29
|
id: `${prefix}.ctaWebsiteTypeStatic`,
|
|
30
30
|
defaultMessage: 'Static',
|
|
31
31
|
},
|
|
32
|
-
// ctaWebsiteTypeDynamic: {
|
|
33
|
-
// id: `${prefix}.ctaWebsiteTypeDynamic`,
|
|
34
|
-
// defaultMessage: 'Dynamic',
|
|
35
|
-
// },
|
|
36
32
|
ctaPhoneNoPlaceholder: {
|
|
37
33
|
id: `${prefix}.ctaPhoneNoPlaceholder`,
|
|
38
34
|
defaultMessage: 'Enter phone number',
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { injectIntl } from 'react-intl';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
import { render, screen, fireEvent } from '../../../utils/test-utils';
|
|
5
|
+
import { CapWhatsappCTA } from '../index';
|
|
6
|
+
import { INITIAL_CTA_DATA } from '../../../v2Containers/Whatsapp/constants';
|
|
7
|
+
import userEvent from '@testing-library/user-event';
|
|
8
|
+
|
|
9
|
+
const updateHandler = jest.fn();
|
|
10
|
+
const deleteHandler = jest.fn();
|
|
11
|
+
const initializeComponent = (data) => {
|
|
12
|
+
const Component = injectIntl(CapWhatsappCTA);
|
|
13
|
+
return render(
|
|
14
|
+
<Component
|
|
15
|
+
ctaData={data}
|
|
16
|
+
updateHandler={updateHandler}
|
|
17
|
+
deleteHandler={deleteHandler}
|
|
18
|
+
/>,
|
|
19
|
+
);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
describe('CapWhatsappCTA', () => {
|
|
23
|
+
it('Test if CapWhatsappCTA component renders', () => {
|
|
24
|
+
initializeComponent([
|
|
25
|
+
{
|
|
26
|
+
index: 0,
|
|
27
|
+
ctaType: 'PHONE_NUMBER',
|
|
28
|
+
text: '',
|
|
29
|
+
phone_number: '9112345',
|
|
30
|
+
urlType: 'STATIC_URL',
|
|
31
|
+
url: '',
|
|
32
|
+
isSaved: false,
|
|
33
|
+
},
|
|
34
|
+
]);
|
|
35
|
+
expect(screen.getByText('Type of action')).toBeInTheDocument();
|
|
36
|
+
expect(screen.getByText('Button text')).toBeInTheDocument();
|
|
37
|
+
expect(screen.getAllByText('Phone number')[1]).toBeInTheDocument();
|
|
38
|
+
expect(screen.getByRole('button', { name: /save/i })).toBeDisabled();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('first button', async () => {
|
|
42
|
+
initializeComponent([
|
|
43
|
+
{
|
|
44
|
+
index: 0,
|
|
45
|
+
ctaType: 'PHONE_NUMBER',
|
|
46
|
+
text: '',
|
|
47
|
+
phone_number: '9112345',
|
|
48
|
+
urlType: 'STATIC_URL',
|
|
49
|
+
url: '',
|
|
50
|
+
isSaved: false,
|
|
51
|
+
},
|
|
52
|
+
]);
|
|
53
|
+
const btnTextEvent = {
|
|
54
|
+
target: {
|
|
55
|
+
value: 'Call us',
|
|
56
|
+
id: 0,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
// button text
|
|
60
|
+
const buttontextInput = await screen.getByPlaceholderText(
|
|
61
|
+
'Enter button text',
|
|
62
|
+
);
|
|
63
|
+
fireEvent.change(buttontextInput, btnTextEvent);
|
|
64
|
+
expect(updateHandler).toHaveBeenCalledWith(
|
|
65
|
+
{
|
|
66
|
+
index: 0,
|
|
67
|
+
ctaType: 'PHONE_NUMBER',
|
|
68
|
+
text: 'Call us',
|
|
69
|
+
phone_number: '9112345',
|
|
70
|
+
urlType: 'STATIC_URL',
|
|
71
|
+
url: '',
|
|
72
|
+
isSaved: false,
|
|
73
|
+
},
|
|
74
|
+
'0',
|
|
75
|
+
);
|
|
76
|
+
});
|
|
77
|
+
it('second button', async () => {
|
|
78
|
+
initializeComponent([
|
|
79
|
+
{
|
|
80
|
+
index: 0,
|
|
81
|
+
ctaType: 'PHONE_NUMBER',
|
|
82
|
+
text: 'Call us',
|
|
83
|
+
phone_number: '9112345',
|
|
84
|
+
urlType: 'STATIC_URL',
|
|
85
|
+
url: '',
|
|
86
|
+
isSaved: true,
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
index: 1,
|
|
90
|
+
ctaType: 'WEBSITE',
|
|
91
|
+
text: 'Visit us',
|
|
92
|
+
phone_number: '',
|
|
93
|
+
urlType: 'STATIC_URL',
|
|
94
|
+
url: '',
|
|
95
|
+
isSaved: false,
|
|
96
|
+
},
|
|
97
|
+
]);
|
|
98
|
+
const urlEvent1 = {
|
|
99
|
+
target: {
|
|
100
|
+
value: 'https://www.google.co.in',
|
|
101
|
+
id: 1,
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
const urlEvent2 = {
|
|
105
|
+
target: {
|
|
106
|
+
value: 'test',
|
|
107
|
+
id: 1,
|
|
108
|
+
},
|
|
109
|
+
};
|
|
110
|
+
// button text
|
|
111
|
+
const urlInput = await screen.getByPlaceholderText(
|
|
112
|
+
'Enter website URL',
|
|
113
|
+
);
|
|
114
|
+
fireEvent.change(urlInput, urlEvent1);
|
|
115
|
+
expect(updateHandler).toHaveBeenCalledWith(
|
|
116
|
+
{
|
|
117
|
+
index: 1,
|
|
118
|
+
ctaType: 'WEBSITE',
|
|
119
|
+
text: 'Visit us',
|
|
120
|
+
phone_number: '',
|
|
121
|
+
urlType: 'STATIC_URL',
|
|
122
|
+
url: 'https://www.google.co.in',
|
|
123
|
+
isSaved: false,
|
|
124
|
+
},
|
|
125
|
+
'1',
|
|
126
|
+
);
|
|
127
|
+
fireEvent.change(urlInput, urlEvent2);
|
|
128
|
+
});
|
|
129
|
+
it('both buttons', async () => {
|
|
130
|
+
initializeComponent([
|
|
131
|
+
{
|
|
132
|
+
index: 0,
|
|
133
|
+
ctaType: 'PHONE_NUMBER',
|
|
134
|
+
text: 'Call us',
|
|
135
|
+
phone_number: '9112345',
|
|
136
|
+
urlType: 'STATIC_URL',
|
|
137
|
+
url: '',
|
|
138
|
+
isSaved: true,
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
index: 1,
|
|
142
|
+
ctaType: 'WEBSITE',
|
|
143
|
+
text: 'Visit us',
|
|
144
|
+
phone_number: '',
|
|
145
|
+
urlType: 'STATIC_URL',
|
|
146
|
+
url: 'https://www.google.co.in',
|
|
147
|
+
isSaved: true,
|
|
148
|
+
},
|
|
149
|
+
]);
|
|
150
|
+
expect(screen.getByText(/https:\/\/www\.google\.co\.in/i)).toBeInTheDocument();
|
|
151
|
+
});
|
|
152
|
+
});
|
|
@@ -21,7 +21,6 @@ import {
|
|
|
21
21
|
} from '../../v2Containers/CreativesContainer/constants';
|
|
22
22
|
import Carousel from '../Carousel';
|
|
23
23
|
import { VIBER, FACEBOOK } from '../../v2Containers/App/constants';
|
|
24
|
-
import { UNSUBSCRIBE_TEXT_LENGTH } from '../../v2Containers/Whatsapp/constants';
|
|
25
24
|
import whatsappMobileAndroid from './assets/images/whatsapp_mobile_android.svg';
|
|
26
25
|
const wechatBodyNew = require('./assets/images/wechat_mobile_android.svg');
|
|
27
26
|
const smsMobileAndroid = require('./assets/images/sms_mobile_android.svg');
|
|
@@ -324,7 +323,7 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
324
323
|
};
|
|
325
324
|
|
|
326
325
|
const whatsappUpdatedAccountName = whatsappAccountName || templateData?.versions?.base?.content?.whatsapp?.accountName || '';
|
|
327
|
-
const whatsappUpdatedLen = whatsappContentLen !== undefined ?
|
|
326
|
+
const whatsappUpdatedLen = whatsappContentLen !== undefined ? whatsappContentLen : content?.charCount;
|
|
328
327
|
|
|
329
328
|
return (
|
|
330
329
|
<CapRow>
|
|
@@ -342,10 +341,10 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
342
341
|
<>
|
|
343
342
|
<WhatsappStatusContainer template={templateData} />
|
|
344
343
|
<CapHeading type="h3" className="margin-t-12">
|
|
345
|
-
<FormattedMessage
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
344
|
+
<FormattedMessage
|
|
345
|
+
{...messages.whatsappMessageLength}
|
|
346
|
+
values={{ length: whatsappUpdatedLen }}
|
|
347
|
+
/>
|
|
349
348
|
</CapHeading>
|
|
350
349
|
</>
|
|
351
350
|
) : null}
|
|
@@ -22,18 +22,10 @@ export default defineMessages({
|
|
|
22
22
|
id: 'creatives.componentsV2.TemplatePreview.charactersTotal',
|
|
23
23
|
defaultMessage: "{smsCount} SMS ({charCount} characters)",
|
|
24
24
|
},
|
|
25
|
-
whatsappCharactersTotal: {
|
|
26
|
-
id: 'creatives.componentsV2.TemplatePreview.whatsappCharactersTotal',
|
|
27
|
-
defaultMessage: "{charCount} characters",
|
|
28
|
-
},
|
|
29
25
|
optoutCharactersTotal: {
|
|
30
26
|
id: 'app.components.TemplatePreview.optoutCharactersTotal',
|
|
31
27
|
defaultMessage: "Includes optout tag ({optoutUrlLength} characters)",
|
|
32
28
|
},
|
|
33
|
-
whatsappUnsubscribeLength: {
|
|
34
|
-
id: 'app.components.TemplatePreview.whatsappUnsubscribeLength',
|
|
35
|
-
defaultMessage: "Includes 36 characters of (Click {{unsubscribe}} to unsubscribe)",
|
|
36
|
-
},
|
|
37
29
|
whatsappMessageLength: {
|
|
38
30
|
id: 'app.components.TemplatePreview.whatsappMessageLength',
|
|
39
31
|
defaultMessage: "1 Message ({length} characters)",
|
|
@@ -3,10 +3,7 @@
|
|
|
3
3
|
exports[`Test Templates container Should render correct preview component for rcs channel 1`] = `
|
|
4
4
|
<CapRow>
|
|
5
5
|
<CapColumn
|
|
6
|
-
span={
|
|
7
|
-
/>
|
|
8
|
-
<CapColumn
|
|
9
|
-
span={8}
|
|
6
|
+
span={24}
|
|
10
7
|
>
|
|
11
8
|
<div
|
|
12
9
|
className="preview-container "
|
|
@@ -24,7 +21,21 @@ exports[`Test Templates container Should render correct preview component for rc
|
|
|
24
21
|
>
|
|
25
22
|
<div
|
|
26
23
|
className="message-pop sms"
|
|
27
|
-
|
|
24
|
+
>
|
|
25
|
+
<CapLabel
|
|
26
|
+
className="message-pop-item align-left rcs-content"
|
|
27
|
+
fontWeight="bold"
|
|
28
|
+
type="label5"
|
|
29
|
+
>
|
|
30
|
+
RCS Title
|
|
31
|
+
</CapLabel>
|
|
32
|
+
<CapLabel
|
|
33
|
+
className="message-pop-item align-left rcs-content rcs-desc"
|
|
34
|
+
type="label5"
|
|
35
|
+
>
|
|
36
|
+
RCS Description
|
|
37
|
+
</CapLabel>
|
|
38
|
+
</div>
|
|
28
39
|
</div>
|
|
29
40
|
</div>
|
|
30
41
|
</div>
|
|
@@ -35,35 +46,187 @@ exports[`Test Templates container Should render correct preview component for rc
|
|
|
35
46
|
exports[`Test Templates container Should render correct preview component for whatsapp channel 1`] = `
|
|
36
47
|
<CapRow>
|
|
37
48
|
<CapColumn
|
|
38
|
-
span={
|
|
49
|
+
span={24}
|
|
39
50
|
>
|
|
40
|
-
<
|
|
41
|
-
|
|
42
|
-
className="margin-t-12"
|
|
43
|
-
type="h3"
|
|
51
|
+
<div
|
|
52
|
+
className="preview-container "
|
|
44
53
|
>
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
54
|
+
<div
|
|
55
|
+
className="shell-v2 align-center"
|
|
56
|
+
>
|
|
57
|
+
<CapImage
|
|
58
|
+
alt="Preview is being generated"
|
|
59
|
+
className="preview-image"
|
|
60
|
+
src="test-file-stub"
|
|
61
|
+
/>
|
|
62
|
+
<CapLabel
|
|
63
|
+
className="whatsapp-brand-name"
|
|
64
|
+
type="label1"
|
|
65
|
+
>
|
|
66
|
+
30
|
|
67
|
+
</CapLabel>
|
|
68
|
+
<div
|
|
69
|
+
className="msg-container whatsapp-message-container"
|
|
70
|
+
>
|
|
71
|
+
<div
|
|
72
|
+
className="message-pop align-left"
|
|
73
|
+
style={
|
|
74
|
+
Object {
|
|
75
|
+
"background-color": "#ffffff",
|
|
76
|
+
"border-radius": "6px",
|
|
77
|
+
"left": 0,
|
|
78
|
+
"padding": "4px 0 0.571rem",
|
|
79
|
+
"width": "88%",
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
>
|
|
83
|
+
<CapLabel
|
|
84
|
+
className="whatsapp-content"
|
|
85
|
+
type="label1"
|
|
86
|
+
>
|
|
87
|
+
You have received {{1}} points
|
|
88
|
+
</CapLabel>
|
|
89
|
+
<CapDivider
|
|
90
|
+
className="whatsapp-divider"
|
|
91
|
+
/>
|
|
92
|
+
<CapLabel
|
|
93
|
+
className="whatsapp-cta-preview"
|
|
94
|
+
type="label21"
|
|
95
|
+
>
|
|
96
|
+
<CapIcon
|
|
97
|
+
size="xs"
|
|
98
|
+
svgProps={
|
|
99
|
+
Object {
|
|
100
|
+
"style": Object {
|
|
101
|
+
"marginRight": "4px",
|
|
102
|
+
},
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
type="call"
|
|
106
|
+
/>
|
|
107
|
+
Call
|
|
108
|
+
</CapLabel>
|
|
109
|
+
<CapLabel
|
|
110
|
+
className="whatsapp-cta-preview"
|
|
111
|
+
type="label21"
|
|
112
|
+
>
|
|
113
|
+
<CapIcon
|
|
114
|
+
size="xs"
|
|
115
|
+
svgProps={
|
|
116
|
+
Object {
|
|
117
|
+
"style": Object {
|
|
118
|
+
"marginRight": "4px",
|
|
119
|
+
},
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
type="launch"
|
|
123
|
+
/>
|
|
124
|
+
Visit
|
|
125
|
+
</CapLabel>
|
|
126
|
+
</div>
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
<CapHeading
|
|
130
|
+
className="margin-t-16"
|
|
131
|
+
style={
|
|
49
132
|
Object {
|
|
50
|
-
"
|
|
133
|
+
"textAlign": "center",
|
|
51
134
|
}
|
|
52
135
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
136
|
+
type="h3"
|
|
137
|
+
>
|
|
138
|
+
<FormattedMessage
|
|
139
|
+
defaultMessage="1 Message ({length} characters)"
|
|
140
|
+
id="app.components.TemplatePreview.whatsappMessageLength"
|
|
141
|
+
values={
|
|
142
|
+
Object {
|
|
143
|
+
"length": "test",
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
/>
|
|
147
|
+
</CapHeading>
|
|
148
|
+
</div>
|
|
149
|
+
</CapColumn>
|
|
150
|
+
</CapRow>
|
|
151
|
+
`;
|
|
152
|
+
|
|
153
|
+
exports[`Test Templates container Should render correct preview component for whatsapp channel 2`] = `
|
|
154
|
+
<CapRow>
|
|
155
|
+
<CapColumn
|
|
156
|
+
span={24}
|
|
157
|
+
>
|
|
158
|
+
<div
|
|
159
|
+
className="preview-container "
|
|
57
160
|
>
|
|
58
|
-
<
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
161
|
+
<div
|
|
162
|
+
className="shell-v2 align-center"
|
|
163
|
+
>
|
|
164
|
+
<CapImage
|
|
165
|
+
alt="Preview is being generated"
|
|
166
|
+
className="preview-image"
|
|
167
|
+
src="test-file-stub"
|
|
168
|
+
/>
|
|
169
|
+
<CapLabel
|
|
170
|
+
className="whatsapp-brand-name"
|
|
171
|
+
type="label1"
|
|
172
|
+
>
|
|
173
|
+
30
|
|
174
|
+
</CapLabel>
|
|
175
|
+
<div
|
|
176
|
+
className="msg-container whatsapp-message-container"
|
|
177
|
+
>
|
|
178
|
+
<div
|
|
179
|
+
className="message-pop align-left"
|
|
180
|
+
style={
|
|
181
|
+
Object {
|
|
182
|
+
"background-color": "#ffffff",
|
|
183
|
+
"border-radius": "6px",
|
|
184
|
+
"left": 0,
|
|
185
|
+
"padding": "4px 0 0.571rem",
|
|
186
|
+
"width": "88%",
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
>
|
|
190
|
+
<CapLabel
|
|
191
|
+
className="whatsapp-content"
|
|
192
|
+
type="label1"
|
|
193
|
+
>
|
|
194
|
+
You have received {{1}} points
|
|
195
|
+
</CapLabel>
|
|
196
|
+
<CapDivider
|
|
197
|
+
className="whatsapp-divider"
|
|
198
|
+
/>
|
|
199
|
+
</div>
|
|
200
|
+
</div>
|
|
201
|
+
</div>
|
|
202
|
+
<CapHeading
|
|
203
|
+
className="margin-t-16"
|
|
204
|
+
style={
|
|
205
|
+
Object {
|
|
206
|
+
"textAlign": "center",
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
type="h3"
|
|
210
|
+
>
|
|
211
|
+
<FormattedMessage
|
|
212
|
+
defaultMessage="1 Message ({length} characters)"
|
|
213
|
+
id="app.components.TemplatePreview.whatsappMessageLength"
|
|
214
|
+
values={
|
|
215
|
+
Object {
|
|
216
|
+
"length": "test",
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
/>
|
|
220
|
+
</CapHeading>
|
|
221
|
+
</div>
|
|
64
222
|
</CapColumn>
|
|
223
|
+
</CapRow>
|
|
224
|
+
`;
|
|
225
|
+
|
|
226
|
+
exports[`Test Templates container Should render correct preview component for whatsapp channel 3`] = `
|
|
227
|
+
<CapRow>
|
|
65
228
|
<CapColumn
|
|
66
|
-
span={
|
|
229
|
+
span={24}
|
|
67
230
|
>
|
|
68
231
|
<div
|
|
69
232
|
className="preview-container "
|
|
@@ -116,7 +279,7 @@ exports[`Test Templates container Should render correct preview component for wh
|
|
|
116
279
|
id="app.components.TemplatePreview.whatsappMessageLength"
|
|
117
280
|
values={
|
|
118
281
|
Object {
|
|
119
|
-
"length":
|
|
282
|
+
"length": "test",
|
|
120
283
|
}
|
|
121
284
|
}
|
|
122
285
|
/>
|
|
@@ -3,22 +3,69 @@ import { shallowWithIntl } from '../../../helpers/intl-enzym-test-helpers';
|
|
|
3
3
|
|
|
4
4
|
import { TemplatePreview } from '../index';
|
|
5
5
|
|
|
6
|
-
|
|
7
6
|
describe('Test Templates container', () => {
|
|
8
7
|
let renderedComponent;
|
|
9
8
|
|
|
10
|
-
const renderFunction = (
|
|
9
|
+
const renderFunction = (
|
|
10
|
+
channel,
|
|
11
|
+
content,
|
|
12
|
+
whatsappAccountName,
|
|
13
|
+
whatsappContentLen,
|
|
14
|
+
) => {
|
|
11
15
|
renderedComponent = shallowWithIntl(
|
|
12
|
-
<TemplatePreview
|
|
16
|
+
<TemplatePreview
|
|
17
|
+
channel={channel}
|
|
18
|
+
content={content}
|
|
19
|
+
whatsappAccountName={whatsappAccountName}
|
|
20
|
+
whatsappContentLen={whatsappContentLen}
|
|
21
|
+
/>,
|
|
13
22
|
);
|
|
14
23
|
};
|
|
15
24
|
|
|
16
25
|
it('Should render correct preview component for whatsapp channel', () => {
|
|
17
|
-
renderFunction(
|
|
26
|
+
renderFunction(
|
|
27
|
+
'whatsapp',
|
|
28
|
+
{
|
|
29
|
+
templateMsg: 'You have received {{1}} points',
|
|
30
|
+
ctaData: [
|
|
31
|
+
{
|
|
32
|
+
index: 0,
|
|
33
|
+
type: 'PHONE_NUMBER',
|
|
34
|
+
text: 'Call',
|
|
35
|
+
phone_number: '+917892303868',
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
index: 1,
|
|
39
|
+
type: 'STATIC_URL',
|
|
40
|
+
text: 'Visit',
|
|
41
|
+
url: 'https://www.capillarytech.com/',
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
},
|
|
45
|
+
30,
|
|
46
|
+
'test',
|
|
47
|
+
);
|
|
48
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
49
|
+
renderFunction(
|
|
50
|
+
'whatsapp',
|
|
51
|
+
{
|
|
52
|
+
templateMsg: 'You have received {{1}} points',
|
|
53
|
+
ctaData: [{}],
|
|
54
|
+
},
|
|
55
|
+
30,
|
|
56
|
+
'test',
|
|
57
|
+
);
|
|
58
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
59
|
+
renderFunction('whatsapp', {}, 0, 'test');
|
|
18
60
|
expect(renderedComponent).toMatchSnapshot();
|
|
19
61
|
});
|
|
20
62
|
it('Should render correct preview component for rcs channel', () => {
|
|
21
|
-
renderFunction('rcs'
|
|
63
|
+
renderFunction('rcs', {
|
|
64
|
+
rcsPreviewContent: {
|
|
65
|
+
rcsTitle: 'RCS Title',
|
|
66
|
+
rcsDesc: 'RCS Description',
|
|
67
|
+
},
|
|
68
|
+
});
|
|
22
69
|
expect(renderedComponent).toMatchSnapshot();
|
|
23
70
|
});
|
|
24
71
|
});
|