@capillarytech/creatives-library 8.0.346 → 8.0.347

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/package.json +1 -1
  2. package/services/api.js +20 -0
  3. package/services/tests/api.test.js +59 -0
  4. package/utils/tests/v2Common.test.js +46 -1
  5. package/utils/v2common.js +18 -0
  6. package/v2Components/CapCustomSkeleton/index.js +1 -1
  7. package/v2Components/CapCustomSkeleton/tests/__snapshots__/index.test.js.snap +12 -12
  8. package/v2Containers/Assets/images/archive_Empty_Illustration.svg +9 -0
  9. package/v2Containers/CreativesContainer/SlideBoxFooter.js +3 -1
  10. package/v2Containers/CreativesContainer/index.js +5 -0
  11. package/v2Containers/CreativesContainer/messages.js +4 -0
  12. package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +3 -0
  13. package/v2Containers/Templates/ChannelTypeIllustration.js +23 -6
  14. package/v2Containers/Templates/_templates.scss +179 -24
  15. package/v2Containers/Templates/actions.js +44 -0
  16. package/v2Containers/Templates/constants.js +23 -0
  17. package/v2Containers/Templates/index.js +378 -58
  18. package/v2Containers/Templates/messages.js +88 -0
  19. package/v2Containers/Templates/reducer.js +84 -1
  20. package/v2Containers/Templates/sagas.js +64 -0
  21. package/v2Containers/Templates/selectors.js +12 -0
  22. package/v2Containers/Templates/tests/ChannelTypeIllustration.test.js +12 -0
  23. package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +1345 -1122
  24. package/v2Containers/Templates/tests/index.test.js +6 -0
  25. package/v2Containers/Templates/tests/reducer.test.js +178 -0
  26. package/v2Containers/Templates/tests/sagas.test.js +390 -8
  27. package/v2Containers/Templates/tests/selector.test.js +32 -0
  28. package/v2Containers/TemplatesV2/TemplatesV2.style.js +1 -1
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@capillarytech/creatives-library",
3
3
  "author": "meharaj",
4
- "version": "8.0.346",
4
+ "version": "8.0.347",
5
5
  "description": "Capillary creatives ui",
6
6
  "main": "./index.js",
7
7
  "module": "./index.es.js",
package/services/api.js CHANGED
@@ -361,6 +361,26 @@ export const deleteTemplate = ({channel, id}) => {
361
361
  //return API.deleteResource(url);
362
362
  };
363
363
 
364
+ export const archiveTemplate = ({ channel, id }) => {
365
+ const url = `${API_ENDPOINT}/templates/archive/${id}/${channel}`;
366
+ return request(url, getAPICallObject('PUT'));
367
+ };
368
+
369
+ export const unarchiveTemplate = ({ channel, id }) => {
370
+ const url = `${API_ENDPOINT}/templates/unarchive/${id}/${channel}`;
371
+ return request(url, getAPICallObject('PUT'));
372
+ };
373
+
374
+ export const bulkArchiveTemplates = ({ channel, ids }) => {
375
+ const url = `${API_ENDPOINT}/templates/archive/bulk/${channel}`;
376
+ return request(url, getAPICallObject('PUT', { ids }));
377
+ };
378
+
379
+ export const bulkUnarchiveTemplates = ({ channel, ids }) => {
380
+ const url = `${API_ENDPOINT}/templates/unarchive/bulk/${channel}`;
381
+ return request(url, getAPICallObject('PUT', { ids }));
382
+ };
383
+
364
384
  export const deleteRcsTemplate = ({ templateName }) => {
365
385
  const url = `${API_ENDPOINT}/templates/${templateName}/RCS`;
366
386
  return request(url, getAPICallObject('DELETE'))
@@ -1086,3 +1086,62 @@ describe('createTestCustomer', () => {
1086
1086
  expect(lastCall[1].body).toBe(JSON.stringify(payload));
1087
1087
  });
1088
1088
  });
