attachment page navigation fix
Issue-ID: SDC-1239
Change-Id: Ib597238233e9a035944b7a56a56601cdfd624ca2
Signed-off-by: svishnev <shlomo-stanisla.vishnevetskiy@amdocs.com>
diff --git a/openecomp-ui/test/licenseModel/entitlementPools/test.js b/openecomp-ui/test/licenseModel/entitlementPools/test.js
index dc56b11..63eab1f 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 () {
+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
+ };
- 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());
- it('Load Entitlement Pools List', () => {
+ const expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.entitlementPool.entitlementPoolsList',
+ entitlementPoolsList
+ );
- const entitlementPoolsList = buildListFromFactory(EntitlementPoolStoreFactory);
- deepFreeze(entitlementPoolsList);
- const store = storeCreator();
- deepFreeze(store.getState());
+ 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 };
+ });
- const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', entitlementPoolsList);
+ return EntitlementPoolsActionHelper.fetchEntitlementPoolsList(
+ store.dispatch,
+ { licenseModelId: LICENSE_MODEL_ID, version }
+ ).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
- 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};
- });
+ it('Delete Entitlement Pool', () => {
+ const entitlementPoolsList = buildListFromFactory(
+ EntitlementPoolStoreFactory,
+ 1
+ );
+ deepFreeze(entitlementPoolsList);
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps },
+ licenseModel: {
+ entitlementPool: {
+ entitlementPoolsList
+ }
+ }
+ });
+ deepFreeze(store.getState());
- return EntitlementPoolsActionHelper.fetchEntitlementPoolsList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID, version}).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
- it('Delete Entitlement Pool', () => {
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.entitlementPool.entitlementPoolsList',
+ []
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
- const entitlementPoolsList = buildListFromFactory(EntitlementPoolStoreFactory,1);
- deepFreeze(entitlementPoolsList);
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps},
- licenseModel: {
- entitlementPool: {
- entitlementPoolsList
- }
- }
- });
- deepFreeze(store.getState());
+ 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'
+ }
+ };
+ });
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
+ 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
+ }
+ };
+ });
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', []);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
+ 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
+ };
+ });
- 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);
- });
- });
+ return EntitlementPoolsActionHelper.deleteEntitlementPool(
+ store.dispatch,
+ {
+ licenseModelId: LICENSE_MODEL_ID,
+ version,
+ entitlementPoolId: entitlementPoolsList[0].id
+ }
+ ).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
- it('Add Entitlement Pool', () => {
+ it('Add Entitlement Pool', () => {
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps }
+ });
+ deepFreeze(store.getState());
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps}
- });
- deepFreeze(store.getState());
+ const EntitlementPoolPostRequest = EntitlementPoolPostFactory.build();
- const EntitlementPoolPostRequest = EntitlementPoolPostFactory.build();
+ deepFreeze(EntitlementPoolPostRequest);
- deepFreeze(EntitlementPoolPostRequest);
+ const entitlementPoolIdFromResponse = 'ADDED_ID';
+ const entitlementPoolAfterAdd = EntitlementPoolStoreFactory.build({
+ id: entitlementPoolIdFromResponse
+ });
+ deepFreeze(entitlementPoolAfterAdd);
- const entitlementPoolIdFromResponse = 'ADDED_ID';
- const entitlementPoolAfterAdd = EntitlementPoolStoreFactory.build({id: entitlementPoolIdFromResponse});
- deepFreeze(entitlementPoolAfterAdd);
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.entitlementPool.entitlementPoolsList',
+ [entitlementPoolAfterAdd]
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
- 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('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}/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);
+ });
+ });
- 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);
- it('Update Entitlement Pool', () => {
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps },
+ licenseModel: {
+ entitlementPool: {
+ entitlementPoolsList
+ }
+ }
+ });
- const entitlementPoolsList = buildListFromFactory(EntitlementPoolStoreFactory, 1);
- deepFreeze(entitlementPoolsList);
+ deepFreeze(store.getState());
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps},
- licenseModel: {
- entitlementPool: {
- entitlementPoolsList
- }
- }
- });
+ const toBeUpdatedEntitlementPoolId = entitlementPoolsList[0].id;
+ const previousEntitlementPoolData = entitlementPoolsList[0];
+ const entitlementPoolUpdateData = EntitlementPoolStoreFactory.build({
+ name: 'ep1_UPDATED',
+ description: 'string_UPDATED',
+ id: toBeUpdatedEntitlementPoolId
+ });
+ deepFreeze(entitlementPoolUpdateData);
- deepFreeze(store.getState());
+ const entitlementPoolPutRequest = EntitlementPoolPostFactory.build({
+ name: 'ep1_UPDATED',
+ description: 'string_UPDATED'
+ });
+ deepFreeze(entitlementPoolPutRequest);
- const toBeUpdatedEntitlementPoolId = entitlementPoolsList[0].id;
- const previousEntitlementPoolData = entitlementPoolsList[0];
- const entitlementPoolUpdateData = EntitlementPoolStoreFactory.build({name: 'ep1_UPDATED', description: 'string_UPDATED', id: toBeUpdatedEntitlementPoolId});
- deepFreeze(entitlementPoolUpdateData);
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
- const entitlementPoolPutRequest = EntitlementPoolPostFactory.build({name: 'ep1_UPDATED', description: 'string_UPDATED'});
- deepFreeze(entitlementPoolPutRequest);
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.entitlementPool.entitlementPoolsList',
+ [entitlementPoolUpdateData]
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
+ 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' };
+ });
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', [entitlementPoolUpdateData]);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
+ 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
+ };
+ });
- 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'};
- });
+ return EntitlementPoolsActionHelper.saveEntitlementPool(
+ store.dispatch,
+ {
+ licenseModelId: LICENSE_MODEL_ID,
+ version,
+ previousEntitlementPool: previousEntitlementPoolData,
+ entitlementPool: entitlementPoolUpdateData
+ }
+ ).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
- 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}};
- });
+ it('Load Limits List', () => {
+ const limitsList = LimitItemFactory.buildList(3);
+ deepFreeze(limitsList);
+ const store = storeCreator();
+ deepFreeze(store.getState());
- return EntitlementPoolsActionHelper.saveEntitlementPool(store.dispatch, {
- licenseModelId: LICENSE_MODEL_ID,
- version,
- previousEntitlementPool: previousEntitlementPoolData,
- entitlementPool: entitlementPoolUpdateData
- }).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
+ 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 };
+ });
- 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);
+ return EntitlementPoolsActionHelper.fetchLimits(store.dispatch, {
+ licenseModelId: LICENSE_MODEL_ID,
+ version,
+ entitlementPool
+ }).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
- const LimitIdFromResponse = 'ADDED_ID';
- const limitAddedItem = {...limitToAdd, id: LimitIdFromResponse};
- deepFreeze(limitAddedItem);
- const entitlementPool = EntitlementPoolStoreFactory.build();
+ it('Add Limit', () => {
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps }
+ });
+ deepFreeze(store.getState());
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
+ const limitToAdd = LimitPostFactory.build();
+ let limitFromBE = { ...limitToAdd };
+ limitFromBE.metric = getStrValue(limitFromBE.metric);
+ limitFromBE.unit = getStrValue(limitFromBE.unit);
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolEditor.limitsList', [limitAddedItem]);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
+ deepFreeze(limitToAdd);
+ deepFreeze(limitFromBE);
- 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
- };
- });
+ const LimitIdFromResponse = 'ADDED_ID';
+ const limitAddedItem = { ...limitToAdd, id: LimitIdFromResponse };
+ deepFreeze(limitAddedItem);
+ 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: [limitAddedItem]};
- });
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
- 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}};
- });
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.entitlementPool.entitlementPoolEditor.limitsList',
+ [limitAddedItem]
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
- return EntitlementPoolsActionHelper.submitLimit(store.dispatch,
- {
- licenseModelId: LICENSE_MODEL_ID,
- version,
- entitlementPool,
- limit: limitToAdd
- }
- ).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
+ 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] };
+ });
- it('Delete Limit', () => {
+ 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
+ }
+ };
+ });
- const limitsList = LimitItemFactory.buildList(1);
- deepFreeze(limitsList);
+ 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
+ };
+ });
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps},
- licenseModel: {
- entitlementPool: {
- entitlementPoolEditor: {
- limitsList
- }
- }
- }
- });
- deepFreeze(store.getState());
+ return EntitlementPoolsActionHelper.submitLimit(store.dispatch, {
+ licenseModelId: LICENSE_MODEL_ID,
+ version,
+ entitlementPool,
+ limit: limitToAdd
+ }).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
- const entitlementPool = EntitlementPoolStoreFactory.build();
+ it('Delete Limit', () => {
+ const limitsList = LimitItemFactory.buildList(1);
+ deepFreeze(limitsList);
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps },
+ licenseModel: {
+ entitlementPool: {
+ entitlementPoolEditor: {
+ limitsList
+ }
+ }
+ }
+ });
+ deepFreeze(store.getState());
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolEditor.limitsList', []);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
+ const entitlementPool = EntitlementPoolStoreFactory.build();
- 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'
- }
- };
- });
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
- 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: []};
- });
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.entitlementPool.entitlementPoolEditor.limitsList',
+ []
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
- 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('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'
+ }
+ };
+ });
- return EntitlementPoolsActionHelper.deleteLimit(store.dispatch, {
- licenseModelId: LICENSE_MODEL_ID,
- version,
- entitlementPool,
- limit: limitsList[0]
- }).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
+ 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: [] };
+ });
- it('Update Limit', () => {
+ 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
+ }
+ };
+ });
- const limitsList = LimitItemFactory.buildList(1);
- deepFreeze(limitsList);
- const entitlementPool = EntitlementPoolStoreFactory.build();
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps},
- licenseModel: {
- entitlementPool: {
- entitlementPoolEditor: {
- limitsList
- }
- }
- }
- });
+ 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
+ };
+ });
- deepFreeze(store.getState());
+ 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
+ }
+ }
+ }
+ });
- const previousData = limitsList[0];
+ deepFreeze(store.getState());
- deepFreeze(previousData);
- const limitId = limitsList[0].id;
+ const previousData = limitsList[0];
- let updatedLimit = {...previousData, name: 'updatedLimit'};
+ deepFreeze(previousData);
+ const limitId = limitsList[0].id;
- const updatedLimitForPut = {...updatedLimit, id: undefined};
- updatedLimit.metric = {choice: updatedLimit.metric, other: ''};
- updatedLimit.unit = {choice: updatedLimit.unit, other: ''};
- deepFreeze(updatedLimit);
+ let updatedLimit = { ...previousData, name: 'updatedLimit' };
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
+ const updatedLimitForPut = { ...updatedLimit, id: undefined };
+ updatedLimit.metric = { choice: updatedLimit.metric, other: '' };
+ updatedLimit.unit = { choice: updatedLimit.unit, other: '' };
+ deepFreeze(updatedLimit);
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolEditor.limitsList', [updatedLimitForPut]);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
+ 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('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/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}/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);
- });
- });
+ 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 eb947b8..63c876c 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';
+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
+ };
-describe('Feature Groups Module Tests', function () {
+ it('Load Feature Groups List', () => {
+ const featureGroupsList = buildListFromFactory(
+ FeatureGroupStoreFactory
+ );
+ deepFreeze(featureGroupsList);
- 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};
+ const store = storeCreator();
+ deepFreeze(store.getState());
- it('Load Feature Groups List', () => {
+ const expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.featureGroup.featureGroupsList',
+ featureGroupsList
+ );
- const featureGroupsList = buildListFromFactory(FeatureGroupStoreFactory);
- deepFreeze(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 };
+ });
- const store = storeCreator();
- deepFreeze(store.getState());
+ return FeatureGroupsActionHelper.fetchFeatureGroupsList(
+ store.dispatch,
+ { licenseModelId: LICENSE_MODEL_ID, version }
+ ).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
- const expectedStore = cloneAndSet(store.getState(), 'licenseModel.featureGroup.featureGroupsList', featureGroupsList);
+ it('Delete Feature Group', () => {
+ const featureGroupsList = buildListFromFactory(
+ FeatureGroupStoreFactory,
+ 1
+ );
+ deepFreeze(featureGroupsList);
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps },
+ licenseModel: {
+ featureGroup: {
+ featureGroupsList
+ }
+ }
+ });
+ deepFreeze(store.getState());
- 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};
- });
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
- return FeatureGroupsActionHelper.fetchFeatureGroupsList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID, version}).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.featureGroup.featureGroupsList',
+ []
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
- it('Delete Feature Group', () => {
- const featureGroupsList = buildListFromFactory(FeatureGroupStoreFactory, 1);
- deepFreeze(featureGroupsList);
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps},
- licenseModel: {
- featureGroup: {
- featureGroupsList
- }
- }
- });
- deepFreeze(store.getState());
+ const idToDelete = featureGroupsList[0].id;
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
+ 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'
+ }
+ };
+ });
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.featureGroup.featureGroupsList', []);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
+ 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
+ }
+ };
+ });
- const idToDelete = featureGroupsList[0].id;
+ 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
+ };
+ });
- 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'
- }
- };
- });
+ return FeatureGroupsActionHelper.deleteFeatureGroup(store.dispatch, {
+ licenseModelId: LICENSE_MODEL_ID,
+ version,
+ featureGroupId: idToDelete
+ }).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
- 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}};
- });
+ it('Add Feature Group', () => {
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps },
+ licenseModel: {
+ featureGroup: {
+ featureGroupsList: []
+ }
+ }
+ });
+ deepFreeze(store.getState());
- return FeatureGroupsActionHelper.deleteFeatureGroup(store.dispatch, {
- licenseModelId: LICENSE_MODEL_ID,
- version,
- featureGroupId: idToDelete
- }).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
+ const FeatureGroupPostRequest = FeatureGroupPostFactory.build({
+ addedLicenseKeyGroupsIds: [1],
+ addedEntitlementPoolsIds: [1]
+ });
+ const featureGroupToAdd = FeatureGroupDispatchFactory.build({
+ licenseKeyGroupsIds: [1],
+ entitlementPoolsIds: [1]
+ });
- it('Add Feature Group', () => {
+ const featureGroupIdFromResponse = 'ADDED_ID';
+ const featureGroupAfterAdd = FeatureGroupStoreFactory.build({
+ ...featureGroupToAdd,
+ id: featureGroupIdFromResponse
+ });
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps},
- licenseModel: {
- featureGroup: {
- featureGroupsList: []
- }
- }
- });
- deepFreeze(store.getState());
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
- const FeatureGroupPostRequest = FeatureGroupPostFactory.build({
- addedLicenseKeyGroupsIds: [1],
- addedEntitlementPoolsIds: [1]
- });
- const featureGroupToAdd = FeatureGroupDispatchFactory.build({
- licenseKeyGroupsIds: [1],
- entitlementPoolsIds: [1]
- });
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.featureGroup.featureGroupsList',
+ [featureGroupAfterAdd]
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
- const featureGroupIdFromResponse = 'ADDED_ID';
- const featureGroupAfterAdd = FeatureGroupStoreFactory.build({
- ...featureGroupToAdd,
- id: featureGroupIdFromResponse
- });
+ 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
+ };
+ });
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
+ 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: [] };
+ });
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.featureGroup.featureGroupsList', [featureGroupAfterAdd]);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
+ 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('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/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/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/items/${LICENSE_MODEL_ID}`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields
+ };
+ });
- 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.saveFeatureGroup(store.dispatch, {
+ licenseModelId: LICENSE_MODEL_ID,
+ version,
+ featureGroup: featureGroupToAdd
+ }).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
- 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}};
- });
+ 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());
- return FeatureGroupsActionHelper.saveFeatureGroup(store.dispatch, {
- licenseModelId: LICENSE_MODEL_ID,
- version,
- featureGroup: featureGroupToAdd
- }).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
+ const toBeUpdatedFeatureGroupId = featureGroupsList[0].id;
+ const previousFeatureGroupData = featureGroupsList[0];
- it('Update Feature Group', () => {
- const featureGroupsList = buildListFromFactory(FeatureGroupStoreFactory, 1, {
- licenseKeyGroupsIds: [1],
- entitlementPoolsIds: [1]
- });
- deepFreeze(featureGroupsList);
+ const featureGroupUpdateData = FeatureGroupStoreFactory.build({
+ ...previousFeatureGroupData,
+ licenseKeyGroupsIds: [7],
+ entitlementPoolsIds: [7]
+ });
+ deepFreeze(featureGroupUpdateData);
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps},
- licenseModel: {
- featureGroup: {
- featureGroupsList
- }
- }
- });
- deepFreeze(store.getState());
+ const FeatureGroupPutFactoryRequest = FeatureGroupPutFactory.build({
+ name: featureGroupUpdateData.name,
+ description: featureGroupUpdateData.description,
+ partNumber: featureGroupUpdateData.partNumber,
+ addedLicenseKeyGroupsIds: [7],
+ addedEntitlementPoolsIds: [7],
+ removedLicenseKeyGroupsIds: [1],
+ removedEntitlementPoolsIds: [1]
+ });
+ deepFreeze(FeatureGroupPutFactoryRequest);
- const toBeUpdatedFeatureGroupId = featureGroupsList[0].id;
- const previousFeatureGroupData = featureGroupsList[0];
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
- const featureGroupUpdateData = FeatureGroupStoreFactory.build({
- ...previousFeatureGroupData,
- licenseKeyGroupsIds: [7],
- entitlementPoolsIds: [7]
- });
- deepFreeze(featureGroupUpdateData);
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.featureGroup.featureGroupsList',
+ [featureGroupUpdateData]
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
- const FeatureGroupPutFactoryRequest = FeatureGroupPutFactory.build({
- name: featureGroupUpdateData.name,
- description: featureGroupUpdateData.description,
- partNumber: featureGroupUpdateData.partNumber,
- addedLicenseKeyGroupsIds: [7],
- addedEntitlementPoolsIds: [7],
- removedLicenseKeyGroupsIds: [1],
- removedEntitlementPoolsIds: [1]
- });
- deepFreeze(FeatureGroupPutFactoryRequest);
+ 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' };
+ });
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
+ 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: [] };
+ });
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.featureGroup.featureGroupsList', [featureGroupUpdateData]);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
+ 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('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/items/${LICENSE_MODEL_ID}`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields
+ };
+ });
- 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: []};
- });
+ return FeatureGroupsActionHelper.saveFeatureGroup(store.dispatch, {
+ licenseModelId: LICENSE_MODEL_ID,
+ version,
+ previousFeatureGroup: previousFeatureGroupData,
+ featureGroup: featureGroupUpdateData
+ }).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
- 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: []};
- });
+ it('Open Editor', () => {
+ const store = storeCreator();
+ deepFreeze(store.getState());
- 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}};
- });
+ const editorData = FeatureGroupStoreFactory.build();
+ deepFreeze(editorData);
+ const LICENSE_MODEL_ID = '123';
- return FeatureGroupsActionHelper.saveFeatureGroup(store.dispatch, {
- licenseModelId: LICENSE_MODEL_ID,
- version,
- previousFeatureGroup: previousFeatureGroupData,
- featureGroup: featureGroupUpdateData
- }).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
+ 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: [] };
+ });
- 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);
- });
- });
-
+ 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 5a3dd17..17cad4f 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
+ );
- it('Load License Agreement List', () => {
- const licenseAgreementList = buildListFromFactory(LicenseAgreementStoreFactory);
+ const store = storeCreator();
+ deepFreeze(store.getState());
- const store = storeCreator();
- deepFreeze(store.getState());
+ const expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.licenseAgreement.licenseAgreementList',
+ licenseAgreementList
+ );
- 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);
+ });
+ });
- 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
+ );
- 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('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);
- });
- });
+ 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());
+ it('Add License Agreement', () => {
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps }
+ });
+ deepFreeze(store.getState());
- const licenseAgreementToAdd = LicenseAgreementDispatchFactory.build();
+ const licenseAgreementToAdd = LicenseAgreementDispatchFactory.build();
- const LicenseAgreementPostRequest = LicenseAgreementPostFactory.build(
- pickBy(licenseAgreementToAdd, (val, key) => key !== 'featureGroupsIds')
- );
+ const LicenseAgreementPostRequest = LicenseAgreementPostFactory.build(
+ pickBy(
+ licenseAgreementToAdd,
+ (val, key) => key !== 'featureGroupsIds'
+ )
+ );
- deepFreeze(LicenseAgreementPostRequest);
+ 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);
+ 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('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);
- });
- });
+ 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
+ };
+ });
- it('Update License Agreement', () => {
- const licenseAgreementList = buildListFromFactory(LicenseAgreementStoreFactory, 1, {featureGroupsIds: ['77']});
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps},
- licenseModel: {
- licenseAgreement: {
- licenseAgreementList
- }
- }
- });
- deepFreeze(store.getState());
+ return LicenseAgreementActionHelper.saveLicenseAgreement(
+ store.dispatch,
+ {
+ licenseAgreement: licenseAgreementToAdd,
+ licenseModelId: LICENSE_MODEL_ID,
+ version
+ }
+ ).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
- const previousLicenseAgreementData = licenseAgreementList[0];
- const toBeUpdatedLicenseAgreementId = previousLicenseAgreementData.id;
- const oldFeatureGroupIds = previousLicenseAgreementData.featureGroupsIds;
+ it('Update License Agreement', () => {
+ const licenseAgreementList = buildListFromFactory(
+ LicenseAgreementStoreFactory,
+ 1,
+ { featureGroupsIds: ['77'] }
+ );
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps },
+ licenseModel: {
+ licenseAgreement: {
+ licenseAgreementList
+ }
+ }
+ });
+ deepFreeze(store.getState());
- const newFeatureGroupsIds = ['update_id_1', 'update_id_2'];
+ const previousLicenseAgreementData = licenseAgreementList[0];
+ const toBeUpdatedLicenseAgreementId = previousLicenseAgreementData.id;
+ const oldFeatureGroupIds =
+ previousLicenseAgreementData.featureGroupsIds;
- const licenseAgreementUpdateData = LicenseAgreementStoreFactory.build({
- id: toBeUpdatedLicenseAgreementId,
- featureGroupsIds: newFeatureGroupsIds
- });
- deepFreeze(licenseAgreementUpdateData);
+ const newFeatureGroupsIds = ['update_id_1', 'update_id_2'];
- const LicenseAgreementPutFactoryRequest = LicenseAgreementPutFactory.build({
- addedFeatureGroupsIds: newFeatureGroupsIds,
- removedFeatureGroupsIds: oldFeatureGroupIds
- });
+ const licenseAgreementUpdateData = LicenseAgreementStoreFactory.build({
+ id: toBeUpdatedLicenseAgreementId,
+ featureGroupsIds: newFeatureGroupsIds
+ });
+ deepFreeze(licenseAgreementUpdateData);
- deepFreeze(LicenseAgreementPutFactoryRequest);
+ const LicenseAgreementPutFactoryRequest = LicenseAgreementPutFactory.build(
+ {
+ addedFeatureGroupsIds: newFeatureGroupsIds,
+ removedFeatureGroupsIds: oldFeatureGroupIds
+ }
+ );
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseAgreement.licenseAgreementList', [licenseAgreementUpdateData]);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
+ deepFreeze(LicenseAgreementPutFactoryRequest);
- 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};
- });
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.licenseAgreement.licenseAgreementList',
+ [licenseAgreementUpdateData]
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
- return LicenseAgreementActionHelper.saveLicenseAgreement(store.dispatch, {
- licenseModelId: LICENSE_MODEL_ID,
- version,
- previousLicenseAgreement: previousLicenseAgreementData,
- licenseAgreement: licenseAgreementUpdateData
- }).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
+ 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 09a2c6f..1326025 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';
+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 () {
+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
+ };
- 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
+ );
- it('Load License Key Group', () => {
+ deepFreeze(licenseKeyGroupsList);
+ const store = storeCreator();
+ deepFreeze(store.getState());
- const licenseKeyGroupsList = buildListFromFactory(LicenseKeyGroupStoreFactory);
+ const expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.licenseKeyGroup.licenseKeyGroupsList',
+ licenseKeyGroupsList
+ );
- deepFreeze(licenseKeyGroupsList);
- const store = storeCreator();
- deepFreeze(store.getState());
+ 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 };
+ });
- const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', licenseKeyGroupsList);
+ return LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(
+ store.dispatch,
+ { licenseModelId: LICENSE_MODEL_ID, version }
+ ).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
- 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};
- });
+ it('Delete License Key Group', () => {
+ const licenseKeyGroupsList = buildListFromFactory(
+ LicenseKeyGroupStoreFactory,
+ 1
+ );
- return LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID, version}).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
+ deepFreeze(licenseKeyGroupsList);
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps },
+ licenseModel: {
+ licenseKeyGroup: {
+ licenseKeyGroupsList
+ }
+ }
+ });
+ deepFreeze(store.getState());
+ const toBeDeletedLicenseKeyGroupId = licenseKeyGroupsList[0].id;
- it('Delete License Key Group', () => {
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
- const licenseKeyGroupsList = buildListFromFactory(LicenseKeyGroupStoreFactory, 1);
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.licenseKeyGroup.licenseKeyGroupsList',
+ []
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
- deepFreeze(licenseKeyGroupsList);
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps},
- licenseModel: {
- licenseKeyGroup: {
- licenseKeyGroupsList
- }
- }
- });
- deepFreeze(store.getState());
- const toBeDeletedLicenseKeyGroupId = licenseKeyGroupsList[0].id;
+ 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);
+ });
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
+ 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
+ }
+ };
+ });
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', []);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
+ 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
+ };
+ });
- 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);
- });
+ return LicenseKeyGroupsActionHelper.deleteLicenseKeyGroup(
+ store.dispatch,
+ {
+ licenseKeyGroupId: toBeDeletedLicenseKeyGroupId,
+ licenseModelId: LICENSE_MODEL_ID,
+ version
+ }
+ ).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
- 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}};
- });
+ it('Add License Key Group', () => {
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps }
+ });
+ deepFreeze(store.getState());
- return LicenseKeyGroupsActionHelper.deleteLicenseKeyGroup(store.dispatch, {
- licenseKeyGroupId: toBeDeletedLicenseKeyGroupId,
- licenseModelId: LICENSE_MODEL_ID,
- version
- }).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
+ const LicenseKeyGroupPost = LicenseKeyGroupPostFactory.build();
+ deepFreeze(LicenseKeyGroupPost);
- it('Add License Key Group', () => {
+ const LicenseKeyGroupStore = LicenseKeyGroupStoreFactory.build();
+ deepFreeze(LicenseKeyGroupStore);
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps}
- });
- deepFreeze(store.getState());
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
- const LicenseKeyGroupPost = LicenseKeyGroupPostFactory.build();
- deepFreeze(LicenseKeyGroupPost);
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.licenseKeyGroup.licenseKeyGroupsList',
+ [LicenseKeyGroupStore]
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
- const LicenseKeyGroupStore = LicenseKeyGroupStoreFactory.build();
- deepFreeze(LicenseKeyGroupStore);
+ 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
+ };
+ });
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
+ 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
+ }
+ };
+ });
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', [LicenseKeyGroupStore]);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
+ 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
+ };
+ });
- 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
- };
- });
+ return LicenseKeyGroupsActionHelper.saveLicenseKeyGroup(
+ store.dispatch,
+ {
+ licenseKeyGroup: LicenseKeyGroupPost,
+ licenseModelId: LICENSE_MODEL_ID,
+ version
+ }
+ ).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
- 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}};
- });
+ it('Update License Key Group', () => {
+ const licenseKeyGroupsList = buildListFromFactory(
+ LicenseKeyGroupStoreFactory,
+ 1
+ );
+ deepFreeze(licenseKeyGroupsList);
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps },
+ licenseModel: {
+ licenseKeyGroup: {
+ licenseKeyGroupsList
+ }
+ }
+ });
- return LicenseKeyGroupsActionHelper.saveLicenseKeyGroup(store.dispatch, {
- licenseKeyGroup: LicenseKeyGroupPost,
- licenseModelId: LICENSE_MODEL_ID,
- version
- }).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
+ const toBeUpdatedLicenseKeyGroupId = licenseKeyGroupsList[0].id;
+ const previousLicenseKeyGroupData = licenseKeyGroupsList[0];
- it('Update License Key Group', () => {
- const licenseKeyGroupsList = buildListFromFactory(LicenseKeyGroupStoreFactory, 1);
- deepFreeze(licenseKeyGroupsList);
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps},
- licenseModel: {
- licenseKeyGroup: {
- licenseKeyGroupsList
- }
- }
- });
+ const licenseKeyGroupUpdatedData = LicenseKeyGroupPostFactory.build({
+ name: 'lsk1_UPDATE',
+ description: 'string_UPDATE',
+ id: toBeUpdatedLicenseKeyGroupId
+ });
+ deepFreeze(licenseKeyGroupUpdatedData);
- const toBeUpdatedLicenseKeyGroupId = licenseKeyGroupsList[0].id;
- const previousLicenseKeyGroupData = licenseKeyGroupsList[0];
+ const licenseKeyGroupPutRequest = LicenseKeyGroupPostFactory.build({
+ name: 'lsk1_UPDATE',
+ description: 'string_UPDATE'
+ });
- const licenseKeyGroupUpdatedData = LicenseKeyGroupPostFactory.build({
- name: 'lsk1_UPDATE',
- description: 'string_UPDATE',
- id: toBeUpdatedLicenseKeyGroupId
- });
- deepFreeze(licenseKeyGroupUpdatedData);
+ deepFreeze(licenseKeyGroupPutRequest);
- const licenseKeyGroupPutRequest = LicenseKeyGroupPostFactory.build({
- name: 'lsk1_UPDATE',
- description: 'string_UPDATE'
- });
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
- deepFreeze(licenseKeyGroupPutRequest);
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.licenseKeyGroup.licenseKeyGroupsList',
+ [licenseKeyGroupUpdatedData]
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
+ 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);
+ });
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', [licenseKeyGroupUpdatedData]);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
+ 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('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}`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...returnedVersionFields
+ };
+ });
- 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);
+ });
+ });
- 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());
- it('Load Limits List', () => {
+ 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 };
+ });
- 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);
+ return LicenseKeyGroupsActionHelper.fetchLimits(store.dispatch, {
+ licenseModelId: LICENSE_MODEL_ID,
+ version,
+ licenseKeyGroup
+ }).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
- deepFreeze(limitToAdd);
- deepFreeze(limitFromBE);
+ it('Add Limit', () => {
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps }
+ });
+ deepFreeze(store.getState());
- const LimitIdFromResponse = 'ADDED_ID';
- const limitAddedItem = {...limitToAdd, id: LimitIdFromResponse};
- deepFreeze(limitAddedItem);
- const licenseKeyGroup = LicenseKeyGroupStoreFactory.build();
+ const limitToAdd = LimitPostFactory.build();
+ let limitFromBE = { ...limitToAdd };
+ limitFromBE.metric = getStrValue(limitFromBE.metric);
+ limitFromBE.unit = getStrValue(limitFromBE.unit);
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
+ deepFreeze(limitToAdd);
+ deepFreeze(limitFromBE);
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsEditor.limitsList', [limitAddedItem]);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
+ const LimitIdFromResponse = 'ADDED_ID';
+ const limitAddedItem = { ...limitToAdd, id: LimitIdFromResponse };
+ deepFreeze(limitAddedItem);
+ const licenseKeyGroup = LicenseKeyGroupStoreFactory.build();
- 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
- };
- });
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
- 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]};
- });
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.licenseKeyGroup.licenseKeyGroupsEditor.limitsList',
+ [limitAddedItem]
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
- 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('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
+ };
+ });
- return LicenseKeyGroupsActionHelper.submitLimit(store.dispatch,
- {
- licenseModelId: LICENSE_MODEL_ID,
- version,
- licenseKeyGroup,
- limit: limitToAdd
- }
- ).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
+ 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] };
+ });
- it('Delete Limit', () => {
+ 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
+ }
+ };
+ });
- const limitsList = LimitItemFactory.buildList(1);
- deepFreeze(limitsList);
+ 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
+ };
+ });
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps},
- licenseModel: {
- entitlementPool: {
- entitlementPoolEditor: {
- limitsList
- }
- }
- }
- });
- deepFreeze(store.getState());
+ return LicenseKeyGroupsActionHelper.submitLimit(store.dispatch, {
+ licenseModelId: LICENSE_MODEL_ID,
+ version,
+ licenseKeyGroup,
+ limit: limitToAdd
+ }).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
- const licenseKeyGroup = LicenseKeyGroupStoreFactory.build();
+ it('Delete Limit', () => {
+ const limitsList = LimitItemFactory.buildList(1);
+ deepFreeze(limitsList);
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps },
+ licenseModel: {
+ entitlementPool: {
+ entitlementPoolEditor: {
+ limitsList
+ }
+ }
+ }
+ });
+ deepFreeze(store.getState());
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsEditor.limitsList', []);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
+ const licenseKeyGroup = LicenseKeyGroupStoreFactory.build();
- 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'
- }
- };
- });
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
- 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: []};
- });
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'licenseModel.licenseKeyGroup.licenseKeyGroupsEditor.limitsList',
+ []
+ );
+ expectedStore = cloneAndSet(
+ expectedStore,
+ 'currentScreen.itemPermission',
+ expectedCurrentScreenProps.itemPermission
+ );
- 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('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'
+ }
+ };
+ });
- return LicenseKeyGroupsActionHelper.deleteLimit(store.dispatch, {
- licenseModelId: LICENSE_MODEL_ID,
- version,
- licenseKeyGroup,
- limit: limitsList[0]
- }).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
+ 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: [] };
+ });
- it('Update Limit', () => {
+ 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
+ }
+ };
+ });
- const limitsList = LimitItemFactory.buildList(1);
- deepFreeze(limitsList);
- const licenseKeyGroup = LicenseKeyGroupStoreFactory.build();
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps},
- licenseModel: {
- licenseKeyGroup: {
- licenseKeyGroupsEditor: {
- limitsList
- }
- }
- }
- });
+ 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
+ };
+ });
- deepFreeze(store.getState());
+ 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
+ }
+ }
+ }
+ });
- const previousData = limitsList[0];
- deepFreeze(previousData);
- const limitId = limitsList[0].id;
+ deepFreeze(store.getState());
- 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 previousData = limitsList[0];
+ deepFreeze(previousData);
+ const limitId = limitsList[0].id;
- const expectedCurrentScreenProps = {
- ...itemPermissionAndProps,
- itemPermission: {
- ...itemPermissionAndProps.itemPermission,
- isDirty: true
- }
- };
+ let updatedLimit = { ...previousData, name: 'updatedLimit' };
+ const updatedLimitForPut = { ...updatedLimit, id: undefined };
+ updatedLimit.metric = { choice: updatedLimit.metric, other: '' };
+ updatedLimit.unit = { choice: updatedLimit.unit, other: '' };
+ deepFreeze(updatedLimit);
- let expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsEditor.limitsList', [updatedLimitForPut]);
- expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
+ 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('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/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}/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);
- });
- });
+ 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 6cb2168..bbebcaf 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';
+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());
+describe('License Model Module Tests', function() {
+ it('Add License Model', () => {
+ const store = storeCreator();
+ deepFreeze(store.getState());
- const licenseModelPostRequest = LicenseModelPostFactory.build();
+ const licenseModelPostRequest = LicenseModelPostFactory.build();
- const licenseModelToAdd = LicenseModelDispatchFactory.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
- };
- });
+ const licenseModelIdFromResponse = 'ADDED_ID';
- return LicenseModelCreationActionHelper.createLicenseModel(store.dispatch, {
- licenseModel: licenseModelToAdd
- }).then((response) => {
- expect(response.value).toEqual(licenseModelIdFromResponse);
- });
- });
+ 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
+ };
+ });
- it('Validating readonly screen after submit', () => {
- const version = VersionFactory.build({}, {isCertified: false});
- const itemPermissionAndProps = CurrentScreenFactory.build({}, {version});
- const licenseModel = LicenseModelStoreFactory.build();
- deepFreeze(licenseModel);
+ return LicenseModelCreationActionHelper.createLicenseModel(
+ store.dispatch,
+ {
+ licenseModel: licenseModelToAdd
+ }
+ ).then(response => {
+ expect(response.value).toEqual(licenseModelIdFromResponse);
+ });
+ });
- const store = storeCreator({
- currentScreen: {...itemPermissionAndProps},
- licenseModel: {
- licenseModelEditor: {data: licenseModel},
- }
- });
- deepFreeze(store.getState());
+ it('Validating readonly screen after submit', () => {
+ const version = VersionFactory.build({}, { isCertified: false });
+ const itemPermissionAndProps = CurrentScreenFactory.build(
+ {},
+ { version }
+ );
+ const licenseModel = LicenseModelStoreFactory.build();
+ deepFreeze(licenseModel);
- const certifiedVersion = {
- ...itemPermissionAndProps.props.version,
- status: 'Certified'
- };
+ const store = storeCreator({
+ currentScreen: { ...itemPermissionAndProps },
+ licenseModel: {
+ licenseModelEditor: { data: licenseModel }
+ }
+ });
+ deepFreeze(store.getState());
- 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 certifiedVersion = {
+ ...itemPermissionAndProps.props.version,
+ status: 'Certified'
+ };
- const versionsList = {
- itemType: itemTypes.LICENSE_MODEL,
- itemId: licenseModel.id,
- versions: [{...certifiedVersion}]
- };
+ 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'
+ };
- 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 );
+ const versionsList = {
+ itemType: itemTypes.LICENSE_MODEL,
+ itemId: licenseModel.id,
+ versions: [{ ...certifiedVersion }]
+ };
- 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'};
- });
+ 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.CREATE_PACKAGE});
- 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.SUBMIT
+ });
+ 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('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`);
- 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/${licenseModel.id}/versions/${
+ version.id
+ }`
+ );
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ ...certifiedVersion,
+ state: {
+ synchronizationState: SyncStates.UP_TO_DATE,
+ dirty: false
+ }
+ };
+ });
- return LicenseModelActionHelper.performSubmitAction(store.dispatch, {
- licenseModelId: licenseModel.id,
- version
- }).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- });
- });
+ 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 1b89a30..bf9ce63 100644
--- a/openecomp-ui/test/onboard/filter/filter.test.js
+++ b/openecomp-ui/test/onboard/filter/filter.test.js
@@ -24,7 +24,8 @@
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 @@
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 @@
done();
});
});
- /**
- * TODO Turn ON when FILTER TOGGLE Will BE REMOVED
- */
- /*
+
it('load certifed data', done => {
const store = storeCreator();
@@ -112,7 +112,7 @@
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 a75070b..b2131ce 100644
--- a/openecomp-ui/test/onboard/test.js
+++ b/openecomp-ui/test/onboard/test.js
@@ -20,6 +20,11 @@
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 @@
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 @@
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 @@
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 15f7a21..91b4e7d 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);
+ });
+ });
+});