aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-ui/test
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-ui/test')
-rw-r--r--openecomp-ui/test/licenseModel/entitlementPools/test.js179
-rw-r--r--openecomp-ui/test/licenseModel/licenseKeyGroups/test.js176
-rw-r--r--openecomp-ui/test/nfvo-components/listEditor/listEditor.test.js9
-rw-r--r--openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js12
4 files changed, 366 insertions, 10 deletions
diff --git a/openecomp-ui/test/licenseModel/entitlementPools/test.js b/openecomp-ui/test/licenseModel/entitlementPools/test.js
index 15e1deecd6..f5415239ad 100644
--- a/openecomp-ui/test/licenseModel/entitlementPools/test.js
+++ b/openecomp-ui/test/licenseModel/entitlementPools/test.js
@@ -20,6 +20,8 @@ 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 {LimitItemFactory, LimitPostFactory} from 'test-utils/factories/licenseModel/LimitFactories.js';
+import {getStrValue} from 'nfvo-utils/getValue.js';
describe('Entitlement Pools Module Tests', function () {
@@ -162,4 +164,181 @@ describe('Entitlement Pools Module Tests', function () {
});
});
+ 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();
+ deepFreeze(store.getState());
+
+ const limitToAdd = LimitPostFactory.build();
+ let limitFromBE = {...limitToAdd};
+ limitFromBE.metric = getStrValue(limitFromBE.metric);
+ limitFromBE.unit = getStrValue(limitFromBE.unit);
+
+ deepFreeze(limitToAdd);
+ deepFreeze(limitFromBE);
+
+ const LimitIdFromResponse = 'ADDED_ID';
+ const limitAddedItem = {...limitToAdd, id: LimitIdFromResponse};
+ deepFreeze(limitAddedItem);
+ const entitlementPool = EntitlementPoolStoreFactory.build();
+
+ const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolEditor.limitsList', [limitAddedItem]);
+
+ 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]};
+ });
+
+ return EntitlementPoolsActionHelper.submitLimit(store.dispatch,
+ {
+ licenseModelId: LICENSE_MODEL_ID,
+ version,
+ entitlementPool,
+ limit: limitToAdd
+ }
+ ).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+
+ it('Delete Limit', () => {
+
+ const limitsList = LimitItemFactory.buildList(1);
+ deepFreeze(limitsList);
+
+ const store = storeCreator({
+ licenseModel: {
+ entitlementPool: {
+ entitlementPoolEditor: {
+ limitsList
+ }
+ }
+ }
+ });
+ deepFreeze(store.getState());
+
+ const entitlementPool = EntitlementPoolStoreFactory.build();
+ const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolEditor.limitsList', []);
+
+ mockRest.addHandler('destroy', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools/${entitlementPool.id}/limits/${limitsList[0].id}`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ results: {
+ returnCode: 'OK'
+ }
+ };
+ });
+
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools/${entitlementPool.id}/limits`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: []};
+ });
+
+ 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({
+ licenseModel: {
+ entitlementPool: {
+ entitlementPoolEditor: {
+ limitsList
+ }
+ }
+ }
+ });
+
+ deepFreeze(store.getState());
+
+
+ const previousData = limitsList[0];
+
+ deepFreeze(previousData);
+ const limitId = limitsList[0].id;
+
+ let updatedLimit = {...previousData, name: 'updatedLimit'};
+
+ const updatedLimitForPut = {...updatedLimit, id: undefined};
+ updatedLimit.metric = {choice: updatedLimit.metric, other: ''};
+ updatedLimit.unit = {choice: updatedLimit.unit, other: ''};
+ deepFreeze(updatedLimit);
+
+ const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolEditor.limitsList', [updatedLimitForPut]);
+
+
+ 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]};
+ });
+
+ 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/licenseKeyGroups/test.js b/openecomp-ui/test/licenseModel/licenseKeyGroups/test.js
index dd09030f4f..739e266d7f 100644
--- a/openecomp-ui/test/licenseModel/licenseKeyGroups/test.js
+++ b/openecomp-ui/test/licenseModel/licenseKeyGroups/test.js
@@ -21,6 +21,8 @@ import {LicenseKeyGroupStoreFactory, LicenseKeyGroupPostFactory} from 'test-util
import LicenseKeyGroupsActionHelper from 'sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js';
import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
+import {LimitItemFactory, LimitPostFactory} from 'test-utils/factories/licenseModel/LimitFactories.js';
+import {getStrValue} from 'nfvo-utils/getValue.js';
describe('License Key Groups Module Tests', function () {
@@ -157,4 +159,178 @@ describe('License Key Groups Module Tests', function () {
});
});
+ it('Load Limits List', () => {
+
+ const limitsList = LimitItemFactory.buildList(3);
+ deepFreeze(limitsList);
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsEditor.limitsList', limitsList);
+ const licenseKeyGroup = LicenseKeyGroupStoreFactory.build();
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups/${licenseKeyGroup.id}/limits`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: limitsList};
+ });
+
+ return LicenseKeyGroupsActionHelper.fetchLimits(store.dispatch, {licenseModelId: LICENSE_MODEL_ID, version, licenseKeyGroup}).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+ it('Add Limit', () => {
+
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const limitToAdd = LimitPostFactory.build();
+ let limitFromBE = {...limitToAdd};
+ limitFromBE.metric = getStrValue(limitFromBE.metric);
+ limitFromBE.unit = getStrValue(limitFromBE.unit);
+
+ deepFreeze(limitToAdd);
+ deepFreeze(limitFromBE);
+
+ const LimitIdFromResponse = 'ADDED_ID';
+ const limitAddedItem = {...limitToAdd, id: LimitIdFromResponse};
+ deepFreeze(limitAddedItem);
+ const licenseKeyGroup = LicenseKeyGroupStoreFactory.build();
+
+ const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsEditor.limitsList', [limitAddedItem]);
+
+ mockRest.addHandler('post', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups/${licenseKeyGroup.id}/limits`);
+ expect(data).toEqual(limitFromBE);
+ expect(options).toEqual(undefined);
+ return {
+ returnCode: 'OK',
+ value: LimitIdFromResponse
+ };
+ });
+
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups/${licenseKeyGroup.id}/limits`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: [limitAddedItem]};
+ });
+
+ return LicenseKeyGroupsActionHelper.submitLimit(store.dispatch,
+ {
+ licenseModelId: LICENSE_MODEL_ID,
+ version,
+ licenseKeyGroup,
+ limit: limitToAdd
+ }
+ ).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+ it('Delete Limit', () => {
+
+ const limitsList = LimitItemFactory.buildList(1);
+ deepFreeze(limitsList);
+
+ const store = storeCreator({
+ licenseModel: {
+ entitlementPool: {
+ entitlementPoolEditor: {
+ limitsList
+ }
+ }
+ }
+ });
+ deepFreeze(store.getState());
+
+ const licenseKeyGroup = LicenseKeyGroupStoreFactory.build();
+ const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsEditor.limitsList', []);
+
+ mockRest.addHandler('destroy', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups/${licenseKeyGroup.id}/limits/${limitsList[0].id}`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {
+ results: {
+ returnCode: 'OK'
+ }
+ };
+ });
+
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups/${licenseKeyGroup.id}/limits`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: []};
+ });
+
+ 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({
+ licenseModel: {
+ licenseKeyGroup: {
+ licenseKeyGroupsEditor: {
+ limitsList
+ }
+ }
+ }
+ });
+
+ deepFreeze(store.getState());
+
+
+ const previousData = limitsList[0];
+ deepFreeze(previousData);
+ const limitId = limitsList[0].id;
+
+ let updatedLimit = {...previousData, name: 'updatedLimit'};
+ const updatedLimitForPut = {...updatedLimit, id: undefined};
+ updatedLimit.metric = {choice: updatedLimit.metric, other: ''};
+ updatedLimit.unit = {choice: updatedLimit.unit, other: ''};
+ deepFreeze(updatedLimit);
+
+ const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsEditor.limitsList', [updatedLimitForPut]);
+
+
+ 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]};
+ });
+
+ 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/nfvo-components/listEditor/listEditor.test.js b/openecomp-ui/test/nfvo-components/listEditor/listEditor.test.js
index 029ea31889..b1127386f7 100644
--- a/openecomp-ui/test/nfvo-components/listEditor/listEditor.test.js
+++ b/openecomp-ui/test/nfvo-components/listEditor/listEditor.test.js
@@ -40,7 +40,7 @@ describe('listEditor Module Tests', function () {
</ListEditorView>
);
expect(itemView).toBeTruthy();
- let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'sliders');
+ let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, '__sliders');
TestUtils.Simulate.click(sliderIcon);
});
@@ -60,7 +60,7 @@ describe('listEditor Module Tests', function () {
</ListEditorItemView>
);
expect(itemView).toBeTruthy();
- let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'sliders');
+ let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, '__sliders');
TestUtils.Simulate.click(sliderIcon);
});
@@ -71,7 +71,7 @@ describe('listEditor Module Tests', function () {
</ListEditorItemView>
);
expect(itemView).toBeTruthy();
- let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'trashO');
+ let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, '__trashO');
TestUtils.Simulate.click(sliderIcon);
});
@@ -82,7 +82,8 @@ describe('listEditor Module Tests', function () {
</ListEditorItemView>
);
expect(itemView).toBeTruthy();
- let trashIcon = TestUtils.scryRenderedDOMComponentsWithClass(itemView, 'fa-trash-o');
+ let trashIcon = TestUtils.scryRenderedDOMComponentsWithClass(itemView, '__trashOq');
expect(trashIcon).toEqual([]);
});
+
});
diff --git a/openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js b/openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js
index 7d4d57eb35..e14e9b76f5 100644
--- a/openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js
+++ b/openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js
@@ -16,7 +16,7 @@
import React from 'react';
-
+import ReactDOMServer from 'react-dom/server';
import TestUtils from 'react-addons-test-utils';
import {mount} from 'enzyme';
import VersionController from 'nfvo-components/panel/versionController/VersionController.jsx';
@@ -131,21 +131,21 @@ describe('versionController UI Component', () => {
let callVCActionProps = { ...props, version: '1.0', callVCAction: function(){} };
let versionController = mount(<VersionController isCheckedOut={true} status={statusEnum.CHECK_OUT_STATUS} {...callVCActionProps} />);
let elem = versionController.find('[data-test-id="vc-checkout-btn"]');
- let svgIcon = versionController.find('.versionControllerLockClosed');
+
expect(elem).toBeTruthy();
expect(elem.length).toEqual(1);
- expect(svgIcon.hasClass('disabled')).toBe(true);
+ expect(elem.find('.svg-icon').length).toEqual(1);
+ expect(elem.find('.svg-icon').hasClass('disabled')).toBe(true);
});
it('Doesn\'t show the checkout button', () => {
let callVCActionProps = { ...props, version: '1.0', callVCAction: function(){} };
let versionController = mount(<VersionController isCheckedOut={false} status={statusEnum.CHECK_IN_STATUS} {...callVCActionProps} />);
let elem = versionController.find('[data-test-id="vc-checkout-btn"]');
- let svgIcon = versionController.find('.versionControllerLockClosed');
-
expect(elem).toBeTruthy();
expect(elem.length).toBe(1);
- expect(svgIcon.hasClass('disabled')).toBe(true);
+ expect(elem.find('.svg-icon').length).toEqual(1);
+ expect(elem.find('.svg-icon').hasClass('disabled')).toBe(true);
});