@capillarytech/creatives-library 7.17.35 → 7.17.36

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 (46) hide show
  1. package/containers/Templates/actions.js +0 -5
  2. package/index.js +6 -0
  3. package/package.json +1 -1
  4. package/routes.js +5 -0
  5. package/services/api.js +6 -1
  6. package/v2Components/WhatsappStatusContainer/_whatsappStatusContainer.scss +2 -1
  7. package/v2Containers/App/constants.js +1 -0
  8. package/v2Containers/CreativesContainer/SlideBoxContent.js +13 -0
  9. package/v2Containers/CreativesContainer/SlideBoxHeader.js +9 -6
  10. package/v2Containers/CreativesContainer/constants.js +1 -0
  11. package/v2Containers/CreativesContainer/index.scss +3 -0
  12. package/v2Containers/CreativesContainer/messages.js +8 -0
  13. package/v2Containers/CreativesContainer/tests/SlideBoxHeader.test.js +6 -1
  14. package/v2Containers/CreativesContainer/tests/__snapshots__/SlideBoxHeader.test.js.snap +58 -0
  15. package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +18114 -88
  16. package/v2Containers/Templates/_templates.scss +20 -2
  17. package/v2Containers/Templates/actions.js +4 -3
  18. package/v2Containers/Templates/constants.js +2 -1
  19. package/v2Containers/Templates/index.js +319 -120
  20. package/v2Containers/Templates/messages.js +28 -8
  21. package/v2Containers/Templates/reducer.js +3 -1
  22. package/v2Containers/Templates/sagas.js +2 -2
  23. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +724 -43
  24. package/v2Containers/Templates/tests/actions.test.js +18 -0
  25. package/v2Containers/Templates/tests/index.test.js +52 -1
  26. package/v2Containers/Templates/tests/mockData.js +41 -1
  27. package/v2Containers/Templates/tests/reducer.test.js +50 -0
  28. package/v2Containers/Templates/tests/sagas.test.js +40 -2
  29. package/v2Containers/Templates/tests/selector.test.js +17 -0
  30. package/v2Containers/TemplatesV2/index.js +2 -2
  31. package/v2Containers/TemplatesV2/messages.js +4 -0
  32. package/v2Containers/Zalo/actions.js +17 -0
  33. package/v2Containers/Zalo/constants.js +57 -0
  34. package/v2Containers/Zalo/index.js +391 -0
  35. package/v2Containers/Zalo/index.scss +76 -0
  36. package/v2Containers/Zalo/messages.js +74 -0
  37. package/v2Containers/Zalo/reducer.js +57 -0
  38. package/v2Containers/Zalo/saga.js +35 -0
  39. package/v2Containers/Zalo/selectors.js +14 -0
  40. package/v2Containers/Zalo/tests/actions.test.js +20 -0
  41. package/v2Containers/Zalo/tests/index.test.js +127 -0
  42. package/v2Containers/Zalo/tests/mockData.js +11470 -0
  43. package/v2Containers/Zalo/tests/reducer.test.js +85 -0
  44. package/v2Containers/Zalo/tests/saga.test.js +115 -0
  45. package/v2Containers/Zalo/tests/selectors.test.js +52 -0
  46. package/v2Containers/mockdata.js +817 -680
@@ -0,0 +1,18 @@
1
+ import { getAllTemplates } from "../actions";
2
+ import * as types from "../constants";
3
+
4
+ describe("Test zalo list actions", () => {
5
+ it("has a type of GET_ALL_TEMPLATES_REQUEST action", () => {
6
+ const channel = "Zalo";
7
+ const queryParams = {
8
+ page: 1,
9
+ perPage: 25,
10
+ };
11
+ const expected = {
12
+ type: types.GET_ALL_TEMPLATES_REQUEST,
13
+ channel,
14
+ queryParams,
15
+ };
16
+ expect(getAllTemplates(channel, queryParams)).toEqual(expected);
17
+ });
18
+ });
@@ -4,7 +4,7 @@ import { shallowWithIntl } from '../../../helpers/intl-enzym-test-helpers';
4
4
  import { Templates } from '../index';
