@capillarytech/creatives-library 8.0.345 → 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/services/api.js +0 -20
- package/services/tests/api.test.js +0 -59
- package/v2Components/CapCustomSkeleton/index.js +1 -1
- package/v2Components/CapCustomSkeleton/tests/__snapshots__/index.test.js.snap +12 -12
- package/v2Containers/CreativesContainer/SlideBoxFooter.js +1 -3
- package/v2Containers/CreativesContainer/index.js +0 -5
- package/v2Containers/CreativesContainer/messages.js +0 -4
- package/v2Containers/CreativesContainer/tests/__snapshots__/index.test.js.snap +0 -3
- 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/v2Containers/Templates/ChannelTypeIllustration.js +6 -23
- package/v2Containers/Templates/_templates.scss +24 -130
- package/v2Containers/Templates/actions.js +0 -36
- package/v2Containers/Templates/constants.js +0 -23
- package/v2Containers/Templates/index.js +30 -286
- package/v2Containers/Templates/messages.js +0 -68
- package/v2Containers/Templates/reducer.js +0 -68
- package/v2Containers/Templates/sagas.js +1 -89
- package/v2Containers/Templates/selectors.js +0 -12
- package/v2Containers/Templates/tests/ChannelTypeIllustration.test.js +0 -12
- package/v2Containers/Templates/tests/__snapshots__/index.test.js.snap +1122 -1300
- package/v2Containers/Templates/tests/index.test.js +0 -6
- package/v2Containers/Templates/tests/reducer.test.js +0 -178
- package/v2Containers/Templates/tests/sagas.test.js +8 -314
- package/v2Containers/Templates/tests/selector.test.js +0 -32
- package/v2Containers/Assets/images/archive_Empty_Illustration.svg +0 -9
package/package.json
CHANGED
package/services/api.js
CHANGED
|
@@ -361,26 +361,6 @@ export const deleteTemplate = ({channel, id}) => {
|
|
|
361
361
|
//return API.deleteResource(url);
|
|
362
362
|
};
|
|
363
363
|
|
|
364
|
-
export const archiveTemplate = ({ channel, id }) => {
|
|
365
|
-
const url = `${API_ENDPOINT}/templates/archive/${id}/${channel}`;
|
|
366
|
-
return request(url, getAPICallObject('PUT'));
|
|
367
|
-
};
|
|
368
|
-
|
|
369
|
-
export const unarchiveTemplate = ({ channel, id }) => {
|
|
370
|
-
const url = `${API_ENDPOINT}/templates/unarchive/${id}/${channel}`;
|
|
371
|
-
return request(url, getAPICallObject('PUT'));
|
|
372
|
-
};
|
|
373
|
-
|
|
374
|
-
export const bulkArchiveTemplates = ({ channel, ids }) => {
|
|
375
|
-
const url = `${API_ENDPOINT}/templates/archive/bulk/${channel}`;
|
|
376
|
-
return request(url, getAPICallObject('PUT', { ids }));
|
|
377
|
-
};
|
|
378
|
-
|
|
379
|
-
export const bulkUnarchiveTemplates = ({ channel, ids }) => {
|
|
380
|
-
const url = `${API_ENDPOINT}/templates/unarchive/bulk/${channel}`;
|
|
381
|
-
return request(url, getAPICallObject('PUT', { ids }));
|
|
382
|
-
};
|
|
383
|
-
|
|
384
364
|
export const deleteRcsTemplate = ({ templateName }) => {
|
|
385
365
|
const url = `${API_ENDPOINT}/templates/${templateName}/RCS`;
|
|
386
366
|
return request(url, getAPICallObject('DELETE'))
|
|
@@ -1086,62 +1086,3 @@ describe('createTestCustomer', () => {
|
|
|
1086
1086
|
expect(lastCall[1].body).toBe(JSON.stringify(payload));
|
|
1087
1087
|
});
|
|
1088
1088
|
});
|
|
1089
|
-
|
|
1090
|
-
import {
|
|
1091
|
-
archiveTemplate,
|
|
1092
|
-
unarchiveTemplate,
|
|
1093
|
-
bulkArchiveTemplates,
|
|
1094
|
-
bulkUnarchiveTemplates,
|
|
1095
|
-
} from '../api';
|
|
1096
|
-
|
|
1097
|
-
describe('archiveTemplate', () => {
|
|
1098
|
-
beforeEach(() => {
|
|
1099
|
-
global.fetch = jest.fn().mockReturnValue(Promise.resolve({ json: () => Promise.resolve({}) }));
|
|
1100
|
-
});
|
|
1101
|
-
|
|
1102
|
-
it('should call PUT on archive endpoint', () => {
|
|
1103
|
-
archiveTemplate({ channel: 'EMAIL', id: 'id123' });
|
|
1104
|
-
expect(global.fetch).toHaveBeenCalled();
|
|
1105
|
-
const lastCall = global.fetch.mock.calls[global.fetch.mock.calls.length - 1];
|
|
1106
|
-
expect(lastCall[1].method).toBe('PUT');
|
|
1107
|
-
});
|
|
1108
|
-
});
|
|
1109
|
-
|
|
1110
|
-
describe('unarchiveTemplate', () => {
|
|
1111
|
-
beforeEach(() => {
|
|
1112
|
-
global.fetch = jest.fn().mockReturnValue(Promise.resolve({ json: () => Promise.resolve({}) }));
|
|
1113
|
-
});
|
|
1114
|
-
|
|
1115
|
-
it('should call PUT on unarchive endpoint', () => {
|
|
1116
|
-
unarchiveTemplate({ channel: 'EMAIL', id: 'id123' });
|
|
1117
|
-
expect(global.fetch).toHaveBeenCalled();
|
|
1118
|
-
const lastCall = global.fetch.mock.calls[global.fetch.mock.calls.length - 1];
|
|
1119
|
-
expect(lastCall[1].method).toBe('PUT');
|
|
1120
|
-
});
|
|
1121
|
-
});
|
|
1122
|
-
|
|
1123
|
-
describe('bulkArchiveTemplates', () => {
|
|
1124
|
-
beforeEach(() => {
|
|
1125
|
-
global.fetch = jest.fn().mockReturnValue(Promise.resolve({ json: () => Promise.resolve({}) }));
|
|
1126
|
-
});
|
|
1127
|
-
|
|
1128
|
-
it('should call PUT on bulk archive endpoint with ids', () => {
|
|
1129
|
-
bulkArchiveTemplates({ channel: 'EMAIL', ids: ['id1', 'id2'] });
|
|
1130
|
-
expect(global.fetch).toHaveBeenCalled();
|
|
1131
|
-
const lastCall = global.fetch.mock.calls[global.fetch.mock.calls.length - 1];
|
|
1132
|
-
expect(lastCall[1].method).toBe('PUT');
|
|
1133
|
-
});
|
|
1134
|
-
});
|
|
1135
|
-
|
|
1136
|
-
describe('bulkUnarchiveTemplates', () => {
|
|
1137
|
-
beforeEach(() => {
|
|
1138
|
-
global.fetch = jest.fn().mockReturnValue(Promise.resolve({ json: () => Promise.resolve({}) }));
|
|
1139
|
-
});
|
|
1140
|
-
|
|
1141
|
-
it('should call PUT on bulk unarchive endpoint with ids', () => {
|
|
1142
|
-
bulkUnarchiveTemplates({ channel: 'EMAIL', ids: ['id1', 'id2'] });
|
|
1143
|
-
expect(global.fetch).toHaveBeenCalled();
|
|
1144
|
-
const lastCall = global.fetch.mock.calls[global.fetch.mock.calls.length - 1];
|
|
1145
|
-
expect(lastCall[1].method).toBe('PUT');
|
|
1146
|
-
});
|
|
1147
|
-
});
|
|
@@ -20,7 +20,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
|
|
|
20
20
|
>
|
|
21
21
|
<CapColumn
|
|
22
22
|
key="0"
|
|
23
|
-
lg={
|
|
23
|
+
lg={6}
|
|
24
24
|
md={8}
|
|
25
25
|
sm={12}
|
|
26
26
|
xs={24}
|
|
@@ -40,7 +40,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
|
|
|
40
40
|
</CapColumn>
|
|
41
41
|
<CapColumn
|
|
42
42
|
key="1"
|
|
43
|
-
lg={
|
|
43
|
+
lg={6}
|
|
44
44
|
md={8}
|
|
45
45
|
sm={12}
|
|
46
46
|
xs={24}
|
|
@@ -60,7 +60,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
|
|
|
60
60
|
</CapColumn>
|
|
61
61
|
<CapColumn
|
|
62
62
|
key="2"
|
|
63
|
-
lg={
|
|
63
|
+
lg={6}
|
|
64
64
|
md={8}
|
|
65
65
|
sm={12}
|
|
66
66
|
xs={24}
|
|
@@ -80,7 +80,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
|
|
|
80
80
|
</CapColumn>
|
|
81
81
|
<CapColumn
|
|
82
82
|
key="3"
|
|
83
|
-
lg={
|
|
83
|
+
lg={6}
|
|
84
84
|
md={8}
|
|
85
85
|
sm={12}
|
|
86
86
|
xs={24}
|
|
@@ -100,7 +100,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
|
|
|
100
100
|
</CapColumn>
|
|
101
101
|
<CapColumn
|
|
102
102
|
key="4"
|
|
103
|
-
lg={
|
|
103
|
+
lg={6}
|
|
104
104
|
md={8}
|
|
105
105
|
sm={12}
|
|
106
106
|
xs={24}
|
|
@@ -120,7 +120,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
|
|
|
120
120
|
</CapColumn>
|
|
121
121
|
<CapColumn
|
|
122
122
|
key="5"
|
|
123
|
-
lg={
|
|
123
|
+
lg={6}
|
|
124
124
|
md={8}
|
|
125
125
|
sm={12}
|
|
126
126
|
xs={24}
|
|
@@ -140,7 +140,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
|
|
|
140
140
|
</CapColumn>
|
|
141
141
|
<CapColumn
|
|
142
142
|
key="6"
|
|
143
|
-
lg={
|
|
143
|
+
lg={6}
|
|
144
144
|
md={8}
|
|
145
145
|
sm={12}
|
|
146
146
|
xs={24}
|
|
@@ -160,7 +160,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
|
|
|
160
160
|
</CapColumn>
|
|
161
161
|
<CapColumn
|
|
162
162
|
key="7"
|
|
163
|
-
lg={
|
|
163
|
+
lg={6}
|
|
164
164
|
md={8}
|
|
165
165
|
sm={12}
|
|
166
166
|
xs={24}
|
|
@@ -180,7 +180,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
|
|
|
180
180
|
</CapColumn>
|
|
181
181
|
<CapColumn
|
|
182
182
|
key="8"
|
|
183
|
-
lg={
|
|
183
|
+
lg={6}
|
|
184
184
|
md={8}
|
|
185
185
|
sm={12}
|
|
186
186
|
xs={24}
|
|
@@ -200,7 +200,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
|
|
|
200
200
|
</CapColumn>
|
|
201
201
|
<CapColumn
|
|
202
202
|
key="9"
|
|
203
|
-
lg={
|
|
203
|
+
lg={6}
|
|
204
204
|
md={8}
|
|
205
205
|
sm={12}
|
|
206
206
|
xs={24}
|
|
@@ -220,7 +220,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
|
|
|
220
220
|
</CapColumn>
|
|
221
221
|
<CapColumn
|
|
222
222
|
key="10"
|
|
223
|
-
lg={
|
|
223
|
+
lg={6}
|
|
224
224
|
md={8}
|
|
225
225
|
sm={12}
|
|
226
226
|
xs={24}
|
|
@@ -240,7 +240,7 @@ exports[`CapCustomSkeleton test renders correct CapCustomSkeleton component 1`]
|
|
|
240
240
|
</CapColumn>
|
|
241
241
|
<CapColumn
|
|
242
242
|
key="11"
|
|
243
|
-
lg={
|
|
243
|
+
lg={6}
|
|
244
244
|
md={8}
|
|
245
245
|
sm={12}
|
|
246
246
|
xs={24}
|
|
@@ -24,7 +24,6 @@ function SlideBoxFooter(props) {
|
|
|
24
24
|
slidBoxContent,
|
|
25
25
|
onSave,
|
|
26
26
|
onEditTemplate,
|
|
27
|
-
isTemplateArchived,
|
|
28
27
|
onCreateNextStep,
|
|
29
28
|
isFullMode,
|
|
30
29
|
fetchingCmsData,
|
|
@@ -215,7 +214,7 @@ function SlideBoxFooter(props) {
|
|
|
215
214
|
<FormattedMessage {...(continueButtonLabel || messages.continue)} />
|
|
216
215
|
</CapButton>
|
|
217
216
|
)}
|
|
218
|
-
{slidBoxContent === PREVIEW &&
|
|
217
|
+
{slidBoxContent === PREVIEW && (
|
|
219
218
|
<CapButton onClick={onEditTemplate} type="secondary">
|
|
220
219
|
<FormattedMessage {...messages.creativesTemplatesEdit} />
|
|
221
220
|
</CapButton>
|
|
@@ -228,7 +227,6 @@ SlideBoxFooter.propTypes = {
|
|
|
228
227
|
slidBoxContent: PropTypes.node,
|
|
229
228
|
onSave: PropTypes.func,
|
|
230
229
|
onEditTemplate: PropTypes.func,
|
|
231
|
-
isTemplateArchived: PropTypes.bool,
|
|
232
230
|
onCreateNextStep: PropTypes.func,
|
|
233
231
|
shouldShowContinueFooter: PropTypes.func,
|
|
234
232
|
shouldShowDoneFooter: PropTypes.func,
|
|
@@ -260,10 +260,6 @@ export class Creatives extends React.Component {
|
|
|
260
260
|
};
|
|
261
261
|
|
|
262
262
|
onEditTemplate = () => {
|
|
263
|
-
if (this.props.templateData && this.props.templateData.isArchived) {
|
|
264
|
-
CapNotification.error({ message: this.props.intl.formatMessage(messages.cannotEditArchivedTemplate) });
|
|
265
|
-
return;
|
|
266
|
-
}
|
|
267
263
|
this.setState({ slidBoxContent: 'editTemplate', showSlideBox: true, templateNameExists: true });
|
|
268
264
|
};
|
|
269
265
|
|
|
@@ -2140,7 +2136,6 @@ export class Creatives extends React.Component {
|
|
|
2140
2136
|
onSave={this.saveMessage}
|
|
2141
2137
|
onDiscard={this.discardMessage}
|
|
2142
2138
|
onEditTemplate={this.onEditTemplate}
|
|
2143
|
-
isTemplateArchived={!!(this.props.templateData && this.props.templateData.isArchived)}
|
|
2144
2139
|
slidBoxContent={slidBoxContent}
|
|
2145
2140
|
onCreateNextStep={this.onCreateNextStep}
|
|
2146
2141
|
currentChannel={currentChannel.toUpperCase()}
|
|
@@ -390,8 +390,4 @@ export default defineMessages({
|
|
|
390
390
|
id: `${scope}.personalizationTokensErrorMessage`,
|
|
391
391
|
defaultMessage: `Personalization tags are not supported for anonymous customers, please remove the tags.`,
|
|
392
392
|
},
|
|
393
|
-
"cannotEditArchivedTemplate": {
|
|
394
|
-
id: `${scope}.cannotEditArchivedTemplate`,
|
|
395
|
-
defaultMessage: 'Cannot edit an archived template. Please unarchive it first.',
|
|
396
|
-
},
|
|
397
393
|
});
|
|
@@ -295,7 +295,6 @@ exports[`Test SlideBoxContent container campaign message, whatsapp edit all data
|
|
|
295
295
|
isEmptyContent={false}
|
|
296
296
|
isFullMode={false}
|
|
297
297
|
isLiquidValidationError={false}
|
|
298
|
-
isTemplateArchived={false}
|
|
299
298
|
isTemplateNameEmpty={false}
|
|
300
299
|
onCreateNextStep={[Function]}
|
|
301
300
|
onDiscard={[Function]}
|
|
@@ -435,7 +434,6 @@ exports[`Test SlideBoxContent container campaign message, whatsapp edit min data
|
|
|
435
434
|
isEmptyContent={false}
|
|
436
435
|
isFullMode={false}
|
|
437
436
|
isLiquidValidationError={false}
|
|
438
|
-
isTemplateArchived={false}
|
|
439
437
|
isTemplateNameEmpty={false}
|
|
440
438
|
onCreateNextStep={[Function]}
|
|
441
439
|
onDiscard={[Function]}
|
|
@@ -575,7 +573,6 @@ exports[`Test SlideBoxContent container it should clear the url, on channel chan
|
|
|
575
573
|
isEmptyContent={false}
|
|
576
574
|
isFullMode={false}
|
|
577
575
|
isLiquidValidationError={false}
|
|
578
|
-
isTemplateArchived={false}
|
|
579
576
|
isTemplateNameEmpty={false}
|
|
580
577
|
onCreateNextStep={[Function]}
|
|
581
578
|
onDiscard={[Function]}
|
|
@@ -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
|
|