@capillarytech/creatives-library 7.13.5 → 7.13.8

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 (34) hide show
  1. package/package.json +2 -1
  2. package/routes.js +1 -0
  3. package/services/api.js +6 -1
  4. package/utils/cdnTransformation.js +416 -0
  5. package/utils/tests/__snapshots__/cdnTransformation.test.js.snap +298 -0
  6. package/utils/tests/cdnTransformation.mockdata.js +301 -0
  7. package/utils/tests/cdnTransformation.test.js +287 -0
  8. package/v2Components/FormBuilder/index.js +18 -12
  9. package/v2Components/FormBuilder/tests/index.test.js +41 -0
  10. package/v2Components/FormBuilder/tests/mockData.js +120 -0
  11. package/v2Components/NewCallTask/index.js +3 -1
  12. package/v2Components/NewCallTask/tests/index.test.js +36 -0
  13. package/v2Components/NewCallTask/tests/mockData.js +20 -0
  14. package/v2Containers/CallTask/index.js +4 -2
  15. package/v2Containers/Cap/actions.js +0 -1
  16. package/v2Containers/CreativesContainer/actions.js +1 -1
  17. package/v2Containers/CreativesContainer/index.js +6 -1
  18. package/v2Containers/CreativesContainer/tests/index.test.js +4 -0
  19. package/v2Containers/Email/index.js +4 -1
  20. package/v2Containers/Facebook/Advertisement/index.js +4 -4
  21. package/v2Containers/Line/Container/Image/index.js +5 -4
  22. package/v2Containers/Line/Container/ImageCarousel/index.js +6 -5
  23. package/v2Containers/Line/Container/ImageMap/index.js +2 -1
  24. package/v2Containers/MobilePush/Create/index.js +5 -7
  25. package/v2Containers/MobilePush/Edit/index.js +4 -3
  26. package/v2Containers/MobilePush/initialSchema.js +4 -0
  27. package/v2Containers/Rcs/index.js +2 -1
  28. package/v2Containers/Templates/actions.js +6 -0
  29. package/v2Containers/Templates/constants.js +4 -0
  30. package/v2Containers/Templates/sagas.js +25 -0
  31. package/v2Containers/TemplatesV2/index.js +5 -0
  32. package/v2Containers/Viber/index.js +11 -2
  33. package/v2Containers/WeChat/RichmediaTemplates/Create/index.js +3 -1
  34. package/v2Containers/Whatsapp/index.js +4 -2
