@capillarytech/creatives-library 8.0.345-alpha.9 → 8.0.346
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/v2Containers/CreativesContainer/SlideBoxContent.js +1 -20
- package/v2Containers/CreativesContainer/index.js +1 -4
- package/v2Containers/Email/index.js +0 -21
- package/v2Containers/Email/reducer.js +12 -3
- package/v2Containers/Email/sagas.js +9 -4
- package/v2Containers/Email/tests/__snapshots__/reducer.test.js.snap +4 -0
- package/v2Containers/Email/tests/reducer.test.js +47 -0
- package/v2Containers/Email/tests/sagas.test.js +146 -6
package/package.json
CHANGED
|
@@ -705,27 +705,8 @@ export function SlideBoxContent(props) {
|
|
|
705
705
|
// and getDetails?type=BEE_PLUGIN would never fire. Routing BEE
|
|
706
706
|
// templates through the direct <Email> path — which is already
|
|
707
707
|
// battle-tested for the CKEditor flow — sidesteps that entirely.
|
|
708
|
-
const vBase = templateData?.versions?.base;
|
|
709
|
-
const vBaseActiveTab = vBase?.activeTab || vBase?.selectedLanguages?.[0] || 'en';
|
|
710
708
|
const isBEETemplate = templateData?.base?.is_drag_drop === true
|
|
711
|
-
|| templateData?.base?.is_drag_drop === 1
|
|
712
|
-
|| vBase?.[vBaseActiveTab]?.is_drag_drop === true
|
|
713
|
-
|| vBase?.[vBaseActiveTab]?.is_drag_drop === 1;
|
|
714
|
-
console.log('[SlideBoxContent] BEE routing debug', {
|
|
715
|
-
supportCKEditor,
|
|
716
|
-
'templateData._id': templateData?._id,
|
|
717
|
-
'templateData.type': templateData?.type,
|
|
718
|
-
'templateData.base': templateData?.base,
|
|
719
|
-
'templateData.base.is_drag_drop': templateData?.base?.is_drag_drop,
|
|
720
|
-
'templateData.base.drag_drop_id': templateData?.base?.drag_drop_id,
|
|
721
|
-
vBase,
|
|
722
|
-
vBaseActiveTab,
|
|
723
|
-
'vBase[vBaseActiveTab]': vBase?.[vBaseActiveTab],
|
|
724
|
-
'vBase[vBaseActiveTab].is_drag_drop': vBase?.[vBaseActiveTab]?.is_drag_drop,
|
|
725
|
-
'vBase[vBaseActiveTab].drag_drop_id': vBase?.[vBaseActiveTab]?.drag_drop_id,
|
|
726
|
-
isBEETemplate,
|
|
727
|
-
routingTo: (supportCKEditor || isBEETemplate) ? 'Email (direct)' : 'EmailWrapper',
|
|
728
|
-
});
|
|
709
|
+
|| templateData?.base?.is_drag_drop === 1;
|
|
729
710
|
if (supportCKEditor || isBEETemplate) {
|
|
730
711
|
return (
|
|
731
712
|
<Email
|
|
@@ -966,13 +966,10 @@ export class Creatives extends React.Component {
|
|
|
966
966
|
case constants.EMAIL:
|
|
967
967
|
if (template?.value?.base) {
|
|
968
968
|
let emailBase = template.value.base;
|
|
969
|
-
const { html_content
|
|
969
|
+
const { html_content } = emailBase || {};
|
|
970
970
|
if (!html_content) {
|
|
971
971
|
emailBase = templateRecords.base;
|
|
972
972
|
}
|
|
973
|
-
if (!emailBase.drag_drop_id && formDragDropId) {
|
|
974
|
-
emailBase = { ...emailBase, drag_drop_id: formDragDropId };
|
|
975
|
-
}
|
|
976
973
|
const newHtmlContent = await updateImagesInHtml(html_content);
|
|
977
974
|
templateData = {
|
|
978
975
|
...templateData, ...emailBase, emailBody: newHtmlContent, emailSubject: (emailBase && emailBase.subject) ? emailBase.subject : '',
|
|
@@ -224,7 +224,6 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
224
224
|
|| _.get(this.props.Templates.BEETemplate, 'versions.base.drag_drop_id')
|
|
225
225
|
|| _.get(this.props.Templates.BEETemplate, 'versions.base.id')
|
|
226
226
|
|| this.props.Templates.BEETemplate?._id;
|
|
227
|
-
console.log('[Rafeeq manzoor] comes here 1');
|
|
228
227
|
this.props.actions.getCmsSetting(BEE_PLUGIN, dragDropId, 'open', undefined, isBEESupport, isBEEAppEnable);
|
|
229
228
|
} else if (this.props.location.query.module !== "library" || (this.props.location.query.module === "library" && !this.props.templateData)) {
|
|
230
229
|
// Extract drag_drop_id - check multiple possible paths
|
|
@@ -235,7 +234,6 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
235
234
|
|| _.get(this.props.Templates.BEETemplate, 'versions.base.drag_drop_id')
|
|
236
235
|
|| _.get(this.props.Templates.BEETemplate, 'versions.base.id')
|
|
237
236
|
|| this.props.Templates.BEETemplate?._id;
|
|
238
|
-
console.log('[Rafeeq manzoor] comes here 2');
|
|
239
237
|
this.props.actions.getCmsSetting(BEE_PLUGIN, dragDropId, 'create', undefined, isBEESupport, isBEEAppEnable);
|
|
240
238
|
}
|
|
241
239
|
}
|
|
@@ -288,10 +286,8 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
288
286
|
|
|
289
287
|
if (this.props.params.id) {
|
|
290
288
|
const activeTabForLang = beeTemplate.versions?.base?.activeTab || 'en';
|
|
291
|
-
console.log('[Rafeeq manzoor] comes here 3');
|
|
292
289
|
this.props.actions.getCmsSetting(BEE_PLUGIN, dragDropId, 'open', activeTabForLang, isBEESupport, isBEEAppEnable);
|
|
293
290
|
} else {
|
|
294
|
-
console.log('[Rafeeq manzoor] comes here 4');
|
|
295
291
|
this.props.actions.getCmsSetting(BEE_PLUGIN, dragDropId, 'create', undefined, isBEESupport, isBEEAppEnable);
|
|
296
292
|
}
|
|
297
293
|
}
|
|
@@ -456,10 +452,8 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
456
452
|
// Extract langId from active tab
|
|
457
453
|
const activeTabForLang = beeTemplate.versions?.base?.activeTab || 'en';
|
|
458
454
|
if (hasParamsId) {
|
|
459
|
-
console.log('[Rafeeq manzoor] comes here 5');
|
|
460
455
|
this.props.actions.getCmsSetting(BEE_PLUGIN, dragDropId, 'open', activeTabForLang, isBEESupport, isBEEAppEnable);
|
|
461
456
|
} else if (nextProps.location.query.module !== "library" || (nextProps.location.query.module === "library" && !nextProps.templateData)) {
|
|
462
|
-
console.log('[Rafeeq manzoor] comes here 6');
|
|
463
457
|
this.props.actions.getCmsSetting(BEE_PLUGIN, dragDropId, 'create', undefined, isBEESupport, isBEEAppEnable);
|
|
464
458
|
}
|
|
465
459
|
}
|
|
@@ -476,10 +470,6 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
476
470
|
}
|
|
477
471
|
});
|
|
478
472
|
}
|
|
479
|
-
console.log('[Rafeeq manzoor] here we have data 1', this.state.isEdit, nextProps.location.query.module);
|
|
480
|
-
console.log('[Rafeeq manzoor] here we have data 2', nextProps.templateData, !_.isEmpty(nextProps.templateData), this.props.params.id, nextProps.isGetFormData);
|
|
481
|
-
console.log('[Rafeeq manzoor] here we have data 3', _.isEmpty(_.get(this, `state.formData['template-subject']`)));
|
|
482
|
-
|
|
483
473
|
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']`))) {
|
|
484
474
|
this.startTemplateCreation(nextProps.templateData);
|
|
485
475
|
}
|
|
@@ -1248,7 +1238,6 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
1248
1238
|
// formData.base.activeTab = language;
|
|
1249
1239
|
// }
|
|
1250
1240
|
if (language && editData.versions.base[language].is_drag_drop && isBEEAppEnable) {
|
|
1251
|
-
console.log('[Rafeeq manzoor] comes here 7');
|
|
1252
1241
|
this.props.actions.getCmsSetting(BEE_PLUGIN, editData._id, 'open', language, isBEESupport, isBEEAppEnable);
|
|
1253
1242
|
}
|
|
1254
1243
|
});
|
|
@@ -1472,7 +1461,6 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
1472
1461
|
const currentTab = this.state.currentTab - 1;
|
|
1473
1462
|
const baseLanguage = this.props.currentOrgDetails.basic_details.base_language ? this.props.currentOrgDetails.basic_details.base_language : 'en';
|
|
1474
1463
|
if (formData[currentTab][baseLanguage].is_drag_drop && isBEEAppEnable) {
|
|
1475
|
-
console.log('[Rafeeq manzoor] comes here 8');
|
|
1476
1464
|
this.props.actions.getCmsSetting(BEE_PLUGIN, formData[currentTab][baseLanguage].drag_drop_id, 'duplicate', baseLanguage, isEdmSupport, isBEEAppEnable);
|
|
1477
1465
|
}
|
|
1478
1466
|
});
|
|
@@ -1651,9 +1639,6 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
1651
1639
|
if (content.id) {
|
|
1652
1640
|
tmpData.id = content.id;
|
|
1653
1641
|
}
|
|
1654
|
-
if (content.drag_drop_id) {
|
|
1655
|
-
tmpData.drag_drop_id = content.drag_drop_id;
|
|
1656
|
-
}
|
|
1657
1642
|
}
|
|
1658
1643
|
newFormData.base = _.cloneDeep(tmpData);
|
|
1659
1644
|
newFormData.secondary_templates.push({template_data: tmpData});
|
|
@@ -2530,7 +2515,6 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
2530
2515
|
const isBEEAppEnable = this.checkBeeEditorAllowedForLibrary();
|
|
2531
2516
|
if (templates.drag_drop_id && isBEEAppEnable) {
|
|
2532
2517
|
tempData.drag_drop_id = templates.drag_drop_id;
|
|
2533
|
-
console.log('[Rafeeq manzoor] comes here 9');
|
|
2534
2518
|
this.props.actions.getCmsSetting(BEE_PLUGIN, tempData._id, 'open', tempData.iso_code, isEdmSupport, isBEEAppEnable);
|
|
2535
2519
|
}
|
|
2536
2520
|
// formData.usingTabContainer = true;
|
|
@@ -2551,17 +2535,13 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
2551
2535
|
});
|
|
2552
2536
|
this.addLanguage(false, formData, false, additionalLanguages);
|
|
2553
2537
|
}
|
|
2554
|
-
console.log("[Rafeeq manzoor] comes here lib 1", formData[0])
|
|
2555
2538
|
formData.base = _.cloneDeep(formData[0]);
|
|
2556
2539
|
if (formData?.['template-subject'] !== '') {
|
|
2557
|
-
console.log("[Rafeeq manzoor] comes here lib 1 if", formData)
|
|
2558
2540
|
this.setState({formData, loading: false, injectedTags: data.tags, tabKey, isDragDrop: (data.base.is_drag_drop !== 0 )}, () => {
|
|
2559
2541
|
// this.setState({tabKey: ''});
|
|
2560
2542
|
const isBEEEnable = this.checkBeeEditorAllowedForLibrary();
|
|
2561
|
-
console.log("[Rafeeq manzoor] comes here lib 1 isBEEEnable", isBEEEnable)
|
|
2562
2543
|
_.forEach(formData[0].selectedLanguages, (language) => {
|
|
2563
2544
|
if (formData[0][language].is_drag_drop && isBEEEnable) {
|
|
2564
|
-
console.log('[Rafeeq manzoor] comes here 10');
|
|
2565
2545
|
this.props.actions.getCmsSetting(BEE_PLUGIN, formData[0][language].drag_drop_id, 'open', language, isEdmSupport, isBEEEnable);
|
|
2566
2546
|
}
|
|
2567
2547
|
});
|
|
@@ -2904,7 +2884,6 @@ export class Email extends React.Component { // eslint-disable-line react/prefer
|
|
|
2904
2884
|
// let getQuery = '';
|
|
2905
2885
|
const isEdmSupport = (this.props.location.query.isEdmSupport !== "false") || false;
|
|
2906
2886
|
const isBEEAppEnable = this.checkBeeEditorAllowedForLibrary();
|
|
2907
|
-
console.log('[Rafeeq manzoor] comes here 11');
|
|
2908
2887
|
this.props.actions.getCmsSetting(BEE_PLUGIN, data._id, 'create', this.state.formData[this.state.currentTab - 1].activeTab, isEdmSupport, isBEEAppEnable);
|
|
2909
2888
|
// this.props.templatesActions.setEdmTemplate(data);
|
|
2910
2889
|
this.toggleEdmEmailTemplateSelection();
|
|
@@ -12,6 +12,8 @@ const initialState = fromJS({
|
|
|
12
12
|
createTemplateInProgress: false,
|
|
13
13
|
createResponse: {},
|
|
14
14
|
isBeeEnabled: null,
|
|
15
|
+
fetchingCmsAccounts: false,
|
|
16
|
+
cmsAccountsLoaded: false,
|
|
15
17
|
});
|
|
16
18
|
|
|
17
19
|
function emailReducer(state = initialState, action) {
|
|
@@ -85,6 +87,7 @@ function emailReducer(state = initialState, action) {
|
|
|
85
87
|
case types.GET_CMS_EDITOR_DETAILS_SUCCESS:
|
|
86
88
|
return state
|
|
87
89
|
.set('fetchingCmsSettings', false)
|
|
90
|
+
.set('isBeeEnabled', action.isBeeEnabled)
|
|
88
91
|
.set('CmsSettings', fromJS(action.settings));
|
|
89
92
|
case types.GET_CMS_EDITOR_DETAILS_FAILURE:
|
|
90
93
|
return state
|
|
@@ -110,13 +113,19 @@ function emailReducer(state = initialState, action) {
|
|
|
110
113
|
.set('fetchingCmsDataFailed', true);
|
|
111
114
|
case types.GET_CMS_ACCOUNTS_REQUEST:
|
|
112
115
|
return state
|
|
113
|
-
.set('isBeeEnabled', false)
|
|
116
|
+
.set('isBeeEnabled', false)
|
|
117
|
+
.set('fetchingCmsAccounts', true)
|
|
118
|
+
.set('cmsAccountsLoaded', false);
|
|
114
119
|
case types.GET_CMS_ACCOUNTS_SUCCESS:
|
|
115
120
|
return state
|
|
116
|
-
.set('isBeeEnabled', action.isBeeEnabled)
|
|
121
|
+
.set('isBeeEnabled', action.isBeeEnabled)
|
|
122
|
+
.set('fetchingCmsAccounts', false)
|
|
123
|
+
.set('cmsAccountsLoaded', true);
|
|
117
124
|
case types.GET_CMS_ACCOUNTS_FAILURE:
|
|
118
125
|
return state
|
|
119
|
-
.set('isBeeEnabled', false)
|
|
126
|
+
.set('isBeeEnabled', false)
|
|
127
|
+
.set('fetchingCmsAccounts', false)
|
|
128
|
+
.set('cmsAccountsLoaded', true);
|
|
120
129
|
case types.CLEAR_EMAIL_CRUD_RESPONSE_REQUEST:
|
|
121
130
|
return state
|
|
122
131
|
.set('createResponse', fromJS({}));
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {
|
|
2
|
-
call, put, takeLatest, takeEvery, all,
|
|
2
|
+
call, put, takeLatest, takeEvery, all, select, take,
|
|
3
3
|
} from 'redux-saga/effects';
|
|
4
4
|
import CapNotification from '@capillarytech/cap-ui-library/CapNotification';
|
|
5
5
|
import * as Api from '../../services/api';
|
|
@@ -103,14 +103,19 @@ export function* getAllAssets(assetType, queryParams) {
|
|
|
103
103
|
}
|
|
104
104
|
|
|
105
105
|
export function* getCmsSetting({
|
|
106
|
-
cmsType, projectId, cmsMode, langId, isEdmSupport, isBEEAppEnable,
|
|
106
|
+
cmsType, projectId, cmsMode, langId, isEdmSupport, isBEEAppEnable: isBEEAppEnableFromAction,
|
|
107
107
|
}) {
|
|
108
108
|
try {
|
|
109
|
+
const emailState = yield select((state) => state.get('email'));
|
|
110
|
+
if (!emailState.get('cmsAccountsLoaded') && emailState.get('fetchingCmsAccounts')) {
|
|
111
|
+
yield take([types.GET_CMS_ACCOUNTS_SUCCESS, types.GET_CMS_ACCOUNTS_FAILURE]);
|
|
112
|
+
}
|
|
113
|
+
const updatedState = yield select((state) => state.get('email'));
|
|
114
|
+
const isBEEAppEnable = updatedState.get('isBeeEnabled') ?? isBEEAppEnableFromAction;
|
|
109
115
|
const result = yield call(Api.getCmsTemplateSettingsV2, cmsType, projectId, cmsMode, langId, isEdmSupport, isBEEAppEnable);
|
|
110
116
|
const cmsAccountDetail = result.data?.response.cmsDetails || {};
|
|
111
117
|
const isBeeEnabled = cmsAccountDetail?.type === cmsType;
|
|
112
|
-
yield put({ type: types.
|
|
113
|
-
yield put({ type: types.GET_CMS_EDITOR_DETAILS_SUCCESS, settings: result.data.response.cmsDetails });
|
|
118
|
+
yield put({ type: types.GET_CMS_EDITOR_DETAILS_SUCCESS, settings: cmsAccountDetail, isBeeEnabled });
|
|
114
119
|
} catch (error) {
|
|
115
120
|
yield put({ type: types.GET_CMS_EDITOR_DETAILS_FAILURE, error });
|
|
116
121
|
}
|
|
@@ -5,6 +5,8 @@ Immutable.Map {
|
|
|
5
5
|
"createTemplateInProgress": false,
|
|
6
6
|
"createResponse": Immutable.Map {},
|
|
7
7
|
"isBeeEnabled": null,
|
|
8
|
+
"fetchingCmsAccounts": false,
|
|
9
|
+
"cmsAccountsLoaded": false,
|
|
8
10
|
}
|
|
9
11
|
`;
|
|
10
12
|
|
|
@@ -13,5 +15,7 @@ Immutable.Map {
|
|
|
13
15
|
"createTemplateInProgress": true,
|
|
14
16
|
"createResponse": Immutable.Map {},
|
|
15
17
|
"isBeeEnabled": null,
|
|
18
|
+
"fetchingCmsAccounts": false,
|
|
19
|
+
"cmsAccountsLoaded": false,
|
|
16
20
|
}
|
|
17
21
|
`;
|
|
@@ -16,6 +16,53 @@ describe('emailReducer', () => {
|
|
|
16
16
|
expect(emailReducer(undefined, action)).toMatchSnapshot();
|
|
17
17
|
});
|
|
18
18
|
|
|
19
|
+
it.concurrent('it handles GET_CMS_EDITOR_DETAILS_SUCCESS action — sets isBeeEnabled true and CmsSettings', () => {
|
|
20
|
+
const initialState = fromJS({ isBeeEnabled: null, fetchingCmsSettings: true });
|
|
21
|
+
const action = {
|
|
22
|
+
type: types.GET_CMS_EDITOR_DETAILS_SUCCESS,
|
|
23
|
+
isBeeEnabled: true,
|
|
24
|
+
settings: { isDragDrop: true, editorType: 'bee' },
|
|
25
|
+
};
|
|
26
|
+
const result = emailReducer(initialState, action);
|
|
27
|
+
expect(result.get('fetchingCmsSettings')).toBe(false);
|
|
28
|
+
expect(result.get('isBeeEnabled')).toBe(true);
|
|
29
|
+
expect(result.getIn(['CmsSettings', 'isDragDrop'])).toBe(true);
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it.concurrent('it handles GET_CMS_EDITOR_DETAILS_SUCCESS action — sets isBeeEnabled false', () => {
|
|
33
|
+
const initialState = fromJS({ isBeeEnabled: true, fetchingCmsSettings: true });
|
|
34
|
+
const action = {
|
|
35
|
+
type: types.GET_CMS_EDITOR_DETAILS_SUCCESS,
|
|
36
|
+
isBeeEnabled: false,
|
|
37
|
+
settings: {},
|
|
38
|
+
};
|
|
39
|
+
const result = emailReducer(initialState, action);
|
|
40
|
+
expect(result.get('fetchingCmsSettings')).toBe(false);
|
|
41
|
+
expect(result.get('isBeeEnabled')).toBe(false);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it.concurrent('it handles GET_CMS_EDITOR_DETAILS_SUCCESS action — overwrites stale isBeeEnabled from CLEAR_ALL_VALUES (null)', () => {
|
|
45
|
+
const initialState = fromJS({ isBeeEnabled: null, fetchingCmsSettings: true });
|
|
46
|
+
const action = {
|
|
47
|
+
type: types.GET_CMS_EDITOR_DETAILS_SUCCESS,
|
|
48
|
+
isBeeEnabled: true,
|
|
49
|
+
settings: { type: 'bee' },
|
|
50
|
+
};
|
|
51
|
+
const result = emailReducer(initialState, action);
|
|
52
|
+
expect(result.get('isBeeEnabled')).toBe(true);
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
it.concurrent('it handles GET_CMS_EDITOR_DETAILS_SUCCESS action — sets CmsSettings to empty object when settings is {}', () => {
|
|
56
|
+
const initialState = fromJS({ CmsSettings: { old: 'data' } });
|
|
57
|
+
const action = {
|
|
58
|
+
type: types.GET_CMS_EDITOR_DETAILS_SUCCESS,
|
|
59
|
+
isBeeEnabled: false,
|
|
60
|
+
settings: {},
|
|
61
|
+
};
|
|
62
|
+
const result = emailReducer(initialState, action);
|
|
63
|
+
expect(result.get('CmsSettings').toJS()).toEqual({});
|
|
64
|
+
});
|
|
65
|
+
|
|
19
66
|
it.concurrent('it handles GET_CMS_ACCOUNTS_REQUEST action (line 111-113)', () => {
|
|
20
67
|
const initialState = fromJS({
|
|
21
68
|
isBeeEnabled: true, // Start with true to verify it gets set to false
|
|
@@ -3,6 +3,7 @@ import { expectSaga } from 'redux-saga-test-plan';
|
|
|
3
3
|
import { takeLatest } from 'redux-saga/effects';
|
|
4
4
|
import * as matchers from 'redux-saga-test-plan/matchers';
|
|
5
5
|
import { throwError } from 'redux-saga-test-plan/providers';
|
|
6
|
+
import { fromJS } from 'immutable';
|
|
6
7
|
import * as types from '../constants';
|
|
7
8
|
import * as sagas from '../sagas';
|
|
8
9
|
import { v2EmailDuplicateTemplateSaga, v2EmailSagas } from '../sagas';
|
|
@@ -709,10 +710,14 @@ describe('getCmsSetting saga', () => {
|
|
|
709
710
|
|
|
710
711
|
return expectSaga(sagas.getCmsSetting, basePayload)
|
|
711
712
|
.provide([
|
|
713
|
+
{
|
|
714
|
+
select(effect, next) {
|
|
715
|
+
return fromJS({ cmsAccountsLoaded: true, isBeeEnabled: true });
|
|
716
|
+
},
|
|
717
|
+
},
|
|
712
718
|
[matchers.call.fn(Api.getCmsTemplateSettingsV2), fakeResponse],
|
|
713
719
|
])
|
|
714
|
-
.put({ type: types.
|
|
715
|
-
.put({ type: types.GET_CMS_EDITOR_DETAILS_SUCCESS, settings: fakeResponse.data.response.cmsDetails })
|
|
720
|
+
.put({ type: types.GET_CMS_EDITOR_DETAILS_SUCCESS, settings: fakeResponse.data.response.cmsDetails, isBeeEnabled: true })
|
|
716
721
|
.run();
|
|
717
722
|
});
|
|
718
723
|
|
|
@@ -727,10 +732,14 @@ describe('getCmsSetting saga', () => {
|
|
|
727
732
|
|
|
728
733
|
return expectSaga(sagas.getCmsSetting, basePayload)
|
|
729
734
|
.provide([
|
|
735
|
+
{
|
|
736
|
+
select(effect, next) {
|
|
737
|
+
return fromJS({ cmsAccountsLoaded: true, isBeeEnabled: false });
|
|
738
|
+
},
|
|
739
|
+
},
|
|
730
740
|
[matchers.call.fn(Api.getCmsTemplateSettingsV2), fakeResponse],
|
|
731
741
|
])
|
|
732
|
-
.put({ type: types.
|
|
733
|
-
.put({ type: types.GET_CMS_EDITOR_DETAILS_SUCCESS, settings: fakeResponse.data.response.cmsDetails })
|
|
742
|
+
.put({ type: types.GET_CMS_EDITOR_DETAILS_SUCCESS, settings: fakeResponse.data.response.cmsDetails, isBeeEnabled: false })
|
|
734
743
|
.run();
|
|
735
744
|
});
|
|
736
745
|
|
|
@@ -743,10 +752,14 @@ describe('getCmsSetting saga', () => {
|
|
|
743
752
|
|
|
744
753
|
return expectSaga(sagas.getCmsSetting, basePayload)
|
|
745
754
|
.provide([
|
|
755
|
+
{
|
|
756
|
+
select(effect, next) {
|
|
757
|
+
return fromJS({ cmsAccountsLoaded: true, isBeeEnabled: false });
|
|
758
|
+
},
|
|
759
|
+
},
|
|
746
760
|
[matchers.call.fn(Api.getCmsTemplateSettingsV2), fakeResponse],
|
|
747
761
|
])
|
|
748
|
-
.put({ type: types.
|
|
749
|
-
.put({ type: types.GET_CMS_EDITOR_DETAILS_SUCCESS, settings: undefined })
|
|
762
|
+
.put({ type: types.GET_CMS_EDITOR_DETAILS_SUCCESS, settings: {}, isBeeEnabled: false })
|
|
750
763
|
.run();
|
|
751
764
|
});
|
|
752
765
|
|
|
@@ -755,11 +768,138 @@ describe('getCmsSetting saga', () => {
|
|
|
755
768
|
|
|
756
769
|
return expectSaga(sagas.getCmsSetting, basePayload)
|
|
757
770
|
.provide([
|
|
771
|
+
{
|
|
772
|
+
select(effect, next) {
|
|
773
|
+
return fromJS({ cmsAccountsLoaded: true, isBeeEnabled: true });
|
|
774
|
+
},
|
|
775
|
+
},
|
|
758
776
|
[matchers.call.fn(Api.getCmsTemplateSettingsV2), throwError(fakeError)],
|
|
759
777
|
])
|
|
760
778
|
.put({ type: types.GET_CMS_EDITOR_DETAILS_FAILURE, error: fakeError })
|
|
761
779
|
.run();
|
|
762
780
|
});
|
|
781
|
+
|
|
782
|
+
it('should wait for accounts when fetchingCmsAccounts is true and cmsAccountsLoaded is false (accounts succeed)', () => {
|
|
783
|
+
const fakeResponse = {
|
|
784
|
+
data: { response: { cmsDetails: { type: 'bee', settings: {} } } },
|
|
785
|
+
};
|
|
786
|
+
let selectCallCount = 0;
|
|
787
|
+
|
|
788
|
+
return expectSaga(sagas.getCmsSetting, basePayload)
|
|
789
|
+
.provide([
|
|
790
|
+
{
|
|
791
|
+
select(effect, next) {
|
|
792
|
+
selectCallCount += 1;
|
|
793
|
+
if (selectCallCount === 1) {
|
|
794
|
+
return fromJS({ cmsAccountsLoaded: false, fetchingCmsAccounts: true, isBeeEnabled: null });
|
|
795
|
+
}
|
|
796
|
+
return fromJS({ cmsAccountsLoaded: true, fetchingCmsAccounts: false, isBeeEnabled: true });
|
|
797
|
+
},
|
|
798
|
+
},
|
|
799
|
+
[matchers.call.fn(Api.getCmsTemplateSettingsV2), fakeResponse],
|
|
800
|
+
])
|
|
801
|
+
.dispatch({ type: types.GET_CMS_ACCOUNTS_SUCCESS, isBeeEnabled: true })
|
|
802
|
+
.put({ type: types.GET_CMS_EDITOR_DETAILS_SUCCESS, settings: { type: 'bee', settings: {} }, isBeeEnabled: true })
|
|
803
|
+
.run();
|
|
804
|
+
});
|
|
805
|
+
|
|
806
|
+
it('should wait for accounts when fetchingCmsAccounts is true and cmsAccountsLoaded is false (accounts fail)', () => {
|
|
807
|
+
const fakeResponse = {
|
|
808
|
+
data: { response: { cmsDetails: { type: 'ck', settings: {} } } },
|
|
809
|
+
};
|
|
810
|
+
let selectCallCount = 0;
|
|
811
|
+
|
|
812
|
+
return expectSaga(sagas.getCmsSetting, basePayload)
|
|
813
|
+
.provide([
|
|
814
|
+
{
|
|
815
|
+
select(effect, next) {
|
|
816
|
+
selectCallCount += 1;
|
|
817
|
+
if (selectCallCount === 1) {
|
|
818
|
+
return fromJS({ cmsAccountsLoaded: false, fetchingCmsAccounts: true, isBeeEnabled: null });
|
|
819
|
+
}
|
|
820
|
+
return fromJS({ cmsAccountsLoaded: true, fetchingCmsAccounts: false, isBeeEnabled: false });
|
|
821
|
+
},
|
|
822
|
+
},
|
|
823
|
+
[matchers.call.fn(Api.getCmsTemplateSettingsV2), fakeResponse],
|
|
824
|
+
])
|
|
825
|
+
.dispatch({ type: types.GET_CMS_ACCOUNTS_FAILURE })
|
|
826
|
+
.put({ type: types.GET_CMS_EDITOR_DETAILS_SUCCESS, settings: { type: 'ck', settings: {} }, isBeeEnabled: false })
|
|
827
|
+
.run();
|
|
828
|
+
});
|
|
829
|
+
|
|
830
|
+
it('should skip wait and use isBEEAppEnableFromAction as fallback when cmsAccountsLoaded is false but fetchingCmsAccounts is false', () => {
|
|
831
|
+
const fakeResponse = {
|
|
832
|
+
data: { response: { cmsDetails: { type: 'bee', settings: {} } } },
|
|
833
|
+
};
|
|
834
|
+
|
|
835
|
+
return expectSaga(sagas.getCmsSetting, { ...basePayload, isBEEAppEnable: true })
|
|
836
|
+
.provide([
|
|
837
|
+
{
|
|
838
|
+
select(effect, next) {
|
|
839
|
+
return fromJS({ cmsAccountsLoaded: false, fetchingCmsAccounts: false, isBeeEnabled: null });
|
|
840
|
+
},
|
|
841
|
+
},
|
|
842
|
+
[matchers.call.fn(Api.getCmsTemplateSettingsV2), fakeResponse],
|
|
843
|
+
])
|
|
844
|
+
.put({ type: types.GET_CMS_EDITOR_DETAILS_SUCCESS, settings: { type: 'bee', settings: {} }, isBeeEnabled: true })
|
|
845
|
+
.run();
|
|
846
|
+
});
|
|
847
|
+
|
|
848
|
+
it('should use state isBeeEnabled (null) and fall back to isBEEAppEnableFromAction via ?? operator', () => {
|
|
849
|
+
const fakeResponse = {
|
|
850
|
+
data: { response: { cmsDetails: { type: 'bee', settings: {} } } },
|
|
851
|
+
};
|
|
852
|
+
|
|
853
|
+
return expectSaga(sagas.getCmsSetting, { ...basePayload, isBEEAppEnable: true })
|
|
854
|
+
.provide([
|
|
855
|
+
{
|
|
856
|
+
select(effect, next) {
|
|
857
|
+
return fromJS({ cmsAccountsLoaded: true, fetchingCmsAccounts: false, isBeeEnabled: null });
|
|
858
|
+
},
|
|
859
|
+
},
|
|
860
|
+
[matchers.call.fn(Api.getCmsTemplateSettingsV2), fakeResponse],
|
|
861
|
+
])
|
|
862
|
+
.call(Api.getCmsTemplateSettingsV2, basePayload.cmsType, basePayload.projectId, basePayload.cmsMode, basePayload.langId, basePayload.isEdmSupport, true)
|
|
863
|
+
.put({ type: types.GET_CMS_EDITOR_DETAILS_SUCCESS, settings: { type: 'bee', settings: {} }, isBeeEnabled: true })
|
|
864
|
+
.run();
|
|
865
|
+
});
|
|
866
|
+
|
|
867
|
+
it('should use state isBeeEnabled false over isBEEAppEnableFromAction true via ?? operator (false is not null/undefined)', () => {
|
|
868
|
+
const fakeResponse = {
|
|
869
|
+
data: { response: { cmsDetails: { type: 'bee', settings: {} } } },
|
|
870
|
+
};
|
|
871
|
+
|
|
872
|
+
return expectSaga(sagas.getCmsSetting, { ...basePayload, isBEEAppEnable: true })
|
|
873
|
+
.provide([
|
|
874
|
+
{
|
|
875
|
+
select(effect, next) {
|
|
876
|
+
return fromJS({ cmsAccountsLoaded: true, fetchingCmsAccounts: false, isBeeEnabled: false });
|
|
877
|
+
},
|
|
878
|
+
},
|
|
879
|
+
[matchers.call.fn(Api.getCmsTemplateSettingsV2), fakeResponse],
|
|
880
|
+
])
|
|
881
|
+
.call(Api.getCmsTemplateSettingsV2, basePayload.cmsType, basePayload.projectId, basePayload.cmsMode, basePayload.langId, basePayload.isEdmSupport, false)
|
|
882
|
+
.put({ type: types.GET_CMS_EDITOR_DETAILS_SUCCESS, settings: { type: 'bee', settings: {} }, isBeeEnabled: true })
|
|
883
|
+
.run();
|
|
884
|
+
});
|
|
885
|
+
|
|
886
|
+
it('should derive isBeeEnabled false when cmsDetails type is undefined', () => {
|
|
887
|
+
const fakeResponse = {
|
|
888
|
+
data: { response: { cmsDetails: { settings: {} } } },
|
|
889
|
+
};
|
|
890
|
+
|
|
891
|
+
return expectSaga(sagas.getCmsSetting, basePayload)
|
|
892
|
+
.provide([
|
|
893
|
+
{
|
|
894
|
+
select(effect, next) {
|
|
895
|
+
return fromJS({ cmsAccountsLoaded: true, fetchingCmsAccounts: false, isBeeEnabled: true });
|
|
896
|
+
},
|
|
897
|
+
},
|
|
898
|
+
[matchers.call.fn(Api.getCmsTemplateSettingsV2), fakeResponse],
|
|
899
|
+
])
|
|
900
|
+
.put({ type: types.GET_CMS_EDITOR_DETAILS_SUCCESS, settings: { settings: {} }, isBeeEnabled: false })
|
|
901
|
+
.run();
|
|
902
|
+
});
|
|
763
903
|
});
|
|
764
904
|
|
|
765
905
|
|