@capillarytech/creatives-library 8.0.10 → 8.0.11
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/config/app.js +2 -0
- package/containers/App/constants.js +1 -0
- package/initialState.js +3 -0
- package/package.json +1 -1
- package/services/api.js +20 -0
- package/services/tests/api.test.js +148 -0
- package/utils/common.js +7 -0
- package/utils/commonUtils.js +7 -1
- package/utils/tagValidations.js +99 -1
- package/utils/tests/commonUtil.test.js +37 -1
- package/utils/tests/tagValidations.test.js +392 -2
- package/v2Components/Ckeditor/index.js +12 -10
- package/v2Components/ErrorInfoNote/index.js +89 -0
- package/v2Components/ErrorInfoNote/messages.js +29 -0
- package/v2Components/ErrorInfoNote/style.scss +72 -0
- package/v2Components/FormBuilder/_formBuilder.scss +4 -1
- package/v2Components/FormBuilder/index.js +171 -70
- package/v2Components/FormBuilder/messages.js +8 -0
- package/v2Containers/Cap/actions.js +8 -0
- package/v2Containers/Cap/constants.js +4 -0
- package/v2Containers/Cap/mockData.js +74 -0
- package/v2Containers/Cap/reducer.js +12 -0
- package/v2Containers/Cap/sagas.js +28 -1
- package/v2Containers/Cap/selectors.js +5 -0
- package/v2Containers/Cap/tests/__snapshots__/index.test.js.snap +1 -0
- package/v2Containers/Cap/tests/reducer.test.js +50 -0
- package/v2Containers/Cap/tests/saga.test.js +81 -1
- package/v2Containers/CreativesContainer/SlideBoxContent.js +7 -0
- package/v2Containers/CreativesContainer/SlideBoxFooter.js +40 -17
- package/v2Containers/CreativesContainer/constants.js +1 -0
- package/v2Containers/CreativesContainer/index.js +45 -4
- package/v2Containers/CreativesContainer/index.scss +13 -1
- package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +16 -0
- package/v2Containers/Email/_email.scss +3 -0
- package/v2Containers/Email/index.js +2 -0
- package/v2Containers/EmailWrapper/index.js +3 -0
- package/v2Containers/Line/Container/Wrapper/tests/__snapshots__/index.test.js.snap +3 -0
- package/v2Containers/MobilePush/Edit/constants.js +2 -0
- package/v2Containers/MobilePush/Edit/index.js +91 -24
- package/v2Containers/Rcs/tests/__snapshots__/index.test.js.snap +93 -0
- package/v2Containers/SmsTrai/Edit/tests/__snapshots__/index.test.js.snap +12 -0
- package/v2Containers/Viber/constants.js +1 -1
- package/v2Containers/Viber/index.js +19 -19
- package/v2Containers/Viber/messages.js +0 -4
- package/v2Containers/Whatsapp/tests/__snapshots__/index.test.js.snap +12 -0
package/config/app.js
CHANGED
|
@@ -6,6 +6,7 @@ const config = {
|
|
|
6
6
|
api_endpoint: '/arya/api/v1/creatives',
|
|
7
7
|
campaigns_api_endpoint: '/iris/v2/campaigns',
|
|
8
8
|
campaigns_api_org_endpoint: '/iris/v2/org/campaign',
|
|
9
|
+
liquid_endpoint:'/iris/v2/template',
|
|
9
10
|
auth_endpoint: '/arya/api/v1/auth',
|
|
10
11
|
arya_endpoint: '/arya/api/v1',
|
|
11
12
|
login_url: '/auth/login',
|
|
@@ -25,6 +26,7 @@ const config = {
|
|
|
25
26
|
exports_api_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/arya/api/v1/export/data',
|
|
26
27
|
login_url: '/auth/login',
|
|
27
28
|
dashboard_url: '/sms',
|
|
29
|
+
liquid_endpoint: 'https://crm-nightly-new.cc.capillarytech.com/iris/v2/template',
|
|
28
30
|
dashboard_url_v2: '/v2',
|
|
29
31
|
},
|
|
30
32
|
testing: {
|
|
@@ -9,6 +9,7 @@ export const HOSPITALITY_BASED_SCOPE = 'HOSPITALITY_BASED_SCOPE';
|
|
|
9
9
|
export const REGISTRATION_CUSTOM_FIELD = 'Registration custom fields';
|
|
10
10
|
export const GIFT_CARDS = 'GIFT_CARDS';
|
|
11
11
|
export const PROMO_ENGINE = 'PROMO_ENGINE';
|
|
12
|
+
export const LIQUID_SUPPORT = 'ENABLE_LIQUID_SUPPORT';
|
|
12
13
|
export const CUSTOM_TAG = 'CustomTagMessage';
|
|
13
14
|
export const CUSTOMER_EXTENDED_FIELD = 'Customer extended fields';
|
|
14
15
|
export const EXTENDED_TAG = 'ExtendedTagMessage';
|
package/initialState.js
CHANGED
package/package.json
CHANGED
package/services/api.js
CHANGED
|
@@ -14,6 +14,7 @@ let API_ENDPOINT = config.development.api_endpoint;
|
|
|
14
14
|
let EXPORT_API_ENDPOINT = config.development.exports_api_endpoint;
|
|
15
15
|
let CAMPAIGNS_API_ENDPOINT = config.development.campaigns_api_endpoint;
|
|
16
16
|
let CAMPAIGNS_API_ORG_ENDPOINT = config.development.campaigns_api_org_endpoint;
|
|
17
|
+
let LIQUID_API_ENDPOINT = config.development.liquid_endpoint;
|
|
17
18
|
|
|
18
19
|
let API_AUTH_ENDPOINT = config.development.auth_endpoint;
|
|
19
20
|
let ARYA_ENDPOINT = config.development.arya_endpoint;
|
|
@@ -26,6 +27,7 @@ if (process.env.NODE_ENV === 'production') {
|
|
|
26
27
|
ARYA_ENDPOINT = config.production.arya_endpoint;
|
|
27
28
|
SUBSCRIPTION_API_ENDPOINT = config.production.subscription_api_endpoint;
|
|
28
29
|
EXPORT_API_ENDPOINT = config.production.exports_api_endpoint;
|
|
30
|
+
LIQUID_API_ENDPOINT = config.production.liquid_endpoint;
|
|
29
31
|
}
|
|
30
32
|
let requestCallerName = '';
|
|
31
33
|
const isProd = process.env.NODE_ENV === 'production';
|
|
@@ -438,6 +440,19 @@ export const getLocizMessage = async (locale) => {
|
|
|
438
440
|
return response;
|
|
439
441
|
};
|
|
440
442
|
|
|
443
|
+
export const askAiraForLiquid = async ({ templateContent = '', errorMessage = '' }) => {
|
|
444
|
+
const url = `${ARYA_ENDPOINT}/ask-aira-service/creatives_ai/liquidValidation`;
|
|
445
|
+
const response = await request(
|
|
446
|
+
url,
|
|
447
|
+
getAPICallObject("POST", {
|
|
448
|
+
temperature: 0.8,
|
|
449
|
+
templateContent,
|
|
450
|
+
parserError: errorMessage,
|
|
451
|
+
})
|
|
452
|
+
);
|
|
453
|
+
return response;
|
|
454
|
+
};
|
|
455
|
+
|
|
441
456
|
export const getUnsubscribeUrl = () => {
|
|
442
457
|
const body = {
|
|
443
458
|
orgUnitId: -1,
|
|
@@ -543,4 +558,9 @@ export const getNavigationConfigApi = async () => {
|
|
|
543
558
|
return await request(url, getAPICallObject('GET'));
|
|
544
559
|
};
|
|
545
560
|
|
|
561
|
+
export const getLiquidTags = (content) => {
|
|
562
|
+
const url = `${LIQUID_API_ENDPOINT}/extractTags`;
|
|
563
|
+
return request(url, getAPICallObject("POST", { content }, false, true));
|
|
564
|
+
};
|
|
565
|
+
|
|
546
566
|
export {request, getAPICallObject};
|
|
@@ -9,6 +9,8 @@ import {
|
|
|
9
9
|
getAllTemplates,
|
|
10
10
|
getTemplateDetails,
|
|
11
11
|
getTemplateInfoById,
|
|
12
|
+
askAiraForLiquid,
|
|
13
|
+
getLiquidTags,
|
|
12
14
|
} from '../api';
|
|
13
15
|
import { mockData } from './mockData';
|
|
14
16
|
const sampleFile = require('../../assets/line.png');
|
|
@@ -291,3 +293,149 @@ describe('getTemplateInfoById -- Test with valid responses', () => {
|
|
|
291
293
|
});
|
|
292
294
|
});
|
|
293
295
|
});
|
|
296
|
+
|
|
297
|
+
describe('askAiraForLiquid -- Test with various responses', () => {
|
|
298
|
+
beforeEach(() => {
|
|
299
|
+
global.fetch = jest.fn(); // Mocking global fetch function
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
afterEach(() => {
|
|
303
|
+
jest.restoreAllMocks(); // Restore all mocks after each test
|
|
304
|
+
});
|
|
305
|
+
|
|
306
|
+
it('Should return correct response when syntax errors are present', async () => {
|
|
307
|
+
global.fetch.mockReturnValue(
|
|
308
|
+
Promise.resolve({
|
|
309
|
+
status: 200,
|
|
310
|
+
json: () =>
|
|
311
|
+
Promise.resolve({
|
|
312
|
+
status: 200,
|
|
313
|
+
response: 'Error description here',
|
|
314
|
+
}),
|
|
315
|
+
})
|
|
316
|
+
);
|
|
317
|
+
|
|
318
|
+
const templateContent = 'Invalid Liquid Template';
|
|
319
|
+
const errorMessage = 'Parser error message';
|
|
320
|
+
const response = await askAiraForLiquid({ templateContent, errorMessage });
|
|
321
|
+
|
|
322
|
+
expect(response).toEqual({
|
|
323
|
+
status: 200,
|
|
324
|
+
response: 'Error description here',
|
|
325
|
+
});
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
it('Should return empty string when no syntax errors are present', async () => {
|
|
329
|
+
global.fetch.mockReturnValue(
|
|
330
|
+
Promise.resolve({
|
|
331
|
+
status: 200,
|
|
332
|
+
json: () =>
|
|
333
|
+
Promise.resolve({
|
|
334
|
+
status: 200,
|
|
335
|
+
response: '',
|
|
336
|
+
}),
|
|
337
|
+
})
|
|
338
|
+
);
|
|
339
|
+
|
|
340
|
+
const templateContent = 'Valid Liquid Template';
|
|
341
|
+
const errorMessage = '';
|
|
342
|
+
const response = await askAiraForLiquid({ templateContent, errorMessage });
|
|
343
|
+
|
|
344
|
+
expect(response).toEqual({
|
|
345
|
+
status: 200,
|
|
346
|
+
response: '',
|
|
347
|
+
});
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
it('Should handle server errors gracefully', async () => {
|
|
351
|
+
global.fetch.mockReturnValue(
|
|
352
|
+
Promise.resolve({
|
|
353
|
+
status: 500,
|
|
354
|
+
json: () =>
|
|
355
|
+
Promise.resolve({
|
|
356
|
+
status: 500,
|
|
357
|
+
error: 'Internal Server Error',
|
|
358
|
+
}),
|
|
359
|
+
})
|
|
360
|
+
);
|
|
361
|
+
|
|
362
|
+
const templateContent = 'Any Template';
|
|
363
|
+
const errorMessage = 'Any Error Message';
|
|
364
|
+
const response = await askAiraForLiquid({ templateContent, errorMessage });
|
|
365
|
+
|
|
366
|
+
expect(response).toEqual({
|
|
367
|
+
status: 500,
|
|
368
|
+
error: 'Internal Server Error',
|
|
369
|
+
});
|
|
370
|
+
});
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
describe('getLiquidTags -- Test with various responses', () => {
|
|
374
|
+
beforeEach(() => {
|
|
375
|
+
global.fetch = jest.fn(); // Mocking global fetch function
|
|
376
|
+
});
|
|
377
|
+
|
|
378
|
+
afterEach(() => {
|
|
379
|
+
jest.restoreAllMocks(); // Restore all mocks after each test
|
|
380
|
+
});
|
|
381
|
+
|
|
382
|
+
it('Should return correct tags when content has Liquid syntax', async () => {
|
|
383
|
+
const mockResponse = {
|
|
384
|
+
status: 200,
|
|
385
|
+
json: () =>
|
|
386
|
+
Promise.resolve({
|
|
387
|
+
status: 200,
|
|
388
|
+
response: ['tag1', 'tag2'],
|
|
389
|
+
}),
|
|
390
|
+
};
|
|
391
|
+
global.fetch.mockReturnValue(Promise.resolve(mockResponse));
|
|
392
|
+
|
|
393
|
+
const content = 'Some Liquid content with tags';
|
|
394
|
+
const response = await getLiquidTags(content);
|
|
395
|
+
|
|
396
|
+
expect(response).toEqual({
|
|
397
|
+
status: 200,
|
|
398
|
+
response: ['tag1', 'tag2'],
|
|
399
|
+
});
|
|
400
|
+
});
|
|
401
|
+
|
|
402
|
+
it('Should return empty array when content has no Liquid tags', async () => {
|
|
403
|
+
const mockResponse = {
|
|
404
|
+
status: 200,
|
|
405
|
+
json: () =>
|
|
406
|
+
Promise.resolve({
|
|
407
|
+
status: 200,
|
|
408
|
+
response: [],
|
|
409
|
+
}),
|
|
410
|
+
};
|
|
411
|
+
global.fetch.mockReturnValue(Promise.resolve(mockResponse));
|
|
412
|
+
|
|
413
|
+
const content = 'Plain content without Liquid tags';
|
|
414
|
+
const response = await getLiquidTags(content);
|
|
415
|
+
|
|
416
|
+
expect(response).toEqual({
|
|
417
|
+
status: 200,
|
|
418
|
+
response: [],
|
|
419
|
+
});
|
|
420
|
+
});
|
|
421
|
+
|
|
422
|
+
it('Should handle server errors gracefully', async () => {
|
|
423
|
+
const mockResponse = {
|
|
424
|
+
status: 500,
|
|
425
|
+
json: () =>
|
|
426
|
+
Promise.resolve({
|
|
427
|
+
status: 500,
|
|
428
|
+
error: 'Internal Server Error',
|
|
429
|
+
}),
|
|
430
|
+
};
|
|
431
|
+
global.fetch.mockReturnValue(Promise.resolve(mockResponse));
|
|
432
|
+
|
|
433
|
+
const content = 'Any content';
|
|
434
|
+
const response = await getLiquidTags(content);
|
|
435
|
+
|
|
436
|
+
expect(response).toEqual({
|
|
437
|
+
status: 500,
|
|
438
|
+
error: 'Internal Server Error',
|
|
439
|
+
});
|
|
440
|
+
});
|
|
441
|
+
});
|
package/utils/common.js
CHANGED
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
EMAIL_UNSUBSCRIBE_TAG_MANDATORY,
|
|
22
22
|
BADGES_ISSUE,
|
|
23
23
|
ENABLE_WECHAT,
|
|
24
|
+
LIQUID_SUPPORT,
|
|
24
25
|
} from '../containers/App/constants';
|
|
25
26
|
import { apiMessageFormatHandler } from './commonUtils';
|
|
26
27
|
|
|
@@ -88,6 +89,12 @@ export const hasPromoFeature = Auth.hasFeatureAccess.bind(
|
|
|
88
89
|
PROMO_ENGINE,
|
|
89
90
|
);
|
|
90
91
|
|
|
92
|
+
export const hasLiquidSupportFeature = Auth.hasFeatureAccess.bind(
|
|
93
|
+
null,
|
|
94
|
+
LIQUID_SUPPORT,
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
|
|
91
98
|
export const hasGiftVoucherFeature = Auth.hasFeatureAccess.bind(
|
|
92
99
|
null,
|
|
93
100
|
GIFT_CARDS,
|
package/utils/commonUtils.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FormattedMessage } from 'react-intl';
|
|
3
|
+
import get from 'lodash/get';
|
|
4
|
+
import { EMBEDDED } from '../v2Containers/Whatsapp/constants';
|
|
5
|
+
import { EDIT, PREVIEW } from '../v2Containers/App/constants';
|
|
3
6
|
|
|
4
7
|
export const apiMessageFormatHandler = (id, fallback) => (
|
|
5
|
-
|
|
8
|
+
<FormattedMessage id={id} defaultMessage={fallback} />
|
|
6
9
|
);
|
|
7
10
|
|
|
8
11
|
export const addBaseToTemplate = (template) => {
|
|
@@ -20,3 +23,6 @@ export const addBaseToTemplate = (template) => {
|
|
|
20
23
|
}
|
|
21
24
|
return template;
|
|
22
25
|
};
|
|
26
|
+
|
|
27
|
+
export const isEmbeddedEditOrPreview = (queryType, creativesMode) => queryType === EMBEDDED &&
|
|
28
|
+
[EDIT, PREVIEW].includes(creativesMode);
|
package/utils/tagValidations.js
CHANGED
|
@@ -12,6 +12,81 @@ import lodashCloneDeep from 'lodash/cloneDeep';
|
|
|
12
12
|
const DEFAULT = 'default';
|
|
13
13
|
const SUBTAGS = 'subtags';
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Checks if the response object of Tags supports the Tags added in the Add Labels Section
|
|
17
|
+
* @param {Object} response - The response object to check.
|
|
18
|
+
* @param {Object} tagObject - The tagLookupMap.
|
|
19
|
+
*/
|
|
20
|
+
export const checkSupport = (response = {}, tagObject = {}) => {
|
|
21
|
+
const supportedList = [];
|
|
22
|
+
// Verifies the presence of the tag in the 'Add Labels' section.
|
|
23
|
+
const checkNameInTagObject = (name) => !!tagObject[name];
|
|
24
|
+
|
|
25
|
+
// Verify if childTag is a valid sub-tag of parentTag from the 'Add Labels' section or if it's unsupported.
|
|
26
|
+
const checkSubtags = (parentTag, childName) => {
|
|
27
|
+
if (!tagObject?.[parentTag]) return false;
|
|
28
|
+
let updatedChildName = childName;
|
|
29
|
+
if (childName?.includes(".")) {
|
|
30
|
+
updatedChildName = "." + childName?.split(".")?.[1];
|
|
31
|
+
}
|
|
32
|
+
const subTags = tagObject?.[parentTag]?.definition?.subtags;
|
|
33
|
+
return subTags?.includes(updatedChildName);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
//Recursively checks if the childTag is actually a Sub-tag of the ParentTag
|
|
37
|
+
const processChildren = (parentTag = "", children = []) => {
|
|
38
|
+
for (const child of children) {
|
|
39
|
+
if (checkSubtags(parentTag, child?.name)) {
|
|
40
|
+
supportedList.push(child?.name);
|
|
41
|
+
}
|
|
42
|
+
if (child?.children?.length) {
|
|
43
|
+
processChildren(child?.name, child?.children);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
//Checks if the tag is present in the Add Label Section
|
|
49
|
+
for (const item of response?.data || []) {
|
|
50
|
+
if (checkNameInTagObject(item?.name)) {
|
|
51
|
+
supportedList?.push(item?.name);
|
|
52
|
+
}
|
|
53
|
+
//Repeat the process for subtags
|
|
54
|
+
if (item?.children?.length) {
|
|
55
|
+
processChildren(item?.name, item?.children);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
return supportedList;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Extracts the names from the given data.
|
|
65
|
+
* @param {Array} data - The data to extract names from.
|
|
66
|
+
* @returns {Array} - The extracted names.
|
|
67
|
+
*/
|
|
68
|
+
export function extractNames(data) {
|
|
69
|
+
const names = [];
|
|
70
|
+
|
|
71
|
+
function traverse(node) {
|
|
72
|
+
if (node?.name) {
|
|
73
|
+
names.push(node?.name);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
if (node?.children?.length > 0) {
|
|
77
|
+
node?.children?.forEach((child) => traverse(child));
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
data?.forEach((item) => traverse(item));
|
|
82
|
+
|
|
83
|
+
return names;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Validates the tags based on the provided parameters.
|
|
88
|
+
* @param {Object} params - The parameters for tag validation.
|
|
89
|
+
*/
|
|
15
90
|
export const validateTags = ({
|
|
16
91
|
content,
|
|
17
92
|
tagsParam,
|
|
@@ -21,7 +96,8 @@ export const validateTags = ({
|
|
|
21
96
|
}) => {
|
|
22
97
|
const tags = tagsParam;
|
|
23
98
|
const injectedTags = transformInjectedTags(injectedTagsParams);
|
|
24
|
-
let currentModule = location
|
|
99
|
+
let currentModule = location?.query?.module ? location?.query?.module : DEFAULT;
|
|
100
|
+
|
|
25
101
|
if (tagModule) {
|
|
26
102
|
currentModule = tagModule;
|
|
27
103
|
}
|
|
@@ -86,6 +162,12 @@ export const validateTags = ({
|
|
|
86
162
|
return response;
|
|
87
163
|
}
|
|
88
164
|
|
|
165
|
+
/**
|
|
166
|
+
* Checks if the given tag is supported based on the injected tags.
|
|
167
|
+
* @param {string} checkingTag - The tag to check.
|
|
168
|
+
* @param {Array} injectedTags - The injected tags.
|
|
169
|
+
* @returns {boolean} - True if the tag is supported, false otherwise.
|
|
170
|
+
*/
|
|
89
171
|
export const checkIfSupportedTag = (checkingTag, injectedTags) => {
|
|
90
172
|
let result = false;
|
|
91
173
|
lodashForEach(injectedTags, (tag, key) => {
|
|
@@ -156,4 +238,20 @@ export const validateIfTagClosed = (value) => {
|
|
|
156
238
|
|
|
157
239
|
return (l1 == l2 && l2 == l3 && l1 == l3);
|
|
158
240
|
|
|
241
|
+
};
|
|
242
|
+
|
|
243
|
+
//replaces encoded string with their respective characters
|
|
244
|
+
export const preprocessHtml = (content) => {
|
|
245
|
+
|
|
246
|
+
const replacements = {
|
|
247
|
+
"'": "'",
|
|
248
|
+
""": "'",
|
|
249
|
+
'"': "'",
|
|
250
|
+
"&": "&",
|
|
251
|
+
"<": "<",
|
|
252
|
+
">": ">",
|
|
253
|
+
"\n": "", // Handling newlines by replacing them with an empty string
|
|
254
|
+
};
|
|
255
|
+
|
|
256
|
+
return content?.replace(/'|"|&|<|>|"|\n/g, match => replacements[match]);
|
|
159
257
|
};
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
import "@testing-library/jest-dom";
|
|
2
|
+
import get from 'lodash/get';
|
|
2
3
|
import { getTreeStructuredTags } from "../common";
|
|
3
4
|
import * as mockdata from "./common.mockdata";
|
|
4
|
-
import { addBaseToTemplate } from "../commonUtils";
|
|
5
|
+
import { addBaseToTemplate, isEmbeddedEditOrPreview } from "../commonUtils";
|
|
6
|
+
import { EMBEDDED, FULL } from "../../v2Containers/Whatsapp/constants";
|
|
7
|
+
import { CREATE, EDIT, PREVIEW } from "../../v2Containers/App/constants";
|
|
8
|
+
import { query } from "express";
|
|
5
9
|
|
|
6
10
|
jest.mock('@capillarytech/cap-ui-utils', () => ({
|
|
7
11
|
Auth: {
|
|
@@ -12,6 +16,8 @@ jest.mock('@capillarytech/cap-ui-utils', () => ({
|
|
|
12
16
|
},
|
|
13
17
|
}));
|
|
14
18
|
|
|
19
|
+
jest.mock('lodash/get');
|
|
20
|
+
|
|
15
21
|
describe("common utils test", () => {
|
|
16
22
|
it("test for getTreeStructuredTags when tagsList is not empty", () => {
|
|
17
23
|
expect(getTreeStructuredTags({tagsList: mockdata.tagsList})).toEqual(mockdata.output2);
|
|
@@ -77,3 +83,33 @@ describe('addBaseToTemplate', () => {
|
|
|
77
83
|
expect(template).toEqual(originalTemplateCopy);
|
|
78
84
|
});
|
|
79
85
|
});
|
|
86
|
+
|
|
87
|
+
describe('isEmbeddedEditOrPreview', () => {
|
|
88
|
+
beforeEach(() => {
|
|
89
|
+
get.mockClear();
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it('should return true when query type is embedded and creatives mode is edit', () => {
|
|
93
|
+
const queryType = EMBEDDED;
|
|
94
|
+
const creativesMode = EDIT;
|
|
95
|
+
expect(isEmbeddedEditOrPreview(queryType, creativesMode)).toBe(true);
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
it('should return true when query type is embedded and creatives mode is preview', () => {
|
|
99
|
+
const queryType = EMBEDDED;
|
|
100
|
+
const creativesMode = PREVIEW;
|
|
101
|
+
expect(isEmbeddedEditOrPreview(queryType, creativesMode)).toBe(true);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it('should return false when query type is not embedded', () => {
|
|
105
|
+
const queryType = FULL;
|
|
106
|
+
const creativesMode = PREVIEW;
|
|
107
|
+
expect(isEmbeddedEditOrPreview(queryType, creativesMode)).toBe(false);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it('should return false when creatives mode is not edit or preview', () => {
|
|
111
|
+
const queryType = EMBEDDED;
|
|
112
|
+
const creativesMode = CREATE;
|
|
113
|
+
expect(isEmbeddedEditOrPreview(queryType, creativesMode)).toBe(false);
|
|
114
|
+
});
|
|
115
|
+
});
|