@capillarytech/creatives-library 8.0.348 → 8.0.350
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 -0
- package/package.json +1 -1
- package/services/api.js +20 -0
- package/services/tests/api.test.js +59 -0
- package/utils/common.js +6 -0
- package/utils/tests/v2Common.test.js +46 -1
- package/utils/v2common.js +18 -0
- package/v2Components/CapCustomSkeleton/index.js +1 -1
- package/v2Components/CapCustomSkeleton/tests/__snapshots__/index.test.js.snap +12 -12
- package/v2Components/CommonTestAndPreview/UnifiedPreview/WhatsAppPreviewContent.js +6 -18
- package/v2Components/CommonTestAndPreview/UnifiedPreview/_unifiedPreview.scss +0 -27
- package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/WhatsAppPreviewContent.test.js +0 -48
- package/v2Components/TemplatePreview/_templatePreview.scss +0 -21
- package/v2Components/TemplatePreview/index.js +6 -18
- package/v2Components/TemplatePreview/tests/__snapshots__/index.test.js.snap +0 -1
- package/v2Containers/Assets/images/archive_Empty_Illustration.svg +9 -0
- package/v2Containers/CreativesContainer/SlideBoxFooter.js +3 -1
- package/v2Containers/CreativesContainer/index.js +6 -9
- package/v2Containers/CreativesContainer/messages.js +4 -0
- package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +3 -0
- package/v2Containers/Templates/ChannelTypeIllustration.js +23 -6
- package/v2Containers/Templates/_templates.scss +180 -24
- package/v2Containers/Templates/actions.js +44 -0
- package/v2Containers/Templates/constants.js +31 -0
- package/v2Containers/Templates/index.js +364 -60
- package/v2Containers/Templates/messages.js +96 -0
- package/v2Containers/Templates/reducer.js +84 -1
- package/v2Containers/Templates/sagas.js +64 -0
- package/v2Containers/Templates/selectors.js +12 -0
- package/v2Containers/Templates/tests/ChannelTypeIllustration.test.js +12 -0
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +1176 -1122
- package/v2Containers/Templates/tests/index.test.js +6 -0
- package/v2Containers/Templates/tests/reducer.test.js +178 -0
- package/v2Containers/Templates/tests/sagas.test.js +390 -8
- package/v2Containers/Templates/tests/selector.test.js +32 -0
- package/v2Containers/TemplatesV2/TemplatesV2.style.js +1 -1
- package/v2Containers/Whatsapp/constants.js +0 -8
- package/v2Containers/Whatsapp/index.js +5 -142
- package/v2Containers/Whatsapp/index.scss +0 -8
- package/v2Containers/Whatsapp/messages.js +0 -16
package/constants/unified.js
CHANGED
|
@@ -52,6 +52,7 @@ export const EXTENDED_TAG = 'ExtendedTagMessage';
|
|
|
52
52
|
export const BADGES_UI_ENABLED = 'BADGES_UI_ENABLED';
|
|
53
53
|
export const JP_LOCALE_HIDE_FEATURE = 'JP_LOCALE_HIDE_FEATURE';
|
|
54
54
|
export const ENABLE_WECHAT = 'ENABLE_WECHAT';
|
|
55
|
+
export const ENABLE_CREATIVES_ARCHIVAL = 'ENABLE_CREATIVES_ARCHIVAL';
|
|
55
56
|
export const ENABLE_WEBPUSH = 'ENABLE_WEBPUSH';
|
|
56
57
|
export const ENABLE_CUSTOMER_BARCODE_TAG = 'ENABLE_CUSTOMER_BARCODE_TAG';
|
|
57
58
|
export const EMAIL_UNSUBSCRIBE_TAG_MANDATORY = 'EMAIL_UNSUBSCRIBE_TAG_MANDATORY';
|
package/package.json
CHANGED
package/services/api.js
CHANGED
|
@@ -361,6 +361,26 @@ export const deleteTemplate = ({channel, id}) => {
|
|
|
361
361
|
//return API.deleteResource(url);
|
|
362
362
|
};
|
|
363
363
|
|
|
364
|
+
export const archiveTemplate = ({ channel, id }) => {
|
|
365
|
+
const url = `${API_ENDPOINT}/templates/archive/${id}/${channel}`;
|
|
366
|
+
return request(url, getAPICallObject('PUT'));
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
export const unarchiveTemplate = ({ channel, id }) => {
|
|
370
|
+
const url = `${API_ENDPOINT}/templates/unarchive/${id}/${channel}`;
|
|
371
|
+
return request(url, getAPICallObject('PUT'));
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
export const bulkArchiveTemplates = ({ channel, ids }) => {
|
|
375
|
+
const url = `${API_ENDPOINT}/templates/archive/bulk/${channel}`;
|
|
376
|
+
return request(url, getAPICallObject('PUT', { ids }));
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
export const bulkUnarchiveTemplates = ({ channel, ids }) => {
|
|
380
|
+
const url = `${API_ENDPOINT}/templates/unarchive/bulk/${channel}`;
|
|
381
|
+
return request(url, getAPICallObject('PUT', { ids }));
|
|
382
|
+
};
|
|
383
|
+
|
|
364
384
|
export const deleteRcsTemplate = ({ templateName }) => {
|
|
365
385
|
const url = `${API_ENDPOINT}/templates/${templateName}/RCS`;
|
|
366
386
|
return request(url, getAPICallObject('DELETE'))
|
|
@@ -1086,3 +1086,62 @@ describe('createTestCustomer', () => {
|
|
|
1086
1086
|
expect(lastCall[1].body).toBe(JSON.stringify(payload));
|
|
1087
1087
|
});
|
|
1088
1088
|
});
|
|
1089
|
+
|
|
1090
|
+
import {
|
|
1091
|
+
archiveTemplate,
|
|
1092
|
+
unarchiveTemplate,
|
|
1093
|
+
bulkArchiveTemplates,
|
|
1094
|
+
bulkUnarchiveTemplates,
|
|
1095
|
+
} from '../api';
|
|
1096
|
+
|
|
1097
|
+
describe('archiveTemplate', () => {
|
|
1098
|
+
beforeEach(() => {
|
|
1099
|
+
global.fetch = jest.fn().mockReturnValue(Promise.resolve({ json: () => Promise.resolve({}) }));
|
|
1100
|
+
});
|
|
1101
|
+
|
|
1102
|
+
it('should call PUT on archive endpoint', () => {
|
|
1103
|
+
archiveTemplate({ channel: 'EMAIL', id: 'id123' });
|
|
1104
|
+
expect(global.fetch).toHaveBeenCalled();
|
|
1105
|
+
const lastCall = global.fetch.mock.calls[global.fetch.mock.calls.length - 1];
|
|
1106
|
+
expect(lastCall[1].method).toBe('PUT');
|
|
1107
|
+
});
|
|
1108
|
+
});
|
|
1109
|
+
|
|
1110
|
+
describe('unarchiveTemplate', () => {
|
|
1111
|
+
beforeEach(() => {
|
|
1112
|
+
global.fetch = jest.fn().mockReturnValue(Promise.resolve({ json: () => Promise.resolve({}) }));
|
|
1113
|
+
});
|
|
1114
|
+
|
|
1115
|
+
it('should call PUT on unarchive endpoint', () => {
|
|
1116
|
+
unarchiveTemplate({ channel: 'EMAIL', id: 'id123' });
|
|
1117
|
+
expect(global.fetch).toHaveBeenCalled();
|
|
1118
|
+
const lastCall = global.fetch.mock.calls[global.fetch.mock.calls.length - 1];
|
|
1119
|
+
expect(lastCall[1].method).toBe('PUT');
|
|
1120
|
+
});
|
|
1121
|
+
});
|
|
1122
|
+
|
|
1123
|
+
describe('bulkArchiveTemplates', () => {
|
|
1124
|
+
beforeEach(() => {
|
|
1125
|
+
global.fetch = jest.fn().mockReturnValue(Promise.resolve({ json: () => Promise.resolve({}) }));
|
|
1126
|
+
});
|
|
1127
|
+
|
|
1128
|
+
it('should call PUT on bulk archive endpoint with ids', () => {
|
|
1129
|
+
bulkArchiveTemplates({ channel: 'EMAIL', ids: ['id1', 'id2'] });
|
|
1130
|
+
expect(global.fetch).toHaveBeenCalled();
|
|
1131
|
+
const lastCall = global.fetch.mock.calls[global.fetch.mock.calls.length - 1];
|
|
1132
|
+
expect(lastCall[1].method).toBe('PUT');
|
|
1133
|
+
});
|
|
1134
|
+
});
|
|
1135
|
+
|
|
1136
|
+
describe('bulkUnarchiveTemplates', () => {
|
|
1137
|
+
beforeEach(() => {
|
|
1138
|
+
global.fetch = jest.fn().mockReturnValue(Promise.resolve({ json: () => Promise.resolve({}) }));
|
|
1139
|
+
});
|
|
1140
|
+
|
|
1141
|
+
it('should call PUT on bulk unarchive endpoint with ids', () => {
|
|
1142
|
+
bulkUnarchiveTemplates({ channel: 'EMAIL', ids: ['id1', 'id2'] });
|
|
1143
|
+
expect(global.fetch).toHaveBeenCalled();
|
|
1144
|
+
const lastCall = global.fetch.mock.calls[global.fetch.mock.calls.length - 1];
|
|
1145
|
+
expect(lastCall[1].method).toBe('PUT');
|
|
1146
|
+
});
|
|
1147
|
+
});
|
package/utils/common.js
CHANGED
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
ENABLE_NEW_MPUSH,
|
|
28
28
|
ENABLE_NEW_EDITOR_FLOW_INAPP,
|
|
29
29
|
SUPPORT_ENGAGEMENT_MODULE,
|
|
30
|
+
ENABLE_CREATIVES_ARCHIVAL,
|
|
30
31
|
} from '../constants/unified';
|
|
31
32
|
import { apiMessageFormatHandler } from './commonUtils';
|
|
32
33
|
|
|
@@ -122,6 +123,11 @@ export const hasWechatFeatureEnabled = Auth.hasFeatureAccess.bind(
|
|
|
122
123
|
ENABLE_WECHAT,
|
|
123
124
|
);
|
|
124
125
|
|
|
126
|
+
export const hasCreativesArchivalEnabled = Auth.hasFeatureAccess.bind(
|
|
127
|
+
null,
|
|
128
|
+
ENABLE_CREATIVES_ARCHIVAL,
|
|
129
|
+
);
|
|
130
|
+
|
|
125
131
|
export const hasWebPushFeatureEnabled = Auth.hasFeatureAccess.bind(
|
|
126
132
|
null,
|
|
127
133
|
ENABLE_WEBPUSH,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import {
|
|
2
|
+
import { shallow } from 'enzyme';
|
|
3
|
+
import { getObjFromQueryParams, buildTemplateNameDescription } from '../v2common';
|
|
3
4
|
|
|
4
5
|
describe('Test v2common container', () => {
|
|
5
6
|
it('test getObjFromQueryParams', () => {
|
|
@@ -9,3 +10,47 @@ describe('Test v2common container', () => {
|
|
|
9
10
|
});
|
|
10
11
|
});
|
|
11
12
|
});
|
|
13
|
+
|
|
14
|
+
describe('buildTemplateNameDescription', () => {
|
|
15
|
+
it('returns undefined when templateName is empty string', () => {
|
|
16
|
+
expect(buildTemplateNameDescription('Template name', '')).toBeUndefined();
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
it('returns undefined when templateName is null', () => {
|
|
20
|
+
expect(buildTemplateNameDescription('Template name', null)).toBeUndefined();
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('returns undefined when templateName is undefined', () => {
|
|
24
|
+
expect(buildTemplateNameDescription('Template name', undefined)).toBeUndefined();
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
it('renders a span wrapper when templateName is provided', () => {
|
|
28
|
+
const result = buildTemplateNameDescription('Template name', 'Welcome 01');
|
|
29
|
+
const wrapper = shallow(result);
|
|
30
|
+
expect(wrapper.type()).toBe('span');
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it('renders label text in the first CapLabelInline with correct class', () => {
|
|
34
|
+
const result = buildTemplateNameDescription('Template name', 'Welcome 01');
|
|
35
|
+
const wrapper = shallow(result);
|
|
36
|
+
const firstLabel = wrapper.childAt(0);
|
|
37
|
+
expect(firstLabel.prop('className')).toBe('notification-template-label');
|
|
38
|
+
expect(firstLabel.prop('children')).toBe('Template name');
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it('renders template name in the second CapLabelInline with correct class', () => {
|
|
42
|
+
const result = buildTemplateNameDescription('Template name', 'Welcome 01');
|
|
43
|
+
const wrapper = shallow(result);
|
|
44
|
+
const secondLabel = wrapper.childAt(1);
|
|
45
|
+
expect(secondLabel.prop('className')).toBe('notification-template-name');
|
|
46
|
+
expect(secondLabel.prop('children')).toBe('Welcome 01');
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it('both CapLabelInline elements have type="label1"', () => {
|
|
50
|
+
const result = buildTemplateNameDescription('Template name', 'Welcome 01');
|
|
51
|
+
const wrapper = shallow(result);
|
|
52
|
+
wrapper.children().forEach((node) => {
|
|
53
|
+
expect(node.prop('type')).toBe('label1');
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
});
|
package/utils/v2common.js
CHANGED
|
@@ -1,3 +1,21 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import CapLabel from '@capillarytech/cap-ui-library/CapLabel';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Builds a JSX description for template archive/unarchive notifications.
|
|
6
|
+
* @param {string} labelText - Localised label (e.g. "Template name ")
|
|
7
|
+
* @param {string} templateName - The template name to display
|
|
8
|
+
*/
|
|
9
|
+
export const buildTemplateNameDescription = (labelText, templateName) => (
|
|
10
|
+
templateName
|
|
11
|
+
? (
|
|
12
|
+
<span>
|
|
13
|
+
<CapLabel.CapLabelInline type="label1" className="notification-template-label">{labelText}</CapLabel.CapLabelInline>
|
|
14
|
+
<CapLabel.CapLabelInline type="label1" className="notification-template-name">{templateName}</CapLabel.CapLabelInline>
|
|
15
|
+
</span>
|
|
16
|
+
)
|
|
17
|
+
: undefined
|
|
18
|
+
);
|
|
1
19
|
|
|
2
20
|
// returns query items as obj when query string is passed
|
|
3
21
|
/**
|
|
@@ -20,7 +20,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
|
|
|
20
20
|
>
|
|
21
21
|
<CapColumn
|
|
22
22
|
key="0"
|
|
23
|
-
lg={
|
|
23
|
+
lg={8}
|
|
24
24
|
md={8}
|
|
25
25
|
sm={12}
|
|
26
26
|
xs={24}
|
|
@@ -40,7 +40,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
|
|
|
40
40
|
</CapColumn>
|
|
41
41
|
<CapColumn
|
|
42
42
|
key="1"
|
|
43
|
-
lg={
|
|
43
|
+
lg={8}
|
|
44
44
|
md={8}
|
|
45
45
|
sm={12}
|
|
46
46
|
xs={24}
|
|
@@ -60,7 +60,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
|
|
|
60
60
|
</CapColumn>
|
|
61
61
|
<CapColumn
|
|
62
62
|
key="2"
|
|
63
|
-
lg={
|
|
63
|
+
lg={8}
|
|
64
64
|
md={8}
|
|
65
65
|
sm={12}
|
|
66
66
|
xs={24}
|
|
@@ -80,7 +80,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
|
|
|
80
80
|
</CapColumn>
|
|
81
81
|
<CapColumn
|
|
82
82
|
key="3"
|
|
83
|
-
lg={
|
|
83
|
+
lg={8}
|
|
84
84
|
md={8}
|
|
85
85
|
sm={12}
|
|
86
86
|
xs={24}
|
|
@@ -100,7 +100,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
|
|
|
100
100
|
</CapColumn>
|
|
101
101
|
<CapColumn
|
|
102
102
|
key="4"
|
|
103
|
-
lg={
|
|
103
|
+
lg={8}
|
|
104
104
|
md={8}
|
|
105
105
|
sm={12}
|
|
106
106
|
xs={24}
|
|
@@ -120,7 +120,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
|
|
|
120
120
|
</CapColumn>
|
|
121
121
|
<CapColumn
|
|
122
122
|
key="5"
|
|
123
|
-
lg={
|
|
123
|
+
lg={8}
|
|
124
124
|
md={8}
|
|
125
125
|
sm={12}
|
|
126
126
|
xs={24}
|
|
@@ -140,7 +140,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
|
|
|
140
140
|
</CapColumn>
|
|
141
141
|
<CapColumn
|
|
142
142
|
key="6"
|
|
143
|
-
lg={
|
|
143
|
+
lg={8}
|
|
144
144
|
md={8}
|
|
145
145
|
sm={12}
|
|
146
146
|
xs={24}
|
|
@@ -160,7 +160,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
|
|
|
160
160
|
</CapColumn>
|
|
161
161
|
<CapColumn
|
|
162
162
|
key="7"
|
|
163
|
-
lg={
|
|
163
|
+
lg={8}
|
|
164
164
|
md={8}
|
|
165
165
|
sm={12}
|
|
166
166
|
xs={24}
|
|
@@ -180,7 +180,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
|
|
|
180
180
|
</CapColumn>
|
|
181
181
|
<CapColumn
|
|
182
182
|
key="8"
|
|
183
|
-
lg={
|
|
183
|
+
lg={8}
|
|
184
184
|
md={8}
|
|
185
185
|
sm={12}
|
|
186
186
|
xs={24}
|
|
@@ -200,7 +200,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
|
|
|
200
200
|
</CapColumn>
|
|
201
201
|
<CapColumn
|
|
202
202
|
key="9"
|
|
203
|
-
lg={
|
|
203
|
+
lg={8}
|
|
204
204
|
md={8}
|
|
205
205
|
sm={12}
|
|
206
206
|
xs={24}
|
|
@@ -220,7 +220,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
|
|
|
220
220
|
</CapColumn>
|
|
221
221
|
<CapColumn
|
|
222
222
|
key="10"
|
|
223
|
-
lg={
|
|
223
|
+
lg={8}
|
|
224
224
|
md={8}
|
|
225
225
|
sm={12}
|
|
226
226
|
xs={24}
|
|
@@ -240,7 +240,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
|
|
|
240
240
|
</CapColumn>
|
|
241
241
|
<CapColumn
|
|
242
242
|
key="11"
|
|
243
|
-
lg={
|
|
243
|
+
lg={8}
|
|
244
244
|
md={8}
|
|
245
245
|
sm={12}
|
|
246
246
|
xs={24}
|
|
@@ -18,7 +18,7 @@ import CapRow from '@capillarytech/cap-ui-library/CapRow';
|
|
|
18
18
|
import { ANDROID, IOS } from '../constants';
|
|
19
19
|
import messages from '../messages';
|
|
20
20
|
import { getWhatsappQuickReply, getWhatsappCarouselButtonView } from '../../../v2Containers/Whatsapp/utils';
|
|
21
|
-
import { QUICK_REPLY, PHONE_NUMBER, WHATSAPP_CATEGORIES
|
|
21
|
+
import { QUICK_REPLY, PHONE_NUMBER, WHATSAPP_CATEGORIES } from '../../../v2Containers/Whatsapp/constants';
|
|
22
22
|
import videoPlay from '../../../assets/videoPlay.svg';
|
|
23
23
|
import whatsappImageEmptyPreview from '../../TemplatePreview/assets/images/empty_image_preview.svg';
|
|
24
24
|
import whatsappVideoEmptyPreview from '../../TemplatePreview/assets/images/empty_video_preview.svg';
|
|
@@ -27,8 +27,6 @@ import whatsappVideoEmptyPreview from '../../TemplatePreview/assets/images/empty
|
|
|
27
27
|
const whatsappMobileAndroid = require('../../../assets/whatsapp_android.png');
|
|
28
28
|
const whatsappMobileIos = require('../../../assets/whatsapp_ios.png');
|
|
29
29
|
|
|
30
|
-
const { CapLabelInline } = CapLabel;
|
|
31
|
-
|
|
32
30
|
const WhatsAppPreviewContent = ({
|
|
33
31
|
content,
|
|
34
32
|
device,
|
|
@@ -216,21 +214,11 @@ const WhatsAppPreviewContent = ({
|
|
|
216
214
|
|
|
217
215
|
{/* Image Preview */}
|
|
218
216
|
{content?.whatsappImageSrc && (
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
</CapLabelInline>
|
|
225
|
-
</CapRow>
|
|
226
|
-
) : (
|
|
227
|
-
<CapImage
|
|
228
|
-
src={content.whatsappImageSrc}
|
|
229
|
-
className="whatsapp-image"
|
|
230
|
-
alt={formatMessage(messages.previewGenerated)}
|
|
231
|
-
onError={(e) => { e.target.src = whatsappImageEmptyPreview; }}
|
|
232
|
-
/>
|
|
233
|
-
)
|
|
217
|
+
<CapImage
|
|
218
|
+
src={content.whatsappImageSrc}
|
|
219
|
+
className="whatsapp-image"
|
|
220
|
+
alt={formatMessage(messages.previewGenerated)}
|
|
221
|
+
/>
|
|
234
222
|
)}
|
|
235
223
|
|
|
236
224
|
{/* Video Preview */}
|
|
@@ -940,33 +940,6 @@
|
|
|
940
940
|
}
|
|
941
941
|
}
|
|
942
942
|
|
|
943
|
-
.whatsapp-image-url-placeholder {
|
|
944
|
-
display: flex;
|
|
945
|
-
flex-direction: column;
|
|
946
|
-
align-items: center;
|
|
947
|
-
justify-content: center;
|
|
948
|
-
gap: $CAP_SPACE_08;
|
|
949
|
-
width: 100%;
|
|
950
|
-
min-height: 5rem;
|
|
951
|
-
max-height: 8.786rem;
|
|
952
|
-
margin-bottom: $CAP_SPACE_04;
|
|
953
|
-
background-color: $CAP_G09;
|
|
954
|
-
border-radius: $CAP_SPACE_04;
|
|
955
|
-
padding: $CAP_SPACE_08;
|
|
956
|
-
|
|
957
|
-
.whatsapp-image-url-placeholder-icon {
|
|
958
|
-
color: $CAP_G05;
|
|
959
|
-
font-size: 1.5rem;
|
|
960
|
-
}
|
|
961
|
-
|
|
962
|
-
.whatsapp-image-url-placeholder-text {
|
|
963
|
-
font-size: $FONT_SIZE_S;
|
|
964
|
-
color: $CAP_G04;
|
|
965
|
-
text-align: center;
|
|
966
|
-
word-break: break-all;
|
|
967
|
-
}
|
|
968
|
-
}
|
|
969
|
-
|
|
970
943
|
.whatsapp-image {
|
|
971
944
|
width: 100%;
|
|
972
945
|
max-height: 8.786rem;
|
package/v2Components/CommonTestAndPreview/tests/UnifiedPreview/WhatsAppPreviewContent.test.js
CHANGED
|
@@ -26,7 +26,6 @@ jest.mock('../../../../v2Containers/Whatsapp/constants', () => ({
|
|
|
26
26
|
WHATSAPP_CATEGORIES: {
|
|
27
27
|
authentication: 'authentication',
|
|
28
28
|
},
|
|
29
|
-
TEMPLATE_VARIABLE_REGEX: /\{\{.*?\}\}/,
|
|
30
29
|
}));
|
|
31
30
|
|
|
32
31
|
// Convert messages object to format expected by IntlProvider
|
|
@@ -239,53 +238,6 @@ describe('WhatsAppPreviewContent', () => {
|
|
|
239
238
|
expect(image.getAttribute('src')).toBe('https://image.url');
|
|
240
239
|
});
|
|
241
240
|
|
|
242
|
-
it('should render placeholder when whatsappImageSrc is a template variable', () => {
|
|
243
|
-
const props = {
|
|
244
|
-
...defaultProps,
|
|
245
|
-
content: {
|
|
246
|
-
templateMsg: 'Message',
|
|
247
|
-
whatsappImageSrc: '{{imageUrl}}',
|
|
248
|
-
},
|
|
249
|
-
};
|
|
250
|
-
|
|
251
|
-
const { container } = render(
|
|
252
|
-
<TestWrapper>
|
|
253
|
-
<ComponentToRender {...props} />
|
|
254
|
-
</TestWrapper>
|
|
255
|
-
);
|
|
256
|
-
|
|
257
|
-
expect(container.querySelector('.whatsapp-image-url-placeholder')).toBeTruthy();
|
|
258
|
-
expect(container.querySelector('.whatsapp-image-url-placeholder-icon')).toBeTruthy();
|
|
259
|
-
expect(container.querySelector('.whatsapp-image-url-placeholder-text').textContent).toBe('{{imageUrl}}');
|
|
260
|
-
expect(container.querySelector('img.whatsapp-image')).toBeFalsy();
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
it('should fall back to empty preview image when image fails to load', () => {
|
|
264
|
-
const props = {
|
|
265
|
-
...defaultProps,
|
|
266
|
-
content: {
|
|
267
|
-
templateMsg: 'Message',
|
|
268
|
-
whatsappImageSrc: 'https://broken.url/image.jpg',
|
|
269
|
-
},
|
|
270
|
-
};
|
|
271
|
-
|
|
272
|
-
const { container } = render(
|
|
273
|
-
<TestWrapper>
|
|
274
|
-
<ComponentToRender {...props} />
|
|
275
|
-
</TestWrapper>
|
|
276
|
-
);
|
|
277
|
-
|
|
278
|
-
const image = container.querySelector('img.whatsapp-image');
|
|
279
|
-
expect(image).toBeTruthy();
|
|
280
|
-
expect(image.getAttribute('src')).toBe('https://broken.url/image.jpg');
|
|
281
|
-
|
|
282
|
-
// Trigger onError to swap src to fallback
|
|
283
|
-
const errorEvent = new Event('error');
|
|
284
|
-
image.dispatchEvent(errorEvent);
|
|
285
|
-
|
|
286
|
-
expect(image.getAttribute('src')).not.toBe('https://broken.url/image.jpg');
|
|
287
|
-
});
|
|
288
|
-
|
|
289
241
|
it('should render video preview when whatsappVideoPreviewImg is present', () => {
|
|
290
242
|
const props = {
|
|
291
243
|
...defaultProps,
|
|
@@ -816,27 +816,6 @@
|
|
|
816
816
|
}
|
|
817
817
|
}
|
|
818
818
|
|
|
819
|
-
.whatsapp-image-url-placeholder {
|
|
820
|
-
display: flex;
|
|
821
|
-
flex-direction: column;
|
|
822
|
-
align-items: center;
|
|
823
|
-
justify-content: center;
|
|
824
|
-
background-color: $CAP_G09;
|
|
825
|
-
border-radius: $CAP_SPACE_04;
|
|
826
|
-
width: 100%;
|
|
827
|
-
min-height: 5rem;
|
|
828
|
-
max-height: 8.786rem;
|
|
829
|
-
margin-bottom: $CAP_SPACE_04;
|
|
830
|
-
.whatsapp-image-url-placeholder-text {
|
|
831
|
-
font-size: 0.786rem;
|
|
832
|
-
color: $CAP_G04;
|
|
833
|
-
margin-top: $CAP_SPACE_04;
|
|
834
|
-
text-align: center;
|
|
835
|
-
word-break: break-all;
|
|
836
|
-
padding: 0 $CAP_SPACE_04;
|
|
837
|
-
}
|
|
838
|
-
}
|
|
839
|
-
|
|
840
819
|
.msg-container-carousel {
|
|
841
820
|
display: flex;
|
|
842
821
|
flex-direction: column;
|
|
@@ -48,7 +48,7 @@ import { TEMPLATE, IMAGE_CAROUSEL, IMAGE, STICKER, TEXT, IMAGE_MAP, VIDEO } from
|
|
|
48
48
|
import CapFacebookPreview from '../../v2Containers/CapFacebookPreview';
|
|
49
49
|
import WhatsappStatusContainer from '../WhatsappStatusContainer';
|
|
50
50
|
import { getWhatsappQuickReply, getWhatsappCarouselButtonView } from '../../v2Containers/Whatsapp/utils';
|
|
51
|
-
import { QUICK_REPLY, WHATSAPP_CATEGORIES, PHONE_NUMBER
|
|
51
|
+
import { QUICK_REPLY, WHATSAPP_CATEGORIES, PHONE_NUMBER } from '../../v2Containers/Whatsapp/constants';
|
|
52
52
|
import { RCS_BUTTON_TYPES, LEFT, HORIZONTAL, VERTICAL, RIGHT} from '../../v2Containers/Rcs/constants';
|
|
53
53
|
import { ANDROID, INAPP_MESSAGE_LAYOUT_TYPES } from '../../v2Containers/InApp/constants';
|
|
54
54
|
import { CAROUSEL } from '../../v2Containers/MobilePushNew/constants';
|
|
@@ -66,8 +66,6 @@ const lineVideoPlaceholder = require('../../assets/rich-video-placeholder.svg');
|
|
|
66
66
|
const androidPushMessagePhone = require('./assets/images/Android_With_date_and_time.svg');
|
|
67
67
|
const iPhonePushMessagePhone = require('./assets/images/iOS_With_date_and_time.svg');
|
|
68
68
|
|
|
69
|
-
const { CapLabelInline } = CapLabel;
|
|
70
|
-
|
|
71
69
|
export class TemplatePreview extends React.Component { // eslint-disable-line react/prefer-stateless-function
|
|
72
70
|
onPreviewContentClicked = (channel) => {
|
|
73
71
|
const IOSContent = (this.props.templateDataRaw && this.props.templateDataRaw.versions.base.IOS) ||
|
|
@@ -1196,21 +1194,11 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
1196
1194
|
{content?.showUrlPreview
|
|
1197
1195
|
&& renderUrlPreview(content?.metaTagsDetails)}
|
|
1198
1196
|
{content?.whatsappImageSrc && (
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
</CapLabelInline>
|
|
1205
|
-
</div>
|
|
1206
|
-
) : (
|
|
1207
|
-
<CapImage
|
|
1208
|
-
src={content.whatsappImageSrc}
|
|
1209
|
-
className="whatsapp-image"
|
|
1210
|
-
alt={formatMessage(messages.previewGenerated)}
|
|
1211
|
-
onError={(e) => { e.target.src = whatsappImageEmptyPreview; }}
|
|
1212
|
-
/>
|
|
1213
|
-
)
|
|
1197
|
+
<CapImage
|
|
1198
|
+
src={content.whatsappImageSrc}
|
|
1199
|
+
className="whatsapp-image"
|
|
1200
|
+
alt={formatMessage(messages.previewGenerated)}
|
|
1201
|
+
/>
|
|
1214
1202
|
)}
|
|
1215
1203
|
{content?.whatsappVideoPreviewImg && (
|
|
1216
1204
|
<CapTooltip
|
|
@@ -43,7 +43,6 @@ exports[`Test Templates container Should render correct preview component for wh
|
|
|
43
43
|
<CapImage
|
|
44
44
|
alt="Preview is being generated"
|
|
45
45
|
className="whatsapp-image"
|
|
46
|
-
onError={[Function]}
|
|
47
46
|
src="https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/c9edc114-923b-4ac7-82d0-d6682213.jpg"
|
|
48
47
|
/>
|
|
49
48
|
You have received {{1}} points
|