summaryrefslogtreecommitdiffstats
path: root/openecomp-ui
diff options
context:
space:
mode:
authorsvishnev <shlomo-stanisla.vishnevetskiy@amdocs.com>2018-04-22 14:14:31 +0300
committerEinav Keidar <einavw@amdocs.com>2018-04-22 12:19:13 +0000
commit57c5c4ab80cde4290cac97a6eba3dc7de280538a (patch)
tree450d14403035554ca79f0de55c40c81b71e7740e /openecomp-ui
parenteb4b9fb0f4d3b62f3b9e2da81ebe581e7d0fc6eb (diff)
attachment page navigation fix
Issue-ID: SDC-1239 Change-Id: Ib597238233e9a035944b7a56a56601cdfd624ca2 Signed-off-by: svishnev <shlomo-stanisla.vishnevetskiy@amdocs.com>
Diffstat (limited to 'openecomp-ui')
-rw-r--r--openecomp-ui/src/sdc-app/common/helpers/ItemsHelper.js14
-rw-r--r--openecomp-ui/src/sdc-app/common/helpers/ItemsHelperConstants.js10
-rw-r--r--openecomp-ui/src/sdc-app/onboarding/OnboardingPunchOut.jsx7
-rw-r--r--openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementActionHelper.js45
-rw-r--r--openecomp-ui/src/sdc-app/onboarding/onboard/filter/FilterComponents.jsx14
-rw-r--r--openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsView.jsx11
-rw-r--r--openecomp-ui/test/licenseModel/entitlementPools/test.js1133
-rw-r--r--openecomp-ui/test/licenseModel/featureGroups/test.js736
-rw-r--r--openecomp-ui/test/licenseModel/licenseAgreement/test.js587
-rw-r--r--openecomp-ui/test/licenseModel/licenseKeyGroups/test.js1099
-rw-r--r--openecomp-ui/test/licenseModel/test.js303
-rw-r--r--openecomp-ui/test/onboard/filter/filter.test.js14
-rw-r--r--openecomp-ui/test/onboard/test.js30
-rw-r--r--openecomp-ui/test/softwareProduct/test.js227
14 files changed, 2590 insertions, 1640 deletions
diff --git a/openecomp-ui/src/sdc-app/common/helpers/ItemsHelper.js b/openecomp-ui/src/sdc-app/common/helpers/ItemsHelper.js
index ae5c2707b6..bbca87fec5 100644
--- a/openecomp-ui/src/sdc-app/common/helpers/ItemsHelper.js
+++ b/openecomp-ui/src/sdc-app/common/helpers/ItemsHelper.js
@@ -18,8 +18,6 @@ import Configuration from 'sdc-app/config/Configuration.js';
import { permissionTypes } from 'sdc-app/onboarding/permissions/PermissionsConstants.js';
import { actionsEnum as VersionControllerActionsEnum } from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
import { actionTypes as onboardingActionTypes } from 'sdc-app/onboarding/OnboardingConstants.js';
-import { restToggle } from 'sdc-app/features/featureToggleUtils.js';
-import { featureToggleNames } from 'sdc-app/features/FeaturesConstants.js';
import objectPropsToUrlString from 'nfvo-utils/objectPropsToUrlString.js';
export const archiveActions = {
@@ -98,11 +96,7 @@ const ItemsHelper = {
},
fetchItem(itemId) {
- return restToggle({
- restFunction: () => RestAPIUtil.fetch(`${baseUrl()}/${itemId}`),
- featureName: featureToggleNames.ARCHIVE_ITEM,
- mockResult: {}
- });
+ return RestAPIUtil.fetch(`${baseUrl()}/${itemId}`);
},
archiveItem(itemId) {
@@ -118,11 +112,7 @@ const ItemsHelper = {
fetchItems(filterData) {
const str = objectPropsToUrlString(filterData);
- return restToggle({
- restFunction: () => RestAPIUtil.fetch(`${baseUrl()}?${str}`),
- featureName: featureToggleNames.FILTER,
- mockResult: { results: [] }
- });
+ return RestAPIUtil.fetch(`${baseUrl()}?${str}`);
}
};
diff --git a/openecomp-ui/src/sdc-app/common/helpers/ItemsHelperConstants.js b/openecomp-ui/src/sdc-app/common/helpers/ItemsHelperConstants.js
index ebbbfded3b..9837fed53c 100644
--- a/openecomp-ui/src/sdc-app/common/helpers/ItemsHelperConstants.js
+++ b/openecomp-ui/src/sdc-app/common/helpers/ItemsHelperConstants.js
@@ -27,3 +27,13 @@ export const itemType = {
VSP: 'vsp',
VLM: 'vlm'
};
+
+export const itemPermissions = {
+ CONTRIBUTOR: 'Contributor',
+ OWNER: 'Owner'
+};
+
+export const itemOnboardingProcedure = {
+ NETWORK: 'NetworkPackage',
+ MANUAL: 'Manual'
+};
diff --git a/openecomp-ui/src/sdc-app/onboarding/OnboardingPunchOut.jsx b/openecomp-ui/src/sdc-app/onboarding/OnboardingPunchOut.jsx
index 245dd2b55c..a73501468c 100644
--- a/openecomp-ui/src/sdc-app/onboarding/OnboardingPunchOut.jsx
+++ b/openecomp-ui/src/sdc-app/onboarding/OnboardingPunchOut.jsx
@@ -232,12 +232,13 @@ export default class OnboardingPunchOut {
softwareProductScreen ===
enums.SCREEN.SOFTWARE_PRODUCT_ATTACHMENTS
) {
- softwareProduct = vspData;
+ softwareProduct = { ...vspData };
//check current vsp fields to determine which file has uploaded
+
if (
- vspData.onboardingOrigin ===
+ vspData.onboardingOrigin.toLowerCase() ===
onboardingOriginTypes.ZIP ||
- vspData.candidateOnboardingOrigin ===
+ vspData.candidateOnboardingOrigin.toLowerCase() ===
onboardingOriginTypes.ZIP
) {
softwareProductScreen =
diff --git a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementActionHelper.js
index e07777f69e..5d425a8aa4 100644
--- a/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementActionHelper.js
+++ b/openecomp-ui/src/sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementActionHelper.js
@@ -124,46 +124,37 @@ export default {
});
},
- saveLicenseAgreement(
+ async saveLicenseAgreement(
dispatch,
{ licenseModelId, previousLicenseAgreement, licenseAgreement, version }
) {
if (previousLicenseAgreement) {
- return putLicenseAgreement(
+ await putLicenseAgreement(
licenseModelId,
previousLicenseAgreement,
licenseAgreement,
version
- ).then(() => {
- this.fetchLicenseAgreementList(dispatch, {
- licenseModelId,
- version
- });
- return ItemsHelper.checkItemStatus(dispatch, {
- itemId: licenseModelId,
- versionId: version.id
- });
- });
+ );
} else {
- return postLicenseAgreement(
+ await postLicenseAgreement(
licenseModelId,
licenseAgreement,
version
- ).then(() => {
- this.fetchLicenseAgreementList(dispatch, {
- licenseModelId,
- version
- });
- FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {
- licenseModelId,
- version
- });
- return ItemsHelper.checkItemStatus(dispatch, {
- itemId: licenseModelId,
- versionId: version.id
- });
- });
+ );
}
+ await this.fetchLicenseAgreementList(dispatch, {
+ licenseModelId,
+ version
+ });
+ await FeatureGroupsActionHelper.fetchFeatureGroupsList(dispatch, {
+ licenseModelId,
+ version
+ });
+
+ return ItemsHelper.checkItemStatus(dispatch, {
+ itemId: licenseModelId,
+ versionId: version.id
+ });
},
deleteLicenseAgreement(
diff --git a/openecomp-ui/src/sdc-app/onboarding/onboard/filter/FilterComponents.jsx b/openecomp-ui/src/sdc-app/onboarding/onboard/filter/FilterComponents.jsx
index b114941a3c..6a4760afdf 100644
--- a/openecomp-ui/src/sdc-app/onboarding/onboard/filter/FilterComponents.jsx
+++ b/openecomp-ui/src/sdc-app/onboarding/onboard/filter/FilterComponents.jsx
@@ -16,7 +16,11 @@
import React from 'react';
import Input from 'nfvo-components/input/validation/Input.jsx';
import i18n from 'nfvo-utils/i18n/i18n.js';
-import { itemStatus } from 'sdc-app/common/helpers/ItemsHelperConstants.js';
+import {
+ itemStatus,
+ itemPermissions,
+ itemOnboardingProcedure
+} from 'sdc-app/common/helpers/ItemsHelperConstants.js';
import Accordion from 'sdc-ui/lib/react/Accordion.js';
import Checklist from 'sdc-ui/lib/react/Checklist.js';
import Checkbox from 'sdc-ui/lib/react/Checkbox.js';
@@ -102,13 +106,13 @@ export const Permissions = ({ data, onDataChanged }) => {
{
label: i18n('Owner'),
dataTestId: 'catalog-filter-permission-owner',
- value: 'Owner',
+ value: itemPermissions.OWNER,
checked: data.permission && data.permission.Owner
},
{
label: i18n('Contributor'),
dataTestId: 'catalog-filter-permission-contributor',
- value: 'Contributor',
+ value: itemPermissions.CONTRIBUTOR,
checked: data.permission && data.permission.Contributor
}
];
@@ -130,14 +134,14 @@ export const OnboardingProcedure = ({ data, onDataChanged }) => {
{
label: i18n('Network Package'),
dataTestId: 'catalog-filter-procedure-network',
- value: 'NetworkPackage',
+ value: itemOnboardingProcedure.NETWORK,
checked:
data.onboardingMethod && data.onboardingMethod.NetworkPackage
},
{
label: i18n('Manual'),
dataTestId: 'catalog-filter-procedure-manual',
- value: 'Manual',
+ value: itemOnboardingProcedure.MANUAL,
checked: data.onboardingMethod && data.onboardingMethod.Manual
}
];
diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsView.jsx
index 08145be9c7..814f9b38e0 100644
--- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsView.jsx
+++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsView.jsx
@@ -53,6 +53,7 @@ class HeatScreenView extends Component {
onboardingOrigin,
activeTab,
setActiveTab,
+ goToOverview,
...other
} = this.props;
@@ -82,17 +83,13 @@ class HeatScreenView extends Component {
/>
)}
{activeTab === tabsMapping.VALIDATION &&
- softwareProductId && (
+ softwareProductId &&
+ goToOverview && (
<Button
btnType="secondary"
data-test-id="go-to-overview"
- disabled={this.props.goToOverview !== true}
className="go-to-overview-btn"
- onClick={
- this.props.goToOverview
- ? () => onGoToOverview({ version })
- : undefined
- }>
+ onClick={() => onGoToOverview({ version })}>
{i18n('GO TO OVERVIEW')}
</Button>
)}
diff --git a/openecomp-ui/test/licenseModel/entitlementPools/test.js b/openecomp-ui/test/licenseModel/entitlementPools/test.js
index dc56b11f1b..63eab1f7b9 100644
--- a/openecomp-ui/test/licenseModel/entitlementPools/test.js
+++ b/openecomp-ui/test/licenseModel/entitlementPools/test.js
@@ -1,455 +1,706 @@
-/*!
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+/*
+ * Copyright © 2016-2018 European Support Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
import deepFreeze from 'deep-freeze';
import mockRest from 'test-utils/MockRest.js';
-import {cloneAndSet, buildListFromFactory} from 'test-utils/Util.js';
-import {storeCreator} from 'sdc-app/AppStore.js';
+import { cloneAndSet, buildListFromFactory } from 'test-utils/Util.js';
+import { storeCreator } from 'sdc-app/AppStore.js';
import EntitlementPoolsActionHelper from 'sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js';
-import {EntitlementPoolStoreFactory, EntitlementPoolPostFactory} from 'test-utils/factories/licenseModel/EntitlementPoolFactories.js';
+import {
+ EntitlementPoolStoreFactory,
+ EntitlementPoolPostFactory
+} from 'test-utils/factories/licenseModel/EntitlementPoolFactories.js';
import VersionFactory from 'test-utils/factories/common/VersionFactory.js';
-import {LimitItemFactory, LimitPostFactory} from 'test-utils/factories/licenseModel/LimitFactories.js';
-import {getStrValue} from 'nfvo-utils/getValue.js';
-import {SyncStates} from 'sdc-app/common/merge/MergeEditorConstants.js';
+import {
+ LimitItemFactory,
+ LimitPostFactory
+} from 'test-utils/factories/licenseModel/LimitFactories.js';
+import { getStrValue } from 'nfvo-utils/getValue.js';
+import { SyncStates } from 'sdc-app/common/merge/MergeEditorConstants.js';
import CurrentScreenFactory from 'test-utils/factories/common/CurrentScreenFactory.js';
-describe('Entitlement Pools Module Tests', function () {
-
- const LICENSE_MODEL_ID = '555';
- const version = VersionFactory.build();
- const itemPermissionAndProps = CurrentScreenFactory.build({}, {version});
- const returnedVersionFields = {baseId: version.baseId, description: version.description, id: version.id, name: version.name, status: version.status};
-
- it('Load Entitlement Pools List', () => {
-
- const entitlementPoolsList = buildListFromFactory(EntitlementPoolStoreFactory);
- deepFreeze(entitlementPoolsList);
- const store = storeCreator();
- deepFreeze(store.getState());
-
- const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', entitlementPoolsList);
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {results: entitlementPoolsList};
- });
-
- return EntitlementPoolsActionHelper.fetchEntitlementPoolsList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID, version}).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
-
- it('Delete Entitlement Pool', () => {
-
- const entitlementPoolsList = buildListFromFactory(EntitlementPoolStoreFactory,1);
- deepFreeze(entitlementPoolsList);
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps},
- licenseModel: {
- entitlementPool: {
- entitlementPoolsList
- }
- }
- });
- deepFreeze(store.getState());
-
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
-
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', []);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
-
- mockRest.addHandler('destroy', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools/${entitlementPoolsList[0].id}`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {
- results: {
- returnCode: 'OK'
- }
- };
- });
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${version.id}`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {...returnedVersionFields, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: true}};
- });
-
- return EntitlementPoolsActionHelper.deleteEntitlementPool(store.dispatch, {
- licenseModelId: LICENSE_MODEL_ID,
- version,
- entitlementPoolId: entitlementPoolsList[0].id
- }).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
-
- it('Add Entitlement Pool', () => {
-
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps}
- });
- deepFreeze(store.getState());
-
- const EntitlementPoolPostRequest = EntitlementPoolPostFactory.build();
-
- deepFreeze(EntitlementPoolPostRequest);
-
- const entitlementPoolIdFromResponse = 'ADDED_ID';
- const entitlementPoolAfterAdd = EntitlementPoolStoreFactory.build({id: entitlementPoolIdFromResponse});
- deepFreeze(entitlementPoolAfterAdd);
-
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
-
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', [entitlementPoolAfterAdd]);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
-
- mockRest.addHandler('post', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools`);
- expect(data).toEqual(EntitlementPoolPostRequest);
- expect(options).toEqual(undefined);
- return {
- returnCode: 'OK',
- value: entitlementPoolIdFromResponse
- };
- });
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${version.id}`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {...returnedVersionFields, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: true}};
- });
-
-
-
- return EntitlementPoolsActionHelper.saveEntitlementPool(store.dispatch,
- {
- licenseModelId: LICENSE_MODEL_ID,
- version,
- previousEntitlementPool: null,
- entitlementPool: EntitlementPoolPostRequest
- }
- ).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
-
- it('Update Entitlement Pool', () => {
-
- const entitlementPoolsList = buildListFromFactory(EntitlementPoolStoreFactory, 1);
- deepFreeze(entitlementPoolsList);
-
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps},
- licenseModel: {
- entitlementPool: {
- entitlementPoolsList
- }
- }
- });
-
- deepFreeze(store.getState());
-
- const toBeUpdatedEntitlementPoolId = entitlementPoolsList[0].id;
- const previousEntitlementPoolData = entitlementPoolsList[0];
- const entitlementPoolUpdateData = EntitlementPoolStoreFactory.build({name: 'ep1_UPDATED', description: 'string_UPDATED', id: toBeUpdatedEntitlementPoolId});
- deepFreeze(entitlementPoolUpdateData);
-
- const entitlementPoolPutRequest = EntitlementPoolPostFactory.build({name: 'ep1_UPDATED', description: 'string_UPDATED'});
- deepFreeze(entitlementPoolPutRequest);
-
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
-
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', [entitlementPoolUpdateData]);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
-
-
- mockRest.addHandler('put', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools/${toBeUpdatedEntitlementPoolId}`);
- expect(data).toEqual(entitlementPoolPutRequest);
- expect(options).toEqual(undefined);
- return {returnCode: 'OK'};
- });
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${version.id}`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {...returnedVersionFields, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: true}};
- });
-
- return EntitlementPoolsActionHelper.saveEntitlementPool(store.dispatch, {
- licenseModelId: LICENSE_MODEL_ID,
- version,
- previousEntitlementPool: previousEntitlementPoolData,
- entitlementPool: entitlementPoolUpdateData
- }).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
-
- it('Load Limits List', () => {
-
- const limitsList = LimitItemFactory.buildList(3);
- deepFreeze(limitsList);
- const store = storeCreator();
- deepFreeze(store.getState());
-
- const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolEditor.limitsList', limitsList);
- const entitlementPool = EntitlementPoolStoreFactory.build();
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools/${entitlementPool.id}/limits`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {results: limitsList};
- });
-
- return EntitlementPoolsActionHelper.fetchLimits(store.dispatch, {licenseModelId: LICENSE_MODEL_ID, version, entitlementPool}).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
-
- it('Add Limit', () => {
-
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps}
- });
- deepFreeze(store.getState());
-
- const limitToAdd = LimitPostFactory.build();
- let limitFromBE = {...limitToAdd};
- limitFromBE.metric = getStrValue(limitFromBE.metric);
- limitFromBE.unit = getStrValue(limitFromBE.unit);
-
- deepFreeze(limitToAdd);
- deepFreeze(limitFromBE);
-
- const LimitIdFromResponse = 'ADDED_ID';
- const limitAddedItem = {...limitToAdd, id: LimitIdFromResponse};
- deepFreeze(limitAddedItem);
- const entitlementPool = EntitlementPoolStoreFactory.build();
-
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
-
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolEditor.limitsList', [limitAddedItem]);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
-
- mockRest.addHandler('post', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools/${entitlementPool.id}/limits`);
- expect(data).toEqual(limitFromBE);
- expect(options).toEqual(undefined);
- return {
- returnCode: 'OK',
- value: LimitIdFromResponse
- };
- });
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools/${entitlementPool.id}/limits`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {results: [limitAddedItem]};
- });
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${version.id}`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {...returnedVersionFields, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: true}};
- });
-
- return EntitlementPoolsActionHelper.submitLimit(store.dispatch,
- {
- licenseModelId: LICENSE_MODEL_ID,
- version,
- entitlementPool,
- limit: limitToAdd
- }
- ).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
-
-
- it('Delete Limit', () => {
-
- const limitsList = LimitItemFactory.buildList(1);
- deepFreeze(limitsList);
-
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps},
- licenseModel: {
- entitlementPool: {
- entitlementPoolEditor: {
- limitsList
- }
- }
- }
- });
- deepFreeze(store.getState());
-
- const entitlementPool = EntitlementPoolStoreFactory.build();
-
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
-
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolEditor.limitsList', []);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
-
- mockRest.addHandler('destroy', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools/${entitlementPool.id}/limits/${limitsList[0].id}`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {
- results: {
- returnCode: 'OK'
- }
- };
- });
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools/${entitlementPool.id}/limits`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {results: []};
- });
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${version.id}`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {...returnedVersionFields, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: true}};
- });
-
- return EntitlementPoolsActionHelper.deleteLimit(store.dispatch, {
- licenseModelId: LICENSE_MODEL_ID,
- version,
- entitlementPool,
- limit: limitsList[0]
- }).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
-
- it('Update Limit', () => {
-
- const limitsList = LimitItemFactory.buildList(1);
- deepFreeze(limitsList);
- const entitlementPool = EntitlementPoolStoreFactory.build();
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps},
- licenseModel: {
- entitlementPool: {
- entitlementPoolEditor: {
- limitsList
- }
- }
- }
- });
-
- deepFreeze(store.getState());
-
-
- const previousData = limitsList[0];
-
- deepFreeze(previousData);
- const limitId = limitsList[0].id;
-
- let updatedLimit = {...previousData, name: 'updatedLimit'};
-
- const updatedLimitForPut = {...updatedLimit, id: undefined};
- updatedLimit.metric = {choice: updatedLimit.metric, other: ''};
- updatedLimit.unit = {choice: updatedLimit.unit, other: ''};
- deepFreeze(updatedLimit);
-
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
-
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolEditor.limitsList', [updatedLimitForPut]);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
-
-
- mockRest.addHandler('put', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools/${entitlementPool.id}/limits/${limitId}`);
- expect(data).toEqual(updatedLimitForPut);
- expect(options).toEqual(undefined);
- return {returnCode: 'OK'};
- });
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools/${entitlementPool.id}/limits`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {results: [updatedLimitForPut]};
- });
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${version.id}`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {...returnedVersionFields, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: true}};
- });
-
- return EntitlementPoolsActionHelper.submitLimit(store.dispatch,
- {
- licenseModelId: LICENSE_MODEL_ID,
- version,
- entitlementPool,
- limit: updatedLimit
- }
- ).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
-
+describe('Entitlement Pools Module Tests', function() {
+ const LICENSE_MODEL_ID = '555';
+ const version = VersionFactory.build();
+ const itemPermissionAndProps = CurrentScreenFactory.build({}, { version });
+ const returnedVersionFields = {
+ baseId: version.baseId,
+ description: version.description,
+ id: version.id,
+ name: version.name,
+ status: version.status
+ };
+
+ it('Load Entitlement Pools List', () => {
+ const entitlementPoolsList = buildListFromFactory(
+ EntitlementPoolStoreFactory
+ );
+ deepFreeze(entitlementPoolsList);
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.entitlementPool.entitlementPoolsList',
+ entitlementPoolsList
+ );
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/entitlement-pools`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return { results: entitlementPoolsList };
+ });
+
+ return EntitlementPoolsActionHelper.fetchEntitlementPoolsList(
+ store.dispatch,
+ { licenseModelId: LICENSE_MODEL_ID, version }
+ ).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+ it('Delete Entitlement Pool', () => {
+ const entitlementPoolsList = buildListFromFactory(
+ EntitlementPoolStoreFactory,
+ 1
+ );
+ deepFreeze(entitlementPoolsList);
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps },
+ licenseModel: {
+ entitlementPool: {
+ entitlementPoolsList
+ }
+ }
+ });
+ deepFreeze(store.getState());
+
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
+
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.entitlementPool.entitlementPoolsList',
+ []
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
+
+ mockRest.addHandler('destroy', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/entitlement-pools/${entitlementPoolsList[0].id}`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ results: {
+ returnCode: 'OK'
+ }
+ };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields,
+ state: {
+ synchronizationState: SyncStates.UP_TO_DATE,
+ dirty: true
+ }
+ };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields
+ };
+ });
+
+ return EntitlementPoolsActionHelper.deleteEntitlementPool(
+ store.dispatch,
+ {
+ licenseModelId: LICENSE_MODEL_ID,
+ version,
+ entitlementPoolId: entitlementPoolsList[0].id
+ }
+ ).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+ it('Add Entitlement Pool', () => {
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps }
+ });
+ deepFreeze(store.getState());
+
+ const EntitlementPoolPostRequest = EntitlementPoolPostFactory.build();
+
+ deepFreeze(EntitlementPoolPostRequest);
+
+ const entitlementPoolIdFromResponse = 'ADDED_ID';
+ const entitlementPoolAfterAdd = EntitlementPoolStoreFactory.build({
+ id: entitlementPoolIdFromResponse
+ });
+ deepFreeze(entitlementPoolAfterAdd);
+
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
+
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.entitlementPool.entitlementPoolsList',
+ [entitlementPoolAfterAdd]
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
+
+ mockRest.addHandler('post', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/entitlement-pools`
+ );
+ expect(data).toEqual(EntitlementPoolPostRequest);
+ expect(options).toEqual(undefined);
+ return {
+ returnCode: 'OK',
+ value: entitlementPoolIdFromResponse
+ };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields,
+ state: {
+ synchronizationState: SyncStates.UP_TO_DATE,
+ dirty: true
+ }
+ };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields
+ };
+ });
+
+ return EntitlementPoolsActionHelper.saveEntitlementPool(
+ store.dispatch,
+ {
+ licenseModelId: LICENSE_MODEL_ID,
+ version,
+ previousEntitlementPool: null,
+ entitlementPool: EntitlementPoolPostRequest
+ }
+ ).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+ it('Update Entitlement Pool', () => {
+ const entitlementPoolsList = buildListFromFactory(
+ EntitlementPoolStoreFactory,
+ 1
+ );
+ deepFreeze(entitlementPoolsList);
+
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps },
+ licenseModel: {
+ entitlementPool: {
+ entitlementPoolsList
+ }
+ }
+ });
+
+ deepFreeze(store.getState());
+
+ const toBeUpdatedEntitlementPoolId = entitlementPoolsList[0].id;
+ const previousEntitlementPoolData = entitlementPoolsList[0];
+ const entitlementPoolUpdateData = EntitlementPoolStoreFactory.build({
+ name: 'ep1_UPDATED',
+ description: 'string_UPDATED',
+ id: toBeUpdatedEntitlementPoolId
+ });
+ deepFreeze(entitlementPoolUpdateData);
+
+ const entitlementPoolPutRequest = EntitlementPoolPostFactory.build({
+ name: 'ep1_UPDATED',
+ description: 'string_UPDATED'
+ });
+ deepFreeze(entitlementPoolPutRequest);
+
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
+
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.entitlementPool.entitlementPoolsList',
+ [entitlementPoolUpdateData]
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
+
+ mockRest.addHandler('put', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/entitlement-pools/${toBeUpdatedEntitlementPoolId}`
+ );
+ expect(data).toEqual(entitlementPoolPutRequest);
+ expect(options).toEqual(undefined);
+ return { returnCode: 'OK' };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields,
+ state: {
+ synchronizationState: SyncStates.UP_TO_DATE,
+ dirty: true
+ }
+ };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields
+ };
+ });
+
+ return EntitlementPoolsActionHelper.saveEntitlementPool(
+ store.dispatch,
+ {
+ licenseModelId: LICENSE_MODEL_ID,
+ version,
+ previousEntitlementPool: previousEntitlementPoolData,
+ entitlementPool: entitlementPoolUpdateData
+ }
+ ).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+ it('Load Limits List', () => {
+ const limitsList = LimitItemFactory.buildList(3);
+ deepFreeze(limitsList);
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.entitlementPool.entitlementPoolEditor.limitsList',
+ limitsList
+ );
+ const entitlementPool = EntitlementPoolStoreFactory.build();
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/entitlement-pools/${entitlementPool.id}/limits`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return { results: limitsList };
+ });
+
+ return EntitlementPoolsActionHelper.fetchLimits(store.dispatch, {
+ licenseModelId: LICENSE_MODEL_ID,
+ version,
+ entitlementPool
+ }).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+ it('Add Limit', () => {
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps }
+ });
+ deepFreeze(store.getState());
+
+ const limitToAdd = LimitPostFactory.build();
+ let limitFromBE = { ...limitToAdd };
+ limitFromBE.metric = getStrValue(limitFromBE.metric);
+ limitFromBE.unit = getStrValue(limitFromBE.unit);
+
+ deepFreeze(limitToAdd);
+ deepFreeze(limitFromBE);
+
+ const LimitIdFromResponse = 'ADDED_ID';
+ const limitAddedItem = { ...limitToAdd, id: LimitIdFromResponse };
+ deepFreeze(limitAddedItem);
+ const entitlementPool = EntitlementPoolStoreFactory.build();
+
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
+
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.entitlementPool.entitlementPoolEditor.limitsList',
+ [limitAddedItem]
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
+
+ mockRest.addHandler('post', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/entitlement-pools/${entitlementPool.id}/limits`
+ );
+ expect(data).toEqual(limitFromBE);
+ expect(options).toEqual(undefined);
+ return {
+ returnCode: 'OK',
+ value: LimitIdFromResponse
+ };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/entitlement-pools/${entitlementPool.id}/limits`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return { results: [limitAddedItem] };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields,
+ state: {
+ synchronizationState: SyncStates.UP_TO_DATE,
+ dirty: true
+ }
+ };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields
+ };
+ });
+
+ return EntitlementPoolsActionHelper.submitLimit(store.dispatch, {
+ licenseModelId: LICENSE_MODEL_ID,
+ version,
+ entitlementPool,
+ limit: limitToAdd
+ }).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+ it('Delete Limit', () => {
+ const limitsList = LimitItemFactory.buildList(1);
+ deepFreeze(limitsList);
+
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps },
+ licenseModel: {
+ entitlementPool: {
+ entitlementPoolEditor: {
+ limitsList
+ }
+ }
+ }
+ });
+ deepFreeze(store.getState());
+
+ const entitlementPool = EntitlementPoolStoreFactory.build();
+
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
+
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.entitlementPool.entitlementPoolEditor.limitsList',
+ []
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
+
+ mockRest.addHandler('destroy', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/entitlement-pools/${entitlementPool.id}/limits/${
+ limitsList[0].id
+ }`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ results: {
+ returnCode: 'OK'
+ }
+ };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/entitlement-pools/${entitlementPool.id}/limits`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return { results: [] };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields,
+ state: {
+ synchronizationState: SyncStates.UP_TO_DATE,
+ dirty: true
+ }
+ };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields
+ };
+ });
+
+ return EntitlementPoolsActionHelper.deleteLimit(store.dispatch, {
+ licenseModelId: LICENSE_MODEL_ID,
+ version,
+ entitlementPool,
+ limit: limitsList[0]
+ }).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+ it('Update Limit', () => {
+ const limitsList = LimitItemFactory.buildList(1);
+ deepFreeze(limitsList);
+ const entitlementPool = EntitlementPoolStoreFactory.build();
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps },
+ licenseModel: {
+ entitlementPool: {
+ entitlementPoolEditor: {
+ limitsList
+ }
+ }
+ }
+ });
+
+ deepFreeze(store.getState());
+
+ const previousData = limitsList[0];
+
+ deepFreeze(previousData);
+ const limitId = limitsList[0].id;
+
+ let updatedLimit = { ...previousData, name: 'updatedLimit' };
+
+ const updatedLimitForPut = { ...updatedLimit, id: undefined };
+ updatedLimit.metric = { choice: updatedLimit.metric, other: '' };
+ updatedLimit.unit = { choice: updatedLimit.unit, other: '' };
+ deepFreeze(updatedLimit);
+
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
+
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.entitlementPool.entitlementPoolEditor.limitsList',
+ [updatedLimitForPut]
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
+
+ mockRest.addHandler('put', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/entitlement-pools/${entitlementPool.id}/limits/${limitId}`
+ );
+ expect(data).toEqual(updatedLimitForPut);
+ expect(options).toEqual(undefined);
+ return { returnCode: 'OK' };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/entitlement-pools/${entitlementPool.id}/limits`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return { results: [updatedLimitForPut] };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields,
+ state: {
+ synchronizationState: SyncStates.UP_TO_DATE,
+ dirty: true
+ }
+ };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields
+ };
+ });
+
+ return EntitlementPoolsActionHelper.submitLimit(store.dispatch, {
+ licenseModelId: LICENSE_MODEL_ID,
+ version,
+ entitlementPool,
+ limit: updatedLimit
+ }).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
});
diff --git a/openecomp-ui/test/licenseModel/featureGroups/test.js b/openecomp-ui/test/licenseModel/featureGroups/test.js
index eb947b83d0..63c876cce3 100644
--- a/openecomp-ui/test/licenseModel/featureGroups/test.js
+++ b/openecomp-ui/test/licenseModel/featureGroups/test.js
@@ -1,306 +1,456 @@
-/*!
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+/*
+ * Copyright © 2016-2018 European Support Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing
- * permissions and limitations under the License.
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
*/
import deepFreeze from 'deep-freeze';
import mockRest from 'test-utils/MockRest.js';
-import {cloneAndSet, buildListFromFactory} from 'test-utils/Util.js';
-import {storeCreator} from 'sdc-app/AppStore.js';
+import { cloneAndSet, buildListFromFactory } from 'test-utils/Util.js';
+import { storeCreator } from 'sdc-app/AppStore.js';
import FeatureGroupsActionHelper from 'sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js';
-import { FeatureGroupStoreFactory, FeatureGroupPostFactory, FeatureGroupDispatchFactory, FeatureGroupPutFactory } from 'test-utils/factories/licenseModel/FeatureGroupFactories.js';
+import {
+ FeatureGroupStoreFactory,
+ FeatureGroupPostFactory,
+ FeatureGroupDispatchFactory,
+ FeatureGroupPutFactory
+} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js';
import VersionFactory from 'test-utils/factories/common/VersionFactory.js';
import CurrentScreenFactory from 'test-utils/factories/common/CurrentScreenFactory.js';
-import {SyncStates} from 'sdc-app/common/merge/MergeEditorConstants.js';
-
-
-describe('Feature Groups Module Tests', function () {
-
- const LICENSE_MODEL_ID = '555';
- const version = VersionFactory.build();
- const itemPermissionAndProps = CurrentScreenFactory.build({}, {version});
- const returnedVersionFields = {baseId: version.baseId, description: version.description, id: version.id, name: version.name, status: version.status};
-
- it('Load Feature Groups List', () => {
-
- const featureGroupsList = buildListFromFactory(FeatureGroupStoreFactory);
- deepFreeze(featureGroupsList);
-
- const store = storeCreator();
- deepFreeze(store.getState());
-
- const expectedStore = cloneAndSet(store.getState(), 'licenseModel.featureGroup.featureGroupsList', featureGroupsList);
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/feature-groups`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {results: featureGroupsList};
- });
-
- return FeatureGroupsActionHelper.fetchFeatureGroupsList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID, version}).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
-
- it('Delete Feature Group', () => {
- const featureGroupsList = buildListFromFactory(FeatureGroupStoreFactory, 1);
- deepFreeze(featureGroupsList);
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps},
- licenseModel: {
- featureGroup: {
- featureGroupsList
- }
- }
- });
- deepFreeze(store.getState());
-
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
-
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.featureGroup.featureGroupsList', []);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
-
- const idToDelete = featureGroupsList[0].id;
-
- mockRest.addHandler('destroy', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/feature-groups/${idToDelete}`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {
- results: {
- returnCode: 'OK'
- }
- };
- });
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${version.id}`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {...returnedVersionFields, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: true}};
- });
-
- return FeatureGroupsActionHelper.deleteFeatureGroup(store.dispatch, {
- licenseModelId: LICENSE_MODEL_ID,
- version,
- featureGroupId: idToDelete
- }).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
-
- it('Add Feature Group', () => {
-
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps},
- licenseModel: {
- featureGroup: {
- featureGroupsList: []
- }
- }
- });
- deepFreeze(store.getState());
-
- const FeatureGroupPostRequest = FeatureGroupPostFactory.build({
- addedLicenseKeyGroupsIds: [1],
- addedEntitlementPoolsIds: [1]
- });
- const featureGroupToAdd = FeatureGroupDispatchFactory.build({
- licenseKeyGroupsIds: [1],
- entitlementPoolsIds: [1]
- });
-
- const featureGroupIdFromResponse = 'ADDED_ID';
- const featureGroupAfterAdd = FeatureGroupStoreFactory.build({
- ...featureGroupToAdd,
- id: featureGroupIdFromResponse
- });
-
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
-
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.featureGroup.featureGroupsList', [featureGroupAfterAdd]);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
-
- mockRest.addHandler('post', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/feature-groups`);
- expect(data).toEqual(FeatureGroupPostRequest);
- expect(options).toEqual(undefined);
- return {
- returnCode: 'OK',
- value: featureGroupIdFromResponse
- };
- });
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {results: []};
- });
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {results: []};
- });
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${version.id}`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {...returnedVersionFields, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: true}};
- });
-
-
- return FeatureGroupsActionHelper.saveFeatureGroup(store.dispatch, {
- licenseModelId: LICENSE_MODEL_ID,
- version,
- featureGroup: featureGroupToAdd
- }).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
-
- it('Update Feature Group', () => {
- const featureGroupsList = buildListFromFactory(FeatureGroupStoreFactory, 1, {
- licenseKeyGroupsIds: [1],
- entitlementPoolsIds: [1]
- });
- deepFreeze(featureGroupsList);
-
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps},
- licenseModel: {
- featureGroup: {
- featureGroupsList
- }
- }
- });
- deepFreeze(store.getState());
-
- const toBeUpdatedFeatureGroupId = featureGroupsList[0].id;
- const previousFeatureGroupData = featureGroupsList[0];
-
- const featureGroupUpdateData = FeatureGroupStoreFactory.build({
- ...previousFeatureGroupData,
- licenseKeyGroupsIds: [7],
- entitlementPoolsIds: [7]
- });
- deepFreeze(featureGroupUpdateData);
-
- const FeatureGroupPutFactoryRequest = FeatureGroupPutFactory.build({
- name: featureGroupUpdateData.name,
- description: featureGroupUpdateData.description,
- partNumber: featureGroupUpdateData.partNumber,
- addedLicenseKeyGroupsIds: [7],
- addedEntitlementPoolsIds: [7],
- removedLicenseKeyGroupsIds: [1],
- removedEntitlementPoolsIds: [1]
- });
- deepFreeze(FeatureGroupPutFactoryRequest);
-
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
-
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.featureGroup.featureGroupsList', [featureGroupUpdateData]);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
-
-
- mockRest.addHandler('put', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/feature-groups/${toBeUpdatedFeatureGroupId}`);
- expect(data).toEqual(FeatureGroupPutFactoryRequest);
- expect(options).toEqual(undefined);
- return {returnCode: 'OK'};
- });
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {results: []};
- });
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {results: []};
- });
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${version.id}`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {...returnedVersionFields, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: true}};
- });
-
- return FeatureGroupsActionHelper.saveFeatureGroup(store.dispatch, {
- licenseModelId: LICENSE_MODEL_ID,
- version,
- previousFeatureGroup: previousFeatureGroupData,
- featureGroup: featureGroupUpdateData
- }).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
-
- });
-
- it('Open Editor', () => {
-
- const store = storeCreator();
- deepFreeze(store.getState());
-
- const editorData = FeatureGroupStoreFactory.build();
- deepFreeze(editorData);
- const LICENSE_MODEL_ID = '123';
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {results: []};
- });
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {results: []};
- });
-
-
- return FeatureGroupsActionHelper.openFeatureGroupsEditor(store.dispatch, {featureGroup: editorData, licenseModelId: '123', version}).then(() => {
- expect(store.getState().licenseModel.featureGroup.featureGroupEditor.data).toEqual(editorData);
- });
- });
-
+import { SyncStates } from 'sdc-app/common/merge/MergeEditorConstants.js';
+
+describe('Feature Groups Module Tests', function() {
+ const LICENSE_MODEL_ID = '555';
+ const version = VersionFactory.build();
+ const itemPermissionAndProps = CurrentScreenFactory.build({}, { version });
+ const returnedVersionFields = {
+ baseId: version.baseId,
+ description: version.description,
+ id: version.id,
+ name: version.name,
+ status: version.status
+ };
+
+ it('Load Feature Groups List', () => {
+ const featureGroupsList = buildListFromFactory(
+ FeatureGroupStoreFactory
+ );
+ deepFreeze(featureGroupsList);
+
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.featureGroup.featureGroupsList',
+ featureGroupsList
+ );
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/feature-groups`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return { results: featureGroupsList };
+ });
+
+ return FeatureGroupsActionHelper.fetchFeatureGroupsList(
+ store.dispatch,
+ { licenseModelId: LICENSE_MODEL_ID, version }
+ ).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+ it('Delete Feature Group', () => {
+ const featureGroupsList = buildListFromFactory(
+ FeatureGroupStoreFactory,
+ 1
+ );
+ deepFreeze(featureGroupsList);
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps },
+ licenseModel: {
+ featureGroup: {
+ featureGroupsList
+ }
+ }
+ });
+ deepFreeze(store.getState());
+
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
+
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.featureGroup.featureGroupsList',
+ []
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
+
+ const idToDelete = featureGroupsList[0].id;
+
+ mockRest.addHandler('destroy', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/feature-groups/${idToDelete}`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ results: {
+ returnCode: 'OK'
+ }
+ };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields,
+ state: {
+ synchronizationState: SyncStates.UP_TO_DATE,
+ dirty: true
+ }
+ };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields
+ };
+ });
+
+ return FeatureGroupsActionHelper.deleteFeatureGroup(store.dispatch, {
+ licenseModelId: LICENSE_MODEL_ID,
+ version,
+ featureGroupId: idToDelete
+ }).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+ it('Add Feature Group', () => {
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps },
+ licenseModel: {
+ featureGroup: {
+ featureGroupsList: []
+ }
+ }
+ });
+ deepFreeze(store.getState());
+
+ const FeatureGroupPostRequest = FeatureGroupPostFactory.build({
+ addedLicenseKeyGroupsIds: [1],
+ addedEntitlementPoolsIds: [1]
+ });
+ const featureGroupToAdd = FeatureGroupDispatchFactory.build({
+ licenseKeyGroupsIds: [1],
+ entitlementPoolsIds: [1]
+ });
+
+ const featureGroupIdFromResponse = 'ADDED_ID';
+ const featureGroupAfterAdd = FeatureGroupStoreFactory.build({
+ ...featureGroupToAdd,
+ id: featureGroupIdFromResponse
+ });
+
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
+
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.featureGroup.featureGroupsList',
+ [featureGroupAfterAdd]
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
+
+ mockRest.addHandler('post', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/feature-groups`
+ );
+ expect(data).toEqual(FeatureGroupPostRequest);
+ expect(options).toEqual(undefined);
+ return {
+ returnCode: 'OK',
+ value: featureGroupIdFromResponse
+ };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/entitlement-pools`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return { results: [] };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/license-key-groups`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return { results: [] };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields,
+ state: {
+ synchronizationState: SyncStates.UP_TO_DATE,
+ dirty: true
+ }
+ };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields
+ };
+ });
+
+ return FeatureGroupsActionHelper.saveFeatureGroup(store.dispatch, {
+ licenseModelId: LICENSE_MODEL_ID,
+ version,
+ featureGroup: featureGroupToAdd
+ }).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+ it('Update Feature Group', () => {
+ const featureGroupsList = buildListFromFactory(
+ FeatureGroupStoreFactory,
+ 1,
+ {
+ licenseKeyGroupsIds: [1],
+ entitlementPoolsIds: [1]
+ }
+ );
+ deepFreeze(featureGroupsList);
+
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps },
+ licenseModel: {
+ featureGroup: {
+ featureGroupsList
+ }
+ }
+ });
+ deepFreeze(store.getState());
+
+ const toBeUpdatedFeatureGroupId = featureGroupsList[0].id;
+ const previousFeatureGroupData = featureGroupsList[0];
+
+ const featureGroupUpdateData = FeatureGroupStoreFactory.build({
+ ...previousFeatureGroupData,
+ licenseKeyGroupsIds: [7],
+ entitlementPoolsIds: [7]
+ });
+ deepFreeze(featureGroupUpdateData);
+
+ const FeatureGroupPutFactoryRequest = FeatureGroupPutFactory.build({
+ name: featureGroupUpdateData.name,
+ description: featureGroupUpdateData.description,
+ partNumber: featureGroupUpdateData.partNumber,
+ addedLicenseKeyGroupsIds: [7],
+ addedEntitlementPoolsIds: [7],
+ removedLicenseKeyGroupsIds: [1],
+ removedEntitlementPoolsIds: [1]
+ });
+ deepFreeze(FeatureGroupPutFactoryRequest);
+
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
+
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.featureGroup.featureGroupsList',
+ [featureGroupUpdateData]
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
+
+ mockRest.addHandler('put', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/feature-groups/${toBeUpdatedFeatureGroupId}`
+ );
+ expect(data).toEqual(FeatureGroupPutFactoryRequest);
+ expect(options).toEqual(undefined);
+ return { returnCode: 'OK' };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/entitlement-pools`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return { results: [] };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/license-key-groups`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return { results: [] };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields,
+ state: {
+ synchronizationState: SyncStates.UP_TO_DATE,
+ dirty: true
+ }
+ };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields
+ };
+ });
+
+ return FeatureGroupsActionHelper.saveFeatureGroup(store.dispatch, {
+ licenseModelId: LICENSE_MODEL_ID,
+ version,
+ previousFeatureGroup: previousFeatureGroupData,
+ featureGroup: featureGroupUpdateData
+ }).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+ it('Open Editor', () => {
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const editorData = FeatureGroupStoreFactory.build();
+ deepFreeze(editorData);
+ const LICENSE_MODEL_ID = '123';
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/entitlement-pools`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return { results: [] };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/license-key-groups`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return { results: [] };
+ });
+
+ return FeatureGroupsActionHelper.openFeatureGroupsEditor(
+ store.dispatch,
+ { featureGroup: editorData, licenseModelId: '123', version }
+ ).then(() => {
+ expect(
+ store.getState().licenseModel.featureGroup.featureGroupEditor
+ .data
+ ).toEqual(editorData);
+ });
+ });
});
diff --git a/openecomp-ui/test/licenseModel/licenseAgreement/test.js b/openecomp-ui/test/licenseModel/licenseAgreement/test.js
index 5a3dd17c6e..17cad4fc39 100644
--- a/openecomp-ui/test/licenseModel/licenseAgreement/test.js
+++ b/openecomp-ui/test/licenseModel/licenseAgreement/test.js
@@ -16,225 +16,386 @@
import deepFreeze from 'deep-freeze';
import pickBy from 'lodash/pickBy';
import mockRest from 'test-utils/MockRest.js';
-import {cloneAndSet, buildListFromFactory} from 'test-utils/Util.js';
-import {storeCreator} from 'sdc-app/AppStore.js';
+import { cloneAndSet, buildListFromFactory } from 'test-utils/Util.js';
+import { storeCreator } from 'sdc-app/AppStore.js';
import LicenseAgreementActionHelper from 'sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementActionHelper.js';
-import { LicenseAgreementStoreFactory, LicenseAgreementDispatchFactory, LicenseAgreementPostFactory, LicenseAgreementPutFactory } from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js';
+import {
+ LicenseAgreementStoreFactory,
+ LicenseAgreementDispatchFactory,
+ LicenseAgreementPostFactory,
+ LicenseAgreementPutFactory
+} from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js';
import VersionFactory from 'test-utils/factories/common/VersionFactory.js';
-import {SyncStates} from 'sdc-app/common/merge/MergeEditorConstants.js';
+import { SyncStates } from 'sdc-app/common/merge/MergeEditorConstants.js';
import CurrentScreenFactory from 'test-utils/factories/common/CurrentScreenFactory.js';
describe('License Agreement Module Tests', () => {
+ const LICENSE_MODEL_ID = '777';
+ const version = VersionFactory.build();
+ const itemPermissionAndProps = CurrentScreenFactory.build({}, { version });
+ const returnedVersionFields = {
+ baseId: version.baseId,
+ description: version.description,
+ id: version.id,
+ name: version.name,
+ status: version.status
+ };
- const LICENSE_MODEL_ID = '777';
- const version = VersionFactory.build();
- const itemPermissionAndProps = CurrentScreenFactory.build({}, {version});
- const returnedVersionFields = {baseId: version.baseId, description: version.description, id: version.id, name: version.name, status: version.status};
-
- it('Load License Agreement List', () => {
- const licenseAgreementList = buildListFromFactory(LicenseAgreementStoreFactory);
-
- const store = storeCreator();
- deepFreeze(store.getState());
-
- const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseAgreement.licenseAgreementList', licenseAgreementList);
-
- mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-agreements`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {results: licenseAgreementList};
- });
- return LicenseAgreementActionHelper.fetchLicenseAgreementList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID, version}).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
-
- it('Delete License Agreement', () => {
- const licenseAgreementList = buildListFromFactory(LicenseAgreementStoreFactory, 1);
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps},
- licenseModel: {
- licenseAgreement: {
- licenseAgreementList
- }
- }
- });
- deepFreeze(store.getState());
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
- const toBeDeletedLicenseAgreementId = licenseAgreementList[0].id;
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseAgreement.licenseAgreementList', []);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
-
- mockRest.addHandler('destroy', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-agreements/${toBeDeletedLicenseAgreementId}`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- });
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${version.id}`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {...returnedVersionFields, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: true}};
- });
-
- return LicenseAgreementActionHelper.deleteLicenseAgreement(store.dispatch, {
- licenseAgreementId: toBeDeletedLicenseAgreementId,
- licenseModelId: LICENSE_MODEL_ID,
- version
- }).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
-
- it('Add License Agreement', () => {
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps}
- });
- deepFreeze(store.getState());
-
- const licenseAgreementToAdd = LicenseAgreementDispatchFactory.build();
-
- const LicenseAgreementPostRequest = LicenseAgreementPostFactory.build(
- pickBy(licenseAgreementToAdd, (val, key) => key !== 'featureGroupsIds')
- );
-
- deepFreeze(LicenseAgreementPostRequest);
-
- const licenseAgreementIdFromResponse = 'ADDED_ID';
- const licenseAgreementAfterAdd = LicenseAgreementStoreFactory.build({
- ...licenseAgreementToAdd,
- id: licenseAgreementIdFromResponse
- });
- deepFreeze(licenseAgreementAfterAdd);
- const licenseAgreementList = [licenseAgreementAfterAdd];
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
- const featureGroupsList = licenseAgreementList[0].featureGroupsIds;
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseAgreement.licenseAgreementList', [licenseAgreementAfterAdd]);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
-
- mockRest.addHandler('post', ({options, data, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-agreements`);
- expect(data).toEqual(LicenseAgreementPostRequest);
- expect(options).toEqual(undefined);
- return {
- value: licenseAgreementIdFromResponse
- };
- });
- mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-agreements`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {results: licenseAgreementList};
- });
- mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/feature-groups`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {results: featureGroupsList};
- });
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${version.id}`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {...returnedVersionFields, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: true}};
-
- });
- return LicenseAgreementActionHelper.saveLicenseAgreement(store.dispatch, {
- licenseAgreement: licenseAgreementToAdd,
- licenseModelId: LICENSE_MODEL_ID,
- version
- }).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
-
- it('Update License Agreement', () => {
- const licenseAgreementList = buildListFromFactory(LicenseAgreementStoreFactory, 1, {featureGroupsIds: ['77']});
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps},
- licenseModel: {
- licenseAgreement: {
- licenseAgreementList
- }
- }
- });
- deepFreeze(store.getState());
-
- const previousLicenseAgreementData = licenseAgreementList[0];
- const toBeUpdatedLicenseAgreementId = previousLicenseAgreementData.id;
- const oldFeatureGroupIds = previousLicenseAgreementData.featureGroupsIds;
-
- const newFeatureGroupsIds = ['update_id_1', 'update_id_2'];
-
- const licenseAgreementUpdateData = LicenseAgreementStoreFactory.build({
- id: toBeUpdatedLicenseAgreementId,
- featureGroupsIds: newFeatureGroupsIds
- });
- deepFreeze(licenseAgreementUpdateData);
-
- const LicenseAgreementPutFactoryRequest = LicenseAgreementPutFactory.build({
- addedFeatureGroupsIds: newFeatureGroupsIds,
- removedFeatureGroupsIds: oldFeatureGroupIds
- });
-
- deepFreeze(LicenseAgreementPutFactoryRequest);
-
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseAgreement.licenseAgreementList', [licenseAgreementUpdateData]);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
-
- mockRest.addHandler('put', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-agreements/${toBeUpdatedLicenseAgreementId}`);
- expect(data).toEqual(LicenseAgreementPutFactoryRequest);
- expect(options).toEqual(undefined);
- });
- mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-agreements`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {results: [licenseAgreementUpdateData]};
- });
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${version.id}`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {...returnedVersionFields, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: true}};
- });
- mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/feature-groups`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {results: newFeatureGroupsIds};
- });
-
- return LicenseAgreementActionHelper.saveLicenseAgreement(store.dispatch, {
- licenseModelId: LICENSE_MODEL_ID,
- version,
- previousLicenseAgreement: previousLicenseAgreementData,
- licenseAgreement: licenseAgreementUpdateData
- }).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
+ it('Load License Agreement List', () => {
+ const licenseAgreementList = buildListFromFactory(
+ LicenseAgreementStoreFactory
+ );
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.licenseAgreement.licenseAgreementList',
+ licenseAgreementList
+ );
+
+ mockRest.addHandler('fetch', ({ options, data, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/license-agreements`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return { results: licenseAgreementList };
+ });
+ return LicenseAgreementActionHelper.fetchLicenseAgreementList(
+ store.dispatch,
+ { licenseModelId: LICENSE_MODEL_ID, version }
+ ).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+ it('Delete License Agreement', () => {
+ const licenseAgreementList = buildListFromFactory(
+ LicenseAgreementStoreFactory,
+ 1
+ );
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps },
+ licenseModel: {
+ licenseAgreement: {
+ licenseAgreementList
+ }
+ }
+ });
+ deepFreeze(store.getState());
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
+ const toBeDeletedLicenseAgreementId = licenseAgreementList[0].id;
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.licenseAgreement.licenseAgreementList',
+ []
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
+
+ mockRest.addHandler('destroy', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/license-agreements/${toBeDeletedLicenseAgreementId}`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ });
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields,
+ state: {
+ synchronizationState: SyncStates.UP_TO_DATE,
+ dirty: true
+ }
+ };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields
+ };
+ });
+
+ return LicenseAgreementActionHelper.deleteLicenseAgreement(
+ store.dispatch,
+ {
+ licenseAgreementId: toBeDeletedLicenseAgreementId,
+ licenseModelId: LICENSE_MODEL_ID,
+ version
+ }
+ ).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+ it('Add License Agreement', () => {
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps }
+ });
+ deepFreeze(store.getState());
+
+ const licenseAgreementToAdd = LicenseAgreementDispatchFactory.build();
+
+ const LicenseAgreementPostRequest = LicenseAgreementPostFactory.build(
+ pickBy(
+ licenseAgreementToAdd,
+ (val, key) => key !== 'featureGroupsIds'
+ )
+ );
+
+ deepFreeze(LicenseAgreementPostRequest);
+
+ const licenseAgreementIdFromResponse = 'ADDED_ID';
+ const licenseAgreementAfterAdd = LicenseAgreementStoreFactory.build({
+ ...licenseAgreementToAdd,
+ id: licenseAgreementIdFromResponse
+ });
+ deepFreeze(licenseAgreementAfterAdd);
+ const licenseAgreementList = [licenseAgreementAfterAdd];
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
+ const featureGroupsList = licenseAgreementList[0].featureGroupsIds;
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.licenseAgreement.licenseAgreementList',
+ [licenseAgreementAfterAdd]
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
+
+ mockRest.addHandler('post', ({ options, data, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/license-agreements`
+ );
+ expect(data).toEqual(LicenseAgreementPostRequest);
+ expect(options).toEqual(undefined);
+ return {
+ value: licenseAgreementIdFromResponse
+ };
+ });
+ mockRest.addHandler('fetch', ({ options, data, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/license-agreements`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return { results: licenseAgreementList };
+ });
+ mockRest.addHandler('fetch', ({ options, data, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/feature-groups`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return { results: featureGroupsList };
+ });
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields,
+ state: {
+ synchronizationState: SyncStates.UP_TO_DATE,
+ dirty: true
+ }
+ };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields
+ };
+ });
+
+ return LicenseAgreementActionHelper.saveLicenseAgreement(
+ store.dispatch,
+ {
+ licenseAgreement: licenseAgreementToAdd,
+ licenseModelId: LICENSE_MODEL_ID,
+ version
+ }
+ ).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+ it('Update License Agreement', () => {
+ const licenseAgreementList = buildListFromFactory(
+ LicenseAgreementStoreFactory,
+ 1,
+ { featureGroupsIds: ['77'] }
+ );
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps },
+ licenseModel: {
+ licenseAgreement: {
+ licenseAgreementList
+ }
+ }
+ });
+ deepFreeze(store.getState());
+
+ const previousLicenseAgreementData = licenseAgreementList[0];
+ const toBeUpdatedLicenseAgreementId = previousLicenseAgreementData.id;
+ const oldFeatureGroupIds =
+ previousLicenseAgreementData.featureGroupsIds;
+
+ const newFeatureGroupsIds = ['update_id_1', 'update_id_2'];
+
+ const licenseAgreementUpdateData = LicenseAgreementStoreFactory.build({
+ id: toBeUpdatedLicenseAgreementId,
+ featureGroupsIds: newFeatureGroupsIds
+ });
+ deepFreeze(licenseAgreementUpdateData);
+
+ const LicenseAgreementPutFactoryRequest = LicenseAgreementPutFactory.build(
+ {
+ addedFeatureGroupsIds: newFeatureGroupsIds,
+ removedFeatureGroupsIds: oldFeatureGroupIds
+ }
+ );
+
+ deepFreeze(LicenseAgreementPutFactoryRequest);
+
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.licenseAgreement.licenseAgreementList',
+ [licenseAgreementUpdateData]
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
+
+ mockRest.addHandler('put', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/license-agreements/${toBeUpdatedLicenseAgreementId}`
+ );
+ expect(data).toEqual(LicenseAgreementPutFactoryRequest);
+ expect(options).toEqual(undefined);
+ });
+ mockRest.addHandler('fetch', ({ options, data, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/license-agreements`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return { results: [licenseAgreementUpdateData] };
+ });
+
+ mockRest.addHandler('fetch', ({ options, data, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/feature-groups`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return { results: [] };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields,
+ state: {
+ synchronizationState: SyncStates.UP_TO_DATE,
+ dirty: true
+ }
+ };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields
+ };
+ });
+
+ return LicenseAgreementActionHelper.saveLicenseAgreement(
+ store.dispatch,
+ {
+ licenseModelId: LICENSE_MODEL_ID,
+ version,
+ previousLicenseAgreement: previousLicenseAgreementData,
+ licenseAgreement: licenseAgreementUpdateData
+ }
+ ).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
});
diff --git a/openecomp-ui/test/licenseModel/licenseKeyGroups/test.js b/openecomp-ui/test/licenseModel/licenseKeyGroups/test.js
index 09a2c6f53a..1326025e5d 100644
--- a/openecomp-ui/test/licenseModel/licenseKeyGroups/test.js
+++ b/openecomp-ui/test/licenseModel/licenseKeyGroups/test.js
@@ -1,5 +1,5 @@
/*!
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2016-2018 European Support Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,432 +15,681 @@
*/
import deepFreeze from 'deep-freeze';
import mockRest from 'test-utils/MockRest.js';
-import {cloneAndSet, buildListFromFactory} from 'test-utils/Util.js';
-import {storeCreator} from 'sdc-app/AppStore.js';
-import {LicenseKeyGroupStoreFactory, LicenseKeyGroupPostFactory} from 'test-utils/factories/licenseModel/LicenseKeyGroupFactories.js';
+import { cloneAndSet, buildListFromFactory } from 'test-utils/Util.js';
+import { storeCreator } from 'sdc-app/AppStore.js';
+import {
+ LicenseKeyGroupStoreFactory,
+ LicenseKeyGroupPostFactory
+} from 'test-utils/factories/licenseModel/LicenseKeyGroupFactories.js';
import LicenseKeyGroupsActionHelper from 'sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js';
import VersionFactory from 'test-utils/factories/common/VersionFactory.js';
import CurrentScreenFactory from 'test-utils/factories/common/CurrentScreenFactory.js';
-import {LimitItemFactory, LimitPostFactory} from 'test-utils/factories/licenseModel/LimitFactories.js';
-import {getStrValue} from 'nfvo-utils/getValue.js';
-import {SyncStates} from 'sdc-app/common/merge/MergeEditorConstants.js';
-
-describe('License Key Groups Module Tests', function () {
-
- const LICENSE_MODEL_ID = '555';
- const version = VersionFactory.build();
- const itemPermissionAndProps = CurrentScreenFactory.build({}, {version});
- const returnedVersionFields = {baseId: version.baseId, description: version.description, id: version.id, name: version.name, status: version.status};
-
- it('Load License Key Group', () => {
-
- const licenseKeyGroupsList = buildListFromFactory(LicenseKeyGroupStoreFactory);
-
- deepFreeze(licenseKeyGroupsList);
- const store = storeCreator();
- deepFreeze(store.getState());
-
- const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', licenseKeyGroupsList);
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {results: licenseKeyGroupsList};
- });
-
- return LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID, version}).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
-
- it('Delete License Key Group', () => {
-
- const licenseKeyGroupsList = buildListFromFactory(LicenseKeyGroupStoreFactory, 1);
-
- deepFreeze(licenseKeyGroupsList);
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps},
- licenseModel: {
- licenseKeyGroup: {
- licenseKeyGroupsList
- }
- }
- });
- deepFreeze(store.getState());
- const toBeDeletedLicenseKeyGroupId = licenseKeyGroupsList[0].id;
-
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
-
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', []);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
-
- mockRest.addHandler('destroy', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups/${toBeDeletedLicenseKeyGroupId}`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- });
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${version.id}`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {...returnedVersionFields, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: true}};
- });
-
- return LicenseKeyGroupsActionHelper.deleteLicenseKeyGroup(store.dispatch, {
- licenseKeyGroupId: toBeDeletedLicenseKeyGroupId,
- licenseModelId: LICENSE_MODEL_ID,
- version
- }).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
-
- it('Add License Key Group', () => {
-
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps}
- });
- deepFreeze(store.getState());
-
- const LicenseKeyGroupPost = LicenseKeyGroupPostFactory.build();
- deepFreeze(LicenseKeyGroupPost);
-
- const LicenseKeyGroupStore = LicenseKeyGroupStoreFactory.build();
- deepFreeze(LicenseKeyGroupStore);
-
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
-
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', [LicenseKeyGroupStore]);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
-
- mockRest.addHandler('post', ({options, data, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups`);
- expect(data).toEqual(LicenseKeyGroupPost);
- expect(options).toEqual(undefined);
- return {
- value: LicenseKeyGroupStore.id
- };
- });
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${version.id}`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {...returnedVersionFields, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: true}};
- });
-
- return LicenseKeyGroupsActionHelper.saveLicenseKeyGroup(store.dispatch, {
- licenseKeyGroup: LicenseKeyGroupPost,
- licenseModelId: LICENSE_MODEL_ID,
- version
- }).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
-
- it('Update License Key Group', () => {
- const licenseKeyGroupsList = buildListFromFactory(LicenseKeyGroupStoreFactory, 1);
- deepFreeze(licenseKeyGroupsList);
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps},
- licenseModel: {
- licenseKeyGroup: {
- licenseKeyGroupsList
- }
- }
- });
-
- const toBeUpdatedLicenseKeyGroupId = licenseKeyGroupsList[0].id;
- const previousLicenseKeyGroupData = licenseKeyGroupsList[0];
-
- const licenseKeyGroupUpdatedData = LicenseKeyGroupPostFactory.build({
- name: 'lsk1_UPDATE',
- description: 'string_UPDATE',
- id: toBeUpdatedLicenseKeyGroupId
- });
- deepFreeze(licenseKeyGroupUpdatedData);
-
- const licenseKeyGroupPutRequest = LicenseKeyGroupPostFactory.build({
- name: 'lsk1_UPDATE',
- description: 'string_UPDATE'
- });
-
- deepFreeze(licenseKeyGroupPutRequest);
-
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
-
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', [licenseKeyGroupUpdatedData]);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
-
- mockRest.addHandler('put', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups/${toBeUpdatedLicenseKeyGroupId}`);
- expect(data).toEqual(licenseKeyGroupPutRequest);
- expect(options).toEqual(undefined);
- });
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${version.id}`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {...returnedVersionFields, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: true}};
- });
-
- return LicenseKeyGroupsActionHelper.saveLicenseKeyGroup(store.dispatch, {
- previousLicenseKeyGroup: previousLicenseKeyGroupData,
- licenseKeyGroup: licenseKeyGroupUpdatedData,
- licenseModelId: LICENSE_MODEL_ID,
- version
- }).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
-
- it('Load Limits List', () => {
-
- const limitsList = LimitItemFactory.buildList(3);
- deepFreeze(limitsList);
- const store = storeCreator();
- deepFreeze(store.getState());
-
- const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsEditor.limitsList', limitsList);
- const licenseKeyGroup = LicenseKeyGroupStoreFactory.build();
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups/${licenseKeyGroup.id}/limits`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {results: limitsList};
- });
-
- return LicenseKeyGroupsActionHelper.fetchLimits(store.dispatch, {licenseModelId: LICENSE_MODEL_ID, version, licenseKeyGroup}).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
-
- it('Add Limit', () => {
-
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps}
- });
- deepFreeze(store.getState());
-
- const limitToAdd = LimitPostFactory.build();
- let limitFromBE = {...limitToAdd};
- limitFromBE.metric = getStrValue(limitFromBE.metric);
- limitFromBE.unit = getStrValue(limitFromBE.unit);
-
- deepFreeze(limitToAdd);
- deepFreeze(limitFromBE);
-
- const LimitIdFromResponse = 'ADDED_ID';
- const limitAddedItem = {...limitToAdd, id: LimitIdFromResponse};
- deepFreeze(limitAddedItem);
- const licenseKeyGroup = LicenseKeyGroupStoreFactory.build();
-
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
-
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsEditor.limitsList', [limitAddedItem]);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
-
- mockRest.addHandler('post', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups/${licenseKeyGroup.id}/limits`);
- expect(data).toEqual(limitFromBE);
- expect(options).toEqual(undefined);
- return {
- returnCode: 'OK',
- value: LimitIdFromResponse
- };
- });
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups/${licenseKeyGroup.id}/limits`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {results: [limitAddedItem]};
- });
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${version.id}`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {...returnedVersionFields, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: true}};
- });
-
- return LicenseKeyGroupsActionHelper.submitLimit(store.dispatch,
- {
- licenseModelId: LICENSE_MODEL_ID,
- version,
- licenseKeyGroup,
- limit: limitToAdd
- }
- ).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
-
- it('Delete Limit', () => {
-
- const limitsList = LimitItemFactory.buildList(1);
- deepFreeze(limitsList);
-
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps},
- licenseModel: {
- entitlementPool: {
- entitlementPoolEditor: {
- limitsList
- }
- }
- }
- });
- deepFreeze(store.getState());
-
- const licenseKeyGroup = LicenseKeyGroupStoreFactory.build();
-
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
-
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsEditor.limitsList', []);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
-
- mockRest.addHandler('destroy', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups/${licenseKeyGroup.id}/limits/${limitsList[0].id}`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {
- results: {
- returnCode: 'OK'
- }
- };
- });
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups/${licenseKeyGroup.id}/limits`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {results: []};
- });
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${version.id}`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {...returnedVersionFields, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: true}};
- });
-
- return LicenseKeyGroupsActionHelper.deleteLimit(store.dispatch, {
- licenseModelId: LICENSE_MODEL_ID,
- version,
- licenseKeyGroup,
- limit: limitsList[0]
- }).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
-
- it('Update Limit', () => {
-
- const limitsList = LimitItemFactory.buildList(1);
- deepFreeze(limitsList);
- const licenseKeyGroup = LicenseKeyGroupStoreFactory.build();
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps},
- licenseModel: {
- licenseKeyGroup: {
- licenseKeyGroupsEditor: {
- limitsList
- }
- }
- }
- });
-
- deepFreeze(store.getState());
-
-
- const previousData = limitsList[0];
- deepFreeze(previousData);
- const limitId = limitsList[0].id;
-
- let updatedLimit = {...previousData, name: 'updatedLimit'};
- const updatedLimitForPut = {...updatedLimit, id: undefined};
- updatedLimit.metric = {choice: updatedLimit.metric, other: ''};
- updatedLimit.unit = {choice: updatedLimit.unit, other: ''};
- deepFreeze(updatedLimit);
-
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
-
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsEditor.limitsList', [updatedLimitForPut]);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
-
-
- mockRest.addHandler('put', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups/${licenseKeyGroup.id}/limits/${limitId}`);
- expect(data).toEqual(updatedLimitForPut);
- expect(options).toEqual(undefined);
- return {returnCode: 'OK'};
- });
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups/${licenseKeyGroup.id}/limits`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {results: [updatedLimitForPut]};
- });
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${version.id}`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {...returnedVersionFields, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: true}};
- });
-
- return LicenseKeyGroupsActionHelper.submitLimit(store.dispatch,
- {
- licenseModelId: LICENSE_MODEL_ID,
- version,
- licenseKeyGroup,
- limit: updatedLimit
- }
- ).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
-
+import {
+ LimitItemFactory,
+ LimitPostFactory
+} from 'test-utils/factories/licenseModel/LimitFactories.js';
+import { getStrValue } from 'nfvo-utils/getValue.js';
+import { SyncStates } from 'sdc-app/common/merge/MergeEditorConstants.js';
+
+describe('License Key Groups Module Tests', function() {
+ const LICENSE_MODEL_ID = '555';
+ const version = VersionFactory.build();
+ const itemPermissionAndProps = CurrentScreenFactory.build({}, { version });
+ const returnedVersionFields = {
+ baseId: version.baseId,
+ description: version.description,
+ id: version.id,
+ name: version.name,
+ status: version.status
+ };
+
+ it('Load License Key Group', () => {
+ const licenseKeyGroupsList = buildListFromFactory(
+ LicenseKeyGroupStoreFactory
+ );
+
+ deepFreeze(licenseKeyGroupsList);
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.licenseKeyGroup.licenseKeyGroupsList',
+ licenseKeyGroupsList
+ );
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/license-key-groups`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return { results: licenseKeyGroupsList };
+ });
+
+ return LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(
+ store.dispatch,
+ { licenseModelId: LICENSE_MODEL_ID, version }
+ ).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+ it('Delete License Key Group', () => {
+ const licenseKeyGroupsList = buildListFromFactory(
+ LicenseKeyGroupStoreFactory,
+ 1
+ );
+
+ deepFreeze(licenseKeyGroupsList);
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps },
+ licenseModel: {
+ licenseKeyGroup: {
+ licenseKeyGroupsList
+ }
+ }
+ });
+ deepFreeze(store.getState());
+ const toBeDeletedLicenseKeyGroupId = licenseKeyGroupsList[0].id;
+
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
+
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.licenseKeyGroup.licenseKeyGroupsList',
+ []
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
+
+ mockRest.addHandler('destroy', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/license-key-groups/${toBeDeletedLicenseKeyGroupId}`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields,
+ state: {
+ synchronizationState: SyncStates.UP_TO_DATE,
+ dirty: true
+ }
+ };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields
+ };
+ });
+
+ return LicenseKeyGroupsActionHelper.deleteLicenseKeyGroup(
+ store.dispatch,
+ {
+ licenseKeyGroupId: toBeDeletedLicenseKeyGroupId,
+ licenseModelId: LICENSE_MODEL_ID,
+ version
+ }
+ ).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+ it('Add License Key Group', () => {
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps }
+ });
+ deepFreeze(store.getState());
+
+ const LicenseKeyGroupPost = LicenseKeyGroupPostFactory.build();
+ deepFreeze(LicenseKeyGroupPost);
+
+ const LicenseKeyGroupStore = LicenseKeyGroupStoreFactory.build();
+ deepFreeze(LicenseKeyGroupStore);
+
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
+
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.licenseKeyGroup.licenseKeyGroupsList',
+ [LicenseKeyGroupStore]
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
+
+ mockRest.addHandler('post', ({ options, data, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/license-key-groups`
+ );
+ expect(data).toEqual(LicenseKeyGroupPost);
+ expect(options).toEqual(undefined);
+ return {
+ value: LicenseKeyGroupStore.id
+ };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields,
+ state: {
+ synchronizationState: SyncStates.UP_TO_DATE,
+ dirty: true
+ }
+ };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields
+ };
+ });
+
+ return LicenseKeyGroupsActionHelper.saveLicenseKeyGroup(
+ store.dispatch,
+ {
+ licenseKeyGroup: LicenseKeyGroupPost,
+ licenseModelId: LICENSE_MODEL_ID,
+ version
+ }
+ ).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+ it('Update License Key Group', () => {
+ const licenseKeyGroupsList = buildListFromFactory(
+ LicenseKeyGroupStoreFactory,
+ 1
+ );
+ deepFreeze(licenseKeyGroupsList);
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps },
+ licenseModel: {
+ licenseKeyGroup: {
+ licenseKeyGroupsList
+ }
+ }
+ });
+
+ const toBeUpdatedLicenseKeyGroupId = licenseKeyGroupsList[0].id;
+ const previousLicenseKeyGroupData = licenseKeyGroupsList[0];
+
+ const licenseKeyGroupUpdatedData = LicenseKeyGroupPostFactory.build({
+ name: 'lsk1_UPDATE',
+ description: 'string_UPDATE',
+ id: toBeUpdatedLicenseKeyGroupId
+ });
+ deepFreeze(licenseKeyGroupUpdatedData);
+
+ const licenseKeyGroupPutRequest = LicenseKeyGroupPostFactory.build({
+ name: 'lsk1_UPDATE',
+ description: 'string_UPDATE'
+ });
+
+ deepFreeze(licenseKeyGroupPutRequest);
+
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
+
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.licenseKeyGroup.licenseKeyGroupsList',
+ [licenseKeyGroupUpdatedData]
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
+
+ mockRest.addHandler('put', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/license-key-groups/${toBeUpdatedLicenseKeyGroupId}`
+ );
+ expect(data).toEqual(licenseKeyGroupPutRequest);
+ expect(options).toEqual(undefined);
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields,
+ state: {
+ synchronizationState: SyncStates.UP_TO_DATE,
+ dirty: true
+ }
+ };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields
+ };
+ });
+
+ return LicenseKeyGroupsActionHelper.saveLicenseKeyGroup(
+ store.dispatch,
+ {
+ previousLicenseKeyGroup: previousLicenseKeyGroupData,
+ licenseKeyGroup: licenseKeyGroupUpdatedData,
+ licenseModelId: LICENSE_MODEL_ID,
+ version
+ }
+ ).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+ it('Load Limits List', () => {
+ const limitsList = LimitItemFactory.buildList(3);
+ deepFreeze(limitsList);
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.licenseKeyGroup.licenseKeyGroupsEditor.limitsList',
+ limitsList
+ );
+ const licenseKeyGroup = LicenseKeyGroupStoreFactory.build();
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/license-key-groups/${licenseKeyGroup.id}/limits`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return { results: limitsList };
+ });
+
+ return LicenseKeyGroupsActionHelper.fetchLimits(store.dispatch, {
+ licenseModelId: LICENSE_MODEL_ID,
+ version,
+ licenseKeyGroup
+ }).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+ it('Add Limit', () => {
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps }
+ });
+ deepFreeze(store.getState());
+
+ const limitToAdd = LimitPostFactory.build();
+ let limitFromBE = { ...limitToAdd };
+ limitFromBE.metric = getStrValue(limitFromBE.metric);
+ limitFromBE.unit = getStrValue(limitFromBE.unit);
+
+ deepFreeze(limitToAdd);
+ deepFreeze(limitFromBE);
+
+ const LimitIdFromResponse = 'ADDED_ID';
+ const limitAddedItem = { ...limitToAdd, id: LimitIdFromResponse };
+ deepFreeze(limitAddedItem);
+ const licenseKeyGroup = LicenseKeyGroupStoreFactory.build();
+
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
+
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.licenseKeyGroup.licenseKeyGroupsEditor.limitsList',
+ [limitAddedItem]
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
+
+ mockRest.addHandler('post', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/license-key-groups/${licenseKeyGroup.id}/limits`
+ );
+ expect(data).toEqual(limitFromBE);
+ expect(options).toEqual(undefined);
+ return {
+ returnCode: 'OK',
+ value: LimitIdFromResponse
+ };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/license-key-groups/${licenseKeyGroup.id}/limits`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return { results: [limitAddedItem] };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields,
+ state: {
+ synchronizationState: SyncStates.UP_TO_DATE,
+ dirty: true
+ }
+ };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields
+ };
+ });
+
+ return LicenseKeyGroupsActionHelper.submitLimit(store.dispatch, {
+ licenseModelId: LICENSE_MODEL_ID,
+ version,
+ licenseKeyGroup,
+ limit: limitToAdd
+ }).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+ it('Delete Limit', () => {
+ const limitsList = LimitItemFactory.buildList(1);
+ deepFreeze(limitsList);
+
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps },
+ licenseModel: {
+ entitlementPool: {
+ entitlementPoolEditor: {
+ limitsList
+ }
+ }
+ }
+ });
+ deepFreeze(store.getState());
+
+ const licenseKeyGroup = LicenseKeyGroupStoreFactory.build();
+
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
+
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.licenseKeyGroup.licenseKeyGroupsEditor.limitsList',
+ []
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
+
+ mockRest.addHandler('destroy', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/license-key-groups/${licenseKeyGroup.id}/limits/${
+ limitsList[0].id
+ }`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ results: {
+ returnCode: 'OK'
+ }
+ };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/license-key-groups/${licenseKeyGroup.id}/limits`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return { results: [] };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields,
+ state: {
+ synchronizationState: SyncStates.UP_TO_DATE,
+ dirty: true
+ }
+ };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields
+ };
+ });
+
+ return LicenseKeyGroupsActionHelper.deleteLimit(store.dispatch, {
+ licenseModelId: LICENSE_MODEL_ID,
+ version,
+ licenseKeyGroup,
+ limit: limitsList[0]
+ }).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+ it('Update Limit', () => {
+ const limitsList = LimitItemFactory.buildList(1);
+ deepFreeze(limitsList);
+ const licenseKeyGroup = LicenseKeyGroupStoreFactory.build();
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps },
+ licenseModel: {
+ licenseKeyGroup: {
+ licenseKeyGroupsEditor: {
+ limitsList
+ }
+ }
+ }
+ });
+
+ deepFreeze(store.getState());
+
+ const previousData = limitsList[0];
+ deepFreeze(previousData);
+ const limitId = limitsList[0].id;
+
+ let updatedLimit = { ...previousData, name: 'updatedLimit' };
+ const updatedLimitForPut = { ...updatedLimit, id: undefined };
+ updatedLimit.metric = { choice: updatedLimit.metric, other: '' };
+ updatedLimit.unit = { choice: updatedLimit.unit, other: '' };
+ deepFreeze(updatedLimit);
+
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
+
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.licenseKeyGroup.licenseKeyGroupsEditor.limitsList',
+ [updatedLimitForPut]
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
+
+ mockRest.addHandler('put', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/license-key-groups/${licenseKeyGroup.id}/limits/${limitId}`
+ );
+ expect(data).toEqual(updatedLimitForPut);
+ expect(options).toEqual(undefined);
+ return { returnCode: 'OK' };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }/license-key-groups/${licenseKeyGroup.id}/limits`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return { results: [updatedLimitForPut] };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${
+ version.id
+ }`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields,
+ state: {
+ synchronizationState: SyncStates.UP_TO_DATE,
+ dirty: true
+ }
+ };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields
+ };
+ });
+
+ return LicenseKeyGroupsActionHelper.submitLimit(store.dispatch, {
+ licenseModelId: LICENSE_MODEL_ID,
+ version,
+ licenseKeyGroup,
+ limit: updatedLimit
+ }).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
});
diff --git a/openecomp-ui/test/licenseModel/test.js b/openecomp-ui/test/licenseModel/test.js
index 6cb2168cbb..bbebcaf079 100644
--- a/openecomp-ui/test/licenseModel/test.js
+++ b/openecomp-ui/test/licenseModel/test.js
@@ -1,5 +1,5 @@
/*!
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2016-2018 European Support Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -15,127 +15,188 @@
*/
import deepFreeze from 'deep-freeze';
import mockRest from 'test-utils/MockRest.js';
-import {storeCreator} from 'sdc-app/AppStore.js';
-import {cloneAndSet} from 'test-utils/Util.js';
+import { storeCreator } from 'sdc-app/AppStore.js';
+import { cloneAndSet } from 'test-utils/Util.js';
import LicenseModelActionHelper from 'sdc-app/onboarding/licenseModel/LicenseModelActionHelper.js';
import LicenseModelCreationActionHelper from 'sdc-app/onboarding/licenseModel/creation/LicenseModelCreationActionHelper.js';
-import {LicenseModelPostFactory, LicenseModelDispatchFactory, LicenseModelStoreFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
+import {
+ LicenseModelPostFactory,
+ LicenseModelDispatchFactory,
+ LicenseModelStoreFactory
+} from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
import VersionFactory from 'test-utils/factories/common/VersionFactory.js';
-import {default as CurrentScreenFactory} from 'test-utils/factories/common/CurrentScreenFactory.js';
-import {actionsEnum as VersionControllerActionsEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
-import {SyncStates} from 'sdc-app/common/merge/MergeEditorConstants.js';
-import {itemTypes} from 'sdc-app/onboarding/versionsPage/VersionsPageConstants.js';
-
-describe('License Model Module Tests', function () {
- it('Add License Model', () => {
- const store = storeCreator();
- deepFreeze(store.getState());
-
- const licenseModelPostRequest = LicenseModelPostFactory.build();
-
- const licenseModelToAdd = LicenseModelDispatchFactory.build();
-
- const licenseModelIdFromResponse = 'ADDED_ID';
-
- mockRest.addHandler('post', ({options, data, baseUrl}) => {
- expect(baseUrl).toEqual('/onboarding-api/v1.0/vendor-license-models/');
- expect(data).toEqual(licenseModelPostRequest);
- expect(options).toEqual(undefined);
- return {
- value: licenseModelIdFromResponse
- };
- });
-
- return LicenseModelCreationActionHelper.createLicenseModel(store.dispatch, {
- licenseModel: licenseModelToAdd
- }).then((response) => {
- expect(response.value).toEqual(licenseModelIdFromResponse);
- });
- });
-
- it('Validating readonly screen after submit', () => {
- const version = VersionFactory.build({}, {isCertified: false});
- const itemPermissionAndProps = CurrentScreenFactory.build({}, {version});
- const licenseModel = LicenseModelStoreFactory.build();
- deepFreeze(licenseModel);
-
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps},
- licenseModel: {
- licenseModelEditor: {data: licenseModel},
- }
- });
- deepFreeze(store.getState());
-
- const certifiedVersion = {
- ...itemPermissionAndProps.props.version,
- status: 'Certified'
- };
-
- const expectedCurrentScreenProps = {
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isCertified: true
- },
- props: {
- isReadOnlyMode: true,
- version: certifiedVersion
- }
- };
- const expectedSuccessModal = {
- cancelButtonText: 'OK',
- modalClassName: 'notification-modal',
- msg: 'This license model successfully submitted',
- timeout: 2000,
- title: 'Submit Succeeded',
- type: 'success'
- };
-
- const versionsList = {
- itemType: itemTypes.LICENSE_MODEL,
- itemId: licenseModel.id,
- versions: [{...certifiedVersion}]
- };
-
- let expectedStore = store.getState();
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.props', expectedCurrentScreenProps.props);
- expectedStore = cloneAndSet(expectedStore, 'modal', expectedSuccessModal);
- expectedStore = cloneAndSet(expectedStore, 'versionsPage.versionsList', versionsList );
-
- mockRest.addHandler('put', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${licenseModel.id}/versions/${version.id}/actions`);
- expect(data).toEqual({action: VersionControllerActionsEnum.SUBMIT});
- expect(options).toEqual(undefined);
- return {returnCode: 'OK'};
- });
-
- mockRest.addHandler('put', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${licenseModel.id}/versions/${version.id}/actions`);
- expect(data).toEqual({action: VersionControllerActionsEnum.CREATE_PACKAGE});
- expect(options).toEqual(undefined);
- return {returnCode: 'OK'};
- });
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${licenseModel.id}/versions/${version.id}`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {...certifiedVersion, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: false}};
- });
-
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${licenseModel.id}/versions`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {results: [{...certifiedVersion}]};
- });
-
- return LicenseModelActionHelper.performSubmitAction(store.dispatch, {
- licenseModelId: licenseModel.id,
- version
- }).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
+import { default as CurrentScreenFactory } from 'test-utils/factories/common/CurrentScreenFactory.js';
+import { actionsEnum as VersionControllerActionsEnum } from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
+import { SyncStates } from 'sdc-app/common/merge/MergeEditorConstants.js';
+import { itemTypes } from 'sdc-app/onboarding/versionsPage/VersionsPageConstants.js';
+
+describe('License Model Module Tests', function() {
+ it('Add License Model', () => {
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const licenseModelPostRequest = LicenseModelPostFactory.build();
+
+ const licenseModelToAdd = LicenseModelDispatchFactory.build();
+
+ const licenseModelIdFromResponse = 'ADDED_ID';
+
+ mockRest.addHandler('post', ({ options, data, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ '/onboarding-api/v1.0/vendor-license-models/'
+ );
+ expect(data).toEqual(licenseModelPostRequest);
+ expect(options).toEqual(undefined);
+ return {
+ value: licenseModelIdFromResponse
+ };
+ });
+
+ return LicenseModelCreationActionHelper.createLicenseModel(
+ store.dispatch,
+ {
+ licenseModel: licenseModelToAdd
+ }
+ ).then(response => {
+ expect(response.value).toEqual(licenseModelIdFromResponse);
+ });
+ });
+
+ it('Validating readonly screen after submit', () => {
+ const version = VersionFactory.build({}, { isCertified: false });
+ const itemPermissionAndProps = CurrentScreenFactory.build(
+ {},
+ { version }
+ );
+ const licenseModel = LicenseModelStoreFactory.build();
+ deepFreeze(licenseModel);
+
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps },
+ licenseModel: {
+ licenseModelEditor: { data: licenseModel }
+ }
+ });
+ deepFreeze(store.getState());
+
+ const certifiedVersion = {
+ ...itemPermissionAndProps.props.version,
+ status: 'Certified'
+ };
+
+ const expectedCurrentScreenProps = {
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isCertified: true
+ },
+ props: {
+ isReadOnlyMode: true,
+ version: certifiedVersion
+ }
+ };
+ const expectedSuccessModal = {
+ cancelButtonText: 'OK',
+ modalClassName: 'notification-modal',
+ msg: 'This license model successfully submitted',
+ timeout: 2000,
+ title: 'Submit Succeeded',
+ type: 'success'
+ };
+
+ const versionsList = {
+ itemType: itemTypes.LICENSE_MODEL,
+ itemId: licenseModel.id,
+ versions: [{ ...certifiedVersion }]
+ };
+
+ let expectedStore = store.getState();
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.props',
+ expectedCurrentScreenProps.props
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'modal',
+ expectedSuccessModal
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'versionsPage.versionsList',
+ versionsList
+ );
+
+ mockRest.addHandler('put', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${
+ licenseModel.id
+ }/versions/${version.id}/actions`
+ );
+ expect(data).toEqual({
+ action: VersionControllerActionsEnum.SUBMIT
+ });
+ expect(options).toEqual(undefined);
+ return { returnCode: 'OK' };
+ });
+
+ mockRest.addHandler('put', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-license-models/${
+ licenseModel.id
+ }/versions/${version.id}/actions`
+ );
+ expect(data).toEqual({
+ action: VersionControllerActionsEnum.CREATE_PACKAGE
+ });
+ expect(options).toEqual(undefined);
+ return { returnCode: 'OK' };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${licenseModel.id}/versions/${
+ version.id
+ }`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...certifiedVersion,
+ state: {
+ synchronizationState: SyncStates.UP_TO_DATE,
+ dirty: false
+ }
+ };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${licenseModel.id}`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return { ...certifiedVersion };
+ });
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${licenseModel.id}/versions`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return { results: [{ ...certifiedVersion }] };
+ });
+
+ return LicenseModelActionHelper.performSubmitAction(store.dispatch, {
+ licenseModelId: licenseModel.id,
+ version
+ }).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
});
diff --git a/openecomp-ui/test/onboard/filter/filter.test.js b/openecomp-ui/test/onboard/filter/filter.test.js
index 1b89a306bf..bf9ce63346 100644
--- a/openecomp-ui/test/onboard/filter/filter.test.js
+++ b/openecomp-ui/test/onboard/filter/filter.test.js
@@ -24,7 +24,8 @@ import {
import { FilterFactory } from 'test-utils/factories/onboard/FilterFactories.js';
import {
itemStatus,
- versionStatus
+ versionStatus,
+ itemPermissions
} from 'sdc-app/common/helpers/ItemsHelperConstants.js';
import OnboardActionHelper from 'sdc-app/onboarding/onboard/OnboardActionHelper.js';
import { tabsMapping } from 'sdc-app/onboarding/onboard/OnboardConstants.js';
@@ -46,7 +47,9 @@ describe('Onboard Filter Tests', () => {
expect(baseUrl).toEqual(
`/onboarding-api/v1.0/items?&itemStatus=${
itemStatus.ACTIVE
- }&versionStatus=${versionStatus.DRAFT}`
+ }&versionStatus=${versionStatus.DRAFT}&permission=${
+ itemPermissions.OWNER
+ },${itemPermissions.CONTRIBUTOR}`
);
expect(data).toEqual(undefined);
expect(options).toEqual(undefined);
@@ -62,10 +65,7 @@ describe('Onboard Filter Tests', () => {
done();
});
});
- /**
- * TODO Turn ON when FILTER TOGGLE Will BE REMOVED
- */
- /*
+
it('load certifed data', done => {
const store = storeCreator();
@@ -112,7 +112,7 @@ describe('Onboard Filter Tests', () => {
done();
});
});
- */
+
it('onboarding tabs switching filter updates', done => {
const store = storeCreator();
diff --git a/openecomp-ui/test/onboard/test.js b/openecomp-ui/test/onboard/test.js
index a75070bf26..b2131ceed5 100644
--- a/openecomp-ui/test/onboard/test.js
+++ b/openecomp-ui/test/onboard/test.js
@@ -20,6 +20,11 @@ import OnboardingCatalogActionHelper from 'sdc-app/onboarding/onboard/onboarding
import { tabsMapping as onboardTabsMapping } from 'sdc-app/onboarding/onboard/OnboardConstants.js';
import { tabsMapping as onboardCatalogTabsMapping } from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogConstants.js';
import { FilterFactory } from 'test-utils/factories/onboard/FilterFactories.js';
+import mockRest from 'test-utils/MockRest.js';
+import {
+ itemStatus,
+ versionStatus
+} from 'sdc-app/common/helpers/ItemsHelperConstants.js';
describe('Onboard Module Tests', () => {
it('should return default state', () => {
@@ -34,6 +39,18 @@ describe('Onboard Module Tests', () => {
activeTab: onboardTabsMapping.CATALOG,
filter: FilterFactory.build({ versionStatus: 'Certified' })
});
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items?&itemStatus=${
+ itemStatus.ACTIVE
+ }&versionStatus=${versionStatus.CERTIFIED}`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return { results: [] };
+ });
+
OnboardActionHelper.changeActiveTab(
store.dispatch,
onboardTabsMapping.CATALOG
@@ -62,6 +79,18 @@ describe('Onboard Module Tests', () => {
const store = storeCreator();
const expectedStore = OnboardStoreFactory.build();
OnboardActionHelper.changeSearchValue(store.dispatch, 'hello');
+
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items?&itemStatus=${
+ itemStatus.ACTIVE
+ }&versionStatus=${versionStatus.CERTIFIED}`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return { results: [] };
+ });
+
OnboardActionHelper.changeActiveTab(
store.dispatch,
onboardTabsMapping.CATALOG
@@ -70,6 +99,7 @@ describe('Onboard Module Tests', () => {
store.dispatch,
onboardCatalogTabsMapping.ACTIVE
);
+
OnboardActionHelper.resetOnboardStore(store.dispatch, 'hello');
expect(store.getState().onboard).toEqual(expectedStore);
});
diff --git a/openecomp-ui/test/softwareProduct/test.js b/openecomp-ui/test/softwareProduct/test.js
index 15f7a21866..91b4e7d40e 100644
--- a/openecomp-ui/test/softwareProduct/test.js
+++ b/openecomp-ui/test/softwareProduct/test.js
@@ -1,5 +1,5 @@
/*!
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright © 2016-2018 European Support Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -16,101 +16,156 @@
import deepFreeze from 'deep-freeze';
import mockRest from 'test-utils/MockRest.js';
-import {cloneAndSet} from 'test-utils/Util.js';
-import {storeCreator} from 'sdc-app/AppStore.js';
+import { cloneAndSet } from 'test-utils/Util.js';
+import { storeCreator } from 'sdc-app/AppStore.js';
import SoftwareProductActionHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js';
-import {VSPEditorFactoryWithLicensingData} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
+import { VSPEditorFactoryWithLicensingData } from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
import VersionFactory from 'test-utils/factories/common/VersionFactory.js';
-import {default as CurrentScreenFactory} from 'test-utils/factories/common/CurrentScreenFactory.js';
-import {actionsEnum as VersionControllerActionsEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
-import {SyncStates} from 'sdc-app/common/merge/MergeEditorConstants.js';
-import {itemTypes} from 'sdc-app/onboarding/versionsPage/VersionsPageConstants.js';
+import { default as CurrentScreenFactory } from 'test-utils/factories/common/CurrentScreenFactory.js';
+import { actionsEnum as VersionControllerActionsEnum } from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
+import { SyncStates } from 'sdc-app/common/merge/MergeEditorConstants.js';
+import { itemTypes } from 'sdc-app/onboarding/versionsPage/VersionsPageConstants.js';
-describe('Software Product Module Tests', function () {
- it('Validating readonly screen after submit', () => {
- const version = VersionFactory.build({}, {isCertified: false});
- const itemPermissionAndProps = CurrentScreenFactory.build({}, {version});
- const softwareProduct = VSPEditorFactoryWithLicensingData.build();
- deepFreeze(softwareProduct);
+describe('Software Product Module Tests', function() {
+ it('Validating readonly screen after submit', () => {
+ const version = VersionFactory.build({}, { isCertified: false });
+ const itemPermissionAndProps = CurrentScreenFactory.build(
+ {},
+ { version }
+ );
+ const softwareProduct = VSPEditorFactoryWithLicensingData.build();
+ deepFreeze(softwareProduct);
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps},
- softwareProduct: {
- softwareProductEditor: {data: softwareProduct},
- softwareProductQuestionnaire: {qdata: 'test', qschema: {type: 'string'}}
- }
- });
- deepFreeze(store.getState());
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps },
+ softwareProduct: {
+ softwareProductEditor: { data: softwareProduct },
+ softwareProductQuestionnaire: {
+ qdata: 'test',
+ qschema: { type: 'string' }
+ }
+ }
+ });
+ deepFreeze(store.getState());
- const certifiedVersion = {
- ...itemPermissionAndProps.props.version,
- status: 'Certified'
- };
+ const certifiedVersion = {
+ ...itemPermissionAndProps.props.version,
+ status: 'Certified'
+ };
- const versionsList = {
- itemType: itemTypes.SOFTWARE_PRODUCT,
- itemId: softwareProduct.id,
- versions: [{...certifiedVersion}]
- };
- const expectedCurrentScreenProps = {
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isCertified: true
- },
- props: {
- isReadOnlyMode: true,
- version: certifiedVersion
- }
- };
- const expectedSuccessModal = {
- cancelButtonText: 'OK',
- modalClassName: 'notification-modal',
- msg: 'This software product successfully submitted',
- timeout: 2000,
- title: 'Submit Succeeded',
- type: 'success'
- };
+ const versionsList = {
+ itemType: itemTypes.SOFTWARE_PRODUCT,
+ itemId: softwareProduct.id,
+ versions: [{ ...certifiedVersion }]
+ };
+ const expectedCurrentScreenProps = {
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isCertified: true
+ },
+ props: {
+ isReadOnlyMode: true,
+ version: certifiedVersion
+ }
+ };
+ const expectedSuccessModal = {
+ cancelButtonText: 'OK',
+ modalClassName: 'notification-modal',
+ msg: 'This software product successfully submitted',
+ timeout: 2000,
+ title: 'Submit Succeeded',
+ type: 'success'
+ };
- let expectedStore = store.getState();
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.props', expectedCurrentScreenProps.props);
- expectedStore = cloneAndSet(expectedStore, 'modal', expectedSuccessModal);
- expectedStore = cloneAndSet(expectedStore, 'versionsPage.versionsList', versionsList );
+ let expectedStore = store.getState();
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.props',
+ expectedCurrentScreenProps.props
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'modal',
+ expectedSuccessModal
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'versionsPage.versionsList',
+ versionsList
+ );
- mockRest.addHandler('put', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProduct.id}/versions/${version.id}/actions`);
- expect(data).toEqual({action: VersionControllerActionsEnum.SUBMIT});
- expect(options).toEqual(undefined);
- return {returnCode: 'OK'};
- });
+ mockRest.addHandler('put', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-software-products/${
+ softwareProduct.id
+ }/versions/${version.id}/actions`
+ );
+ expect(data).toEqual({
+ action: VersionControllerActionsEnum.SUBMIT
+ });
+ expect(options).toEqual(undefined);
+ return { returnCode: 'OK' };
+ });
- mockRest.addHandler('put', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProduct.id}/versions/${version.id}/actions`);
- expect(data).toEqual({action: VersionControllerActionsEnum.CREATE_PACKAGE});
- expect(options).toEqual(undefined);
- return {returnCode: 'OK'};
- });
+ mockRest.addHandler('put', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-software-products/${
+ softwareProduct.id
+ }/versions/${version.id}/actions`
+ );
+ expect(data).toEqual({
+ action: VersionControllerActionsEnum.CREATE_PACKAGE
+ });
+ expect(options).toEqual(undefined);
+ return { returnCode: 'OK' };
+ });
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${softwareProduct.id}/versions/${version.id}`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {...certifiedVersion, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: false}};
- });
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${softwareProduct.id}/versions/${
+ version.id
+ }`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...certifiedVersion,
+ state: {
+ synchronizationState: SyncStates.UP_TO_DATE,
+ dirty: false
+ }
+ };
+ });
- mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${softwareProduct.id}/versions`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return {results: [{...certifiedVersion}]};
- });
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${softwareProduct.id}`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return { ...certifiedVersion };
+ });
- return SoftwareProductActionHelper.performSubmitAction(store.dispatch, {
- softwareProductId: softwareProduct.id,
- version
- }).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
-}); \ No newline at end of file
+ mockRest.addHandler('fetch', ({ data, options, baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/items/${softwareProduct.id}/versions`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return { results: [{ ...certifiedVersion }] };
+ });
+
+ return SoftwareProductActionHelper.performSubmitAction(store.dispatch, {
+ softwareProductId: softwareProduct.id,
+ version
+ }).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+});