@capillarytech/creatives-library 7.17.40-alpha.0 → 7.17.41

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.
Files changed (43) hide show
  1. package/components/CapTagList/index.js +1 -1
  2. package/components/CapTagList/messages.js +0 -4
  3. package/components/FormBuilder/index.js +2 -2
  4. package/components/FormBuilder/messages.js +0 -8
  5. package/containers/App/constants.js +0 -26
  6. package/containers/Assets/Gallery/index.js +1 -1
  7. package/containers/Assets/Gallery/messages.js +0 -4
  8. package/containers/Email/index.js +1 -1
  9. package/containers/Templates/index.js +1 -1
  10. package/containers/Templates/messages.js +0 -4
  11. package/index.js +2 -2
  12. package/package.json +1 -1
  13. package/services/api.js +6 -6
  14. package/utils/common.js +6 -13
  15. package/utils/tests/common.test.js +5 -5
  16. package/v2Components/CapTagList/index.js +2 -1
  17. package/v2Components/FormBuilder/index.js +1 -1
  18. package/v2Components/FormBuilder/messages.js +0 -4
  19. package/v2Components/TemplatePreview/_templatePreview.scss +40 -0
  20. package/v2Components/TemplatePreview/index.js +34 -0
  21. package/v2Components/TemplatePreview/tests/__snapshots__/index.test.js.snap +47 -0
  22. package/v2Components/TemplatePreview/tests/index.test.js +9 -0
  23. package/v2Containers/CreativesContainer/SlideBoxContent.js +12 -6
  24. package/v2Containers/CreativesContainer/SlideBoxHeader.js +2 -3
  25. package/v2Containers/CreativesContainer/index.js +57 -7
  26. package/v2Containers/CreativesContainer/messages.js +1 -9
  27. package/v2Containers/TagList/index.js +5 -18
  28. package/v2Containers/Templates/index.js +19 -4
  29. package/v2Containers/Templates/messages.js +4 -0
  30. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +28 -129
  31. package/v2Containers/TemplatesV2/tests/index.test.js +1 -0
  32. package/v2Containers/Zalo/constants.js +0 -1
  33. package/v2Containers/Zalo/index.js +280 -189
  34. package/v2Containers/Zalo/index.scss +3 -4
  35. package/v2Containers/Zalo/messages.js +17 -5
  36. package/v2Containers/Zalo/saga.js +10 -4
  37. package/v2Containers/Zalo/selectors.js +8 -10
  38. package/v2Containers/Zalo/tests/index.test.js +67 -48
  39. package/v2Containers/Zalo/tests/mockData.js +5056 -5045
  40. package/v2Containers/Zalo/tests/reducer.test.js +3 -3
  41. package/v2Containers/Zalo/tests/saga.test.js +5 -2
  42. package/v2Containers/Zalo/tests/selector.test.js +28 -0
  43. 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: payload?.preview
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: res?.error || res?.message,
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 = (state = fromJS({})) => state.get("zalo");
3
+ const selectZaloDomain = () => (state) => state.get('zalo');
4
+ const selectAccountDomain = () => (state) => state.get('templates');
5
5
 
6
6
  const makeSelectZalo = () =>
