@capillarytech/creatives-library 7.10.50 → 7.10.52

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 (28) hide show
  1. package/containers/Assets/Gallery/tests/__snapshots__/reducer.test.js.snap +2 -0
  2. package/containers/Email/index.js +3 -2
  3. package/package.json +1 -1
  4. package/utils/v2common.js +0 -13
  5. package/v2Components/TemplatePreview/_templatePreview.scss +17 -9
  6. package/v2Components/TemplatePreview/assets/images/whatsapp_mobile_android.svg +1 -2041
  7. package/v2Components/TemplatePreview/index.js +66 -41
  8. package/v2Components/TemplatePreview/messages.js +4 -0
  9. package/v2Components/WhatsappStatusContainer/_whatsappStatusContainer.scss +13 -0
  10. package/v2Components/WhatsappStatusContainer/index.js +58 -0
  11. package/v2Containers/Assets/Gallery/tests/__snapshots__/reducer.test.js.snap +2 -0
  12. package/v2Containers/Cap/messages.js +8 -0
  13. package/v2Containers/CreativesContainer/SlideBoxContent.js +9 -9
  14. package/v2Containers/CreativesContainer/SlideBoxHeader.js +2 -1
  15. package/v2Containers/CreativesContainer/index.js +24 -46
  16. package/v2Containers/Email/index.js +3 -1
  17. package/v2Containers/Templates/_templates.scss +19 -45
  18. package/v2Containers/Templates/actions.js +10 -16
  19. package/v2Containers/Templates/index.js +79 -89
  20. package/v2Containers/Templates/messages.js +8 -4
  21. package/v2Containers/TemplatesV2/index.js +4 -11
  22. package/v2Containers/Whatsapp/index.js +20 -87
  23. package/v2Containers/Whatsapp/index.scss +53 -54
  24. package/v2Containers/Whatsapp/messages.js +0 -17
  25. package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +34190 -6356
  26. package/v2Containers/Whatsapp/tests/index.test.js +51 -13
  27. package/v2Containers/Whatsapp/tests/mockData.js +120 -1
  28. package/v2Containers/Whatsapp/utils.js +0 -47