@@ -0,0 +1,287 @@
1
+ import * as cdnUtils from "../cdnTransformation";
2
+ import * as mockdata from "./cdnTransformation.mockdata";
3
+
4
+ beforeEach(() => {
5
+ var localStorageMock = (function () {
6
+ var store = {
7
+ CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX: "cdn-cgi/image",
8
+ CREATIVES_S3_BUCKET_PATH: "intouch_creative_assets",
9
+ CREATIVES_CDN_BASE_URL: "https://storage.crm.n.content-cdn.io",
10
+ CREATIVES_CDN_QUALITY_CONFIG:
11
+ '{"EMAIL":75,"RCS":75,"VIBER":75,"WHATSAPP":75,"MOBILE_PUSH":75,"FACEBOOK":75,"LINE":75,"DEFAULT":75}',
12
+ };
13
+ return {
14
+ getItem: function (key) {
15
+ return store[key];
16
+ },
17
+ setItem: function (key, value) {
18
+ store[key] = value.toString();
19
+ },
20
+ clear: function () {
21
+ store = {};
22
+ },
23
+ removeItem: function (key) {
24
+ delete store[key];
25
+ },
26
+ };
27
+ })();
28
+ Object.defineProperty(window, "localStorage", { value: localStorageMock });
29
+ });
30
+
31
+ afterEach(() => {
32
+ localStorage.setItem(
33
+ "CREATIVES_CDN_QUALITY_CONFIG",
34
+ '{"EMAIL":75,"RCS":75,"VIBER":75,"WHATSAPP":75,"MOBILE_PUSH":75,"FACEBOOK":75,"LINE":75,"DEFAULT":75}'
35
+ );
36
+ localStorage.setItem(
37
+ "CREATIVES_S3_BUCKET_PATH", "intouch_creative_assets"
38
+ );
39
+ });
40
+
41
+ describe("cdnTransformationTests", () => {
42
+ describe("getCdnUrl()", () => {
43
+ it("should return s3 url if bucket subfolder doesn't contain intouch_creative_assets", () => {
44
+ const TEST_S3_URL = `https://crm-nightly-new-fileservice.s3.amazonaws.com/test/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
45
+ const GENERATED_CDN_URL = cdnUtils.getCdnUrl({
46
+ url: TEST_S3_URL,
47
+ channelName: "EMAIL",
48
+ });
49
+ expect(GENERATED_CDN_URL).toEqual(TEST_S3_URL);
50
+ });
51
+
52
+ it("should return s3 if channelName is not defined", () => {
53
+ const TEST_S3_URL = `https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
54
+ const GENERATED_CDN_URL = cdnUtils.getCdnUrl({ url: TEST_S3_URL });
55
+ expect(GENERATED_CDN_URL).toEqual(TEST_S3_URL);
56
+ });
57
+
58
+ it("should return s3 if specified channelSubType doesn't exist", () => {
59
+ const TEST_S3_URL = `https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
60
+ const GENERATED_CDN_URL = cdnUtils.getCdnUrl({
61
+ url: TEST_S3_URL,
62
+ channelName: "LINE",
63
+ channelSubType: "ABC",
64
+ });
65
+ expect(GENERATED_CDN_URL).toEqual(TEST_S3_URL);
66
+ });
67
+
68
+ it("Should replace s3 url with cdn url for email when h/w are not provided", () => {
69
+ const TEST_S3_URL = `https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
70
+ const GENERATED_CDN_URL = cdnUtils.getCdnUrl({
71
+ url: TEST_S3_URL,
72
+ channelName: "EMAIL",
73
+ });
74
+ const EXPECTED_CDN_URL = `https://storage.crm.n.content-cdn.io/cdn-cgi/image/format=auto,quality=75,/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
75
+ expect(GENERATED_CDN_URL).toEqual(EXPECTED_CDN_URL);
76
+ });
77
+
78
+ it("Should replace s3 url with cdn url for email when h/w are provided", () => {
79
+ const TEST_S3_URL = `https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
80
+ const GENERATED_CDN_URL = cdnUtils.getCdnUrl({
81
+ url: TEST_S3_URL,
82
+ channelName: "EMAIL",
83
+ height: 100,
84
+ width: 200,
85
+ });
86
+ const EXPECTED_CDN_URL = `https://storage.crm.n.content-cdn.io/cdn-cgi/image/width=200,height=100,format=auto,quality=75,/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
87
+ expect(GENERATED_CDN_URL).toEqual(EXPECTED_CDN_URL);
88
+ });
89
+
90
+ it("Should replace s3 url with cdn url for email when bucket name is other than intouch_creatives_assets in case of prod.", () => {
91
+ localStorage.setItem("CREATIVES_S3_BUCKET_PATH", "fileservice.in/intouch_creative_assets");
92
+ const TEST_S3_URL = `https://crm-nightly-new-fileservice.s3.amazonaws.com/fileservice.in/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
93
+ const GENERATED_CDN_URL = cdnUtils.getCdnUrl({
94
+ url: TEST_S3_URL,
95
+ channelName: "EMAIL",
96
+ height: 100,
97
+ width: 200,
98
+ });
99
+ const EXPECTED_CDN_URL = `https://storage.crm.n.content-cdn.io/cdn-cgi/image/width=200,height=100,format=auto,quality=75,/fileservice.in/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
100
+ expect(GENERATED_CDN_URL).toEqual(EXPECTED_CDN_URL);
101
+ });
102
+
103
+ it("Should replace s3 url with cdn url for email when bucket name is other than intouch_creatives_assets in case of prod. It should remove leading/trailing forward slashes from bucket path", () => {
104
+ localStorage.setItem("CREATIVES_S3_BUCKET_PATH", "/fileservice.in/intouch_creative_assets/");
105
+ const TEST_S3_URL = `https://crm-nightly-new-fileservice.s3.amazonaws.com/fileservice.in/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
106
+ const GENERATED_CDN_URL = cdnUtils.getCdnUrl({
107
+ url: TEST_S3_URL,
108
+ channelName: "EMAIL",
109
+ height: 100,
110
+ width: 200,
111
+ });
112
+ const EXPECTED_CDN_URL = `https://storage.crm.n.content-cdn.io/cdn-cgi/image/width=200,height=100,format=auto,quality=75,/fileservice.in/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
113
+ expect(GENERATED_CDN_URL).toEqual(EXPECTED_CDN_URL);
114
+ });
115
+
116
+ it("Should replace s3 url with cdn url for email without transformation for formats other than jpg/png/jpeg", () => {
117
+ const TEST_S3_URL = `https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.avif`; //this is random url
118
+ const GENERATED_CDN_URL = cdnUtils.getCdnUrl({
119
+ url: TEST_S3_URL,
120
+ channelName: "EMAIL",
121
+ height: 100,
122
+ width: 200,
123
+ });
124
+ const EXPECTED_CDN_URL = `https://storage.crm.n.content-cdn.io/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.avif`;
125
+ expect(GENERATED_CDN_URL).toEqual(EXPECTED_CDN_URL);
126
+ });
127
+
128
+ it("should replace cdn url with new cdn url for email incase h/w etc changed", () => {
129
+ const TEST_S3_URL = `https://storage.crm.n.content-cdn.io/cdn-cgi/image/width=200,height=100,format=auto,quality=75,/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
130
+ const GENERATED_CDN_URL = cdnUtils.getCdnUrl({
131
+ url: TEST_S3_URL,
132
+ channelName: "EMAIL",
133
+ height: 400,
134
+ width: 500,
135
+ });
136
+ const EXPECTED_CDN_URL = `https://storage.crm.n.content-cdn.io/cdn-cgi/image/width=500,height=400,format=auto,quality=75,/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
137
+ expect(GENERATED_CDN_URL).toEqual(EXPECTED_CDN_URL);
138
+ });
139
+
140
+ it("should replace cdn url with new cdn url incase channelName is LINE and channelSubType is RICH_MESSAGE without transformation", () => {
141
+ const TEST_S3_URL = `https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8`;
142
+ const GENERATED_CDN_URL = cdnUtils.getCdnUrl({
143
+ url: TEST_S3_URL,
144
+ channelName: "LINE",
145
+ channelSubType: "RICH_MESSAGE",
146
+ });
147
+ const EXPECTED_CDN_URL = `https://storage.crm.n.content-cdn.io/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8`;
148
+ expect(GENERATED_CDN_URL).toEqual(EXPECTED_CDN_URL);
149
+ });
150
+
151
+ it("should replace cdn url with new cdn url for channels which has predefined h/w for channel", () => {
152
+ const TEST_S3_URL = `https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
153
+ const GENERATED_CDN_URL = cdnUtils.getCdnUrl({
154
+ url: TEST_S3_URL,
155
+ channelName: "RCS",
156
+ });
157
+ const EXPECTED_CDN_URL = `https://storage.crm.n.content-cdn.io/cdn-cgi/image/width=1440,height=720,quality=75,/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
158
+ expect(GENERATED_CDN_URL).toEqual(EXPECTED_CDN_URL);
159
+ });
160
+
161
+ it("should return url directly if typeof CREATIVES_CDN_QUALITY_CONFIG is not object", () => {
162
+ localStorage.setItem("CREATIVES_CDN_QUALITY_CONFIG", "a");
163
+ const TEST_S3_URL = `https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
164
+ const GENERATED_CDN_URL = cdnUtils.getCdnUrl({
165
+ url: TEST_S3_URL,
166
+ channelName: "EMAIL",
167
+ });
168
+ expect(GENERATED_CDN_URL).toEqual(TEST_S3_URL);
169
+ });
170
+
171
+ it("should return cdn url with full quality if quality is not number", () => {
172
+ localStorage.setItem(
173
+ "CREATIVES_CDN_QUALITY_CONFIG",
174
+ '{"EMAIL":"a","RCS":75,"VIBER":75,"WHATSAPP":75,"MOBILE_PUSH":75,"FACEBOOK":75,"LINE":75,"DEFAULT":75}'
175
+ );
176
+
177
+ const TEST_S3_URL = `https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
178
+ const GENERATED_CDN_URL = cdnUtils.getCdnUrl({
179
+ url: TEST_S3_URL,
180
+ channelName: "EMAIL",
181
+ height: 100,
182
+ width: 200,
183
+ });
184
+ const EXPECTED_CDN_URL = `https://storage.crm.n.content-cdn.io/cdn-cgi/image/width=200,height=100,format=auto,quality=100,/intouch_creative_assets/2c9233ed-0959-4aff-b749-9171b5c8.jpg`;
185
+
186
+ expect(GENERATED_CDN_URL).toEqual(EXPECTED_CDN_URL);
187
+ });
188
+ });
189
+
190
+ describe("updateImagesInHtml()", () => {
191
+ it("should update images in html", () => {
192
+ const htmlContentsInput = mockdata.emailRawInput;
193
+ const htmlContentsOutput = cdnUtils.updateImagesInHtml(htmlContentsInput);
194
+ const expected = mockdata.emailRawTransformed;
195
+ expect(htmlContentsOutput).toEqual(expected);
196
+ });
197
+ });
198
+
199
+ describe("transformEmailTemplate()", () => {
200
+ it("should transform email template", () => {
201
+ const emailTemplateInput = mockdata.emailTemplateRaw;
202
+ const emailTemplateOutput =
203
+ cdnUtils.transformEmailTemplates(emailTemplateInput);
204
+ expect(emailTemplateOutput).toMatchSnapshot();
205
+ });
206
+ });
207
+
208
+ describe("saveCdnConfigs()", () => {
209
+ it("should set received input values in localStorage", () => {
210
+ const cdnConfigs = {
211
+ transformationUrlSuffix: "cdn-cgi/image",
212
+ hostname: "https://storage.crm.n.content-cdn.io",
213
+ qualityCfg: {
214
+ EMAIL: 75,
215
+ RCS: 75,
216
+ VIBER: 75,
217
+ WHATSAPP: 75,
218
+ MOBILE_PUSH: 75,
219
+ FACEBOOK: 75,
220
+ LINE: 75,
221
+ DEFAULT: 75,
222
+ },
223
+ };
224
+
225
+ const expected = {
226
+ CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX: "cdn-cgi/image",
227
+ CREATIVES_CDN_BASE_URL: "https://storage.crm.n.content-cdn.io",
228
+ CREATIVES_CDN_QUALITY_CONFIG:
229
+ '{"EMAIL":75,"RCS":75,"VIBER":75,"WHATSAPP":75,"MOBILE_PUSH":75,"FACEBOOK":75,"LINE":75,"DEFAULT":75}',
230
+ };
231
+ cdnUtils.saveCdnConfigs(cdnConfigs);
232
+
233
+ expect(
234
+ localStorage.getItem("CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX")
235
+ ).toBe(expected.CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX);
236
+ expect(localStorage.getItem("CREATIVES_CDN_BASE_URL")).toBe(
237
+ expected.CREATIVES_CDN_BASE_URL
238
+ );
239
+ expect(localStorage.getItem("CREATIVES_CDN_QUALITY_CONFIG")).toBe(
240
+ expected.CREATIVES_CDN_QUALITY_CONFIG
241
+ );
242
+ });
243
+
244
+ it("should clear items from localStorage if input does not contain hostname or transformationUrlSuffix", () => {
245
+ const cdnConfigs = {
246
+ qualityCfg: {
247
+ EMAIL: 75,
248
+ RCS: 75,
249
+ VIBER: 75,
250
+ WHATSAPP: 75,
251
+ MOBILE_PUSH: 75,
252
+ FACEBOOK: 75,
253
+ LINE: 75,
254
+ DEFAULT: 75,
255
+ },
256
+ };
257
+
258
+ const expected = {
259
+ CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX: "cdn-cgi/image",
260
+ CREATIVES_CDN_BASE_URL: "https://storage.crm.n.content-cdn.io",
261
+ CREATIVES_CDN_QUALITY_CONFIG:
262
+ '{"EMAIL":75,"RCS":75,"VIBER":75,"WHATSAPP":75,"MOBILE_PUSH":75,"FACEBOOK":75,"LINE":75,"DEFAULT":75}',
263
+ };
264
+ cdnUtils.saveCdnConfigs(cdnConfigs);
265
+
266
+ expect(
267
+ localStorage.getItem("CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX")
268
+ ).toBe(undefined);
269
+ expect(localStorage.getItem("CREATIVES_CDN_BASE_URL")).toBe(undefined);
270
+ expect(localStorage.getItem("CREATIVES_CDN_QUALITY_CONFIG")).toBe(
271
+ expected.CREATIVES_CDN_QUALITY_CONFIG
272
+ );
273
+ });
274
+
275
+ it("should clear items from localStorage if input is null or empty object", () => {
276
+ const cdnConfigs = {};
277
+
278
+ cdnUtils.saveCdnConfigs(cdnConfigs);
279
+
280
+ expect(
281
+ localStorage.getItem("CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX")
282
+ ).toBe(undefined);
283
+ expect(localStorage.getItem("CREATIVES_CDN_BASE_URL")).toBe(undefined);
284
+ expect(localStorage.getItem("CREATIVES_CDN_QUALITY_CONFIG")).toBe(undefined);
285
+ });
286
+ });
287
+ });
@@ -11,7 +11,7 @@ import PropTypes from 'prop-types';
11
11
  import React from 'react';
