@capillarytech/creatives-library 7.17.39-alpha.3 → 7.17.39-alpha.5
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
CHANGED
|
@@ -504,6 +504,7 @@ export class Creatives extends React.Component {
|
|
|
504
504
|
}
|
|
505
505
|
case constants.ZALO: {
|
|
506
506
|
creativesTemplateData = {
|
|
507
|
+
type: constants.ZALO,
|
|
507
508
|
...templateData,
|
|
508
509
|
};
|
|
509
510
|
break;
|
|
@@ -812,6 +813,7 @@ export class Creatives extends React.Component {
|
|
|
812
813
|
templateData = {
|
|
813
814
|
...template.value,
|
|
814
815
|
};
|
|
816
|
+
templateData?.type && delete templateData.type;
|
|
815
817
|
}
|
|
816
818
|
}
|
|
817
819
|
break;
|
|
@@ -159,14 +159,14 @@ export const Zalo = (props) => {
|
|
|
159
159
|
updateTextAreaId(paramsData[0]?.name);
|
|
160
160
|
};
|
|
161
161
|
|
|
162
|
-
// in creatives
|
|
163
162
|
useEffect(() => {
|
|
164
163
|
setDataForEdit(false);
|
|
165
164
|
}, [zaloTemplateInfoValue]);
|
|
166
165
|
|
|
167
|
-
// in campaigns
|
|
168
166
|
useEffect(() => {
|
|
169
|
-
|
|
167
|
+
if (!isEmpty(varMapped)) {
|
|
168
|
+
setDataForEdit(true);
|
|
169
|
+
}
|
|
170
170
|
}, [varMapped]);
|
|
171
171
|
|
|
172
172
|
useEffect(() => {
|
|
@@ -354,7 +354,7 @@ export const Zalo = (props) => {
|
|
|
354
354
|
accountId: oa_id,
|
|
355
355
|
accountName: username,
|
|
356
356
|
templateConfigs: {
|
|
357
|
-
|
|
357
|
+
id: templateId.toString(),
|
|
358
358
|
name: templateName,
|
|
359
359
|
template: templatePreviewUrl,
|
|
360
360
|
varMapped: varMap,
|
|
@@ -28,7 +28,7 @@ export default defineMessages({
|
|
|
28
28
|
"Character count for this variable should be in between {minLength} to {maxLength}",
|
|
29
29
|
},
|
|
30
30
|
previewHead: {
|
|
31
|
-
id: `${prefix}.
|
|
31
|
+
id: `${prefix}.previewHead`,
|
|
32
32
|
defaultMessage: "Preview",
|
|
33
33
|
},
|
|
34
34
|
previewText: {
|
|
@@ -0,0 +1,146 @@
|
|
|
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
|
+
import {
|
|
9
|
+
metaEntities,
|
|
10
|
+
editData,
|
|
11
|
+
location,
|
|
12
|
+
getDefaultTags,
|
|
13
|
+
injectedTags,
|
|
14
|
+
accountData,
|
|
15
|
+
templateData,
|
|
16
|
+
templateConfigs,
|
|
17
|
+
} from './mockData';
|
|
18
|
+
import { render, screen, fireEvent } from '../../../utils/test-utils';
|
|
19
|
+
|
|
20
|
+
const mockActions = {
|
|
21
|
+
getTemplateInfoById: jest.fn(),
|
|
22
|
+
};
|
|
23
|
+
const mockGlobalActions = {
|
|
24
|
+
fetchSchemaForEntity: jest.fn(),
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
let store;
|
|
28
|
+
beforeAll(() => {
|
|
29
|
+
store = configureStore({}, browserHistory);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const ComponentToRender = injectIntl(Zalo);
|
|
33
|
+
const renderComponent = (props) =>
|
|
34
|
+
render(
|
|
35
|
+
<Provider store={store}>
|
|
36
|
+
<ComponentToRender {...props} />
|
|
37
|
+
</Provider>,
|
|
38
|
+
);
|
|
39
|
+
|
|
40
|
+
describe('Test activity zalo container', () => {
|
|
41
|
+
it('test case for zalo template', async () => {
|
|
42
|
+
renderComponent({
|
|
43
|
+
actions: mockActions,
|
|
44
|
+
globalActions: mockGlobalActions,
|
|
45
|
+
editData,
|
|
46
|
+
metaEntities,
|
|
47
|
+
location,
|
|
48
|
+
getDefaultTags,
|
|
49
|
+
injectedTags,
|
|
50
|
+
accountData,
|
|
51
|
+
templateData,
|
|
52
|
+
isFullMode: true,
|
|
53
|
+
});
|
|
54
|
+
const inputBox = await screen.findAllByPlaceholderText(
|
|
55
|
+
'Add labels or text or combination of both',
|
|
56
|
+
);
|
|
57
|
+
fireEvent.change(inputBox[0], { target: { value: 'Hello, welcome' } });
|
|
58
|
+
inputBox[0].focus();
|
|
59
|
+
const previewButton = screen.getByTestId('preview-link-button');
|
|
60
|
+
previewButton.click();
|
|
61
|
+
expect(
|
|
62
|
+
screen.getByText('This template has been enabled'),
|
|
63
|
+
).toBeInTheDocument();
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it('test case for text field curly braces error', async () => {
|
|
67
|
+
renderComponent({
|
|
68
|
+
actions: mockActions,
|
|
69
|
+
globalActions: mockGlobalActions,
|
|
70
|
+
editData,
|
|
71
|
+
metaEntities,
|
|
72
|
+
location,
|
|
73
|
+
getDefaultTags,
|
|
74
|
+
injectedTags,
|
|
75
|
+
accountData,
|
|
76
|
+
templateData,
|
|
77
|
+
isFullMode: true,
|
|
78
|
+
});
|
|
79
|
+
const inputBox = await screen.findAllByPlaceholderText(
|
|
80
|
+
'Add labels or text or combination of both',
|
|
81
|
+
);
|
|
82
|
+
fireEvent.change(inputBox[0], { target: { value: 'Hello, welcome {{' } });
|
|
83
|
+
inputBox[0].focus();
|
|
84
|
+
expect(
|
|
85
|
+
screen.getByText('Invalid label, please close all curly braces'),
|
|
86
|
+
).toBeInTheDocument();
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
it('test case for unsupported tag', async () => {
|
|
90
|
+
renderComponent({
|
|
91
|
+
actions: mockActions,
|
|
92
|
+
globalActions: mockGlobalActions,
|
|
93
|
+
editData,
|
|
94
|
+
metaEntities,
|
|
95
|
+
location,
|
|
96
|
+
getDefaultTags,
|
|
97
|
+
injectedTags,
|
|
98
|
+
accountData,
|
|
99
|
+
templateData,
|
|
100
|
+
isFullMode: true,
|
|
101
|
+
});
|
|
102
|
+
const inputBox = await screen.findAllByPlaceholderText(
|
|
103
|
+
'Add labels or text or combination of both',
|
|
104
|
+
);
|
|
105
|
+
fireEvent.change(inputBox[0], {
|
|
106
|
+
target: { value: 'Hello, welcome {{fsdaf}}' },
|
|
107
|
+
});
|
|
108
|
+
inputBox[0].focus();
|
|
109
|
+
expect(
|
|
110
|
+
screen.getByText(
|
|
111
|
+
'Unsupported tags: fsdaf. Please remove them from this message.',
|
|
112
|
+
),
|
|
113
|
+
).toBeInTheDocument();
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it('test case for set template data', async () => {
|
|
117
|
+
templateData.templateConfigs = templateConfigs;
|
|
118
|
+
renderComponent({
|
|
119
|
+
actions: mockActions,
|
|
120
|
+
globalActions: mockGlobalActions,
|
|
121
|
+
editData,
|
|
122
|
+
metaEntities,
|
|
123
|
+
location,
|
|
124
|
+
getDefaultTags,
|
|
125
|
+
injectedTags,
|
|
126
|
+
accountData,
|
|
127
|
+
templateData,
|
|
128
|
+
isFullMode: false,
|
|
129
|
+
});
|
|
130
|
+
const inputBox = await screen.findAllByPlaceholderText(
|
|
131
|
+
'Add labels or text or combination of both',
|
|
132
|
+
);
|
|
133
|
+
fireEvent.change(inputBox[0], {
|
|
134
|
+
target: {
|
|
135
|
+
value:
|
|
136
|
+
'Hello, welcome user. Habata itara modoranai to ittta Mezashita no wa aoi aoi ano sora',
|
|
137
|
+
},
|
|
138
|
+
});
|
|
139
|
+
inputBox[0].focus();
|
|
140
|
+
expect(
|
|
141
|
+
screen.getByText(
|
|
142
|
+
'Character count for this variable should be in between 0 to 30',
|
|
143
|
+
),
|
|
144
|
+
).toBeInTheDocument();
|
|
145
|
+
});
|
|
146
|
+
});
|