@@ -15,35 +15,56 @@ describe('Creatives Whatsapp test/>', () => {
15
15
  let renderedComponent;
16
16
  const createWhatsappTemplate = jest.fn();
17
17
  const clearCreateResponse = jest.fn();
18
+ const getTemplateDetails = jest.fn();
19
+ const resetEditTemplate = jest.fn();
20
+ const fetchSchemaForEntity = jest.fn();
18
21
  const handleClose = jest.fn();
19
22
  const onCreateComplete = jest.fn();
20
23
  const formatMessage = jest.fn();
21
24
  const location = mockData.location;
22
- beforeEach(() => {
25
+ const params = {
26
+ id: mockData.editData1.templateDetails._id,
27
+ };
28
+ const editData1 = mockData.editData1;
29
+ const editData2 = mockData.editData2;
30
+ const editData3 = mockData.editData3;
31
+ const accountData = mockData.accountData;
32
+
33
+ const renderHelper = (args) => {
23
34
  renderedComponent = mountWithIntl(
24
35
  <Provider store={store}>
25
36
  <Whatsapp
26
- actions={{ createWhatsappTemplate, clearCreateResponse }}
37
+ actions={{
38
+ createWhatsappTemplate,
39
+ clearCreateResponse,
40
+ getTemplateDetails,
41
+ resetEditTemplate,
42
+ }}
43
+ globalActions={{ fetchSchemaForEntity }}
27
44
  onCreateComplete={onCreateComplete}
28
45
  handleClose={handleClose}
46
+ params={args.params}
47
+ editData={args.editData}
48
+ accountData={accountData}
29
49
  location={location}
30
50
  intl={{ formatMessage }}
31
51
  isFullMode={true}
32
- selectedWeChatAccount={{
33
- name: 'Test Account',
34
- configs: { accessToken: '123' },
35
- sourceAccountIdentifier: 'A123',
36
- }}
52
+ isEditFlow={args.isEditFlow || false}
53
+ loadingTags={args.loadingTags}
54
+ metaEntities={[]}
55
+ getDefaultTags={true}
37
56
  />
38
57
  </Provider>,
39
58
  );
40
- });
59
+ }
41
60
 
42
- it('should render', () => {
61
+ it('should render create mode', () => {
62
+ renderHelper({});
43
63
  expect(renderedComponent).toMatchSnapshot();
44
64
  });
45
65
 
46
66
  it('template name change', () => {
67
+ renderHelper({});
47
68
  const templateNameRenderHelper = (val) => {
48
69
  let event = { target: { value: val } };
49
70
  renderedComponent
@@ -60,6 +81,7 @@ describe('Creatives Whatsapp test/>', () => {
60
81
  });
61
82
 
62
83
  it('template category change', () => {
84
+ renderHelper({});
63
85
  renderedComponent
64
86
  .find('CapSelect#select-whatsapp-category')
65
87
  .props()
@@ -68,6 +90,7 @@ describe('Creatives Whatsapp test/>', () => {
68
90
  });
69
91
 
70
92
  it('template message', () => {
93
+ renderHelper({});
71
94
  const templateMessageRenderHelper = (val) => {
72
95
  let event = { target: { value: val } };
73
96
  renderedComponent
@@ -90,25 +113,26 @@ describe('Creatives Whatsapp test/>', () => {
90
113
  });
91
114
 
92
115
  it('send for approval should be disabled', () => {
116
+ renderHelper({});
93
117
  const sendForApprovalBtn = renderedComponent
94
118
  .find('CapButton.whatsapp-create-btn')
95
119
  .props();
96
- expect(sendForApprovalBtn.children.props.defaultMessage).toBe(
97
- 'Send for approval',
98
- );
99
120
  expect(sendForApprovalBtn.disabled).toBe(true);
121
+ sendForApprovalBtn.onClick();
122
+ expect(createWhatsappTemplate).toHaveBeenCalled();
100
123
  });
101
124
 
102
125
  it('Cancel Btn', () => {
126
+ renderHelper({});
103
127
  const cancelBtn = renderedComponent
104
128
  .find('CapButton.whatsapp-cancel-btn')
105
129
  .props();
106
- expect(cancelBtn.children.props.defaultMessage).toBe('Cancel');
107
130
  cancelBtn.onClick();
108
131
  expect(renderedComponent).toMatchSnapshot();
109
132
  });
110
133
 
111
134
  it('set all valid values and send for approval', () => {
135
+ renderHelper({});
112
136
  let event = { target: { value: 'template_name' } };
113
137
  createWhatsappTemplate.mockImplementation((obj, callback) => {
114
138
  callback();
@@ -127,6 +151,20 @@ describe('Creatives Whatsapp test/>', () => {
127
151
  .at(1)
128
152
  .simulate('change', event);
129
153
  renderedComponent.find('CapButton.whatsapp-create-btn').props().onClick();
154
+ });
155
+
156
+ it('should render edit mode in various cases', () => {
157
+ let event = { target: { value: '5454', id: '{{1}}_1' } };
158
+ renderHelper({ params, editData: editData1, isEditFlow: true, loadingTags: false });
159
+ expect(renderedComponent).toMatchSnapshot();
160
+ renderHelper({ params, editData: editData2, isEditFlow: true, loadingTags: false });
161
+ expect(renderedComponent).toMatchSnapshot();
162
+ renderHelper({ params, editData: editData3, isEditFlow: true, loadingTags: false });
163
+ expect(renderedComponent).toMatchSnapshot();
164
+ renderHelper({ params, editData: editData1, isEditFlow: true, loadingTags: false });
165
+ renderedComponent.find('textarea.TextArea__StyledTextArea-sc-177dfyt-2')
166
+ .at(1)
167
+ .simulate('change', event);
130
168
  expect(renderedComponent).toMatchSnapshot();
131
169
  });
132
170
  });
@@ -1,6 +1,125 @@
1
1
  export const mockData = {
2
+ accountData: {
3
+ selectedWhatsappAccount: {
4
+ name: 'WhatsppTest',
5
+ sourceAccountIdentifier: 'AC41030cebba9e2f1ce37c78235da0ee18',
6
+ configs: { accessToken: '4676323eb5d1f975b0987070c03a8efc' },
7
+ },
8
+ },
9
+ editData1: {
10
+ templateDetails: {
11
+ "_id": "62034b4683c75608cf2404ec",
12
+ "name": "points_update",
13
+ "type": "WHATSAPP",
14
+ "versions": {
15
+ "history": [],
16
+ "base": {
17
+ "content": {
18
+ "whatsapp": {
19
+ "status": "approved",
20
+ "templateId": "HT9bb4d61eea1699d2dbcaecd1cb558345",
21
+ "accountName": "WhatsppTest",
22
+ "accessToken": "4676323eb5d1f975b0987070c03a8efc",
23
+ "accountId": "AC41030cebba9e2f1ce37c78235da0ee18",
24
+ "mediaType": "text",
25
+ "languages": [
26
+ {
27
+ "content": "$'Dear Customer, your{{1}} points are about to expire. Redeem before {{2}} at nearest Vishal Mega Mart and SHOP FOR FREE!\nT&C\nClick {{3}} to unsubscribe'",
28
+ "language": "en"
29
+ }
30
+ ],
31
+ "category": "ACCOUNT_UPDATE",
32
+ "rejection_reason": null,
33
+ "varMapped": {
34
+ '{{1}}_1': '500',
35
+ '{{2}}_3': 'tomorrow',
36
+ }
37
+ }
38
+ }
39
+ }
40
+ },
41
+ "isActive": true,
42
+ "orgId": 50146,
43
+ "createdBy": "15000449",
44
+ "updatedBy": "15000449",
45
+ "createdAt": "2022-02-09T05:04:06.579Z",
46
+ "updatedAt": "2022-02-09T05:04:06.579Z"
47
+ },
48
+ },
49
+ editData2: {
50
+ templateDetails: {
51
+ "_id": "62034b4683c75608cf2404ec",
52
+ "name": "points_update",
53
+ "type": "WHATSAPP",
54
+ "versions": {
55
+ "history": [],
56
+ "base": {
57
+ "content": {
58
+ "whatsapp": {
59
+ "status": "rejected",
60
+ "templateId": "HT9bb4d61eea1699d2dbcaecd1cb558345",
61
+ "accountName": "WhatsppTest",
62
+ "accessToken": "4676323eb5d1f975b0987070c03a8efc",
63
+ "accountId": "AC41030cebba9e2f1ce37c78235da0ee18",
64
+ "mediaType": "text",
65
+ "languages": [
66
+ {
67
+ "content": "$'Dear Customer, your{{1}} points are about to expire. Redeem before {{2}} at nearest Vishal Mega Mart and SHOP FOR FREE!\nT&C\nClick {{3}} to unsubscribe'",
68
+ "language": "en"
69
+ }
70
+ ],
71
+ "category": "ACCOUNT_UPDATE",
72
+ "rejection_reason": 'INVALID_FORMAT'
73
+ }
74
+ }
75
+ }
76
+ },
77
+ "isActive": true,
78
+ "orgId": 50146,
79
+ "createdBy": "15000449",
80
+ "updatedBy": "15000449",
81
+ "createdAt": "2022-02-09T05:04:06.579Z",
82
+ "updatedAt": "2022-02-09T05:04:06.579Z"
83
+ },
84
+ },
85
+ editData3: {
86
+ templateDetails: {
87
+ "_id": "62034b4683c75608cf2404ec",
88
+ "name": "points_update",
89
+ "type": "WHATSAPP",
90
+ "versions": {
91
+ "history": [],
92
+ "base": {
93
+ "content": {
94
+ "whatsapp": {
95
+ "status": "rejected",
96
+ "templateId": "HT9bb4d61eea1699d2dbcaecd1cb558345",
97
+ "accountName": "WhatsppTest",
98
+ "accessToken": "4676323eb5d1f975b0987070c03a8efc",
99
+ "accountId": "AC41030cebba9e2f1ce37c78235da0ee18",
100
+ "mediaType": "text",
101
+ "languages": [
102
+ {
103
+ "content": "$'Dear Customer, your{{1}} points are about to expire. Redeem before {{2}} at nearest Vishal Mega Mart and SHOP FOR FREE!\nT&C\nClick {{3}} to unsubscribe'",
104
+ "language": "en"
105
+ }
106
+ ],
107
+ "category": "ACCOUNT_UPDATE",
108
+ "rejection_reason": 'TAG_CONTENT_MISMATCH'
109
+ }
110
+ }
111
+ }
112
+ },
113
+ "isActive": true,
114
+ "orgId": 50146,
115
+ "createdBy": "15000449",
116
+ "updatedBy": "15000449",
117
+ "createdAt": "2022-02-09T05:04:06.579Z",
118
+ "updatedAt": "2022-02-09T05:04:06.579Z"
119
+ },
120
+ },
2
121
  location: {
3
- pathname: '/whatsapp',
122
+ pathname: '/whatsapp/edit',
4
123
  query: {
5
124
  type: false,
6
125
  module: 'default',
@@ -1,9 +1,6 @@
1
1
  import React from 'react';
2
- import { CapRow, CapStatus, CapColoredTag } from '@capillarytech/cap-ui-library';
3
2
  import { WHATSAPP } from '../CreativesContainer/constants';
4
3
  import {
5
- CATEGORY as WHATSAPP_CATEGORY,
6
- STATUS as WHATSAPP_STATUS,
7
4
  STATUS_OPTIONS,
8
5
  CATEGORY_OPTIONS,
9
6
  WHATSAPP_STATUSES,
@@ -42,48 +39,4 @@ export const getWhatsappStatus = (status) => {
42
39
  status = WHATSAPP_STATUSES.awaitingApproval;
43
40
  }
44
41
  return STATUS_OPTIONS.find((obj) => obj.value === status);
45
- }
46
-
47
- export const getWhatsappStatusContainer = (template) => {
48
- const {
49
- versions: {
50
- base: {
51
- content: {
52
- [WHATSAPP.toLowerCase()]: {
53
- [WHATSAPP_STATUS]: status,
54
- [WHATSAPP_CATEGORY]: category,
55
- } = {},
56
- } = {},
57
- } = {},
58
- } = {},
59
- } = template;
60
-
61
- const categoryObj = getWhatsappCategory(category) || {};
62
- const {
63
- label: categoryLabel,
64
- tagColor: categoryTagColor,
65
- tagTextColor: categoryTextColor,
66
- } = categoryObj;
67
- return (
68
- <CapRow type="flex" align="middle" className="whatsapp-status-container">
69
- <CapStatus
70
- type={status}
71
- text={getWhatsappStatus(status)?.label}
72
- labelType="label3"
73
- />
74
- {
75
- categoryLabel ? (
76
- <CapColoredTag
77
- tagColor={categoryTagColor}
78
- tagTextColor={categoryTextColor}
79
- tagHeight="20px"
80
- tagFontSize="12px"
81
- className="whatsapp-category-tag"
82
- >
83
- {categoryLabel}
84
- </CapColoredTag>
85
- ) : null
86
- }
87
- </CapRow>
88
- )
89
42
  }