12
12
  import _ from 'lodash';
13
13
  import { Tabs, Table, Modal} from 'antd';
14
- import { CapSpin, CapDrawer, CapButton, CapInput, CapPopover, CapImage, CapCheckbox, CapRadio, CapSelect, CapTable, CapRow, CapColumn, CapNotification, CapUploader, CapHeading, CapIcon} from '@capillarytech/cap-ui-library';
14
+ import { CapSpin, CapDrawer, CapButton, CapInput, CapPopover, CapImage, CapCheckbox, CapRadio, CapSelect, CapTable, CapRow, CapColumn, CapNotification, CapUploader, CapHeading, CapIcon, CapTooltip} from '@capillarytech/cap-ui-library';
15
15
  import { injectIntl, intlShape, FormattedMessage } from 'react-intl';
16
16
  import LabelHOC from '@capillarytech/cap-ui-library/assets/HOCs/ComponentWithLabelHOC';
17
17
  import { CAP_SPACE_12, CAP_SPACE_08, FONT_COLOR_05, FONT_COLOR_04 } from '@capillarytech/cap-ui-library/styled/variables';
@@ -2800,22 +2800,28 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
2800
2800
  break;
2801
2801
  case "checkbox":
2802
2802
  ifError = this.state.checkValidation && (isVersionEnable ? this.state.errorData[`${this.state.currentTab - 1}`][val.id] : this.state.errorData[val.id]);
