summaryrefslogtreecommitdiffstats
path: root/openecomp-ui/test/licenseModel/entitlementPools/test.js
diff options
context:
space:
mode:
authortalig <talig@amdocs.com>2017-12-20 14:30:43 +0200
committerVitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com>2017-12-21 11:12:33 +0000
commit8e9c0653dd6c6862123c9609ae34e1206d86456e (patch)
tree5eeef00ec0677133baa439ca8d7ffd7aca4804b6 /openecomp-ui/test/licenseModel/entitlementPools/test.js
parent785ebcc95de3e064e843bec04ba7a209d854fc7c (diff)
Add collaboration feature
Issue-ID: SDC-767 Change-Id: I14fb4c1f54086ed03a56a7ff7fab9ecd40381795 Signed-off-by: talig <talig@amdocs.com>
Diffstat (limited to 'openecomp-ui/test/licenseModel/entitlementPools/test.js')
-rw-r--r--openecomp-ui/test/licenseModel/entitlementPools/test.js129
1 files changed, 119 insertions, 10 deletions
diff --git a/openecomp-ui/test/licenseModel/entitlementPools/test.js b/openecomp-ui/test/licenseModel/entitlementPools/test.js
index f5415239ad..173384dc02 100644
--- a/openecomp-ui/test/licenseModel/entitlementPools/test.js
+++ b/openecomp-ui/test/licenseModel/entitlementPools/test.js
@@ -19,14 +19,18 @@ 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 VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.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 CurrentScreenFactory from 'test-utils/factories/common/CurrentScreenFactory.js';
describe('Entitlement Pools Module Tests', function () {
const LICENSE_MODEL_ID = '555';
- const version = VersionControllerUtilsFactory.build().version;
+ 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', () => {
@@ -54,6 +58,7 @@ describe('Entitlement Pools Module Tests', function () {
const entitlementPoolsList = buildListFromFactory(EntitlementPoolStoreFactory,1);
deepFreeze(entitlementPoolsList);
const store = storeCreator({
+ currentScreen: {...itemPermissionAndProps},
licenseModel: {
entitlementPool: {
entitlementPoolsList
@@ -62,7 +67,16 @@ describe('Entitlement Pools Module Tests', function () {
});
deepFreeze(store.getState());
- const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', []);
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
+
+ let expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', []);
+ expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
mockRest.addHandler('destroy', ({data, options, baseUrl}) => {
expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools/${entitlementPoolsList[0].id}`);
@@ -75,6 +89,13 @@ describe('Entitlement Pools Module Tests', function () {
};
});
+ 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,
@@ -86,7 +107,9 @@ describe('Entitlement Pools Module Tests', function () {
it('Add Entitlement Pool', () => {
- const store = storeCreator();
+ const store = storeCreator({
+ currentScreen: {...itemPermissionAndProps}
+ });
deepFreeze(store.getState());
const EntitlementPoolPostRequest = EntitlementPoolPostFactory.build();
@@ -97,7 +120,16 @@ describe('Entitlement Pools Module Tests', function () {
const entitlementPoolAfterAdd = EntitlementPoolStoreFactory.build({id: entitlementPoolIdFromResponse});
deepFreeze(entitlementPoolAfterAdd);
- const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', [entitlementPoolAfterAdd]);
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
+
+ let expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', [entitlementPoolAfterAdd]);
+ expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
mockRest.addHandler('post', ({data, options, baseUrl}) => {
expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools`);
@@ -109,6 +141,13 @@ describe('Entitlement Pools Module Tests', function () {
};
});
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${version.id}`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {...returnedVersionFields, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: true}};
+ });
+
return EntitlementPoolsActionHelper.saveEntitlementPool(store.dispatch,
{
licenseModelId: LICENSE_MODEL_ID,
@@ -127,6 +166,7 @@ describe('Entitlement Pools Module Tests', function () {
deepFreeze(entitlementPoolsList);
const store = storeCreator({
+ currentScreen: {...itemPermissionAndProps},
licenseModel: {
entitlementPool: {
entitlementPoolsList
@@ -144,7 +184,16 @@ describe('Entitlement Pools Module Tests', function () {
const entitlementPoolPutRequest = EntitlementPoolPostFactory.build({name: 'ep1_UPDATED', description: 'string_UPDATED'});
deepFreeze(entitlementPoolPutRequest);
- const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', [entitlementPoolUpdateData]);
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
+
+ let expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', [entitlementPoolUpdateData]);
+ expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
mockRest.addHandler('put', ({data, options, baseUrl}) => {
@@ -154,6 +203,13 @@ describe('Entitlement Pools Module Tests', function () {
return {returnCode: 'OK'};
});
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${version.id}`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {...returnedVersionFields, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: true}};
+ });
+
return EntitlementPoolsActionHelper.saveEntitlementPool(store.dispatch, {
licenseModelId: LICENSE_MODEL_ID,
version,
@@ -187,7 +243,9 @@ describe('Entitlement Pools Module Tests', function () {
it('Add Limit', () => {
- const store = storeCreator();
+ const store = storeCreator({
+ currentScreen: {...itemPermissionAndProps}
+ });
deepFreeze(store.getState());
const limitToAdd = LimitPostFactory.build();
@@ -203,7 +261,16 @@ describe('Entitlement Pools Module Tests', function () {
deepFreeze(limitAddedItem);
const entitlementPool = EntitlementPoolStoreFactory.build();
- const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolEditor.limitsList', [limitAddedItem]);
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
+
+ let expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolEditor.limitsList', [limitAddedItem]);
+ expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
mockRest.addHandler('post', ({data, options, baseUrl}) => {
expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools/${entitlementPool.id}/limits`);
@@ -222,6 +289,13 @@ describe('Entitlement Pools Module Tests', function () {
return {results: [limitAddedItem]};
});
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${version.id}`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {...returnedVersionFields, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: true}};
+ });
+
return EntitlementPoolsActionHelper.submitLimit(store.dispatch,
{
licenseModelId: LICENSE_MODEL_ID,
@@ -241,6 +315,7 @@ describe('Entitlement Pools Module Tests', function () {
deepFreeze(limitsList);
const store = storeCreator({
+ currentScreen: {...itemPermissionAndProps},
licenseModel: {
entitlementPool: {
entitlementPoolEditor: {
@@ -252,7 +327,17 @@ describe('Entitlement Pools Module Tests', function () {
deepFreeze(store.getState());
const entitlementPool = EntitlementPoolStoreFactory.build();
- const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolEditor.limitsList', []);
+
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
+
+ let expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolEditor.limitsList', []);
+ expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
mockRest.addHandler('destroy', ({data, options, baseUrl}) => {
expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools/${entitlementPool.id}/limits/${limitsList[0].id}`);
@@ -272,6 +357,13 @@ describe('Entitlement Pools Module Tests', function () {
return {results: []};
});
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${version.id}`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {...returnedVersionFields, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: true}};
+ });
+
return EntitlementPoolsActionHelper.deleteLimit(store.dispatch, {
licenseModelId: LICENSE_MODEL_ID,
version,
@@ -288,6 +380,7 @@ describe('Entitlement Pools Module Tests', function () {
deepFreeze(limitsList);
const entitlementPool = EntitlementPoolStoreFactory.build();
const store = storeCreator({
+ currentScreen: {...itemPermissionAndProps},
licenseModel: {
entitlementPool: {
entitlementPoolEditor: {
@@ -312,7 +405,16 @@ describe('Entitlement Pools Module Tests', function () {
updatedLimit.unit = {choice: updatedLimit.unit, other: ''};
deepFreeze(updatedLimit);
- const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolEditor.limitsList', [updatedLimitForPut]);
+ 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}) => {
@@ -329,6 +431,13 @@ describe('Entitlement Pools Module Tests', function () {
return {results: [updatedLimitForPut]};
});
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${version.id}`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {...returnedVersionFields, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: true}};
+ });
+
return EntitlementPoolsActionHelper.submitLimit(store.dispatch,
{
licenseModelId: LICENSE_MODEL_ID,