@capillarytech/creatives-library 7.14.29 → 7.14.31
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/services/api.js +2 -2
- package/services/tests/api.test.js +28 -13
- package/services/tests/mockData.js +46 -0
- package/v2Components/CapWhatsappCTA/tests/index.test.js +16 -0
- package/v2Containers/Whatsapp/actions.js +2 -2
- package/v2Containers/Whatsapp/index.js +5 -4
- package/v2Containers/Whatsapp/sagas.js +2 -2
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +15443 -3050
- package/v2Containers/Whatsapp/tests/actions.test.js +41 -0
- package/v2Containers/Whatsapp/tests/index.test.js +6 -3
- package/v2Containers/Whatsapp/tests/mockData.js +8 -0
package/package.json
CHANGED
package/services/api.js
CHANGED
|
@@ -477,10 +477,10 @@ export const checkBulkDuplicates = (data) => {
|
|
|
477
477
|
return request(url, getAPICallObject('POST', data));
|
|
478
478
|
};
|
|
479
479
|
|
|
480
|
-
export const createWhatsappTemplate = ({
|
|
480
|
+
export const createWhatsappTemplate = ({payload, gupshupMediaFile }) => {
|
|
481
481
|
const data = new FormData();
|
|
482
|
-
data.append('gupshupMediaFile', gupshupMediaFile);
|
|
483
482
|
data.append('payload', JSON.stringify(payload));
|
|
483
|
+
data.append('gupshupMediaFile', gupshupMediaFile);
|
|
484
484
|
const url = `${API_ENDPOINT}/templates/WHATSAPP`;
|
|
485
485
|
return request(url, getAPICallObject('POST', data, true));
|
|
486
486
|
};
|
|
@@ -1,31 +1,46 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
getSenderDetails,
|
|
3
|
+
uploadFile,
|
|
4
|
+
getCdnTransformationConfig,
|
|
5
|
+
createWhatsappTemplate
|
|
6
|
+
} from '../api';
|
|
7
|
+
import { mockData } from './mockData';
|
|
8
|
+
const sampleFile = require('../../assets/line.png');
|
|
2
9
|
|
|
3
|
-
describe(
|
|
4
|
-
it(
|
|
5
|
-
expect(getSenderDetails(
|
|
10
|
+
describe('getSenderDetails -- Test with valid responses', () => {
|
|
11
|
+
it('Should return correct response', () =>
|
|
12
|
+
expect(getSenderDetails('WHATSAPP', -1)).toEqual(Promise.resolve()));
|
|
6
13
|
});
|
|
7
14
|
|
|
8
|
-
describe(
|
|
9
|
-
it(
|
|
15
|
+
describe('getCdnTransformationConfigs -- Test with valid responses', () => {
|
|
16
|
+
it('Should return correct response', () =>
|
|
10
17
|
expect(getCdnTransformationConfig()).toEqual(Promise.resolve()));
|
|
11
18
|
});
|
|
12
19
|
|
|
13
|
-
describe(
|
|
14
|
-
it(
|
|
20
|
+
describe('uploadFile -- whatsapp image upload', () => {
|
|
21
|
+
it('Should return correct response', () =>
|
|
15
22
|
expect(
|
|
16
23
|
uploadFile({
|
|
17
24
|
file: new Image(),
|
|
18
|
-
assetType:
|
|
25
|
+
assetType: 'image',
|
|
19
26
|
fileParams: {
|
|
20
27
|
width: 275,
|
|
21
28
|
height: 183,
|
|
22
29
|
error: false,
|
|
23
30
|
},
|
|
24
31
|
whatsappParams: {
|
|
25
|
-
source:
|
|
26
|
-
wabaId:
|
|
27
|
-
accessToken:
|
|
32
|
+
source: 'whatsapp',
|
|
33
|
+
wabaId: '107499611940863',
|
|
34
|
+
accessToken: 'Bearer gDwEuRIm9icV6phixociSw==',
|
|
35
|
+
hostName: 'karixwhatsappbulk',
|
|
28
36
|
},
|
|
29
|
-
})
|
|
37
|
+
}),
|
|
38
|
+
).toEqual(Promise.resolve()));
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe('createWhatsappTemplate -- Test with valid responses', () => {
|
|
42
|
+
it('Should return correct response', () =>
|
|
43
|
+
expect(
|
|
44
|
+
createWhatsappTemplate(sampleFile, mockData.createWhatsappPayload),
|
|
30
45
|
).toEqual(Promise.resolve()));
|
|
31
46
|
});
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export const mockData = {
|
|
2
|
+
createWhatsappPayload: {
|
|
3
|
+
name: 'mar_15_10_9',
|
|
4
|
+
versions: {
|
|
5
|
+
base: {
|
|
6
|
+
content: {
|
|
7
|
+
whatsapp: {
|
|
8
|
+
category: 'TRANSACTIONAL',
|
|
9
|
+
languages: [
|
|
10
|
+
{
|
|
11
|
+
language: 'en',
|
|
12
|
+
content:
|
|
13
|
+
'Hey {{1}}, your appointment for {{2}} is confirmed.\nClick {{3}} to unsubscribe',
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
buttonType: 'CTA',
|
|
17
|
+
buttons: [
|
|
18
|
+
{
|
|
19
|
+
index: 0,
|
|
20
|
+
type: 'PHONE_NUMBER',
|
|
21
|
+
text: 'call',
|
|
22
|
+
phone_number: '+919738751234',
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
index: 1,
|
|
26
|
+
type: 'DYNAMIC_URL',
|
|
27
|
+
text: 'info',
|
|
28
|
+
url: 'https://github.com/Capillary/{{1}}',
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
mediaType: 'IMAGE',
|
|
32
|
+
imageUrl:
|
|
33
|
+
'https://storage.crm.n.content-cdn.io/cdn-cgi/image/quality=70,/intouch_creative_assets/7e167b76-7276-4de3-a767-3d1ae9ae.jpg',
|
|
34
|
+
karixFileHandle: '',
|
|
35
|
+
varMapped: {},
|
|
36
|
+
templateEditor: false,
|
|
37
|
+
accountId: '2000222347',
|
|
38
|
+
accessToken: 'DTpZEh4VK',
|
|
39
|
+
hostName: 'gupshupwhatsappbulk',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
type: 'WHATSAPP',
|
|
45
|
+
},
|
|
46
|
+
};
|
|
@@ -152,4 +152,20 @@ describe('CapWhatsappCTA', () => {
|
|
|
152
152
|
screen.getByText(/https:\/\/www\.google\.co\.in/i),
|
|
153
153
|
).toBeInTheDocument();
|
|
154
154
|
});
|
|
155
|
+
it('Test if gupshup CapWhatsappCTA component renders', () => {
|
|
156
|
+
initializeComponent([
|
|
157
|
+
{
|
|
158
|
+
index: 0,
|
|
159
|
+
ctaType: 'WEBSITE',
|
|
160
|
+
text: 'info',
|
|
161
|
+
phone_number: '',
|
|
162
|
+
urlType: 'STATIC_URL',
|
|
163
|
+
url: 'https://www.google.co.in',
|
|
164
|
+
isSaved: false,
|
|
165
|
+
},
|
|
166
|
+
], false, 'gupshupwhatsappbulk');
|
|
167
|
+
expect(screen.getByText('Type of action')).toBeInTheDocument();
|
|
168
|
+
expect(screen.getByText('Button text')).toBeInTheDocument();
|
|
169
|
+
expect(screen.getByRole('button', { name: /save/i })).toBeEnabled();
|
|
170
|
+
});
|
|
155
171
|
});
|
|
@@ -8,12 +8,12 @@ import {
|
|
|
8
8
|
CLEAR_WHATSAPP_ASSET,
|
|
9
9
|
} from './constants';
|
|
10
10
|
|
|
11
|
-
export function createWhatsappTemplate(
|
|
11
|
+
export function createWhatsappTemplate(payload, callback, gupshupMediaFile) {
|
|
12
12
|
return {
|
|
13
13
|
type: TEMPLATE_CREATE_REQUEST,
|
|
14
|
-
gupshupMediaFile,
|
|
15
14
|
payload,
|
|
16
15
|
callback,
|
|
16
|
+
gupshupMediaFile,
|
|
17
17
|
};
|
|
18
18
|
}
|
|
19
19
|
export function clearCreateResponse() {
|
|
@@ -60,6 +60,7 @@ import {
|
|
|
60
60
|
WHATSAPP_IMG_SIZE,
|
|
61
61
|
HOST_TWILIO,
|
|
62
62
|
HOST_KARIX,
|
|
63
|
+
HOST_GUPSHUP,
|
|
63
64
|
ALLOWED_EXTENSIONS_VIDEO_REGEX,
|
|
64
65
|
ALLOWED_EXTENSIONS_DOCUMENT_REGEX,
|
|
65
66
|
WHATSAPP_DOCUMENT_SIZE,
|
|
@@ -715,7 +716,7 @@ export const Whatsapp = (props) => {
|
|
|
715
716
|
accessToken,
|
|
716
717
|
hostName: host,
|
|
717
718
|
};
|
|
718
|
-
if (isFullMode && !isEditFlow && host
|
|
719
|
+
if (isFullMode && !isEditFlow && host === HOST_GUPSHUP) {
|
|
719
720
|
setGupshupMediaFile(file);
|
|
720
721
|
}
|
|
721
722
|
actions.uploadWhatsappAsset(file, type, fileParams, 0, whatsappParams);
|
|
@@ -1035,14 +1036,14 @@ export const Whatsapp = (props) => {
|
|
|
1035
1036
|
|
|
1036
1037
|
const createApprovalHandler = () => {
|
|
1037
1038
|
setSpin(true);
|
|
1038
|
-
actions.createWhatsappTemplate(
|
|
1039
|
+
actions.createWhatsappTemplate(createPayload(), (resp, errorMessage) => {
|
|
1039
1040
|
actionCallback({ resp, errorMessage });
|
|
1040
1041
|
if (!errorMessage) {
|
|
1041
1042
|
onCreateComplete();
|
|
1042
1043
|
} else {
|
|
1043
1044
|
setSpin(false);
|
|
1044
1045
|
}
|
|
1045
|
-
});
|
|
1046
|
+
}, gupshupMediaFile);
|
|
1046
1047
|
};
|
|
1047
1048
|
|
|
1048
1049
|
const onDoneCallback = () => {
|
|
@@ -1157,7 +1158,7 @@ export const Whatsapp = (props) => {
|
|
|
1157
1158
|
<CapSelect
|
|
1158
1159
|
id="select-whatsapp-category"
|
|
1159
1160
|
options={
|
|
1160
|
-
host ===
|
|
1161
|
+
host === HOST_TWILIO ? twilioCategoryOptions : karixGupshupCategoryOptions
|
|
1161
1162
|
}
|
|
1162
1163
|
onChange={onTemplateCategoryChange}
|
|
1163
1164
|
value={templateCategory}
|
|
@@ -36,10 +36,10 @@ function* watchUploadWhatsappAsset() {
|
|
|
36
36
|
yield cancel(watcher);
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
-
export function* sendForApprovalCreate({
|
|
39
|
+
export function* sendForApprovalCreate({ payload, callback, gupshupMediaFile }) {
|
|
40
40
|
let errorMsg;
|
|
41
41
|
try {
|
|
42
|
-
const result = yield call(Api.createWhatsappTemplate, {
|
|
42
|
+
const result = yield call(Api.createWhatsappTemplate, { payload, gupshupMediaFile });
|
|
43
43
|
if (result?.status?.code && result.status.code >= 400) {
|
|
44
44
|
errorMsg = result?.message || result.status.code;
|
|
45
45
|
throw errorMsg;
|