2803
+ const { disabled , hoverText } = val || {};
2803
2804
  if (styling === 'semantic') {
2804
2805
  columns.push(
2805
2806
  <CapColumn key="input" span={val.width} offset={val.offset}>
2806
- <CapCheckbox
2807
- key={val.id}
2808
- className={`${ifError ? 'error' : ''}`}
2809
- errorMessage={val.errorMessage && ifError ? val.errorMessage : ''}
2810
- onChange={(e) => this.updateFormData(e.target.checked, val, val.submitAction)}
2811
- checked={isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : this.state.formData[val.id]}
2812
- defaultChecked={isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : this.state.formData[val.id]}
2813
- style={val.style ? val.style : {}}
2814
- disabled={val.disabled}
2815
- inductiveText={val.inductiveText}
2807
+ <CapTooltip
2808
+ title={ disabled && hoverText ? hoverText : '' }
2809
+ placement="topLeft"
2816
2810
  >
2811
+ <CapCheckbox
2812
+ key={val.id}
2813
+ className={`${ifError ? 'error' : ''}`}
2814
+ errorMessage={val.errorMessage && ifError ? val.errorMessage : ''}
2815
+ onChange={(e) => this.updateFormData(e.target.checked, val, val.submitAction)}
2816
+ checked={isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : this.state.formData[val.id]}
2817
+ defaultChecked={isVersionEnable ? this.state.formData[`${this.state.currentTab - 1}`][val.id] : this.state.formData[val.id]}
2818
+ style={val.style ? val.style : {}}
2819
+ disabled={val.disabled}
2820
+ inductiveText={val.inductiveText}
2821
+ >
2817
2822
  {val.label}
2818
- </CapCheckbox>
2823
+ </CapCheckbox>
2824
+ </CapTooltip>
2819
2825
  </CapColumn>
2820
2826
  );
2821
2827
  }