5
5
  import mockdata from '../../mockdata';
6
6
 
7
- const { whatsappTemplates: TemplatesProp, getCreativesParamsOutput } = mockdata;
7
+ const { whatsappTemplates: TemplatesProp, getCreativesParamsOutput, zaloTemplates: ZaloTemplateProp } = mockdata;
8
8
 
9
9
  jest.mock('../../CreativesContainer', () => ({
10
10
  __esModule: true,
@@ -57,6 +57,35 @@ describe('Test Templates container', () => {
57
57
  );
58
58
  };
59
59
 
60
+ const renderZaloFunction = (isFullMode) => {
61
+ renderedComponent = shallowWithIntl(
62
+ <Templates
63
+ route={{
64
+ name: 'Zalo',
65
+ }}
66
+ Templates={ZaloTemplateProp}
67
+ actions={{
68
+ getWeCrmAccounts,
69
+ setChannelAccount,
70
+ getAllTemplates,
71
+ getUserList,
72
+ }}
73
+ location={{
74
+ pathname: '/Zalo',
75
+ query: {},
76
+ search: '',
77
+ }}
78
+ EmailCreate={{
79
+ duplicateTemplateInProgress: false,
80
+ }}
81
+ isFullMode={isFullMode}
82
+ intl={{
83
+ formatMessage: () => {},
84
+ }}
85
+ />,
86
+ );
87
+ };
88
+
60
89
  it('Should render correct component for whatsapp channel', () => {
61
90
  renderFunction();
62
91
  expect(renderedComponent).toMatchSnapshot();
@@ -97,6 +126,28 @@ describe('Test Templates container', () => {
97
126
  getCreativesParamsOutput,
98
127
  );
99
128
  });
129
+ it('Should render correct component for zalo channel', () => {
130
+ renderZaloFunction();
131
+ expect(renderedComponent).toMatchSnapshot();
132
+ });
133
+ it('Should render temlates when zalo templates are passed', () => {
134
+ renderZaloFunction();
135
+ renderedComponent.setProps({ TemplatesList: ZaloTemplateProp.templates });
136
+ expect(renderedComponent).toMatchSnapshot();
137
+ });
138
+ it('Should render temlates when Zalo templates are passed in full mode', () => {
139
+ renderZaloFunction(true);
140
+ renderedComponent.setProps({ TemplatesList: ZaloTemplateProp.templates });
141
+ expect(renderedComponent).toMatchSnapshot();
142
+ });
143
+ it('Should render illustration when no templates are passed', () => {
144
+ renderZaloFunction();
145
+ renderedComponent.setProps({
146
+ TemplatesList: [],
147
+ Templates: {},
148
+ });
149
+ expect(renderedComponent).toMatchSnapshot();
150
+ });
100
151
 
101
152
  const getFilterContainer = () => {
102
153
  const FilterContainer = () =>
@@ -23,8 +23,48 @@ export const getCdnTransformationConfigSuccess = {
23
23
  }
24
24
  };
25
25
 
26
+ export const getAllTemplatesListSuccess = {
27
+ "name": "Test2 QR - Thông báo thanh toán thành công",
28
+ "versions": {
29
+ "base": {
30
+ "content": {
31
+ "ZALO": {
32
+ "templateId": "268531",
33
+ "templateName": "Test QR - Thông báo thanh toán thành công",
34
+ "listParams": [
35
+ {
36
+ "name": "danh_xung",
37
+ "require": true,
38
+ "type": "STRING",
39
+ "maxLength": 30,
40
+ "minLength": 0,
41
+ "acceptNull": false,
42
+ },
43
+ {
44
+ "name": "name",
45
+ "require": true,
46
+ "type": "STRING",
47
+ "maxLength": 30,
48
+ "minLength": 0,
49
+ "acceptNull": false,
50
+ },
51
+ ],
52
+ "previewUrl": "https://account.zalo.cloud/znspreview/-e0cMil4NU5WUUAVzP7T_g=="
53
+ },
54
+ },
55
+ },
56
+ },
57
+ "type": "ZALO",
58
+ };
59
+
26
60
  export const getCdnTransformationConfigFailure = {
27
61
  "isError": true,
28
62
  "message": "Resource Not Found",
29
63
  "error": {}
30
- };
64
+ };
65
+
66
+ export const getAllTemplatesListFailure = {
67
+ "isError": true,
68
+ "message": "Resource Not Found",
69
+ "error": {},
70
+ };
@@ -0,0 +1,50 @@
1
+ import reducer, { initialState } from "../reducer";
2
+ import * as types from "../constants";
3
+ import * as mockData from "./mockData";
4
+
5
+ describe("test reducer", () => {
6
+ afterEach(() => {
7
+ jest.clearAllMocks();
8
+ });
9
+
10
+ it("should return the initial state", () => {
11
+ expect(reducer(undefined, {})).toEqual(initialState);
12
+ });
13
+
14
+ it("should handle GET_ALL_TEMPLATES_REQUEST", () => {
15
+ const action = {
16
+ type: types.GET_ALL_TEMPLATES_REQUEST,
17
+ };
18
+ expect(reducer(initialState, action).toJS()).toEqual({
19
+ ...initialState.toJS(),
20
+ getAllTemplatesInProgress: true,
21
+ });
22
+ });
23
+
24
+ it("should handle GET_ALL_TEMPLATES_SUCCESS", () => {
25
+ const action = {
26
+ type: types.GET_ALL_TEMPLATES_SUCCESS,
27
+ data: mockData.getAllTemplatesListSuccess,
28
+ };
29
+ const expectedResult = {
30
+ ...initialState.toJS(),
31
+ getAllTemplatesInProgress: false,
32
+ templateError: {},
33
+ weCRMtemplates: [],
34
+ templates: [undefined],
35
+ isSearch: undefined,
36
+ };
37
+ expect(reducer(initialState, action).toJS()).toEqual(expectedResult);
38
+ });
39
+
40
+ it("should handle GET_ALL_TEMPLATES_FAILURE", () => {
41
+ const action = {
42
+ type: types.GET_ALL_TEMPLATES_FAILURE,
43
+ };
44
+ expect(reducer(initialState, action).toJS()).toEqual({
45
+ ...initialState.toJS(),
46
+ getAllTemplatesInProgress: false,
47
+ templateError: undefined,
48
+ });
49
+ });
50
+ });
@@ -7,7 +7,9 @@ import * as cdnUtils from '../../../utils/cdnTransformation';
7
7
 
8
8
  import {
9
9
  getCdnTransformationConfig,
10
- watchGetCdnTransformationConfig
10
+ getAllTemplates,
11
+ watchGetCdnTransformationConfig,
12
+ watchGetAllTemplates,
11
13
  } from '../sagas';
12
14
 
13
15
  import * as mockData from './mockData';
@@ -73,4 +75,40 @@ describe('watchForGetJourneyList saga', () => {
73
75
  takeLatest(types.GET_CDN_TRANSFORMATION_CONFIG_REQUEST, getCdnTransformationConfig),
74
76
  );
75
77
  });
76
- });
78
+ });
79
+
80
+ describe('templateList saga', () => {
81
+ it('handle valid response from api', () => {
82
+ expectSaga(getAllTemplates, mockData.getAllTemplatesListSuccess)
83
+ .provide([[matchers.call.fn(api.getAllTemplates, mockData.getAllTemplatesListSuccess)]])
84
+ .put({
85
+ type: types.GET_ALL_TEMPLATES_SUCCESS,
86
+ res: mockData.getAllTemplatesListSuccess,
87
+ })
88
+ .run();
89
+ });
90
+
91
+ it('handles error thrown from api', () => {
92
+ expectSaga(getAllTemplates, mockData.getAllTemplatesListFailure)
93
+ .provide([
94
+ [
95
+ call(api.getAllTemplates),
96
+ mockData.getAllTemplatesListFailure,
97
+ ],
98
+ ])
99
+ .put({
100
+ type: types.GET_ALL_TEMPLATES_FAILURE,
101
+ res: mockData.getAllTemplatesListFailure,
102
+ })
103
+ .run();
104
+ });
105
+ });
106
+
107
+ describe('watchForTemplates saga', () => {
108
+ const generator = watchGetAllTemplates();
109
+ it('should call watchers functions', () => {
110
+ expect(generator.next().value).toEqual(
111
+ takeLatest(types.GET_ALL_TEMPLATES_REQUEST, getAllTemplates),
112
+ );
113
+ });
114
+ });
@@ -0,0 +1,17 @@
1
+ import { fromJS } from "immutable";
2
+ import { makeSelectTemplatesResponse } from "../selectors";
3
+
4
+ describe("Template selectors", () => {
5
+ const mockState = fromJS({
6
+ templates: [],
7
+ });
8
+
9
+ describe("makeSelectTemplatesResponse selector", () => {
10
+ it("should return the correct substate", () => {
11
+ const selected = makeSelectTemplatesResponse().resultFunc(
12
+ mockState.get("templates")
13
+ );
14
+ expect(selected).toEqual(mockState.getIn(["templates", "templates"]));
15
+ });
16
+ });
17
+ });
@@ -29,7 +29,7 @@ import FTP from '../FTP';
29
29
  import Gallery from '../Assets/Gallery';
