@capillarytech/creatives-library 7.13.16 → 7.13.18
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.
- package/package.json +1 -1
- package/services/tests/api.test.js +6 -1
- package/utils/cdnTransformation.js +0 -2
- package/utils/tests/cdnTransformation.mockdata.js +37 -0
- package/utils/tests/cdnTransformation.test.js +66 -2
- package/v2Components/FormBuilder/index.js +1 -0
- package/v2Components/TemplatePreview/index.js +2 -1
- package/v2Containers/CreativesContainer/SlideBoxContent.js +4 -0
- package/v2Containers/CreativesContainer/index.js +1 -0
- package/v2Containers/MobilePush/Create/index.js +1 -0
- package/v2Containers/MobilePush/Edit/index.js +1 -0
- package/v2Containers/MobilepushWrapper/index.js +1 -0
- package/v2Containers/Templates/sagas.js +2 -3
- package/v2Containers/Templates/tests/mockData.js +30 -0
- package/v2Containers/Templates/tests/sagas.test.js +76 -0
- package/v2Containers/TemplatesV2/index.js +1 -0
package/package.json
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
|
-
import { getSenderDetails, uploadFile } from "../api";
|
|
1
|
+
import { getSenderDetails, uploadFile, getCdnTransformationConfig } from "../api";
|
|
2
2
|
|
|
3
3
|
describe("getSenderDetails -- Test with valid responses", () => {
|
|
4
4
|
it("Should return correct response", () =>
|
|
5
5
|
expect(getSenderDetails("WHATSAPP", -1)).toEqual(Promise.resolve()));
|
|
6
6
|
});
|
|
7
7
|
|
|
8
|
+
describe("getCdnTransformationConfigs -- Test with valid responses", () => {
|
|
9
|
+
it("Should return correct response", () =>
|
|
10
|
+
expect(getCdnTransformationConfig()).toEqual(Promise.resolve()));
|
|
11
|
+
});
|
|
12
|
+
|
|
8
13
|
describe("uploadFile -- whatsapp image upload", () => {
|
|
9
14
|
it("Should return correct response", () =>
|
|
10
15
|
expect(
|
|
@@ -299,3 +299,40 @@ export const emailTemplateRaw = {
|
|
|
299
299
|
"type": "EMAIL",
|
|
300
300
|
"name": "test template1"
|
|
301
301
|
}
|
|
302
|
+
|
|
303
|
+
export const emailTemplateRawWithError = {
|
|
304
|
+
"versions": {
|
|
305
|
+
"base": {
|
|
306
|
+
"activeTab": "en",
|
|
307
|
+
"selectedLanguages": [
|
|
308
|
+
"en"
|
|
309
|
+
],
|
|
310
|
+
"base": true,
|
|
311
|
+
"tabKey": "6",
|
|
312
|
+
"subject": "hello subject"
|
|
313
|
+
},
|
|
314
|
+
"history": [
|
|
315
|
+
{
|
|
316
|
+
"activeTab": "en",
|
|
317
|
+
"en": {
|
|
318
|
+
"is_drag_drop": false,
|
|
319
|
+
"lang_id": 69,
|
|
320
|
+
"iso_code": "en",
|
|
321
|
+
"language": "English",
|
|
322
|
+
"template-content": "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional //EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">\n<html xmlns=\"http://www.w3.org/1999/xhtml\" xmlns:o=\"urn:schemas-microsoft-com:office:office\" xmlns:v=\"urn:schemas-microsoft-com:vml\">\n<head><!--[if gte mso 9]><xml><o:OfficeDocumentSettings><o:AllowPNG/><o:PixelsPerInch>96</o:PixelsPerInch></o:OfficeDocumentSettings></xml><![endif]--><meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"><meta name=\"viewport\" content=\"width=device-width\"><!--[if !mso]><meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\"><!--<![endif]-->\n\t<title></title>\n\t<!--[if !mso]><!--<![endif]-->\n\t<style type=\"text/css\">body {\n margin: 0;\n padding: 0; }\n\ntable,\ntd,\ntr {\n vertical-align: top;\n border-collapse: collapse; }\n\n* {\n line-height: inherit; }\n\na[x-apple-data-detectors=true] {\n color: inherit !important;\n text-decoration: none !important; }\n\t</style>\n\t<style id=\"media-query\" type=\"text/css\">@media (max-width: 520px) {\n .block-grid,\n.col {\n min-width: 320px !important;\n max-width: 100% !important;\n display: block !important;\n }\n\n .block-grid {\n width: 100% !important;\n }\n\n .col {\n width: 100% !important;\n }\n\n .col > div {\n margin: 0 auto;\n }\n\n img.fullwidth,\nimg.fullwidthOnMobile {\n max-width: 100% !important;\n }\n\n .no-stack .col {\n min-width: 0 !important;\n display: table-cell !important;\n }\n\n .no-stack.two-up .col {\n width: 50% !important;\n }\n\n .no-stack .col.num4 {\n width: 33% !important;\n }\n\n .no-stack .col.num8 {\n width: 66% !important;\n }\n\n .no-stack .col.num4 {\n width: 33% !important;\n }\n\n .no-stack .col.num3 {\n width: 25% !important;\n }\n\n .no-stack .col.num6 {\n width: 50% !important;\n }\n\n .no-stack .col.num9 {\n width: 75% !important;\n }\n\n .video-block {\n max-width: none !important;\n }\n\n .mobile_hide {\n min-height: 0px;\n max-height: 0px;\n max-width: 0px;\n display: none;\n overflow: hidden;\n font-size: 0px;\n }\n\n .desktop_hide {\n display: block !important;\n max-height: none !important;\n }\n}\n\t</style>\n</head>\n<body class=\"clean-body\" style=\"margin: 0; padding: 0; -webkit-text-size-adjust: 100%; background-color: #FFFFFF;\">\n<p><!--[if IE]><div class=\"ie-browser\"><![endif]-->hello world</p>\n\n<p><img alt=\"Capillary Image\" height=\"171\" src=\"https://crm-nightly-new-fileservice.s3.amazonaws.com/intouch_creative_assets/b4b63b22-8a81-41ee-a8df-6db967fc.jpg\" width=\"257\" /></p>\n\n<table bgcolor=\"#FFFFFF\" cellpadding=\"0\" cellspacing=\"0\" class=\"nl-container\" role=\"presentation\" style=\"background-color:#ffffff; border-collapse:collapse; border-spacing:0; margin:0 auto; min-width:320px; mso-table-lspace:0pt; mso-table-rspace:0pt; table-layout:fixed; vertical-align:top; width:100%\" valign=\"top\">\n\t<tbody>\n\t\t<tr style=\"vertical-align:top\" valign=\"top\">\n\t\t\t<td style=\"vertical-align:top; word-break:break-word\"><!--[if (mso)|(IE)]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td align=\"center\" style=\"background-color:#FFFFFF\"><![endif]-->\n\t\t\t<div style=\"background-color:transparent\">\n\t\t\t<div class=\"block-grid\" style=\"background-color:transparent; margin-bottom:0; margin-left:auto; margin-right:auto; margin-top:0; max-width:500px; min-width:320px; overflow-wrap:break-word; word-break:break-word; word-wrap:break-word\">\n\t\t\t<div style=\"background-color:transparent; border-collapse:collapse; display:table; width:100%\"><!--[if (mso)|(IE)]><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"background-color:transparent;\"><tr><td align=\"center\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"width:500px\"><tr class=\"layout-full-width\" style=\"background-color:transparent\"><![endif]--><!--[if (mso)|(IE)]><td align=\"center\" width=\"500\" style=\"background-color:transparent;width:500px; border-top: 0px solid transparent; border-left: 0px solid transparent; border-bottom: 0px solid transparent; border-right: 0px solid transparent;\" valign=\"top\"><table width=\"100%\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\"><tr><td style=\"padding-right: 0px; padding-left: 0px; padding-top:5px; padding-bottom:5px;\"><![endif]-->\n\t\t\t<div class=\"col num12\" style=\"display:table-cell; max-width:500px; min-width:320px; vertical-align:top; width:500px\">\n\t\t\t<div style=\"width:100% !important\"><!--[if (!mso)&(!IE)]><div style=\"border-top:0px solid transparent; border-left:0px solid transparent; border-bottom:0px solid transparent; border-right:0px solid transparent; padding-top:5px; padding-bottom:5px; padding-right: 0px; padding-left: 0px;\"><!--<![endif]--><!--[if (!mso)&(!IE)]></div><!--<![endif]--></div>\n\t\t\t</div>\n\t\t\t<!--[if (mso)|(IE)]></td></tr></table><![endif]--><!--[if (mso)|(IE)]></td></tr></table></td></tr></table><![endif]--></div>\n\t\t\t</div>\n\t\t\t</div>\n\t\t\t<!--[if (mso)|(IE)]></td></tr></table><![endif]--></td>\n\t\t</tr>\n\t</tbody>\n</table>\n<!--[if (IE)]></div><![endif]--></body>\n</html>\n",
|
|
323
|
+
"drag_drop_id": "",
|
|
324
|
+
"tabKey": "6",
|
|
325
|
+
"id": "5f7b61605f09ebe595ff404e"
|
|
326
|
+
},
|
|
327
|
+
"selectedLanguages": [
|
|
328
|
+
"en"
|
|
329
|
+
],
|
|
330
|
+
"base": true,
|
|
331
|
+
"tabKey": "6",
|
|
332
|
+
"subject": "hello subject"
|
|
333
|
+
}
|
|
334
|
+
]
|
|
335
|
+
},
|
|
336
|
+
"type": "EMAIL",
|
|
337
|
+
"name": "test template1"
|
|
338
|
+
}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import * as cdnUtils from "../cdnTransformation";
|
|
2
2
|
import * as mockdata from "./cdnTransformation.mockdata";
|
|
3
|
+
import * as nodeHtmlParser from 'node-html-parser'
|
|
4
|
+
import Bugsnag from '@bugsnag/js';
|
|
3
5
|
|
|
6
|
+
var bugsnagSpy;
|
|
7
|
+
var localStorageMock;
|
|
4
8
|
beforeEach(() => {
|
|
5
|
-
|
|
9
|
+
localStorageMock = (function () {
|
|
6
10
|
var store = {
|
|
7
11
|
CREATIVES_CDN_TRANSFORMATION_URL_SUFFIX: "cdn-cgi/image",
|
|
8
12
|
CREATIVES_S3_BUCKET_PATH: "intouch_creative_assets",
|
|
@@ -25,7 +29,8 @@ beforeEach(() => {
|
|
|
25
29
|
},
|
|
26
30
|
};
|
|
27
31
|
})();
|
|
28
|
-
Object.defineProperty(window, "localStorage", { value: localStorageMock });
|
|
32
|
+
Object.defineProperty(window, "localStorage", { value: localStorageMock, writable: true, configurable: true});
|
|
33
|
+
bugsnagSpy = jest.spyOn(Bugsnag, 'notify');
|
|
29
34
|
});
|
|
30
35
|
|
|
31
36
|
afterEach(() => {
|
|
@@ -36,6 +41,8 @@ afterEach(() => {
|
|
|
36
41
|
localStorage.setItem(
|
|
37
42
|
"CREATIVES_S3_BUCKET_PATH", "intouch_creative_assets"
|
|
38
43
|
);
|
|
44
|
+
jest.restoreAllMocks();
|
|
45
|
+
jest.resetAllMocks();
|
|
39
46
|
});
|
|
40
47
|
|
|
41
48
|
describe("cdnTransformationTests", () => {
|
|
@@ -212,6 +219,14 @@ describe("cdnTransformationTests", () => {
|
|
|
212
219
|
expect(cdnUtils.updateImagesInHtml(null)).toEqual(null);
|
|
213
220
|
expect(cdnUtils.updateImagesInHtml("")).toEqual("");
|
|
214
221
|
});
|
|
222
|
+
|
|
223
|
+
it("should call bugsnag when parse() throws some unexpected error.", () => {
|
|
224
|
+
const spy = jest.spyOn(nodeHtmlParser, 'parse').mockImplementation(()=>{
|
|
225
|
+
throw new Error();
|
|
226
|
+
})
|
|
227
|
+
expect(cdnUtils.updateImagesInHtml(mockdata.emailRawInput)).toEqual(mockdata.emailRawInput);
|
|
228
|
+
expect(bugsnagSpy).toHaveBeenCalled();
|
|
229
|
+
});
|
|
215
230
|
});
|
|
216
231
|
|
|
217
232
|
describe("transformEmailTemplate()", () => {
|
|
@@ -221,6 +236,13 @@ describe("cdnTransformationTests", () => {
|
|
|
221
236
|
cdnUtils.transformEmailTemplates(emailTemplateInput);
|
|
222
237
|
expect(emailTemplateOutput).toMatchSnapshot();
|
|
223
238
|
});
|
|
239
|
+
it("should return original contents transform email template throws an error inside. This might be due to improper input or unexpected error.", () => {
|
|
240
|
+
const emailTemplateInputWithError = mockdata.emailTemplateRawWithError;
|
|
241
|
+
const emailTemplateOutput =
|
|
242
|
+
cdnUtils.transformEmailTemplates(emailTemplateInputWithError);
|
|
243
|
+
expect(emailTemplateInputWithError).toEqual(emailTemplateOutput);
|
|
244
|
+
expect(bugsnagSpy).toHaveBeenCalled();
|
|
245
|
+
});
|
|
224
246
|
});
|
|
225
247
|
|
|
226
248
|
describe("saveCdnConfigs()", () => {
|
|
@@ -238,6 +260,7 @@ describe("cdnTransformationTests", () => {
|
|
|
238
260
|
LINE: 75,
|
|
239
261
|
DEFAULT: 75,
|
|
240
262
|
},
|
|
263
|
+
bucketPath: 'intouch_creative_assets'
|
|
241
264
|
};
|
|
242
265
|
|
|
243
266
|
const expected = {
|
|
@@ -245,6 +268,7 @@ describe("cdnTransformationTests", () => {
|
|
|
245
268
|
CREATIVES_CDN_BASE_URL: "https://storage.crm.n.content-cdn.io",
|
|
246
269
|
CREATIVES_CDN_QUALITY_CONFIG:
|
|
247
270
|
'{"EMAIL":75,"RCS":75,"VIBER":75,"WHATSAPP":75,"MOBILE_PUSH":75,"FACEBOOK":75,"LINE":75,"DEFAULT":75}',
|
|
271
|
+
CREATIVES_S3_BUCKET_PATH: 'intouch_creative_assets',
|
|
248
272
|
};
|
|
249
273
|
cdnUtils.saveCdnConfigs(cdnConfigs);
|
|
250
274
|
|
|
@@ -257,6 +281,19 @@ describe("cdnTransformationTests", () => {
|
|
|
257
281
|
expect(localStorage.getItem("CREATIVES_CDN_QUALITY_CONFIG")).toBe(
|
|
258
282
|
expected.CREATIVES_CDN_QUALITY_CONFIG
|
|
259
283
|
);
|
|
284
|
+
expect(localStorage.getItem("CREATIVES_S3_BUCKET_PATH")).toBe(
|
|
285
|
+
expected.CREATIVES_S3_BUCKET_PATH
|
|
286
|
+
);
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
it("should clear items from localStorage if qualityConfigs is not present", () => {
|
|
290
|
+
const cdnConfigs = {
|
|
291
|
+
bucketPath: "intouch_creative_assets",
|
|
292
|
+
};
|
|
293
|
+
cdnUtils.saveCdnConfigs(cdnConfigs);
|
|
294
|
+
expect(localStorage.getItem("CREATIVES_CDN_QUALITY_CONFIG")).toBe(
|
|
295
|
+
undefined
|
|
296
|
+
);
|
|
260
297
|
});
|
|
261
298
|
|
|
262
299
|
it("should clear items from localStorage if input does not contain hostname or transformationUrlSuffix", () => {
|
|
@@ -301,5 +338,32 @@ describe("cdnTransformationTests", () => {
|
|
|
301
338
|
expect(localStorage.getItem("CREATIVES_CDN_BASE_URL")).toBe(undefined);
|
|
302
339
|
expect(localStorage.getItem("CREATIVES_CDN_QUALITY_CONFIG")).toBe(undefined);
|
|
303
340
|
});
|
|
341
|
+
|
|
342
|
+
it("should call bugsnag notify if any unexpected error occured during removeAllCdnLocalStorageItems", () => {
|
|
343
|
+
delete window.localStorage.removeItem;
|
|
344
|
+
|
|
345
|
+
cdnUtils.removeAllCdnLocalStorageItems('CREATIVES_CDN_BASE_URL');
|
|
346
|
+
|
|
347
|
+
expect(bugsnagSpy).toHaveBeenCalled();
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
it("should call bugsnag notify if any unexpected error occured during saveCdnConfigs", () => {
|
|
351
|
+
delete window?.localStorage?.setItem; //this is a case used to mimick any unexpected error
|
|
352
|
+
|
|
353
|
+
const cdnConfigs = {
|
|
354
|
+
transformationUrlSuffix: "cdn-cgi/image",
|
|
355
|
+
hostname: "https://storage.crm.n.content-cdn.io",
|
|
356
|
+
qualityCfg: {
|
|
357
|
+
DEFAULT: 75,
|
|
358
|
+
},
|
|
359
|
+
bucketPath: 'intouch_creative_assets'
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
cdnUtils.saveCdnConfigs(cdnConfigs);
|
|
363
|
+
|
|
364
|
+
expect(bugsnagSpy).toHaveBeenCalled();
|
|
365
|
+
|
|
366
|
+
window.localStorage.setItem = ()=>{};
|
|
367
|
+
});
|
|
304
368
|
});
|
|
305
369
|
});
|
|
@@ -3092,6 +3092,7 @@ class FormBuilder extends React.Component { // eslint-disable-line react/prefer-
|
|
|
3092
3092
|
onTestContentClicked={this.props.onTestContentClicked}
|
|
3093
3093
|
templateDataRaw={this.props.templateData}
|
|
3094
3094
|
module={this.props.location.query.module}
|
|
3095
|
+
hideTestAndPreviewBtn={this.props.hideTestAndPreviewBtn}
|
|
3095
3096
|
>
|
|
3096
3097
|
</TemplatePreview>
|
|
3097
3098
|
</CapColumn>
|
|
@@ -160,6 +160,7 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
160
160
|
intl,
|
|
161
161
|
templateData,
|
|
162
162
|
rcsIosPreview,
|
|
163
|
+
hideTestAndPreviewBtn
|
|
163
164
|
} = this.props;
|
|
164
165
|
const { formatMessage } = intl;
|
|
165
166
|
const { buttonText, imageURL, rcsPreviewContent, messageContent: viberMessageContent } = content || {};
|
|
@@ -193,7 +194,7 @@ export class TemplatePreview extends React.Component { // eslint-disable-line re
|
|
|
193
194
|
const disablePreviewAndTest = this.props.channel === 'MOBILEPUSH' ? !this.props.content.header : (this.props.channel === 'SMS' ? !this.props.content : false);
|
|
194
195
|
const showTestAndPreview = showTestAndPreviewIcon &&
|
|
195
196
|
channel !== WECHAT &&
|
|
196
|
-
['outbound', 'library'].includes(module);
|
|
197
|
+
['outbound', 'library'].includes(module) && !hideTestAndPreviewBtn;
|
|
197
198
|
|
|
198
199
|
const renderLineMultiText = (content) => {
|
|
199
200
|
let textCount = 0;
|
|
@@ -147,6 +147,7 @@ export function SlideBoxContent(props) {
|
|
|
147
147
|
orgUnitId,
|
|
148
148
|
smsRegister,
|
|
149
149
|
enableNewChannels,
|
|
150
|
+
hideTestAndPreviewBtn
|
|
150
151
|
} = props;
|
|
151
152
|
const type = (messageDetails.type || '').toLowerCase(); // type is context in get tags values : outbound | dvs | referral | loyalty | coupons
|
|
152
153
|
const query = { type: !isFullMode && 'embedded', module: isFullMode ? 'default' : 'library', isEditFromCampaigns: (templateData || {}).isEditFromCampaigns};
|
|
@@ -407,6 +408,7 @@ export function SlideBoxContent(props) {
|
|
|
407
408
|
orgUnitId={orgUnitId}
|
|
408
409
|
smsRegister={smsRegister}
|
|
409
410
|
enableNewChannels={enableNewChannels}
|
|
411
|
+
hideTestAndPreviewBtn={hideTestAndPreviewBtn}
|
|
410
412
|
/>
|
|
411
413
|
)}
|
|
412
414
|
{isPreview && (
|
|
@@ -602,6 +604,7 @@ export function SlideBoxContent(props) {
|
|
|
602
604
|
onPreviewContentClicked={onPreviewContentClicked}
|
|
603
605
|
onTestContentClicked={onTestContentClicked}
|
|
604
606
|
type={type}
|
|
607
|
+
hideTestAndPreviewBtn={hideTestAndPreviewBtn}
|
|
605
608
|
/>
|
|
606
609
|
}
|
|
607
610
|
{isCreateMPush &&
|
|
@@ -628,6 +631,7 @@ export function SlideBoxContent(props) {
|
|
|
628
631
|
onValidationFail={onValidationFail}
|
|
629
632
|
selectedOfferDetails={selectedOfferDetails}
|
|
630
633
|
onPreviewContentClicked={onPreviewContentClicked}
|
|
634
|
+
hideTestAndPreviewBtn={hideTestAndPreviewBtn}
|
|
631
635
|
onTestContentClicked={onTestContentClicked}/>
|
|
632
636
|
}
|
|
633
637
|
{
|
|
@@ -1107,6 +1107,7 @@ export class Creatives extends React.Component {
|
|
|
1107
1107
|
messageStrategy={this.props.strategy}
|
|
1108
1108
|
orgUnitId={this.props.orgUnitId}
|
|
1109
1109
|
enableNewChannels={enableNewChannels}
|
|
1110
|
+
hideTestAndPreviewBtn={this.props.hideTestAndPreviewBtn}
|
|
1110
1111
|
/>
|
|
1111
1112
|
}
|
|
1112
1113
|
footer={this.shouldShowFooter() &&
|
|
@@ -1737,6 +1737,7 @@ export class Create extends React.Component { // eslint-disable-line react/prefe
|
|
|
1737
1737
|
onPreviewContentClicked={this.props.onPreviewContentClicked}
|
|
1738
1738
|
onTestContentClicked={this.props.onTestContentClicked}
|
|
1739
1739
|
templateData={this.props.templateData}
|
|
1740
|
+
hideTestAndPreviewBtn={this.props.hideTestAndPreviewBtn}
|
|
1740
1741
|
/>
|
|
1741
1742
|
</CapColumn>
|
|
1742
1743
|
{this.props.iosCtasData && this.state.showIosCtaTable &&
|
|
@@ -1821,6 +1821,7 @@ export class Edit extends React.Component { // eslint-disable-line react/prefer-
|
|
|
1821
1821
|
onPreviewContentClicked={this.props.onPreviewContentClicked}
|
|
1822
1822
|
onTestContentClicked={this.props.onTestContentClicked}
|
|
1823
1823
|
templateData={this.props.templateData}
|
|
1824
|
+
hideTestAndPreviewBtn={this.props.hideTestAndPreviewBtn}
|
|
1824
1825
|
/>}
|
|
1825
1826
|
</CapColumn>
|
|
1826
1827
|
{this.props.iosCtasData && this.state.showIosCtaTable &&
|
|
@@ -115,6 +115,7 @@ export class MobilepushWrapper extends React.Component { // eslint-disable-line
|
|
|
115
115
|
onPreviewContentClicked={onPreviewContentClicked}
|
|
116
116
|
onTestContentClicked={onTestContentClicked}
|
|
117
117
|
templateData={templateData}
|
|
118
|
+
hideTestAndPreviewBtn={this.props.hideTestAndPreviewBtn}
|
|
118
119
|
/>
|
|
119
120
|
|
|
120
121
|
|
|
@@ -86,10 +86,9 @@ export function* getOrgLevelCampaignSettings() {
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
|
|
89
|
-
function* getCdnTransformationConfig() {
|
|
89
|
+
export function* getCdnTransformationConfig() {
|
|
90
90
|
try {
|
|
91
91
|
const res = yield call(Api.getCdnTransformationConfig);
|
|
92
|
-
|
|
93
92
|
if (res?.success && res?.status?.code === 200) {
|
|
94
93
|
const cdnConfigs = res?.response;
|
|
95
94
|
saveCdnConfigs(cdnConfigs);
|
|
@@ -239,7 +238,7 @@ function* watchGetSenderDetails() {
|
|
|
239
238
|
yield cancel(watcher);
|
|
240
239
|
}
|
|
241
240
|
|
|
242
|
-
function* watchGetCdnTransformationConfig() {
|
|
241
|
+
export function* watchGetCdnTransformationConfig() {
|
|
243
242
|
yield takeLatest(
|
|
244
243
|
types.GET_CDN_TRANSFORMATION_CONFIG_REQUEST,
|
|
245
244
|
getCdnTransformationConfig
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export const getCdnTransformationConfigSuccess = {
|
|
2
|
+
"success": true,
|
|
3
|
+
"status": {
|
|
4
|
+
"isError": false,
|
|
5
|
+
"code": 200,
|
|
6
|
+
"message": "success"
|
|
7
|
+
},
|
|
8
|
+
"message": "CDN transformation config fetched",
|
|
9
|
+
"response": {
|
|
10
|
+
"hostname": "https://storage.crm.staging.content-cdn.io",
|
|
11
|
+
"transformationUrlSuffix": "cdn-cgi/image",
|
|
12
|
+
"bucketPath": "intouch_creative_assets",
|
|
13
|
+
"qualityCfg": {
|
|
14
|
+
"EMAIL": 65,
|
|
15
|
+
"RCS": 75,
|
|
16
|
+
"VIBER": 75,
|
|
17
|
+
"WHATSAPP": 75,
|
|
18
|
+
"MOBILE_PUSH": 75,
|
|
19
|
+
"FACEBOOK": 75,
|
|
20
|
+
"LINE": 75,
|
|
21
|
+
"DEFAULT": 75
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const getCdnTransformationConfigFailure = {
|
|
27
|
+
"isError": true,
|
|
28
|
+
"message": "Resource Not Found",
|
|
29
|
+
"error": {}
|
|
30
|
+
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { expectSaga } from 'redux-saga-test-plan';
|
|
2
|
+
import { take, call, takeLatest, takeEvery } from 'redux-saga/effects';
|
|
3
|
+
import * as matchers from 'redux-saga-test-plan/matchers';
|
|
4
|
+
import * as api from '../../../services/api';
|
|
5
|
+
import * as types from '../constants';
|
|
6
|
+
import * as cdnUtils from '../../../utils/cdnTransformation';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
getCdnTransformationConfig,
|
|
10
|
+
watchGetCdnTransformationConfig
|
|
11
|
+
} from '../sagas';
|
|
12
|
+
|
|
13
|
+
import * as mockData from './mockData';
|
|
14
|
+
|
|
15
|
+
describe('getCdnTransformationConfig saga', () => {
|
|
16
|
+
it("handle valid response from api", () => {
|
|
17
|
+
const saveCdnConfigsSpy = jest.spyOn(cdnUtils, "saveCdnConfigs");
|
|
18
|
+
|
|
19
|
+
expectSaga(getCdnTransformationConfig)
|
|
20
|
+
.provide([
|
|
21
|
+
[
|
|
22
|
+
call(api.getCdnTransformationConfig),
|
|
23
|
+
mockData.getCdnTransformationConfigSuccess,
|
|
24
|
+
],
|
|
25
|
+
])
|
|
26
|
+
.run();
|
|
27
|
+
expect(saveCdnConfigsSpy).toHaveBeenCalled();
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
it("handle error response from api", () => {
|
|
31
|
+
const removeAllCdnLocalStorageItemsSpy = jest.spyOn(
|
|
32
|
+
cdnUtils,
|
|
33
|
+
"removeAllCdnLocalStorageItems"
|
|
34
|
+
);
|
|
35
|
+
|
|
36
|
+
expectSaga(getCdnTransformationConfig)
|
|
37
|
+
.provide([
|
|
38
|
+
[
|
|
39
|
+
call(api.getCdnTransformationConfig),
|
|
40
|
+
mockData.getCdnTransformationConfigFailure,
|
|
41
|
+
],
|
|
42
|
+
])
|
|
43
|
+
.run();
|
|
44
|
+
expect(removeAllCdnLocalStorageItemsSpy).toHaveBeenCalled();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("remove localStorage items when an error is thrown", () => {
|
|
48
|
+
const saveCdnConfigsSpy = jest.spyOn(cdnUtils, "saveCdnConfigs").mockImplementation(()=>{
|
|
49
|
+
throw new Error()
|
|
50
|
+
});
|
|
51
|
+
const removeAllCdnLocalStorageItemsSpy = jest.spyOn(
|
|
52
|
+
cdnUtils,
|
|
53
|
+
"removeAllCdnLocalStorageItems"
|
|
54
|
+
);
|
|
55
|
+
|
|
56
|
+
expectSaga(getCdnTransformationConfig)
|
|
57
|
+
.provide([
|
|
58
|
+
[
|
|
59
|
+
call(api.getCdnTransformationConfig),
|
|
60
|
+
mockData.getCdnTransformationConfigSuccess,
|
|
61
|
+
],
|
|
62
|
+
])
|
|
63
|
+
.run();
|
|
64
|
+
expect(removeAllCdnLocalStorageItemsSpy).toHaveBeenCalled();
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
describe('watchForGetJourneyList saga', () => {
|
|
70
|
+
const generator = watchGetCdnTransformationConfig();
|
|
71
|
+
it('should call watchers functions', () => {
|
|
72
|
+
expect(generator.next().value).toEqual(
|
|
73
|
+
takeLatest(types.GET_CDN_TRANSFORMATION_CONFIG_REQUEST, getCdnTransformationConfig),
|
|
74
|
+
);
|
|
75
|
+
});
|
|
76
|
+
});
|
|
@@ -260,6 +260,7 @@ export class TemplatesV2 extends React.Component { // eslint-disable-line react/
|
|
|
260
260
|
handlePeviewTemplate={this.props.handlePeviewTemplate}
|
|
261
261
|
messageStrategy={this.props.messageStrategy}
|
|
262
262
|
smsRegister={smsRegister}
|
|
263
|
+
hideTestAndPreviewBtn={this.props.hideTestAndPreviewBtn}
|
|
263
264
|
/>);
|
|
264
265
|
}
|
|
265
266
|
}
|