@@ -0,0 +1,41 @@
1
+ import React from "react";
2
+ import { injectIntl } from 'react-intl';
3
+ import '@testing-library/jest-dom';
4
+ import FormBuilder from '../index';
5
+ import { Provider } from 'react-redux';
6
+ import configureStore from '../../../store';
7
+ import {
8
+ render,
9
+ screen,
10
+ fireEvent,
11
+ waitFor
12
+ } from '../../../utils/test-utils';
13
+ import { mockData } from './mockData';
14
+
15
+
16
+ const ComponentToRender = injectIntl(FormBuilder);
17
+ const renderComponent = props => {
18
+ const store = configureStore({}, null);
19
+ return render(
20
+ <Provider store={store}>
21
+ <ComponentToRender {...props} />
22
+ </Provider>,
23
+ );
24
+ };
25
+
26
+ describe("test for checkbox form builder",() => {
27
+ const onFormValidityChange=jest.fn();
28
+ const props={
29
+ ...mockData,
30
+ onFormValidityChange
31
+ }
32
+ renderComponent(props);
33
+ it("add action button to notification disabled in ios", async () => {
34
+ const addNotifBtn=screen.getByLabelText("Add action buttons to notification")
35
+ expect(addNotifBtn).toBeDisabled();
36
+ fireEvent.mouseOver(addNotifBtn);
37
+ await waitFor(() => {
38
+ expect(screen.getByText("This section is being revamped. Till then it will remain disabled.")).toBeInTheDocument();
39
+ })
40
+ })
41
+ })
@@ -0,0 +1,120 @@
1
+ export const mockData = {
2
+ schema:{
3
+ "containers": [
4
+ {
5
+ "id": "pane",
6
+ "supportedEvents": [
7
+ "onTabChange"
8
+ ],
9
+ "panes": [
10
+ {
11
+ "isSupported": true,
12
+ "sectionsHeaders": [
13
+ {
14
+ "type": "multicols",
15
+ "inputFields": [
16
+ {
17
+ "rowStyle": {
18
+ "display": "flex",
19
+ "flex": 1
20
+ },
21
+ "cols": [
22
+ {
23
+ "id": "tab-header",
24
+ "metaType": "label",
25
+ "value": "iOS",
26
+ "primitive": true,
27
+ "dynamicTab": false,
28
+ "type": "div",
29
+ "width": 5,
30
+ "offset": 0,
31
+ "onlyDisplay": true,
32
+ "colStyle": {
33
+ "flex": 1
34
+ },
35
+ "injectedEvents": {}
36
+ }
37
+ ]
38
+ }
39
+ ],
40
+ "actionFields": []
41
+ }
42
+ ],
43
+ "sections": [
44
+ {
45
+ "type": "parent",
46
+ "width": 16,
47
+ "rowStyle": {
48
+ "height": "100%"
49
+ },
50
+ "childSections": [
51
+ {
52
+ "colStyle": {
53
+ "paddingTop": "16px",
54
+ "paddingLeft": "16px",
55
+ "borderRight": "1px solid #d9d9d9",
56
+ "height": "70vh",
57
+ "overflowY": "auto"
58
+ },
59
+ "width": 16,
60
+ "type": "parent",
61
+ "childSections": [
62
+ {
63
+ "type": "multicols",
64
+ "inputFields": [
65
+ {
66
+ "identifier": "add-sec-cta-ios",
67
+ "cols": [
68
+ {
69
+ "id": "add-sec-cta-ios",
70
+ "metaType": "label",
71
+ "dynamicTab": false,
72
+ "label": "Add action buttons to notification",
73
+ "styling": "semantic",
74
+ "type": "checkbox",
75
+ "customComponent": false,
76
+ "datatype": "boolean",
77
+ "fluid": true,
78
+ "onlyDisplay": false,
79
+ "offset": 0,
80
+ "colStyle": {
81
+ "flex": 1
82
+ },
83
+ "submitAction": "addSecondaryCtaIos",
84
+ "supportedEvents": [
85
+ "addSecondaryCtaIos"
86
+ ],
87
+ "disabled": true,
88
+ "hoverText": "This section is being revamped. Till then it will remain disabled.",
89
+ "injectedEvents": {}
90
+ }
91
+ ]
92
+ }
93
+ ],
94
+ "actionFields": []
95
+ }
96
+ ]
97
+ },
98
+ ]
99
+ }
100
+ ]
101
+ }
102
+ ],
103
+ "type": "tabs",
104
+ "defaultPanes": 1,
105
+ "additionalPanes": 0,
106
+ "injectedEvents": {}
107
+ }
108
+ ],
109
+ "channel": "MOBILEPUSH",
110
+ "module": "Campaigns",
111
+ "type": "LAYOUT"
112
+ },
113
+ location:{
114
+ "pathname": "/mobilepush/create/image",
115
+ "query": {
116
+ "type": false,
117
+ "module": "default"
118
+ }
119
+ }
120
+ }
@@ -99,7 +99,7 @@ class NewCallTask extends React.Component { // eslint-disable-line react/prefer-
99
99
  };