1089
+
1090
+ import {
1091
+ archiveTemplate,
1092
+ unarchiveTemplate,
1093
+ bulkArchiveTemplates,
1094
+ bulkUnarchiveTemplates,
1095
+ } from '../api';
1096
+
1097
+ describe('archiveTemplate', () => {
1098
+ beforeEach(() => {
1099
+ global.fetch = jest.fn().mockReturnValue(Promise.resolve({ json: () => Promise.resolve({}) }));
1100
+ });
1101
+
1102
+ it('should call PUT on archive endpoint', () => {
1103
+ archiveTemplate({ channel: 'EMAIL', id: 'id123' });
1104
+ expect(global.fetch).toHaveBeenCalled();
1105
+ const lastCall = global.fetch.mock.calls[global.fetch.mock.calls.length - 1];
1106
+ expect(lastCall[1].method).toBe('PUT');
1107
+ });
1108
+ });
1109
+
1110
+ describe('unarchiveTemplate', () => {
1111
+ beforeEach(() => {
1112
+ global.fetch = jest.fn().mockReturnValue(Promise.resolve({ json: () => Promise.resolve({}) }));
1113
+ });
1114
+
1115
+ it('should call PUT on unarchive endpoint', () => {
1116
+ unarchiveTemplate({ channel: 'EMAIL', id: 'id123' });
1117
+ expect(global.fetch).toHaveBeenCalled();
1118
+ const lastCall = global.fetch.mock.calls[global.fetch.mock.calls.length - 1];
1119
+ expect(lastCall[1].method).toBe('PUT');
1120
+ });
1121
+ });
1122
+
1123
+ describe('bulkArchiveTemplates', () => {
1124
+ beforeEach(() => {
1125
+ global.fetch = jest.fn().mockReturnValue(Promise.resolve({ json: () => Promise.resolve({}) }));
1126
+ });
1127
+
1128
+ it('should call PUT on bulk archive endpoint with ids', () => {
1129
+ bulkArchiveTemplates({ channel: 'EMAIL', ids: ['id1', 'id2'] });
1130
+ expect(global.fetch).toHaveBeenCalled();
1131
+ const lastCall = global.fetch.mock.calls[global.fetch.mock.calls.length - 1];
1132
+ expect(lastCall[1].method).toBe('PUT');
1133
+ });
1134
+ });
1135
+
1136
+ describe('bulkUnarchiveTemplates', () => {
1137
+ beforeEach(() => {
1138
+ global.fetch = jest.fn().mockReturnValue(Promise.resolve({ json: () => Promise.resolve({}) }));
1139
+ });
1140
+
1141
+ it('should call PUT on bulk unarchive endpoint with ids', () => {
1142
+ bulkUnarchiveTemplates({ channel: 'EMAIL', ids: ['id1', 'id2'] });
1143
+ expect(global.fetch).toHaveBeenCalled();
1144
+ const lastCall = global.fetch.mock.calls[global.fetch.mock.calls.length - 1];
1145
+ expect(lastCall[1].method).toBe('PUT');
1146
+ });
1147
+ });
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
- import { getObjFromQueryParams } from '../v2common';
2
+ import { shallow } from 'enzyme';
3
+ import { getObjFromQueryParams, buildTemplateNameDescription } from '../v2common';
3
4
 
4
5
  describe('Test v2common container', () => {
5
6
  it('test getObjFromQueryParams', () => {
@@ -9,3 +10,47 @@ describe('Test v2common container', () => {
9
10
  });
10
11
  });
11
12
  });
13
+
14
+ describe('buildTemplateNameDescription', () => {
15
+ it('returns undefined when templateName is empty string', () => {
16
+ expect(buildTemplateNameDescription('Template name', '')).toBeUndefined();
17
+ });
18
+
19
+ it('returns undefined when templateName is null', () => {
20
+ expect(buildTemplateNameDescription('Template name', null)).toBeUndefined();
21
+ });
22
+
23
+ it('returns undefined when templateName is undefined', () => {
24
+ expect(buildTemplateNameDescription('Template name', undefined)).toBeUndefined();
25
+ });
26
+
27
+ it('renders a span wrapper when templateName is provided', () => {
28
+ const result = buildTemplateNameDescription('Template name', 'Welcome 01');
29
+ const wrapper = shallow(result);
30
+ expect(wrapper.type()).toBe('span');
31
+ });
32
+
33
+ it('renders label text in the first CapLabelInline with correct class', () => {
34
+ const result = buildTemplateNameDescription('Template name', 'Welcome 01');
35
+ const wrapper = shallow(result);
36
+ const firstLabel = wrapper.childAt(0);
37
+ expect(firstLabel.prop('className')).toBe('notification-template-label');
38
+ expect(firstLabel.prop('children')).toBe('Template name');
39
+ });
40
+
41
+ it('renders template name in the second CapLabelInline with correct class', () => {
42
+ const result = buildTemplateNameDescription('Template name', 'Welcome 01');
43
+ const wrapper = shallow(result);
44
+ const secondLabel = wrapper.childAt(1);
45
+ expect(secondLabel.prop('className')).toBe('notification-template-name');
46
+ expect(secondLabel.prop('children')).toBe('Welcome 01');
47
+ });
48
+
49
+ it('both CapLabelInline elements have type="label1"', () => {
50
+ const result = buildTemplateNameDescription('Template name', 'Welcome 01');
51
+ const wrapper = shallow(result);
52
+ wrapper.children().forEach((node) => {
53
+ expect(node.prop('type')).toBe('label1');
54
+ });
55
+ });
56
+ });
package/utils/v2common.js CHANGED
@@ -1,3 +1,21 @@
1
+ import React from 'react';
2
+ import CapLabel from '@capillarytech/cap-ui-library/CapLabel';
3
+
4
+ /**
5
+ * Builds a JSX description for template archive/unarchive notifications.
6
+ * @param {string} labelText - Localised label (e.g. "Template name ")
7
+ * @param {string} templateName - The template name to display
8
+ */
9
+ export const buildTemplateNameDescription = (labelText, templateName) => (
10
+ templateName
11
+ ? (
12
+ <span>
13
+ <CapLabel.CapLabelInline type="label1" className="notification-template-label">{labelText}</CapLabel.CapLabelInline>
14
+ <CapLabel.CapLabelInline type="label1" className="notification-template-name">{templateName}</CapLabel.CapLabelInline>
15
+ </span>
16
+ )
17
+ : undefined
18
+ );
1
19
 
