@capillarytech/creatives-library 7.17.37 → 7.17.39-alpha.0
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/index.js +2 -2
- package/package.json +1 -1
- package/services/api.js +6 -6
- package/v2Components/CapTagList/index.js +2 -1
- package/v2Containers/CreativesContainer/SlideBoxContent.js +12 -6
- package/v2Containers/CreativesContainer/index.js +46 -7
- package/v2Containers/TagList/index.js +2 -0
- package/v2Containers/Templates/index.js +17 -3
- package/v2Containers/Templates/messages.js +4 -0
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +28 -129
- package/v2Containers/TemplatesV2/tests/index.test.js +1 -0
- package/v2Containers/Zalo/constants.js +0 -1
- package/v2Containers/Zalo/index.js +278 -187
- package/v2Containers/Zalo/index.scss +3 -4
- package/v2Containers/Zalo/messages.js +16 -4
- package/v2Containers/Zalo/saga.js +10 -4
- package/v2Containers/Zalo/selectors.js +8 -10
- package/v2Containers/Zalo/tests/index.test.js +94 -47
- package/v2Containers/Zalo/tests/mockData.js +5101 -5045
- package/v2Containers/Zalo/tests/reducer.test.js +3 -3
- package/v2Containers/Zalo/tests/saga.test.js +5 -2
- package/v2Containers/Zalo/tests/selector.test.js +28 -0
- package/v2Containers/Zalo/tests/selectors.test.js +0 -52
|
@@ -8,23 +8,29 @@ import {
|
|
|
8
8
|
} from "./constants";
|
|
9
9
|
|
|
10
10
|
export function* getTemplateInfoById({ payload }) {
|
|
11
|
+
const { preview = "", actionCallback } = payload;
|
|
11
12
|
try {
|
|
12
13
|
const res = yield call(Api.getTemplateInfoById, payload);
|
|
13
14
|
if (res?.success) {
|
|
14
15
|
yield put({
|
|
15
|
-
type:
|
|
16
|
-
? ZALO_TEMPLATE_PREVIEW_INFO
|
|
17
|
-
: ZALO_TEMPLATE_INFO_SUCCESS,
|
|
16
|
+
type: preview ? ZALO_TEMPLATE_PREVIEW_INFO : ZALO_TEMPLATE_INFO_SUCCESS,
|
|
18
17
|
result: res?.response || {},
|
|
19
18
|
});
|
|
20
19
|
} else {
|
|
20
|
+
const errorMsg = res?.message || res?.status?.message;
|
|
21
21
|
yield put({
|
|
22
22
|
type: ZALO_TEMPLATE_INFO_ERROR,
|
|
23
|
-
error:
|
|
23
|
+
error: errorMsg,
|
|
24
24
|
});
|
|
25
|
+
if (actionCallback) {
|
|
26
|
+
actionCallback(errorMsg);
|
|
27
|
+
}
|
|
25
28
|
}
|
|
26
29
|
} catch (error) {
|
|
27
30
|
yield put({ type: ZALO_TEMPLATE_INFO_ERROR, error });
|
|
31
|
+
if (actionCallback) {
|
|
32
|
+
actionCallback(error);
|
|
33
|
+
}
|
|
28
34
|
}
|
|
29
35
|
}
|
|
30
36
|
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { createSelector } from "reselect";
|
|
2
|
-
import { fromJS } from "immutable";
|
|
3
2
|
|
|
4
|
-
const selectZaloDomain = (
|
|
3
|
+
const selectZaloDomain = () => (state) => state.get('zalo');
|
|
4
|
+
const selectAccountDomain = () => (state) => state.get('templates');
|
|
5
5
|
|
|
6
6
|
const makeSelectZalo = () =>
|
|
7
|
-
createSelector(selectZaloDomain, (substate
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
export { makeSelectZalo, selectZaloDomain };
|
|
7
|
+
createSelector(selectZaloDomain(), (substate) => substate && substate.toJS());
|
|
8
|
+
|
|
9
|
+
const makeSelectAccount = () =>
|
|
10
|
+
createSelector(selectAccountDomain(), (substate) => substate && substate.toJS());
|
|
11
|
+
|
|
12
|
+
export { makeSelectZalo, makeSelectAccount };
|
|
@@ -1,27 +1,25 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import { injectIntl } from
|
|
3
|
-
import { browserHistory } from
|
|
4
|
-
import
|
|
5
|
-
import { Provider } from
|
|
6
|
-
import configureStore from
|
|
7
|
-
import { Zalo } from
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { injectIntl } from 'react-intl';
|
|
3
|
+
import { browserHistory } from 'react-router';
|
|
4
|
+
import '@testing-library/jest-dom';
|
|
5
|
+
import { Provider } from 'react-redux';
|
|
6
|
+
import configureStore from '../../../store';
|
|
7
|
+
import { Zalo } from '..';
|
|
8
8
|
import {
|
|
9
9
|
metaEntities,
|
|
10
|
-
|
|
10
|
+
editData,
|
|
11
11
|
location,
|
|
12
12
|
getDefaultTags,
|
|
13
13
|
injectedTags,
|
|
14
|
-
|
|
14
|
+
accountData,
|
|
15
15
|
templateData,
|
|
16
|
-
} from
|
|
17
|
-
import {
|
|
18
|
-
render,
|
|
19
|
-
screen,
|
|
20
|
-
fireEvent,
|
|
21
|
-
} from "../../../utils/test-utils";
|
|
16
|
+
} from './mockData';
|
|
17
|
+
import { render, screen, fireEvent } from '../../../utils/test-utils';
|
|
22
18
|
|
|
23
19
|
const mockActions = {
|
|
24
20
|
getTemplateInfoById: jest.fn(),
|
|
21
|
+
};
|
|
22
|
+
const mockGlobalActions = {
|
|
25
23
|
fetchSchemaForEntity: jest.fn(),
|
|
26
24
|
};
|
|
27
25
|
|
|
@@ -31,97 +29,146 @@ beforeAll(() => {
|
|
|
31
29
|
});
|
|
32
30
|
|
|
33
31
|
const ComponentToRender = injectIntl(Zalo);
|
|
34
|
-
const renderComponent = (props) =>
|
|
35
|
-
|
|
36
|
-
<
|
|
37
|
-
|
|
32
|
+
const renderComponent = (props) =>
|
|
33
|
+
render(
|
|
34
|
+
<Provider store={store}>
|
|
35
|
+
<ComponentToRender {...props} />
|
|
36
|
+
</Provider>,
|
|
38
37
|
);
|
|
39
38
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
it("test case for zalo template", async () => {
|
|
39
|
+
describe('Test activity zalo container', () => {
|
|
40
|
+
it('test case for zalo template', async () => {
|
|
43
41
|
renderComponent({
|
|
44
42
|
actions: mockActions,
|
|
45
|
-
|
|
43
|
+
globalActions: mockGlobalActions,
|
|
44
|
+
editData,
|
|
46
45
|
metaEntities,
|
|
47
46
|
location,
|
|
48
47
|
getDefaultTags,
|
|
49
48
|
injectedTags,
|
|
50
|
-
|
|
49
|
+
accountData,
|
|
51
50
|
templateData,
|
|
51
|
+
isFullMode: true,
|
|
52
52
|
});
|
|
53
|
-
const inputBox = await screen.findAllByPlaceholderText(
|
|
54
|
-
|
|
53
|
+
const inputBox = await screen.findAllByPlaceholderText(
|
|
54
|
+
'Add labels or text or combination of both',
|
|
55
|
+
);
|
|
56
|
+
fireEvent.change(inputBox[0], { target: { value: 'Hello, welcome' } });
|
|
55
57
|
inputBox[0].focus();
|
|
56
|
-
const previewButton = screen.getByTestId(
|
|
58
|
+
const previewButton = screen.getByTestId('preview-link-button');
|
|
57
59
|
previewButton.click();
|
|
58
60
|
expect(
|
|
59
|
-
screen.getByText(
|
|
61
|
+
screen.getByText('This template has been enabled'),
|
|
62
|
+
).toBeInTheDocument();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('test case for text field curly braces error', async () => {
|
|
66
|
+
renderComponent({
|
|
67
|
+
actions: mockActions,
|
|
68
|
+
globalActions: mockGlobalActions,
|
|
69
|
+
editData,
|
|
70
|
+
metaEntities,
|
|
71
|
+
location,
|
|
72
|
+
getDefaultTags,
|
|
73
|
+
injectedTags,
|
|
74
|
+
accountData,
|
|
75
|
+
templateData,
|
|
76
|
+
isFullMode: true,
|
|
77
|
+
});
|
|
78
|
+
const inputBox = await screen.findAllByPlaceholderText(
|
|
79
|
+
'Add labels or text or combination of both',
|
|
80
|
+
);
|
|
81
|
+
fireEvent.change(inputBox[0], { target: { value: 'Hello, welcome {{' } });
|
|
82
|
+
inputBox[0].focus();
|
|
83
|
+
expect(
|
|
84
|
+
screen.getByText('Invalid label, please close all curly braces'),
|
|
60
85
|
).toBeInTheDocument();
|
|
61
86
|
});
|
|
62
87
|
|
|
63
|
-
it(
|
|
88
|
+
it('test case for unsupported tag', async () => {
|
|
64
89
|
renderComponent({
|
|
65
90
|
actions: mockActions,
|
|
66
|
-
|
|
91
|
+
globalActions: mockGlobalActions,
|
|
92
|
+
editData,
|
|
67
93
|
metaEntities,
|
|
68
94
|
location,
|
|
69
95
|
getDefaultTags,
|
|
70
96
|
injectedTags,
|
|
71
|
-
|
|
97
|
+
accountData,
|
|
72
98
|
templateData,
|
|
99
|
+
isFullMode: true,
|
|
100
|
+
});
|
|
101
|
+
const inputBox = await screen.findAllByPlaceholderText(
|
|
102
|
+
'Add labels or text or combination of both',
|
|
103
|
+
);
|
|
104
|
+
fireEvent.change(inputBox[0], {
|
|
105
|
+
target: { value: 'Hello, welcome {{fsdaf}}' },
|
|
73
106
|
});
|
|
74
|
-
const inputBox = await screen.findAllByPlaceholderText('Add labels or text or combination of both');
|
|
75
|
-
fireEvent.change(inputBox[0], { target: { value: "Hello, welcome {{" } });
|
|
76
107
|
inputBox[0].focus();
|
|
77
108
|
expect(
|
|
78
|
-
screen.getByText(
|
|
109
|
+
screen.getByText(
|
|
110
|
+
'Unsupported tags: fsdaf. Please remove them from this message.',
|
|
111
|
+
),
|
|
79
112
|
).toBeInTheDocument();
|
|
80
113
|
});
|
|
81
114
|
|
|
82
|
-
it(
|
|
115
|
+
it('test case for length check', async () => {
|
|
83
116
|
renderComponent({
|
|
84
117
|
actions: mockActions,
|
|
85
|
-
|
|
118
|
+
globalActions: mockGlobalActions,
|
|
119
|
+
editData,
|
|
86
120
|
metaEntities,
|
|
87
121
|
location,
|
|
88
122
|
getDefaultTags,
|
|
89
123
|
injectedTags,
|
|
90
|
-
|
|
124
|
+
accountData,
|
|
91
125
|
templateData,
|
|
126
|
+
isFullMode: false,
|
|
92
127
|
});
|
|
93
|
-
const inputBox = await screen.findAllByPlaceholderText(
|
|
128
|
+
const inputBox = await screen.findAllByPlaceholderText(
|
|
129
|
+
'Add labels or text or combination of both',
|
|
130
|
+
);
|
|
94
131
|
fireEvent.change(inputBox[0], {
|
|
95
|
-
target: {
|
|
132
|
+
target: {
|
|
133
|
+
value:
|
|
134
|
+
'Hello, welcome user. Habata itara modoranai to ittta Mezashita no wa aoi aoi ano sora',
|
|
135
|
+
},
|
|
96
136
|
});
|
|
97
137
|
inputBox[0].focus();
|
|
98
138
|
expect(
|
|
99
139
|
screen.getByText(
|
|
100
|
-
|
|
101
|
-
)
|
|
140
|
+
'Character count for this variable should be in between 0 to 30',
|
|
141
|
+
),
|
|
102
142
|
).toBeInTheDocument();
|
|
103
143
|
});
|
|
104
144
|
|
|
105
|
-
it(
|
|
145
|
+
it('test case for length check', async () => {
|
|
106
146
|
renderComponent({
|
|
107
147
|
actions: mockActions,
|
|
108
|
-
|
|
148
|
+
globalActions: mockGlobalActions,
|
|
149
|
+
editData,
|
|
109
150
|
metaEntities,
|
|
110
151
|
location,
|
|
111
152
|
getDefaultTags,
|
|
112
153
|
injectedTags,
|
|
113
|
-
|
|
154
|
+
accountData,
|
|
114
155
|
templateData,
|
|
156
|
+
isFullMode: true,
|
|
115
157
|
});
|
|
116
|
-
const inputBox = await screen.findAllByPlaceholderText(
|
|
158
|
+
const inputBox = await screen.findAllByPlaceholderText(
|
|
159
|
+
'Add labels or text or combination of both',
|
|
160
|
+
);
|
|
117
161
|
fireEvent.change(inputBox[0], {
|
|
118
162
|
target: {
|
|
119
|
-
value:
|
|
163
|
+
value:
|
|
164
|
+
'Hello, welcome user. Habata itara modoranai to ittta Mezashita no wa aoi aoi ano sora',
|
|
120
165
|
},
|
|
121
166
|
});
|
|
122
167
|
inputBox[0].focus();
|
|
123
168
|
expect(
|
|
124
|
-
screen.getByText(
|
|
169
|
+
screen.getByText(
|
|
170
|
+
'Character count for this variable should be in between 0 to 30',
|
|
171
|
+
),
|
|
125
172
|
).toBeInTheDocument();
|
|
126
173
|
});
|
|
127
174
|
});
|