@capillarytech/creatives-library 7.17.82 → 7.17.84
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 +5 -0
- package/services/tests/api.test.js +9 -1
- package/v2Components/CapWhatsappQuickReply/index.scss +2 -2
- package/v2Components/TemplatePreview/_templatePreview.scss +21 -0
- package/v2Components/TemplatePreview/index.js +36 -0
- package/v2Components/TemplatePreview/messages.js +4 -0
- package/v2Containers/CreativesContainer/index.js +5 -1
- package/v2Containers/Whatsapp/actions.js +16 -0
- package/v2Containers/Whatsapp/constants.js +6 -0
- package/v2Containers/Whatsapp/index.js +78 -9
- package/v2Containers/Whatsapp/index.scss +8 -1
- package/v2Containers/Whatsapp/messages.js +5 -1
- package/v2Containers/Whatsapp/reducer.js +19 -0
- package/v2Containers/Whatsapp/sagas.js +40 -1
- package/v2Containers/Whatsapp/styles.scss +1 -0
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +11386 -1880
- package/v2Containers/Whatsapp/tests/actions.test.js +21 -0
- package/v2Containers/Whatsapp/tests/index.test.js +8 -0
- package/v2Containers/Whatsapp/tests/mockData.js +6 -0
- package/v2Containers/Whatsapp/tests/reducer.test.js +67 -0
- package/v2Containers/Whatsapp/tests/saga.test.js +90 -0
|
@@ -38,4 +38,25 @@ describe('Test whatsapp actions', () => {
|
|
|
38
38
|
actions.createWhatsappTemplate(payload, undefined, undefined),
|
|
39
39
|
).toStrictEqual(expected);
|
|
40
40
|
});
|
|
41
|
+
|
|
42
|
+
it("test getMetaTags", () => {
|
|
43
|
+
const payload = {
|
|
44
|
+
previewUrl: 'https://capillarytech.com',
|
|
45
|
+
callBack: undefined,
|
|
46
|
+
};
|
|
47
|
+
const expected = {
|
|
48
|
+
type: types.URL_META_TAGS_REQUEST,
|
|
49
|
+
previewUrl: 'https://capillarytech.com',
|
|
50
|
+
callBack: undefined,
|
|
51
|
+
};
|
|
52
|
+
expect(actions.getMetaTags(payload)).toStrictEqual(expected);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it("test resetMetaTags", () => {
|
|
56
|
+
const expected = {
|
|
57
|
+
type: types.URL_META_TAGS_RESET,
|
|
58
|
+
};
|
|
59
|
+
expect(actions.resetMetaTags()).toStrictEqual(expected);
|
|
60
|
+
});
|
|
41
61
|
});
|
|
62
|
+
|
|
@@ -23,6 +23,8 @@ describe('Creatives Whatsapp test1/>', () => {
|
|
|
23
23
|
const handleClose = jest.fn();
|
|
24
24
|
const onCreateComplete = jest.fn();
|
|
25
25
|
const formatMessage = jest.fn();
|
|
26
|
+
const getMetaTags = jest.fn();
|
|
27
|
+
const resetMetaTags = jest.fn();
|
|
26
28
|
const location = mockData.location;
|
|
27
29
|
const params = {
|
|
28
30
|
id: mockData.editData1.templateDetails._id,
|
|
@@ -42,6 +44,8 @@ describe('Creatives Whatsapp test1/>', () => {
|
|
|
42
44
|
clearCreateResponse,
|
|
43
45
|
getTemplateDetails,
|
|
44
46
|
resetEditTemplate,
|
|
47
|
+
getMetaTags,
|
|
48
|
+
resetMetaTags,
|
|
45
49
|
}}
|
|
46
50
|
globalActions={{ fetchSchemaForEntity }}
|
|
47
51
|
onCreateComplete={onCreateComplete}
|
|
@@ -268,6 +272,8 @@ describe('Creatives Whatsapp test2/>', () => {
|
|
|
268
272
|
const handleClose = jest.fn();
|
|
269
273
|
const onCreateComplete = jest.fn();
|
|
270
274
|
const formatMessage = jest.fn();
|
|
275
|
+
const getMetaTags = jest.fn();
|
|
276
|
+
const resetMetaTags = jest.fn();
|
|
271
277
|
const location = mockData.location;
|
|
272
278
|
const params = {
|
|
273
279
|
id: mockData.editData1.templateDetails._id,
|
|
@@ -284,6 +290,8 @@ describe('Creatives Whatsapp test2/>', () => {
|
|
|
284
290
|
clearCreateResponse,
|
|
285
291
|
getTemplateDetails,
|
|
286
292
|
resetEditTemplate,
|
|
293
|
+
getMetaTags,
|
|
294
|
+
resetMetaTags,
|
|
287
295
|
}}
|
|
288
296
|
globalActions={{ fetchSchemaForEntity }}
|
|
289
297
|
onCreateComplete={onCreateComplete}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { fromJS } from "immutable";
|
|
2
|
+
import whatsappReducer from "../reducer";
|
|
3
|
+
import {
|
|
4
|
+
URL_META_TAGS_REQUEST,
|
|
5
|
+
URL_META_TAGS_SUCCESS,
|
|
6
|
+
URL_META_TAGS_FAILURE,
|
|
7
|
+
URL_META_TAGS_RESET,
|
|
8
|
+
} from "../constants";
|
|
9
|
+
import { mockData } from "./mockData";
|
|
10
|
+
|
|
11
|
+
describe("whatsapp reducer", () => {
|
|
12
|
+
let state;
|
|
13
|
+
const action = {};
|
|
14
|
+
beforeEach(() => {
|
|
15
|
+
state = fromJS({
|
|
16
|
+
getMetaTagsRequest: false,
|
|
17
|
+
metaTagsDetails: {},
|
|
18
|
+
getMetaTagsError: '',
|
|
19
|
+
});
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
it("Reducer : URL_META_TAGS_REQUEST", () => {
|
|
23
|
+
action.type = URL_META_TAGS_REQUEST;
|
|
24
|
+
state = state
|
|
25
|
+
.set("getMetaTagsRequest", true)
|
|
26
|
+
.set("metaTagsDetails", {});
|
|
27
|
+
const expectedResult = state;
|
|
28
|
+
expect(whatsappReducer(state, action)).toEqual(
|
|
29
|
+
expectedResult
|
|
30
|
+
);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("Reducer : URL_META_TAGS_SUCCESS", () => {
|
|
34
|
+
action.type = URL_META_TAGS_SUCCESS;
|
|
35
|
+
action.data = mockData.metaTagsMock;
|
|
36
|
+
state = state
|
|
37
|
+
.set("getMetaTagsRequest", false)
|
|
38
|
+
.set("metaTagsDetails", mockData.metaTagsMock);
|
|
39
|
+
const expectedResult = state;
|
|
40
|
+
expect(whatsappReducer(state, action)).toEqual(
|
|
41
|
+
expectedResult
|
|
42
|
+
);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it("Reducer : URL_META_TAGS_FAILURE", () => {
|
|
46
|
+
action.type = URL_META_TAGS_FAILURE;
|
|
47
|
+
action.error = 'error';
|
|
48
|
+
state = state
|
|
49
|
+
.set("getMetaTagsRequest", false)
|
|
50
|
+
.set("metaTagsDetails", {})
|
|
51
|
+
.set("getMetaTagsError", 'error');
|
|
52
|
+
const expectedResult = state;
|
|
53
|
+
expect(whatsappReducer(state, action)).toEqual(
|
|
54
|
+
expectedResult
|
|
55
|
+
);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("Reducer : URL_META_TAGS_RESET", () => {
|
|
59
|
+
action.type = URL_META_TAGS_RESET;
|
|
60
|
+
state = state
|
|
61
|
+
.set("metaTagsDetails", {});
|
|
62
|
+
const expectedResult = state;
|
|
63
|
+
expect(whatsappReducer(state, action)).toEqual(
|
|
64
|
+
expectedResult
|
|
65
|
+
);
|
|
66
|
+
});
|
|
67
|
+
});
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { expectSaga, testSaga } from "redux-saga-test-plan";
|
|
2
|
+
import * as matchers from "redux-saga-test-plan/matchers";
|
|
3
|
+
import { takeLatest } from "redux-saga/effects";
|
|
4
|
+
import { getMetaTagsDetails, watchGetMetaTagsDetails } from "../sagas";
|
|
5
|
+
import {
|
|
6
|
+
URL_META_TAGS_REQUEST,
|
|
7
|
+
URL_META_TAGS_SUCCESS,
|
|
8
|
+
URL_META_TAGS_FAILURE,
|
|
9
|
+
} from "../constants";
|
|
10
|
+
import * as Api from "../../../services/api";
|
|
11
|
+
|
|
12
|
+
describe("Whatsapp saga", () => {
|
|
13
|
+
const error = new Error("error");
|
|
14
|
+
const callBack = jest.fn();
|
|
15
|
+
describe("whatsapp test saga", () => {
|
|
16
|
+
it("handle success response from getMetaTagsDetails", () => {
|
|
17
|
+
expectSaga(getMetaTagsDetails, {
|
|
18
|
+
previewUrl: "https://capillarytech.com",
|
|
19
|
+
callBack,
|
|
20
|
+
}).provide([
|
|
21
|
+
[
|
|
22
|
+
matchers.call.fn(Api.getMetaTags),
|
|
23
|
+
{
|
|
24
|
+
success: true,
|
|
25
|
+
result: [],
|
|
26
|
+
},
|
|
27
|
+
],
|
|
28
|
+
])
|
|
29
|
+
.put({
|
|
30
|
+
type: URL_META_TAGS_SUCCESS,
|
|
31
|
+
result: {},
|
|
32
|
+
})
|
|
33
|
+
.run();
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it("handle success false response from getMetaTagsDetails", () => {
|
|
37
|
+
expectSaga(getMetaTagsDetails, {
|
|
38
|
+
previewUrl: "https://capillarytech.com",
|
|
39
|
+
callBack,
|
|
40
|
+
}).provide([
|
|
41
|
+
[
|
|
42
|
+
matchers.call.fn(Api.getMetaTags),
|
|
43
|
+
{
|
|
44
|
+
success: false,
|
|
45
|
+
result: [],
|
|
46
|
+
message: 'error',
|
|
47
|
+
},
|
|
48
|
+
],
|
|
49
|
+
])
|
|
50
|
+
.put({
|
|
51
|
+
type: URL_META_TAGS_FAILURE,
|
|
52
|
+
error: 'error',
|
|
53
|
+
})
|
|
54
|
+
.run();
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
it("handle success false response from getMetaTagsDetails when callback not present", () => {
|
|
58
|
+
expectSaga(getMetaTagsDetails, {
|
|
59
|
+
previewUrl: "https://capillarytech.com",
|
|
60
|
+
}).provide([
|
|
61
|
+
[
|
|
62
|
+
matchers.call.fn(Api.getMetaTags),
|
|
63
|
+
{
|
|
64
|
+
success: false,
|
|
65
|
+
result: [],
|
|
66
|
+
message: 'error',
|
|
67
|
+
},
|
|
68
|
+
],
|
|
69
|
+
])
|
|
70
|
+
.put({
|
|
71
|
+
type: URL_META_TAGS_FAILURE,
|
|
72
|
+
error: 'error',
|
|
73
|
+
})
|
|
74
|
+
.run();
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it("handles error thrown", () => {
|
|
78
|
+
testSaga(getMetaTagsDetails, { callBack }).next().throw(error).next().isDone();
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
|
|
82
|
+
describe("watchGetMetaTagsDetails saga", () => {
|
|
83
|
+
const generator = watchGetMetaTagsDetails();
|
|
84
|
+
it("should call watchers functions", async () => {
|
|
85
|
+
expect(generator.next().value).toEqual(
|
|
86
|
+
takeLatest(URL_META_TAGS_REQUEST, getMetaTagsDetails)
|
|
87
|
+
);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
});
|