summaryrefslogtreecommitdiffstats
path: root/openecomp-ui/test/licenseModel/licenseKeyGroups
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/licenseKeyGroups
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/licenseKeyGroups')
-rw-r--r--openecomp-ui/test/licenseModel/licenseKeyGroups/test.js130
1 files changed, 120 insertions, 10 deletions
diff --git a/openecomp-ui/test/licenseModel/licenseKeyGroups/test.js b/openecomp-ui/test/licenseModel/licenseKeyGroups/test.js
index 739e266d7f..09a2c6f53a 100644
--- a/openecomp-ui/test/licenseModel/licenseKeyGroups/test.js
+++ b/openecomp-ui/test/licenseModel/licenseKeyGroups/test.js
@@ -20,14 +20,18 @@ 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 VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
+import VersionFactory from 'test-utils/factories/common/VersionFactory.js';
+import CurrentScreenFactory from 'test-utils/factories/common/CurrentScreenFactory.js';
import {LimitItemFactory, LimitPostFactory} from 'test-utils/factories/licenseModel/LimitFactories.js';
import {getStrValue} from 'nfvo-utils/getValue.js';
+import {SyncStates} from 'sdc-app/common/merge/MergeEditorConstants.js';
describe('License Key Groups Module Tests', function () {
const LICENSE_MODEL_ID = '555';
- const version = 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 License Key Group', () => {
@@ -57,6 +61,7 @@ describe('License Key Groups Module Tests', function () {
deepFreeze(licenseKeyGroupsList);
const store = storeCreator({
+ currentScreen: {...itemPermissionAndProps},
licenseModel: {
licenseKeyGroup: {
licenseKeyGroupsList
@@ -65,7 +70,17 @@ describe('License Key Groups Module Tests', function () {
});
deepFreeze(store.getState());
const toBeDeletedLicenseKeyGroupId = licenseKeyGroupsList[0].id;
- const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', []);
+
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
+
+ let expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', []);
+ expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
mockRest.addHandler('destroy', ({data, options, baseUrl}) => {
expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups/${toBeDeletedLicenseKeyGroupId}`);
@@ -73,6 +88,13 @@ describe('License Key Groups Module Tests', function () {
expect(options).toEqual(undefined);
});
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${version.id}`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {...returnedVersionFields, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: true}};
+ });
+
return LicenseKeyGroupsActionHelper.deleteLicenseKeyGroup(store.dispatch, {
licenseKeyGroupId: toBeDeletedLicenseKeyGroupId,
licenseModelId: LICENSE_MODEL_ID,
@@ -84,7 +106,9 @@ describe('License Key Groups Module Tests', function () {
it('Add License Key Group', () => {
- const store = storeCreator();
+ const store = storeCreator({
+ currentScreen: {...itemPermissionAndProps}
+ });
deepFreeze(store.getState());
const LicenseKeyGroupPost = LicenseKeyGroupPostFactory.build();
@@ -93,7 +117,16 @@ describe('License Key Groups Module Tests', function () {
const LicenseKeyGroupStore = LicenseKeyGroupStoreFactory.build();
deepFreeze(LicenseKeyGroupStore);
- const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', [LicenseKeyGroupStore]);
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
+
+ let expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', [LicenseKeyGroupStore]);
+ expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
mockRest.addHandler('post', ({options, data, baseUrl}) => {
expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups`);
@@ -104,6 +137,13 @@ describe('License Key Groups 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 LicenseKeyGroupsActionHelper.saveLicenseKeyGroup(store.dispatch, {
licenseKeyGroup: LicenseKeyGroupPost,
licenseModelId: LICENSE_MODEL_ID,
@@ -117,6 +157,7 @@ describe('License Key Groups Module Tests', function () {
const licenseKeyGroupsList = buildListFromFactory(LicenseKeyGroupStoreFactory, 1);
deepFreeze(licenseKeyGroupsList);
const store = storeCreator({
+ currentScreen: {...itemPermissionAndProps},
licenseModel: {
licenseKeyGroup: {
licenseKeyGroupsList
@@ -141,7 +182,16 @@ describe('License Key Groups Module Tests', function () {
deepFreeze(licenseKeyGroupPutRequest);
- const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', [licenseKeyGroupUpdatedData]);
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
+
+ let expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', [licenseKeyGroupUpdatedData]);
+ expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
mockRest.addHandler('put', ({data, options, baseUrl}) => {
expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups/${toBeUpdatedLicenseKeyGroupId}`);
@@ -149,6 +199,13 @@ describe('License Key Groups Module Tests', function () {
expect(options).toEqual(undefined);
});
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${version.id}`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {...returnedVersionFields, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: true}};
+ });
+
return LicenseKeyGroupsActionHelper.saveLicenseKeyGroup(store.dispatch, {
previousLicenseKeyGroup: previousLicenseKeyGroupData,
licenseKeyGroup: licenseKeyGroupUpdatedData,
@@ -182,7 +239,9 @@ describe('License Key Groups Module Tests', function () {
it('Add Limit', () => {
- const store = storeCreator();
+ const store = storeCreator({
+ currentScreen: {...itemPermissionAndProps}
+ });
deepFreeze(store.getState());
const limitToAdd = LimitPostFactory.build();
@@ -198,7 +257,16 @@ describe('License Key Groups Module Tests', function () {
deepFreeze(limitAddedItem);
const licenseKeyGroup = LicenseKeyGroupStoreFactory.build();
- const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsEditor.limitsList', [limitAddedItem]);
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
+
+ let expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsEditor.limitsList', [limitAddedItem]);
+ expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
mockRest.addHandler('post', ({data, options, baseUrl}) => {
expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups/${licenseKeyGroup.id}/limits`);
@@ -217,6 +285,13 @@ describe('License Key Groups 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 LicenseKeyGroupsActionHelper.submitLimit(store.dispatch,
{
licenseModelId: LICENSE_MODEL_ID,
@@ -235,6 +310,7 @@ describe('License Key Groups Module Tests', function () {
deepFreeze(limitsList);
const store = storeCreator({
+ currentScreen: {...itemPermissionAndProps},
licenseModel: {
entitlementPool: {
entitlementPoolEditor: {
@@ -246,7 +322,17 @@ describe('License Key Groups Module Tests', function () {
deepFreeze(store.getState());
const licenseKeyGroup = LicenseKeyGroupStoreFactory.build();
- const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsEditor.limitsList', []);
+
+ const expectedCurrentScreenProps = {
+ ...itemPermissionAndProps,
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isDirty: true
+ }
+ };
+
+ let expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsEditor.limitsList', []);
+ expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
mockRest.addHandler('destroy', ({data, options, baseUrl}) => {
expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups/${licenseKeyGroup.id}/limits/${limitsList[0].id}`);
@@ -266,6 +352,13 @@ describe('License Key Groups 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 LicenseKeyGroupsActionHelper.deleteLimit(store.dispatch, {
licenseModelId: LICENSE_MODEL_ID,
version,
@@ -282,6 +375,7 @@ describe('License Key Groups Module Tests', function () {
deepFreeze(limitsList);
const licenseKeyGroup = LicenseKeyGroupStoreFactory.build();
const store = storeCreator({
+ currentScreen: {...itemPermissionAndProps},
licenseModel: {
licenseKeyGroup: {
licenseKeyGroupsEditor: {
@@ -304,7 +398,16 @@ describe('License Key Groups Module Tests', function () {
updatedLimit.unit = {choice: updatedLimit.unit, other: ''};
deepFreeze(updatedLimit);
- const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsEditor.limitsList', [updatedLimitForPut]);
+ 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}) => {
@@ -321,6 +424,13 @@ describe('License Key Groups 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 LicenseKeyGroupsActionHelper.submitLimit(store.dispatch,
{
licenseModelId: LICENSE_MODEL_ID,