@capillarytech/creatives-library 7.10.66 → 7.10.67
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 +2 -1
- package/utils/tests/v2Common.test.js +11 -0
- package/utils/v2common.js +7 -0
- package/v2Components/TemplatePreview/_templatePreview.scss +0 -7
- package/v2Components/TemplatePreview/index.js +4 -3
- package/v2Components/TemplatePreview/tests/__snapshots__/index.test.js.snap +95 -0
- package/v2Components/TemplatePreview/tests/index.test.js +20 -6
- package/v2Components/WhatsappStatusContainer/tests/__snapshots__/index.test.js.snap +37 -0
- package/v2Components/WhatsappStatusContainer/tests/index.test.js +23 -0
- package/v2Components/mockdata.js +39 -0
- package/v2Containers/Cap/messages.js +5 -0
- package/v2Containers/CreativesContainer/SlideBoxContent.js +1 -1
- package/v2Containers/CreativesContainer/SlideBoxHeader.js +2 -3
- package/v2Containers/CreativesContainer/index.js +5 -5
- package/v2Containers/CreativesContainer/tests/SlideBoxContent.test.js +49 -0
- package/v2Containers/CreativesContainer/tests/SlideBoxHeader.test.js +50 -0
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxContent.test.js.snap +125 -0
- package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxHeader.test.js.snap +166 -0
- package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +145 -0
- package/v2Containers/CreativesContainer/tests/index.test.js +54 -6
- package/v2Containers/Templates/index.js +2 -3
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +5604 -0
- package/v2Containers/Templates/tests/index.test.js +121 -6
- package/v2Containers/TemplatesV2/index.js +7 -7
- package/v2Containers/Whatsapp/constants.js +7 -1
- package/v2Containers/Whatsapp/index.js +23 -18
- package/v2Containers/Whatsapp/messages.js +0 -8
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +10594 -730
- package/v2Containers/Whatsapp/tests/index.test.js +1 -1
- package/v2Containers/Whatsapp/tests/utils.test.js +23 -0
- package/v2Containers/mockdata.js +2208 -0
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capillarytech/creatives-library",
|
|
3
3
|
"author": "meharaj",
|
|
4
|
-
"version": "7.10.
|
|
4
|
+
"version": "7.10.67",
|
|
5
5
|
"description": "Capillary creatives ui",
|
|
6
6
|
"main": "./index.js",
|
|
7
7
|
"module": "./index.es.js",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"license": "LicenseRef-LICENSE",
|
|
14
14
|
"dependencies": {
|
|
15
|
+
"@babel/polyfill": "7.4.3",
|
|
15
16
|
"@bugsnag/js": "^7.2.1",
|
|
16
17
|
"@bugsnag/plugin-react": "^7.2.1",
|
|
17
18
|
"@capillarytech/cap-ui-utils": "1.4.2",
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { getObjFromQueryParams } from '../v2common';
|
|
3
|
+
|
|
4
|
+
describe('Test v2common container', () => {
|
|
5
|
+
it('test getObjFromQueryParams', () => {
|
|
6
|
+
expect(getObjFromQueryParams("?channel=WHATSAPP&mode=CREATE")).toEqual({
|
|
7
|
+
channel: 'WHATSAPP',
|
|
8
|
+
mode: 'CREATE',
|
|
9
|
+
});
|
|
10
|
+
});
|
|
11
|
+
});
|
package/utils/v2common.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
// returns query items as obj when query string is passed
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {*} searchString // '?channel=whatsapp&mode=create
|
|
6
|
+
* @returns // { channel: 'whatsapp', mode: 'create' }
|
|
7
|
+
*/
|
|
1
8
|
export const getObjFromQueryParams = (searchString) => {
|
|
2
9
|
const params = new URLSearchParams(searchString);
|
|
3
10
|
const obj = {};
|
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
} from '../../v2Containers/CreativesContainer/constants';
|
|
21
21
|
import Carousel from '../Carousel';
|
|
22
22
|
import { VIBER, FACEBOOK } from '../../v2Containers/App/constants';
|
|
23
|
+
import { UNSUBSCRIBE_TEXT_LENGTH } from '../../v2Containers/Whatsapp/constants';
|
|
23
24
|
import whatsappMobileAndroid from './assets/images/whatsapp_mobile_android.svg'
|
|
24
25
|
const wechatBodyNew = require('./assets/images/wechat_mobile_android.svg');
|
|
25
26
|
const smsMobileAndroid = require('./assets/images/sms_mobile_android.svg');
|
|
@@ -47,7 +48,7 @@ import { TEMPLATE, IMAGE_CAROUSEL, IMAGE, STICKER, TEXT, IMAGE_MAP, VIDEO } from
|
|
|
47
48
|
import CapFacebookPreview from '../../v2Containers/CapFacebookPreview';
|
|
48
49
|
import WhatsappStatusContainer from '../WhatsappStatusContainer';
|
|
49
50
|
|
|
50
|
-
class TemplatePreview extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
51
|
+
export class TemplatePreview extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
51
52
|
onPreviewContentClicked = (channel) => {
|
|
52
53
|
const IOSContent = (this.props.templateDataRaw && this.props.templateDataRaw.versions.base.IOS) ||
|
|
53
54
|
((this.props.device === 'iphone' || this.props.device === 'ios') && this.props.content);
|
|
@@ -292,8 +293,8 @@ class TemplatePreview extends React.Component { // eslint-disable-line react/pre
|
|
|
292
293
|
</div>
|
|
293
294
|
);
|
|
294
295
|
|
|
295
|
-
const whatsappUpdatedAccountName = whatsappAccountName ||
|
|
296
|
-
const whatsappUpdatedLen = whatsappContentLen !== undefined ?
|
|
296
|
+
const whatsappUpdatedAccountName = whatsappAccountName || templateData?.versions?.base?.content?.whatsapp?.accountName || '';
|
|
297
|
+
const whatsappUpdatedLen = whatsappContentLen !== undefined ? UNSUBSCRIBE_TEXT_LENGTH + whatsappContentLen : content?.templateMsg?.length;
|
|
297
298
|
|
|
298
299
|
return (
|
|
299
300
|
<CapRow>
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Test Templates container Should render correct preview component for whatsapp channel 1`] = `
|
|
4
|
+
<CapRow>
|
|
5
|
+
<CapColumn
|
|
6
|
+
span={16}
|
|
7
|
+
>
|
|
8
|
+
<WhatsappStatusContainer />
|
|
9
|
+
<CapHeading
|
|
10
|
+
className="margin-t-12"
|
|
11
|
+
type="h3"
|
|
12
|
+
>
|
|
13
|
+
<FormattedMessage
|
|
14
|
+
defaultMessage="{charCount} characters"
|
|
15
|
+
id="creatives.componentsV2.TemplatePreview.whatsappCharactersTotal"
|
|
16
|
+
values={
|
|
17
|
+
Object {
|
|
18
|
+
"charCount": undefined,
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/>
|
|
22
|
+
</CapHeading>
|
|
23
|
+
<CapHeading
|
|
24
|
+
type="h6"
|
|
25
|
+
>
|
|
26
|
+
<FormattedMessage
|
|
27
|
+
defaultMessage="Includes 36 characters of (Click {{unsubscribe}} to unsubscribe)"
|
|
28
|
+
id="app.components.TemplatePreview.whatsappUnsubscribeLength"
|
|
29
|
+
values={Object {}}
|
|
30
|
+
/>
|
|
31
|
+
</CapHeading>
|
|
32
|
+
</CapColumn>
|
|
33
|
+
<CapColumn
|
|
34
|
+
span={8}
|
|
35
|
+
>
|
|
36
|
+
<div
|
|
37
|
+
className="preview-container "
|
|
38
|
+
>
|
|
39
|
+
<div
|
|
40
|
+
className="shell-v2 align-center"
|
|
41
|
+
>
|
|
42
|
+
<CapImage
|
|
43
|
+
alt="Preview is being generated"
|
|
44
|
+
className="preview-image"
|
|
45
|
+
src="test-file-stub"
|
|
46
|
+
/>
|
|
47
|
+
<CapLabel
|
|
48
|
+
className="whatsapp-brand-name"
|
|
49
|
+
type="label1"
|
|
50
|
+
/>
|
|
51
|
+
<div
|
|
52
|
+
className="msg-container whatsapp-message-container"
|
|
53
|
+
>
|
|
54
|
+
<div
|
|
55
|
+
className="message-pop align-left"
|
|
56
|
+
style={
|
|
57
|
+
Object {
|
|
58
|
+
"background-color": "#efefef",
|
|
59
|
+
"border-radius": "6px",
|
|
60
|
+
"left": "10%",
|
|
61
|
+
"padding": "4px 0 0.571rem",
|
|
62
|
+
"width": "88%",
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
>
|
|
66
|
+
<CapLabel
|
|
67
|
+
className="whatsapp-content"
|
|
68
|
+
type="label1"
|
|
69
|
+
/>
|
|
70
|
+
</div>
|
|
71
|
+
</div>
|
|
72
|
+
</div>
|
|
73
|
+
<CapHeading
|
|
74
|
+
className="margin-t-16"
|
|
75
|
+
style={
|
|
76
|
+
Object {
|
|
77
|
+
"textAlign": "center",
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
type="h3"
|
|
81
|
+
>
|
|
82
|
+
<FormattedMessage
|
|
83
|
+
defaultMessage="1 Message ({length} characters)"
|
|
84
|
+
id="app.components.TemplatePreview.whatsappMessageLength"
|
|
85
|
+
values={
|
|
86
|
+
Object {
|
|
87
|
+
"length": undefined,
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
/>
|
|
91
|
+
</CapHeading>
|
|
92
|
+
</div>
|
|
93
|
+
</CapColumn>
|
|
94
|
+
</CapRow>
|
|
95
|
+
`;
|
|
@@ -1,10 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shallowWithIntl } from '../../../helpers/intl-enzym-test-helpers';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
import { TemplatePreview } from '../index';
|
|
5
|
+
import mockdata from '../../mockdata';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
7
|
+
|
|
8
|
+
describe('Test Templates container', () => {
|
|
9
|
+
let renderedComponent;
|
|
10
|
+
|
|
11
|
+
const renderFunction = () => {
|
|
12
|
+
renderedComponent = shallowWithIntl(
|
|
13
|
+
<TemplatePreview
|
|
14
|
+
channel="whatsapp"
|
|
15
|
+
showCount
|
|
16
|
+
/>
|
|
17
|
+
);
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
it('Should render correct preview component for whatsapp channel', () => {
|
|
21
|
+
renderFunction();
|
|
22
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
9
23
|
});
|
|
10
24
|
});
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Test WhatsappStatusContainer component Should render correct status component for whatsapp channel 1`] = `
|
|
4
|
+
<CapRow
|
|
5
|
+
align="middle"
|
|
6
|
+
className="whatsapp-status-container"
|
|
7
|
+
type="flex"
|
|
8
|
+
>
|
|
9
|
+
<CapStatus
|
|
10
|
+
color=""
|
|
11
|
+
height="0.571rem"
|
|
12
|
+
labelType="label3"
|
|
13
|
+
text={
|
|
14
|
+
<FormattedMessage
|
|
15
|
+
defaultMessage="Approved"
|
|
16
|
+
id="creatives.containersV2.Whatsapp.approved"
|
|
17
|
+
values={Object {}}
|
|
18
|
+
/>
|
|
19
|
+
}
|
|
20
|
+
type="approved"
|
|
21
|
+
width="0.571rem"
|
|
22
|
+
/>
|
|
23
|
+
<CapColoredTag
|
|
24
|
+
className="whatsapp-category-tag"
|
|
25
|
+
tagColor="#ffe5d2"
|
|
26
|
+
tagFontSize="12px"
|
|
27
|
+
tagHeight="20px"
|
|
28
|
+
tagTextColor="#f87d23"
|
|
29
|
+
>
|
|
30
|
+
<FormattedMessage
|
|
31
|
+
defaultMessage="Payment update"
|
|
32
|
+
id="creatives.containersV2.Whatsapp.paymentUpdate"
|
|
33
|
+
values={Object {}}
|
|
34
|
+
/>
|
|
35
|
+
</CapColoredTag>
|
|
36
|
+
</CapRow>
|
|
37
|
+
`;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shallowWithIntl } from '../../../helpers/intl-enzym-test-helpers';
|
|
3
|
+
import { WhatsappStatusContainer } from '../index';
|
|
4
|
+
import mockdata from '../../mockdata';
|
|
5
|
+
|
|
6
|
+
const { whatsappTemplate } = mockdata;
|
|
7
|
+
|
|
8
|
+
describe('Test WhatsappStatusContainer component', () => {
|
|
9
|
+
let renderedComponent;
|
|
10
|
+
|
|
11
|
+
const renderFunction = () => {
|
|
12
|
+
renderedComponent = shallowWithIntl(
|
|
13
|
+
<WhatsappStatusContainer
|
|
14
|
+
template={whatsappTemplate}
|
|
15
|
+
/>
|
|
16
|
+
);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
it('Should render correct status component for whatsapp channel', () => {
|
|
20
|
+
renderFunction();
|
|
21
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
22
|
+
});
|
|
23
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
whatsappTemplate: {
|
|
3
|
+
"_id": "620dfb2939bd39482baeaabd",
|
|
4
|
+
"name": "demo_2",
|
|
5
|
+
"type": "WHATSAPP",
|
|
6
|
+
"versions": {
|
|
7
|
+
"$init": true,
|
|
8
|
+
"history": [],
|
|
9
|
+
"base": {
|
|
10
|
+
"content": {
|
|
11
|
+
"whatsapp": {
|
|
12
|
+
"status": "approved",
|
|
13
|
+
"templateId": "HTb91abec747c522c6865560016e3b9301",
|
|
14
|
+
"accountName": "whatsappTest",
|
|
15
|
+
"accessToken": "4676323eb5d1f975b0987070c03a8efc",
|
|
16
|
+
"accountId": "AC41030cebba9e2f1ce37c78235da0ee18",
|
|
17
|
+
"templateEditor": "",
|
|
18
|
+
"mediaType": "TEXT",
|
|
19
|
+
"languages": [
|
|
20
|
+
{
|
|
21
|
+
"content": "Hi {{1}}, your account is credited with {{2}}\n\nTC{{3}}\nClick {{4}} to unsubscribe",
|
|
22
|
+
"language": "en"
|
|
23
|
+
}
|
|
24
|
+
],
|
|
25
|
+
"category": "PAYMENT_UPDATE",
|
|
26
|
+
"rejection_reason": null
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
"isActive": true,
|
|
32
|
+
"orgId": 50371,
|
|
33
|
+
"createdBy": "15000449",
|
|
34
|
+
"updatedBy": "15000449",
|
|
35
|
+
"createdAt": "2022-02-17T07:37:14.166Z",
|
|
36
|
+
"updatedAt": "2022-02-17T07:37:14.166Z",
|
|
37
|
+
"totalCount": 5
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -161,5 +161,10 @@ export default defineMessages({
|
|
|
161
161
|
id: `creatives.containersV2.done`,
|
|
162
162
|
defaultMessage: 'Done',
|
|
163
163
|
},
|
|
164
|
+
"unsupportedTagsValidationError": {
|
|
165
|
+
id: `creatives.containersV2.unsupportedTagsValidationError`,
|
|
166
|
+
defaultMessage:
|
|
167
|
+
'Unsupported tags: {unsupportedTags}. Please remove them from this message.',
|
|
168
|
+
},
|
|
164
169
|
});
|
|
165
170
|
|
|
@@ -26,10 +26,9 @@ const renderWhatsappData = (type, value) => (
|
|
|
26
26
|
<StyledLabel type={type}>
|
|
27
27
|
{value}
|
|
28
28
|
</StyledLabel>
|
|
29
|
-
)
|
|
30
|
-
function SlideBoxHeader(props) {
|
|
31
|
-
|
|
29
|
+
);
|
|
32
30
|
|
|
31
|
+
export function SlideBoxHeader(props) {
|
|
33
32
|
const { slidBoxContent, templateData, onShowTemplates, creativesMode, isFullMode, showPrefix, shouldShowTemplateName, channel, templateNameRenderProp, weChatTemplateType, onWeChatMaptemplateStepChange, weChatMaptemplateStep, templateStep, smsRegister } = props;
|
|
34
33
|
const showTemplateNameHeader = isFullMode && shouldShowTemplateName;
|
|
35
34
|
const mapTemplateCreate = !showTemplateNameHeader && slidBoxContent === 'createTemplate' && weChatTemplateType === MAP_TEMPLATE && templateStep !== 'modeSelection';
|
|
@@ -47,7 +47,7 @@ const SlideBoxWrapper = styled.div`
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
`;
|
|
50
|
-
class Creatives extends React.Component {
|
|
50
|
+
export class Creatives extends React.Component {
|
|
51
51
|
constructor(props) {
|
|
52
52
|
super(props);
|
|
53
53
|
this.state = {
|
|
@@ -373,8 +373,8 @@ class Creatives extends React.Component {
|
|
|
373
373
|
varMapped,
|
|
374
374
|
language,
|
|
375
375
|
category,
|
|
376
|
-
mediaType
|
|
377
|
-
}
|
|
376
|
+
mediaType,
|
|
377
|
+
} = {},
|
|
378
378
|
} = templateData;
|
|
379
379
|
creativesTemplateData = {
|
|
380
380
|
type: constants.WHATSAPP,
|
|
@@ -541,11 +541,11 @@ class Creatives extends React.Component {
|
|
|
541
541
|
const accountId = selectedAccountId || (selectedWhatsappAccount?.id || '');
|
|
542
542
|
const { versions } = template.value;
|
|
543
543
|
const {
|
|
544
|
-
languages,
|
|
544
|
+
languages = [{}],
|
|
545
545
|
mediaType,
|
|
546
546
|
category,
|
|
547
547
|
templateEditor,
|
|
548
|
-
varMapped
|
|
548
|
+
varMapped,
|
|
549
549
|
} = cloneDeep(versions.base.content.whatsapp);
|
|
550
550
|
templateData = {
|
|
551
551
|
channel,
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shallowWithIntl } from '../../../helpers/intl-enzym-test-helpers';
|
|
3
|
+
|
|
4
|
+
import { SlideBoxContent } from '../SlideBoxContent';
|
|
5
|
+
import mockdata from '../../mockdata';
|
|
6
|
+
|
|
7
|
+
const { editTemplateData, previewTemplateData } = mockdata;
|
|
8
|
+
|
|
9
|
+
jest.mock("../../../v2Components/FormBuilder", () => ({
|
|
10
|
+
__esModule: true,
|
|
11
|
+
default: (props) => <div className="FormBuilder-mock" {...props}>FormBuilder</div>,
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
describe('Test SlideBoxContent container', () => {
|
|
15
|
+
const onCreateComplete = jest.fn();
|
|
16
|
+
let renderedComponent;
|
|
17
|
+
|
|
18
|
+
const renderFunction = (channel, mode, templateData) => {
|
|
19
|
+
renderedComponent = shallowWithIntl(
|
|
20
|
+
<SlideBoxContent
|
|
21
|
+
slidBoxContent={mode}
|
|
22
|
+
currentChannel={channel}
|
|
23
|
+
templateData={templateData}
|
|
24
|
+
onCreateComplete={onCreateComplete}
|
|
25
|
+
/>
|
|
26
|
+
);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
it('Should render correct component for whatsapp channel create mode', () => {
|
|
30
|
+
renderFunction("WHATSAPP", "createTemplate", { mode: "create" });
|
|
31
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
it('Should render correct component for whatsapp channel edit mode', () => {
|
|
36
|
+
renderFunction("WHATSAPP", "editTemplate", editTemplateData);
|
|
37
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('Should render correct component for whatsapp channel preview mode', () => {
|
|
41
|
+
renderFunction("WHATSAPP", "preview", previewTemplateData);
|
|
42
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('Should render correct component for whatsapp channel templates mode', () => {
|
|
46
|
+
renderFunction("WHATSAPP", "templates");
|
|
47
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
48
|
+
});
|
|
49
|
+
});
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { shallowWithIntl } from '../../../helpers/intl-enzym-test-helpers';
|
|
3
|
+
|
|
4
|
+
import { SlideBoxHeader } from '../SlideBoxHeader';
|
|
5
|
+
import mockdata from '../../mockdata';
|
|
6
|
+
|
|
7
|
+
const { editTemplateData, previewTemplateData } = mockdata;
|
|
8
|
+
|
|
9
|
+
jest.mock("../../../v2Components/FormBuilder", () => ({
|
|
10
|
+
__esModule: true,
|
|
11
|
+
default: (props) => <div className="FormBuilder-mock" {...props}>FormBuilder</div>,
|
|
12
|
+
}));
|
|
13
|
+
|
|
14
|
+
describe('Test SlideBoxHeader container', () => {
|
|
15
|
+
const onCreateComplete = jest.fn();
|
|
16
|
+
let renderedComponent;
|
|
17
|
+
|
|
18
|
+
const renderFunction = (channel, mode, templateData, isFullMode) => {
|
|
19
|
+
renderedComponent = shallowWithIntl(
|
|
20
|
+
<SlideBoxHeader
|
|
21
|
+
slidBoxContent={mode}
|
|
22
|
+
channel={channel}
|
|
23
|
+
templateData={templateData}
|
|
24
|
+
onCreateComplete={onCreateComplete}
|
|
25
|
+
isFullMode={isFullMode}
|
|
26
|
+
/>
|
|
27
|
+
);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
it('Should render correct component for whatsapp channel create mode', () => {
|
|
31
|
+
renderFunction("WHATSAPP", "createTemplate", { mode: "create" });
|
|
32
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
it('Should render correct component for whatsapp channel edit mode', () => {
|
|
37
|
+
renderFunction("WHATSAPP", "editTemplate", editTemplateData, true);
|
|
38
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('Should render correct component for whatsapp channel preview mode', () => {
|
|
42
|
+
renderFunction("WHATSAPP", "preview", previewTemplateData);
|
|
43
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it('Should render correct component for whatsapp channel templates mode', () => {
|
|
47
|
+
renderFunction("WHATSAPP", "templates");
|
|
48
|
+
expect(renderedComponent).toMatchSnapshot();
|
|
49
|
+
});
|
|
50
|
+
});
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`Test SlideBoxContent container Should render correct component for whatsapp channel create mode 1`] = `
|
|
4
|
+
<SlideBoxContent__CreativesWrapper>
|
|
5
|
+
<Connect(UserIsAuthenticated(Connect(InjectIntl(CreativesCommon))))
|
|
6
|
+
onCreateComplete={[MockFunction]}
|
|
7
|
+
/>
|
|
8
|
+
</SlideBoxContent__CreativesWrapper>
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
exports[`Test SlideBoxContent container Should render correct component for whatsapp channel edit mode 1`] = `
|
|
12
|
+
<SlideBoxContent__CreativesWrapper>
|
|
13
|
+
<Connect(UserIsAuthenticated(Connect(InjectIntl(CreativesCommon))))
|
|
14
|
+
getDefaultTags=""
|
|
15
|
+
location={
|
|
16
|
+
Object {
|
|
17
|
+
"pathname": "/whatsapp/edit",
|
|
18
|
+
"query": Object {
|
|
19
|
+
"isEditFromCampaigns": undefined,
|
|
20
|
+
"module": "library",
|
|
21
|
+
"type": "embedded",
|
|
22
|
+
},
|
|
23
|
+
"search": "",
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
params={
|
|
27
|
+
Object {
|
|
28
|
+
"id": "620e213d39bd394c58aeaaca",
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
templateData={
|
|
32
|
+
Object {
|
|
33
|
+
"_id": "620e213d39bd394c58aeaaca",
|
|
34
|
+
"mode": "edit",
|
|
35
|
+
"modeType": "",
|
|
36
|
+
"type": "WHATSAPP",
|
|
37
|
+
"whatsappTemplateCategory": "ALERT_UPDATE",
|
|
38
|
+
"whatsappTemplateName": "amit123456",
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
/>
|
|
42
|
+
</SlideBoxContent__CreativesWrapper>
|
|
43
|
+
`;
|
|
44
|
+
|
|
45
|
+
exports[`Test SlideBoxContent container Should render correct component for whatsapp channel preview mode 1`] = `
|
|
46
|
+
<SlideBoxContent__CreativesWrapper>
|
|
47
|
+
<InjectIntl(TemplatePreview)
|
|
48
|
+
channel="whatsapp"
|
|
49
|
+
charCounterEnabled={false}
|
|
50
|
+
content={
|
|
51
|
+
Object {
|
|
52
|
+
"templateMsg": "1234567890
|
|
53
|
+
Click {{unsubscribe}} to unsubscribe",
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
showCount={true}
|
|
57
|
+
templateData={
|
|
58
|
+
Object {
|
|
59
|
+
"_id": "620e213d39bd394c58aeaaca",
|
|
60
|
+
"createdAt": "2022-02-17T10:19:42.211Z",
|
|
61
|
+
"createdBy": "15000449",
|
|
62
|
+
"isActive": true,
|
|
63
|
+
"mode": "preview",
|
|
64
|
+
"name": "amit123456",
|
|
65
|
+
"orgId": 50371,
|
|
66
|
+
"totalCount": 12,
|
|
67
|
+
"type": "WHATSAPP",
|
|
68
|
+
"updatedAt": "2022-02-17T10:19:42.211Z",
|
|
69
|
+
"updatedBy": "15000449",
|
|
70
|
+
"updatedByName": "Ashish Karan fd",
|
|
71
|
+
"versions": Object {
|
|
72
|
+
"$init": true,
|
|
73
|
+
"base": Object {
|
|
74
|
+
"content": Object {
|
|
75
|
+
"whatsapp": Object {
|
|
76
|
+
"accessToken": "4676323eb5d1f975b0987070c03a8efc",
|
|
77
|
+
"accountId": "AC41030cebba9e2f1ce37c78235da0ee18",
|
|
78
|
+
"accountName": "whatsappTest",
|
|
79
|
+
"category": "ALERT_UPDATE",
|
|
80
|
+
"languages": Array [
|
|
81
|
+
Object {
|
|
82
|
+
"content": "1234567890
|
|
83
|
+
Click {{1}} to unsubscribe",
|
|
84
|
+
"language": "en",
|
|
85
|
+
},
|
|
86
|
+
],
|
|
87
|
+
"mediaType": "TEXT",
|
|
88
|
+
"rejection_reason": null,
|
|
89
|
+
"status": "approved",
|
|
90
|
+
"templateEditor": "",
|
|
91
|
+
"templateId": "HT5203cccf5b1e9e41f222fab6cd6c2754",
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
"history": Array [],
|
|
96
|
+
},
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
viberBrandName=""
|
|
100
|
+
/>
|
|
101
|
+
</SlideBoxContent__CreativesWrapper>
|
|
102
|
+
`;
|
|
103
|
+
|
|
104
|
+
exports[`Test SlideBoxContent container Should render correct component for whatsapp channel templates mode 1`] = `
|
|
105
|
+
<SlideBoxContent__CreativesWrapper>
|
|
106
|
+
<Connect(UserIsAuthenticated(Connect(InjectIntl(withStyles__StyledComponent))))
|
|
107
|
+
FTPMode="create"
|
|
108
|
+
channel="whatsapp"
|
|
109
|
+
location={
|
|
110
|
+
Object {
|
|
111
|
+
"pathname": "/sms/edit",
|
|
112
|
+
"query": Object {
|
|
113
|
+
"isEditFromCampaigns": undefined,
|
|
114
|
+
"module": "library",
|
|
115
|
+
"type": "embedded",
|
|
116
|
+
},
|
|
117
|
+
"search": "",
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
messageDetails={Object {}}
|
|
121
|
+
onCreateComplete={[MockFunction]}
|
|
122
|
+
slidBoxContent="templates"
|
|
123
|
+
/>
|
|
124
|
+
</SlideBoxContent__CreativesWrapper>
|
|
125
|
+
`;
|