7
- createSelector(selectZaloDomain, (substate = fromJS({})) => ({
8
- zaloTemplateInfoStatus: substate.get("zaloTemplateInfoStatus"),
9
- zaloTemplateInfoValue: substate.get("zaloTemplateInfoValue"),
10
- zaloTemplateInfoError: substate.get("zaloTemplateInfoError"),
11
- zaloTemplatePreviewData: substate.get("zaloTemplatePreviewData"),
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,26 @@
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 "..";
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
- zaloTemplateInfoData,
10
+ editData,
11
11
  location,
12
12
  getDefaultTags,
13
13
  injectedTags,
14
- template,
14
+ accountData,
15
15
  templateData,
16
- } from "./mockData";
17
- import {
18
- render,
19
- screen,
20
- fireEvent,
21
- } from "../../../utils/test-utils";
16
+ templateConfigs,
17
+ } from './mockData';
18
+ import { render, screen, fireEvent } from '../../../utils/test-utils';
22
19
 
23
20
  const mockActions = {
24
21
  getTemplateInfoById: jest.fn(),
22
+ };
23
+ const mockGlobalActions = {
25
24
  fetchSchemaForEntity: jest.fn(),
26
25
  };
27
26
 
@@ -31,97 +30,117 @@ beforeAll(() => {
31
30
  });
32
31
 
33
32
  const ComponentToRender = injectIntl(Zalo);
34
- const renderComponent = (props) => render(
35
- <Provider store={store}>
36
- <ComponentToRender {...props} />
37
- </Provider>
33
+ const renderComponent = (props) =>
34
+ render(
35
+ <Provider store={store}>
36
+ <ComponentToRender {...props} />
37
+ </Provider>,
38
38
  );
39
39
 
40
-
41
- describe("Test activity zalo container", () => {
42
- it("test case for zalo template", async () => {
40
+ describe('Test activity zalo container', () => {
41
+ it('test case for zalo template', async () => {
43
42
  renderComponent({
44
43
  actions: mockActions,
45
- zaloTemplateInfoData,
44
+ globalActions: mockGlobalActions,
45
+ editData,
46
46
  metaEntities,
47
47
  location,
48
48
  getDefaultTags,
49
49
  injectedTags,
50
- template,
50
+ accountData,
51
51
  templateData,
52
+ isFullMode: true,
52
53
  });
53
- const inputBox = await screen.findAllByPlaceholderText('Add labels or text or combination of both');
54
- fireEvent.change(inputBox[0], { target: { value: "Hello, welcome" } });
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' } });
55
58
  inputBox[0].focus();
56
- const previewButton = screen.getByTestId("preview-link-button");
59
+ const previewButton = screen.getByTestId('preview-link-button');
57
60
  previewButton.click();
58
61
  expect(
59
- screen.getByText("This template has been enabled")
62
+ screen.getByText('This template has been enabled'),
60
63
  ).toBeInTheDocument();
61
64
  });
62
65
 
63
- it("test case for text field curly braces error", async () => {
66
+ it('test case for text field curly braces error', async () => {
64
67
  renderComponent({
65
68
  actions: mockActions,
66
- zaloTemplateInfoData,
69
+ globalActions: mockGlobalActions,
70
+ editData,
67
71
  metaEntities,
68
72
  location,
69
73
  getDefaultTags,
70
74
  injectedTags,
71
- template,
75
+ accountData,
72
76
  templateData,
77
+ isFullMode: true,
73
78
  });
74
- const inputBox = await screen.findAllByPlaceholderText('Add labels or text or combination of both');
75
- fireEvent.change(inputBox[0], { target: { value: "Hello, welcome {{" } });
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 {{' } });
76
83
  inputBox[0].focus();
77
84
  expect(
78
- screen.getByText("Invalid label, please close all curly braces")
85
+ screen.getByText('Invalid label, please close all curly braces'),
79
86
  ).toBeInTheDocument();
80
87
  });
81
88
 
82
- it("test case for unsupported tag", async () => {
89
+ it('test case for unsupported tag', async () => {
83
90
  renderComponent({
84
91
  actions: mockActions,
85
- zaloTemplateInfoData,
92
+ globalActions: mockGlobalActions,
93
+ editData,
86
94
  metaEntities,
87
95
  location,
88
96
  getDefaultTags,
89
97
  injectedTags,
90
- template,
98
+ accountData,
91
99
  templateData,
100
+ isFullMode: true,
92
101
  });
93
- const inputBox = await screen.findAllByPlaceholderText('Add labels or text or combination of both');
102
+ const inputBox = await screen.findAllByPlaceholderText(
103
+ 'Add labels or text or combination of both',
104
+ );
94
105
  fireEvent.change(inputBox[0], {
95
- target: { value: "Hello, welcome {{fsdaf}}" },
106
+ target: { value: 'Hello, welcome {{fsdaf}}' },
96
107
  });
97
108
  inputBox[0].focus();
98
109
  expect(
99
110
  screen.getByText(
100
- "Unsupported tags: fsdaf. Please remove them from this message."
101
- )
111
+ 'Unsupported tags: fsdaf. Please remove them from this message.',
112
+ ),
102
113
  ).toBeInTheDocument();
103
114
  });
104
115
 
105
- it("test case for length check", async () => {
116
+ it('test case for set template data', async () => {
117
+ templateData.templateConfigs = templateConfigs;
106
118
  renderComponent({
107
119
  actions: mockActions,
108
- zaloTemplateInfoData,
120
+ globalActions: mockGlobalActions,
121
+ editData,
109
122
  metaEntities,
110
123
  location,
111
124
  getDefaultTags,
112
125
  injectedTags,
113
- template,
126
+ accountData,
114
127
  templateData,
128
+ isFullMode: false,
115
129
  });
116
- const inputBox = await screen.findAllByPlaceholderText('Add labels or text or combination of both');
130
+ const inputBox = await screen.findAllByPlaceholderText(
131
+ 'Add labels or text or combination of both',
132
+ );
117
133
  fireEvent.change(inputBox[0], {
118
134
  target: {
119
- value: "Hello, welcome user. Habata itara modoranai to ittta Mezashita no wa aoi aoi ano sora",
135
+ value:
136
+ 'Hello, welcome user. Habata itara modoranai to ittta Mezashita no wa aoi aoi ano sora',
120
137
  },
121
138
  });
122
139
  inputBox[0].focus();
123
140
  expect(
124
- screen.getByText("Character count for this variable should be in between 0 to 30")
141
+ screen.getByText(
142
+ 'Character count for this variable should be in between 0 to 30',
143
+ ),
125
144
  ).toBeInTheDocument();
126
145
  });
127
- });
146
+ });