30
30
  import withStyles from '../../hoc/withStyles';
31
31
  import styles, { CapTabStyle } from './TemplatesV2.style';
32
- import { CREATIVES_UI_VIEW, LOYALTY, WHATSAPP, RCS, LINE, EMAIL, ASSETS, JP_LOCALE_HIDE_FEATURE } from '../App/constants';
32
+ import { CREATIVES_UI_VIEW, LOYALTY, WHATSAPP, RCS, LINE, EMAIL, ASSETS, JP_LOCALE_HIDE_FEATURE, ZALO } from '../App/constants';
33
33
  import AccessForbidden from '../../v2Components/AccessForbidden';
34
34
  import { getObjFromQueryParams } from '../../utils/v2common';
35
35
  import { selectCurrentOrgDetails } from "../../v2Containers/Cap/selectors";
@@ -67,6 +67,7 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
67
67
  viber: {content: <></>, tab: intl.formatMessage(messages.viber), key: 'viber'},
68
68
  facebook: {content: <div></div>, tab: intl.formatMessage(messages.facebook), key: 'facebook'},
69
69
  whatsapp: { content: <></>, tab: intl.formatMessage(messages.whatsapp), key: WHATSAPP },
70
+ zalo: { content: <div></div>, tab: intl.formatMessage(messages.zalo), key: ZALO },
70
71
  };