100
100
 
101
101
  render() {
102
- const { intl, isLoading, metaEntities, selectedOfferDetails } = this.props;
102
+ const { intl, isLoading, metaEntities, selectedOfferDetails , injectedTags} = this.props;
103
103
  const { formatMessage } = intl;
104
104
  const { subject, messageBody, description, callTaskActionType } = this.state;
105
105
  const tags = metaEntities && metaEntities.tags ? metaEntities.tags.standard : [];
@@ -125,6 +125,7 @@ class NewCallTask extends React.Component { // eslint-disable-line react/prefer-
125
125
  tags={tags}
126
126
  onTagSelect={this.onTagSelect}
127
127
  selectedOfferDetails={selectedOfferDetails}
128
+ injectedTags={injectedTags}
128
129
  />
129
130
  <CapInput.TextArea
130
131
  setInputRef={this.setInputRef}
@@ -177,6 +178,7 @@ NewCallTask.propTypes = {
177
178
  selectedOfferDetails: PropTypes.array,
178
179
  messageDetails: PropTypes.object,
179
180
  mode: PropTypes.string,
181
+ injectedTags: PropTypes.object,
180
182
  };
181
183
 
182
184
  export default injectIntl(NewCallTask);
@@ -0,0 +1,36 @@
1
+ import React from "react";
2
+ import { injectIntl } from 'react-intl';
3
+ import '@testing-library/jest-dom';
4
+ import { Provider } from 'react-redux';
5
+ import { browserHistory } from 'react-router';
6
+ import NewCallTask from '../index';
7
+ import configureStore from '../../../store';
8
+ import mockData from './mockData'
9
+ import {
10
+ render,
11
+ } from '../../../utils/test-utils';
12
+ import { Router } from "express";
13
+ const ComponentToRender = injectIntl(NewCallTask);
14
+
15
+ const renderComponent = (props) => {
16
+ const store = configureStore({}, browserHistory);
17
+ return render(
18
+ <Router>
19
+ <Provider store={store}>
20
+ <ComponentToRender {...props} />
21
+ </Provider>
22
+ </Router>,
23
+ );
24
+ };
25
+
26
+ describe("test for NewCallTask", () => {
27
+ const onCallTaskSubmit = jest.fn();
28
+ const props = {
29
+ ...mockData,
30
+ onCallTaskSubmit,
31
+ };
32
+
33
+ it("New call task", async () => {
34
+ renderComponent(props);
35
+ });
36
+ });
@@ -0,0 +1,20 @@
1
+ const mockData= {
2
+ injectedTags: {},
3
+ templateData: {},
4
+ messageDetails: {},
5
+ isLoading: true,
6
+ selectedOfferDetails: [],
7
+ location: {
8
+ pathname: "/NewCallTask",
9
+ query: {
10
+ type: false,
11
+ module: "default",
12
+ },
13
+ },
14
+ match: {
15
+ path: '/NewCallTask',
16
+ url: '/creatives/ui/v2',
17
+ isExact: true,
18
+ params: {},
19
+ }
20
+ }
@@ -16,7 +16,7 @@ import {
16
16
  } from '@capillarytech/cap-ui-library';
17
17
  import { injectIntl, intlShape } from 'react-intl';
18
18
  import { createStructuredSelector } from 'reselect';
19
- import { makeSelectMetaEntities, isLoadingMetaEntities } from '../Cap/selectors';
19
+ import { makeSelectMetaEntities, isLoadingMetaEntities, setInjectedTags } from '../Cap/selectors';
20
20
  import * as globalActions from '../Cap/actions';
21
21
  import * as actions from "./actions";
22
22
  import makeSelectCallTask from './selectors';
@@ -71,7 +71,7 @@ export class CallTask extends React.Component { // eslint-disable-line react/pre
71
71
  };
72
72
  }
73
73
  render() {
74
- const { intl, onCallTaskSubmit, templateData, loadingMetaEntities, metaEntities, selectedOfferDetails, messageDetails } = this.props;
74
+ const { intl, onCallTaskSubmit, templateData, loadingMetaEntities, metaEntities, selectedOfferDetails, messageDetails, injectedTags } = this.props;
75
75
  const { formatMessage } = intl;
76
76
  const { mode } = this.state;
77
77
  return (
@@ -85,6 +85,7 @@ export class CallTask extends React.Component { // eslint-disable-line react/pre
85
85
  onCallTaskSubmit={onCallTaskSubmit}
86
86
  selectedOfferDetails={selectedOfferDetails}
87
87
  messageDetails={messageDetails}
88
+ injectedTags={injectedTags || {}}
88
89
  />
89
90
  :
90
91
  <div>
@@ -144,6 +145,7 @@ const mapStateToProps = createStructuredSelector({
144
145
  CallTask: makeSelectCallTask(),
145
146
  metaEntities: makeSelectMetaEntities(),
146
147
  loadingMetaEntities: isLoadingMetaEntities(),
148
+ injectedTags: setInjectedTags(),
147
149
  });
148
150
 
149
151
  function mapDispatchToProps(dispatch) {
@@ -73,4 +73,3 @@ export function clearTopbarMenuData() {
73
73
  type: types.CLEAR_TOPBAR_MENU_DATA,
74
74
  };
75
75
  }
76
-
@@ -24,4 +24,4 @@ export function hideCreativesContanerLoader() {
24
24
  return {
25
25
  type: HIDE_CONTAINER_LOADER,
26
26
  };
27
- }
27
+ }
@@ -33,6 +33,7 @@ import { CREATIVE } from '../Facebook/constants';
33
33
  import { LOYALTY } from '../App/constants';
34
34
  import { WHATSAPP_STATUSES } from '../Whatsapp/constants';
35
35
 
36
+ import { updateImagesInHtml } from '../../utils/cdnTransformation';
36
37
 
37
38
  const classPrefix = 'add-creatives-section';
38
39
  const CREATIVES_CONTAINER = 'creativesContainer';
@@ -76,6 +77,9 @@ export class Creatives extends React.Component {
76
77
 
77
78
  componentDidMount() {
78
79
  GA.timeTracker.startTimer(CREATIVES_CONTAINER);
80
+ if(!this.props?.isFullMode){
81
+ this.props?.templateActions.getCdnTransformationConfig();
82
+ }
79
83
  }
80
84
 
81
85
  onEnterTemplateName = () => {
@@ -495,7 +499,8 @@ export class Creatives extends React.Component {
495
499
  if (!html_content) {
496
500
  emailBase = templateRecords.base;
497
501
  }
498
- templateData = {...templateData, ...emailBase, emailBody: html_content, emailSubject: (emailBase && emailBase.subject) ? emailBase.subject : ''};
502
+ const newHtmlContent = updateImagesInHtml(html_content);
503
+ templateData = {...templateData, ...emailBase, emailBody: newHtmlContent, emailSubject: (emailBase && emailBase.subject) ? emailBase.subject : ''};
499
504
  delete templateData.html_content;
500
505
  delete templateData.subject;
501
506
  }