@capillarytech/creatives-library 7.13.15 → 7.13.17
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 +9 -1
- package/v2Containers/CapFacebookPreview/index.js +0 -1
- package/v2Containers/CapFacebookPreview/tests/index.test.js +40 -0
- package/v2Containers/CapFacebookPreview/tests/mockdata.js +60 -0
- package/v2Containers/CreativesContainer/constants.js +1 -1
- package/v2Containers/Email/index.js +48 -8
- package/v2Containers/Email/mockdata/mockdata.js +0 -54
- package/v2Containers/Email/tests/index.test.js +0 -35
package/package.json
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capillarytech/creatives-library",
|
|
3
3
|
"author": "meharaj",
|
|
4
|
-
"
|
|
4
|
+
"sideEffects": [
|
|
5
|
+
"*.css",
|
|
6
|
+
"*.scss",
|
|
7
|
+
"*/styles/",
|
|
8
|
+
"*global-styles*",
|
|
9
|
+
"*font*",
|
|
10
|
+
"*moment/locale*"
|
|
11
|
+
],
|
|
12
|
+
"version": "7.13.17",
|
|
5
13
|
"description": "Capillary creatives ui",
|
|
6
14
|
"main": "./index.js",
|
|
7
15
|
"module": "./index.es.js",
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { injectIntl } from 'react-intl';
|
|
3
|
+
import '@testing-library/jest-dom';
|
|
4
|
+
import userEvent from '@testing-library/user-event';
|
|
5
|
+
import {render, screen, fireEvent } from '../../../utils/test-utils';
|
|
6
|
+
import {CapFacebookPreview} from '../index';
|
|
7
|
+
import { facebookImgMockData, getPreviewActionCalledWith } from './mockdata';
|
|
8
|
+
|
|
9
|
+
const ComponentToRender = injectIntl(CapFacebookPreview);
|
|
10
|
+
const renderComponent = props => render(<ComponentToRender {...props} />);
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
const getPreview = jest.fn();
|
|
14
|
+
const clearPreview = jest.fn();
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
describe("CapFacebookPreview Test",()=>{
|
|
18
|
+
it("It should call getPreview action with appropriate fields", ()=>{
|
|
19
|
+
const facebookPreviewActions = {
|
|
20
|
+
getPreview,
|
|
21
|
+
clearPreview
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const props = {
|
|
25
|
+
...facebookImgMockData,
|
|
26
|
+
facebookPreviewActions
|
|
27
|
+
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
renderComponent(props);
|
|
31
|
+
|
|
32
|
+
const generatePreviewBtn = screen.getByRole('button', { name: /generate preview/i});
|
|
33
|
+
expect(generatePreviewBtn).toBeEnabled();
|
|
34
|
+
|
|
35
|
+
fireEvent.click(generatePreviewBtn);
|
|
36
|
+
|
|
37
|
+
expect(getPreview).toHaveBeenCalledTimes(1);
|
|
38
|
+
expect(getPreview).toHaveBeenCalledWith(getPreviewActionCalledWith);
|
|
39
|
+
})
|
|
40
|
+
})
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export const facebookImgMockData = {
|
|
2
|
+
"disablePreviewButton": false,
|
|
3
|
+
"selectedAd": "IMAGE",
|
|
4
|
+
"previewData": [
|
|
5
|
+
{
|
|
6
|
+
"subType": "IMAGE",
|
|
7
|
+
"imageData": {
|
|
8
|
+
"imageSrc": "https://storage.crm.n.content-cdn.io/cdn-cgi/image/quality=75/intouch_creative_assets/e94dbe9b-b3a1-4eec-86d0-d859d7a.jpeg"
|
|
9
|
+
},
|
|
10
|
+
"videoData": {},
|
|
11
|
+
"webSiteLink": "https://www.google.com",
|
|
12
|
+
"linkHeadLine": "asdf",
|
|
13
|
+
"linkDesc": "asdfa",
|
|
14
|
+
"errorMsg": {
|
|
15
|
+
"websiteLinkErrorMsg": false
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
],
|
|
19
|
+
"primaryText": "af",
|
|
20
|
+
"callToAction": "NO_CALL_TO_ACTION",
|
|
21
|
+
"displayLink": "",
|
|
22
|
+
"orgUnitFacebookPageSettingsMap": {
|
|
23
|
+
"pageId": "1234",
|
|
24
|
+
"pageName": "1234_Nightly",
|
|
25
|
+
"pageAccessToken": "randomPageAccessToken",
|
|
26
|
+
"pageStatus": "SENT",
|
|
27
|
+
"verificationStatus": "APPROVED",
|
|
28
|
+
"isPageAccessTokenUpdated": false
|
|
29
|
+
},
|
|
30
|
+
"accessToken": "randomAccessToken",
|
|
31
|
+
"accountId": "1234567",
|
|
32
|
+
"facebookPreviewData": {
|
|
33
|
+
"fetchPreviewStatus": "PreviewNotRequested",
|
|
34
|
+
"previewIframe": "",
|
|
35
|
+
"previewIframeError": ""
|
|
36
|
+
},
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export const getPreviewActionCalledWith = {
|
|
40
|
+
accessToken: "randomAccessToken",
|
|
41
|
+
pageAccessToken: "randomPageAccessToken",
|
|
42
|
+
pageId: "1234",
|
|
43
|
+
actId: "act_1234567",
|
|
44
|
+
params: {
|
|
45
|
+
creative: {
|
|
46
|
+
object_story_spec: {
|
|
47
|
+
page_id: "1234",
|
|
48
|
+
link_data: {
|
|
49
|
+
description: "asdfa",
|
|
50
|
+
message: "af",
|
|
51
|
+
link: "https://www.google.com",
|
|
52
|
+
name: "asdf",
|
|
53
|
+
picture:
|
|
54
|
+
"https://storage.crm.n.content-cdn.io/cdn-cgi/image/quality=75/intouch_creative_assets/e94dbe9b-b3a1-4eec-86d0-d859d7a.jpeg",
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
ad_format: "DESKTOP_FEED_STANDARD",
|
|
59
|
+
},
|
|
60
|
+
};
|
|
@@ -22,4 +22,4 @@ export const RCS = "RCS";
|
|
|
22
22
|
export const SHOW_CONTANER_LOADER = "app/CreativesContainer/SHOW_CONTANER_LOADER";
|
|
23
23
|
export const HIDE_CONTAINER_LOADER = "app/CreativesContainer/HIDE_CONTAINER_LOADER";
|
|
24
24
|
|
|
25
|
-
export const WHATSAPP_HELP_DOC_LINK = "https://
|
|
25
|
+
export const WHATSAPP_HELP_DOC_LINK = "https://support.capillarytech.com/en/support/solutions/articles/4000180620-create-whatsapp-template";
|
|
@@ -324,7 +324,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
324
324
|
if (this.state.isEdit && nextProps.location.query.module === "library" && !_.isEmpty(nextProps.templateData) && !this.props.params.id && !nextProps.isGetFormData && _.isEmpty(_.get(this, `state.formData['template-subject']`))) {
|
|
325
325
|
this.startTemplateCreation(nextProps.templateData);
|
|
326
326
|
}
|
|
327
|
-
if (nextProps.location.query.module === 'library' && nextProps.isGetFormData && (this.props.isGetFormData
|
|
327
|
+
if (nextProps.location.query.module === 'library' && nextProps.isGetFormData && (this.props.isGetFormData!==nextProps.isGetFormData)) {
|
|
328
328
|
const formData = this.state.formData;
|
|
329
329
|
let isBeeEditor = false;
|
|
330
330
|
const isBEEEnable = this.checkBeeEditorAllowedForLibrary();
|
|
@@ -681,9 +681,9 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
681
681
|
channel: EMAIL,
|
|
682
682
|
timeTaken,
|
|
683
683
|
content: base?.[activeTab]?.['template-content'],
|
|
684
|
-
mode: isEdit ? EDIT : CREATE
|
|
684
|
+
mode: isEdit ? EDIT : CREATE
|
|
685
685
|
});
|
|
686
|
-
|
|
686
|
+
|
|
687
687
|
// this.resetSchema();
|
|
688
688
|
let message;
|
|
689
689
|
if (isEdit) {
|
|
@@ -872,6 +872,46 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
872
872
|
} else {
|
|
873
873
|
schema.containers[index].isActive = false;
|
|
874
874
|
}
|
|
875
|
+
// const isLanguageSupport = this.props.location.query.isLanguageSupport;
|
|
876
|
+
|
|
877
|
+
_.forEach(data.selectedLanguages, (lang, langIndex) => {
|
|
878
|
+
if ((type !== 'embedded' || (type === 'embedded' && isLanguageSupport === 'true')) && lang !== this.props.currentOrgDetails.basic_details.base_language) {
|
|
879
|
+
const tabContent = _.cloneDeep(containers[0].tabContent.sections[0]);
|
|
880
|
+
const tabContentSection = tabContent.inputFields[0].cols[0];
|
|
881
|
+
const panes = containers[0].panes.slice();
|
|
882
|
+
const firstPane = _.cloneDeep(panes[0]);
|
|
883
|
+
const sections = [];
|
|
884
|
+
_.forEach(firstPane.sections, (section) => {
|
|
885
|
+
let sect = _.cloneDeep(section);
|
|
886
|
+
|
|
887
|
+
if (sect.type === 'col-label') {
|
|
888
|
+
sect = this.cloneColLabel(sect, (langIndex + 1));
|
|
889
|
+
} else if (sect.type === 'multicols') {
|
|
890
|
+
sect = this.cloneMultiCol(sect, (langIndex + 1));
|
|
891
|
+
} else if (sect.type === 'parent') {
|
|
892
|
+
sect = this.cloneParent(sect, (langIndex + 1));
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
sections.push(sect);
|
|
896
|
+
return true;
|
|
897
|
+
});
|
|
898
|
+
//
|
|
899
|
+
|
|
900
|
+
this.map[`template-content${data.selectedLanguages.indexOf(lang) + 1}`] = this.map['template-content'];
|
|
901
|
+
tabContentSection.id = `${tabContentSection.id}${index + 1}`;
|
|
902
|
+
tabContentSection.value = `${data[lang].language}`;
|
|
903
|
+
|
|
904
|
+
firstPane.sections = sections;
|
|
905
|
+
firstPane.sectionsHeaders = [tabContent];
|
|
906
|
+
|
|
907
|
+
// panes.push(firstPane);
|
|
908
|
+
|
|
909
|
+
schema.containers[index].panes.push(firstPane);
|
|
910
|
+
} else if (lang !== this.props.currentOrgDetails.basic_details.base_language) {
|
|
911
|
+
delete data[lang];
|
|
912
|
+
data.selectedLanguages.splice(langIndex, 1);
|
|
913
|
+
}
|
|
914
|
+
});
|
|
875
915
|
}
|
|
876
916
|
if (data.base) {
|
|
877
917
|
formData.base = data;
|
|
@@ -2333,7 +2373,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
2333
2373
|
const response = {
|
|
2334
2374
|
action: "getFormData",
|
|
2335
2375
|
postAction: this.state.getFormDataValue || 'next',
|
|
2336
|
-
id: _.get(this.props, 'Email.templateDetails._id', ''),
|
|
2376
|
+
id : _.get(this.props, 'Email.templateDetails._id', ''),
|
|
2337
2377
|
value: this.transformFormData(passedData),
|
|
2338
2378
|
validity: this.state.isFormValid,
|
|
2339
2379
|
type: 'EMAIL',
|
|
@@ -2367,9 +2407,9 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
2367
2407
|
const newdata = data;
|
|
2368
2408
|
|
|
2369
2409
|
if (!isNaN(index) && newdata) {
|
|
2370
|
-
|
|
2371
|
-
const baseLangTabKey = newdata[baseLanguage]?.tabKey || newdata.tabKey;
|
|
2410
|
+
const baseLangTabKey = newdata[baseLanguage].tabKey;
|
|
2372
2411
|
newdata.tabKey = baseLangTabKey;
|
|
2412
|
+
newdata.activeTab = baseLanguage;
|
|
2373
2413
|
if (newdata.base) {
|
|
2374
2414
|
baseKey = baseLangTabKey;
|
|
2375
2415
|
}
|
|
@@ -2391,7 +2431,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
2391
2431
|
obj.versions.base = formData.base;
|
|
2392
2432
|
obj.versions.base.tabKey = baseKey;
|
|
2393
2433
|
obj.versions.base.subject = formData['template-subject'];
|
|
2394
|
-
obj.versions.base.activeTab =
|
|
2434
|
+
obj.versions.base.activeTab = baseLanguage;
|
|
2395
2435
|
_.forEach(obj.versions.base.selectedLanguages, (language) => {
|
|
2396
2436
|
if (obj.versions.base[language].is_drag_drop) {
|
|
2397
2437
|
delete obj.versions.base[language].edmeditorsrc;
|
|
@@ -2690,7 +2730,7 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
2690
2730
|
isEdit={this.state.isEdit}
|
|
2691
2731
|
iframeParent={parent}
|
|
2692
2732
|
router={this.props.router}
|
|
2693
|
-
baseLanguage={this.
|
|
2733
|
+
baseLanguage={this.props.currentOrgDetails.basic_details.base_language}
|
|
2694
2734
|
supportedLanguages={this.getSupportedLanguages(this.props)}
|
|
2695
2735
|
isSchemaChanged={this.state.isSchemaChanged}
|
|
2696
2736
|
cmsTemplates={this.props.Templates.cmsTemplates}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
export const EMAILPreviewMockData = {
|
|
2
|
-
loadingStatus: 0,
|
|
3
|
-
formData: {},
|
|
4
|
-
tabCount: 1,
|
|
5
|
-
currentTab: 1,
|
|
6
|
-
events: {
|
|
7
|
-
blur: (() => {}),
|
|
8
|
-
afterPaste: (() => {}),
|
|
9
|
-
change: (() => {}),
|
|
10
|
-
},
|
|
11
|
-
isEdit: false,
|
|
12
|
-
schema: {},
|
|
13
|
-
loading: false,
|
|
14
|
-
isFormValid: true,
|
|
15
|
-
injectedTags: {},
|
|
16
|
-
checkValidation: false,
|
|
17
|
-
saveEdmDataMode: 'save',
|
|
18
|
-
tabKey: '',
|
|
19
|
-
showEmailPreview: false,
|
|
20
|
-
device: "desktop",
|
|
21
|
-
editorInstanse: undefined,
|
|
22
|
-
showImageSelectionBox: false,
|
|
23
|
-
isDragDrop: false,
|
|
24
|
-
showConfirmationModal: false,
|
|
25
|
-
modalContent: {title: "", body: "", type: 'confirm', id: 'email-language-delete-modal'},
|
|
26
|
-
showModal: false,
|
|
27
|
-
page: 1,
|
|
28
|
-
perPageLimit: 25,
|
|
29
|
-
totalCount: 0,
|
|
30
|
-
searchText: '',
|
|
31
|
-
saveCount: 0,
|
|
32
|
-
cmsDataCount: 0,
|
|
33
|
-
targetSaveCount: 0,
|
|
34
|
-
saveObj: {},
|
|
35
|
-
showEdmEmailTemplates: false,
|
|
36
|
-
editDataSet: false,
|
|
37
|
-
languageDataSet: false,
|
|
38
|
-
addLanguageType: '',
|
|
39
|
-
startValidation: false,
|
|
40
|
-
saveForm: false,
|
|
41
|
-
|
|
42
|
-
params: {},
|
|
43
|
-
location: {
|
|
44
|
-
pathname: '/creatives/ui/v2',
|
|
45
|
-
search: '',
|
|
46
|
-
hash: '',
|
|
47
|
-
key: 'm54f44',
|
|
48
|
-
query: {module: "library"},
|
|
49
|
-
},
|
|
50
|
-
Templates: {},
|
|
51
|
-
Email: {},
|
|
52
|
-
isGetFormData: true,
|
|
53
|
-
currentOrgDetails: {basic_details: {}},
|
|
54
|
-
};
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { injectIntl } from 'react-intl';
|
|
3
|
-
import '@testing-library/jest-dom';
|
|
4
|
-
import {
|
|
5
|
-
render,
|
|
6
|
-
} from '../../../utils/test-utils';
|
|
7
|
-
import { EMAILPreviewMockData } from '../mockdata/mockdata';
|
|
8
|
-
import { Email } from "../index";
|
|
9
|
-
|
|
10
|
-
const initializeComponent = () => {
|
|
11
|
-
const Component = injectIntl(Email);
|
|
12
|
-
const resetUploadData = jest.fn();
|
|
13
|
-
const clearStoreValues = jest.fn();
|
|
14
|
-
const clearCRUDResponse = jest.fn();
|
|
15
|
-
const fetchSchemaForEntity = jest.fn();
|
|
16
|
-
|
|
17
|
-
return render( <Component
|
|
18
|
-
{...EMAILPreviewMockData}
|
|
19
|
-
templatesActions={{resetUploadData}}
|
|
20
|
-
actions={{
|
|
21
|
-
clearStoreValues,
|
|
22
|
-
clearCRUDResponse,
|
|
23
|
-
}}
|
|
24
|
-
globalActions={{
|
|
25
|
-
fetchSchemaForEntity,
|
|
26
|
-
}}
|
|
27
|
-
/>);
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
describe('renders a message', () => {
|
|
31
|
-
it("Test if Email component renders", () => {
|
|
32
|
-
initializeComponent();
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
|