71
72
  let filteredPanes = Object.keys(defaultPanes)
72
73
  .filter((key) => !channelsToHide.includes(key)).reduce((obj = [], key) => {
@@ -148,7 +149,6 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
148
149
 
149
150
  componentDidMount() {
150
151
  const queryItems = getObjFromQueryParams(location.search);
151
-
152
152
  if (queryItems.channel === WHATSAPP) {
153
153
  this.channelChange(WHATSAPP);
154
154
  }
@@ -78,4 +78,8 @@ export default defineMessages({
78
78
  id: `creatives.containersV2.TemplatesV2.facebookDisableinfo`,
79
79
  defaultMessage: 'Please integrate Facebook page ID & page name to enable this option.',
80
80
  },
81
+ zalo: {
82
+ id: `creatives.containersV2.TemplatesV2.zalo`,
83
+ defaultMessage: 'Zalo',
84
+ },
81
85
  });
@@ -0,0 +1,17 @@
1
+ import {
2
+ ZALO_TEMPLATE_INFO_REQUEST,
3
+ ZALO_TEMPLATE_PREVIEW_RESET,
4
+ } from "./constants";
5
+
6
+ export function getTemplateInfoById(payload) {
7
+ return {
8
+ type: ZALO_TEMPLATE_INFO_REQUEST,
9
+ payload,
10
+ };
11
+ }
12
+
13
+ export function resetTemplateInfoData() {
14
+ return {
15
+ type: ZALO_TEMPLATE_PREVIEW_RESET,
16
+ };
17
+ }
@@ -0,0 +1,57 @@
1
+ import React from 'react';
2
+ import { FormattedMessage } from 'react-intl';
3
+ import messages from './messages';
4
+ export const SUCCESS_ALERT = 'success';
5
+ export const WARNING_ALERT = 'warning';
6
+ export const ERROR_ALERT = 'error';
7
+ export const SUCCESS = 'SUCCESS';
8
+ export const REQUEST = 'REQUEST';
9
+ export const ERROR = 'ERROR';
10
+ export const STRING = 'STRING';
11
+ export const NUMBER = 'NUMBER';
12
+ export const DATE = 'DATE';
13
+ export const ENABLE = 'ENABLE';
14
+
15
+ export const TAG = 'TAG';
16
+ export const EMBEDDED = 'embedded';
17
+ export const DEFAULT = 'default';
18
+ export const LIBRARY = 'library';
19
+ export const FULL = 'full';
20
+ export const ALL = 'all';
21
+
22
+ const prefix = 'app/v2Containers/Zalo';
23
+ export const ZALO_TEMPLATE_INFO_REQUEST = `${prefix}/ZALO_TEMPLATE_INFO_REQUEST`;
24
+ export const ZALO_TEMPLATE_INFO_SUCCESS = `${prefix}/ZALO_TEMPLATE_INFO_SUCCESS`;
25
+ export const ZALO_TEMPLATE_INFO_ERROR = `${prefix}/ZALO_TEMPLATE_INFO_ERROR`;
26
+ export const ZALO_TEMPLATE_PREVIEW_RESET = `${prefix}/ZALO_TEMPLATE_PREVIEW_RESET`;
27
+ export const ZALO_TEMPLATE_PREVIEW_INFO = `${prefix}/ZALO_TEMPLATE_PREVIEW_INFO`;
28
+
29
+ export const ZALO_STATUSES = {
30
+ PENDING_REVIEW: 'PENDING_REVIEW',
31
+ REJECT: 'REJECT',
32
+ ENABLE: 'ENABLE',
33
+ DISABLE: 'DISABLE',
34
+ };
35
+
36
+ export const ZALO_STATUS_OPTIONS = [
37
+ {
38
+ key: 'enable',
39
+ value: ZALO_STATUSES.ENABLE,
40
+ label: <FormattedMessage {...messages.ENABLE_STATUS} />,
41
+ },
42
+ {
43
+ key: 'reject',
44
+ value: ZALO_STATUSES.REJECT,
45
+ label: <FormattedMessage {...messages.REJECT_STATUS} />,
46
+ },
47
+ {
48
+ key: 'disable',
49
+ value: ZALO_STATUSES.DISABLE,
50
+ label: <FormattedMessage {...messages.DISABLE_STATUS} />,
51
+ },
52
+ {
53
+ key: 'reviewPending',
54
+ value: ZALO_STATUSES.PENDING_REVIEW,
55
+ label: <FormattedMessage {...messages.PENDING_REVIEW_STATUS} />,
56
+ },
57
+ ];