2
20
  // returns query items as obj when query string is passed
3
21
  /**
@@ -28,7 +28,7 @@ export default function CapCustomSkeleton(props) {
28
28
  xs={24}
29
29
  sm={12}
30
30
  md={8}
31
- lg={6}
31
+ lg={8}
32
32
  >
33
33
  <CapSkeleton
34
34
  active
@@ -20,7 +20,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
20
20
  >
21
21
  <CapColumn
22
22
  key="0"
23
- lg={6}
23
+ lg={8}
24
24
  md={8}
25
25
  sm={12}
26
26
  xs={24}
@@ -40,7 +40,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
40
40
  </CapColumn>
41
41
  <CapColumn
42
42
  key="1"
43
- lg={6}
43
+ lg={8}
44
44
  md={8}
45
45
  sm={12}
46
46
  xs={24}
@@ -60,7 +60,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
60
60
  </CapColumn>
61
61
  <CapColumn
62
62
  key="2"
63
- lg={6}
63
+ lg={8}
64
64
  md={8}
65
65
  sm={12}
66
66
  xs={24}
@@ -80,7 +80,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
80
80
  </CapColumn>
81
81
  <CapColumn
82
82
  key="3"
83
- lg={6}
83
+ lg={8}
84
84
  md={8}
85
85
  sm={12}
86
86
  xs={24}
@@ -100,7 +100,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
100
100
  </CapColumn>
101
101
  <CapColumn
102
102
  key="4"
103
- lg={6}
103
+ lg={8}
104
104
  md={8}
105
105
  sm={12}
106
106
  xs={24}
@@ -120,7 +120,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
120
120
  </CapColumn>
121
121
  <CapColumn
122
122
  key="5"
123
- lg={6}
123
+ lg={8}
124
124
  md={8}
125
125
  sm={12}
126
126
  xs={24}
@@ -140,7 +140,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
140
140
  </CapColumn>
141
141
  <CapColumn
142
142
  key="6"
143
- lg={6}
143
+ lg={8}
144
144
  md={8}
145
145
  sm={12}
146
146
  xs={24}
@@ -160,7 +160,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
160
160
  </CapColumn>
161
161
  <CapColumn
162
162
  key="7"
163
- lg={6}
163
+ lg={8}
164
164
  md={8}
165
165
  sm={12}
166
166
  xs={24}
@@ -180,7 +180,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
180
180
  </CapColumn>
181
181
  <CapColumn
182
182
  key="8"
183
- lg={6}
183
+ lg={8}
184
184
  md={8}
185
185
  sm={12}
186
186
  xs={24}
@@ -200,7 +200,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
200
200
  </CapColumn>
201
201
  <CapColumn
202
202
  key="9"
203
- lg={6}
203
+ lg={8}
204
204
  md={8}
205
205
  sm={12}
206
206
  xs={24}
@@ -220,7 +220,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
220
220
  </CapColumn>
221
221
  <CapColumn
222
222
  key="10"
223
- lg={6}
223
+ lg={8}
224
224
  md={8}
225
225
  sm={12}
226
226
  xs={24}
@@ -240,7 +240,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
240
240
  </CapColumn>
241
241
  <CapColumn
242
242
  key="11"
243
- lg={6}
243
+ lg={8}
244
244
  md={8}
245
245
  sm={12}
246
246
  xs={24}