summaryrefslogtreecommitdiffstats
path: root/openecomp-ui/test/licenseModel/featureGroups
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-ui/test/licenseModel/featureGroups')
-rw-r--r--openecomp-ui/test/licenseModel/featureGroups/LicenseModelFeatureGroupEditor.test.js74
-rw-r--r--openecomp-ui/test/licenseModel/featureGroups/LicenseModelFeatureGroupListEditor.test.js90
-rw-r--r--openecomp-ui/test/licenseModel/featureGroups/test.js212
3 files changed, 289 insertions, 87 deletions
diff --git a/openecomp-ui/test/licenseModel/featureGroups/LicenseModelFeatureGroupEditor.test.js b/openecomp-ui/test/licenseModel/featureGroups/LicenseModelFeatureGroupEditor.test.js
new file mode 100644
index 0000000000..5f5e2a0c9e
--- /dev/null
+++ b/openecomp-ui/test/licenseModel/featureGroups/LicenseModelFeatureGroupEditor.test.js
@@ -0,0 +1,74 @@
+/*!
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * 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
+ *
+ * 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.
+ */
+
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import {mapStateToProps} from 'sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditor.js';
+import FeatureGroupEditorView from 'sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditorView.jsx';
+import {LicenseModelOverviewFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
+import {FeatureGroupStoreFactory} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js';
+
+describe('License Model Feature Groups Editor Module Tests', function () {
+
+ it('should mapper exist', () => {
+ expect(mapStateToProps).toBeTruthy();
+ });
+
+ it('should return empty data', () => {
+
+ let licenseModel = LicenseModelOverviewFactory.build({
+ featureGroup: {
+ featureGroupEditor: {
+ data: FeatureGroupStoreFactory.build()
+ },
+ featureGroupsList: []
+ }
+ });
+
+ var results = mapStateToProps({licenseModel});
+ expect(results.entitlementPoolsList).toEqual([]);
+ expect(results.licenseKeyGroupsList).toEqual([]);
+ });
+
+ it ('should return fg names list', () => {
+ let licenseModel = LicenseModelOverviewFactory.build({
+ featureGroup: {
+ featureGroupEditor: {
+ data: FeatureGroupStoreFactory.build()
+ },
+ featureGroupsList: [{
+ name: 'fg1',
+ id: 'fg1_id'
+ }, {
+ name: 'fg2',
+ id: 'fg2_id'
+ }]
+ }
+ });
+ var results = mapStateToProps({licenseModel});
+ expect(results.FGNames).toEqual({fg1: 'fg1_id', fg2: 'fg2_id'});
+ });
+
+ it('jsx view test', () => {
+ var view = TestUtils.renderIntoDocument(<FeatureGroupEditorView
+ isReadOnlyMode={true}
+ onTabSelect={() => {}}
+ entitlementPoolsList={[{id: '1', name: '1'}]}
+ licenseKeyGroupsList={[{id: '1', name: '1'}]}/>);
+ expect(view).toBeTruthy();
+ });
+
+});
diff --git a/openecomp-ui/test/licenseModel/featureGroups/LicenseModelFeatureGroupListEditor.test.js b/openecomp-ui/test/licenseModel/featureGroups/LicenseModelFeatureGroupListEditor.test.js
new file mode 100644
index 0000000000..5dc20047bc
--- /dev/null
+++ b/openecomp-ui/test/licenseModel/featureGroups/LicenseModelFeatureGroupListEditor.test.js
@@ -0,0 +1,90 @@
+/*!
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * 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
+ *
+ * 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.
+ */
+
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import {mapStateToProps} from 'sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditor.js';
+import FeatureGroupsListEditorView from 'sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditorView.jsx';
+import { FeatureGroupStoreFactory } from 'test-utils/factories/licenseModel/FeatureGroupFactories.js';
+import {LicenseModelOverviewFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
+import { buildListFromFactory } from 'test-utils/Util.js';
+import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
+
+describe('License Model Feature Group List Module Tests', function () {
+
+ it('should mapper exist', () => {
+ expect(mapStateToProps).toBeTruthy();
+ });
+
+
+ it('should return empty data', () => {
+
+
+ let licenseModel = LicenseModelOverviewFactory.build({
+ featureGroup: {
+ featureGroupEditor: {},
+ featureGroupsList: []
+ },
+ licenseModelEditor: {
+ data:{
+ ...VersionControllerUtilsFactory.build()
+ }
+ }
+ });
+ var results = mapStateToProps({licenseModel});
+ expect(results.vendorName).toEqual(undefined);
+ expect(results.featureGroupsModal.show).toEqual(false);
+ expect(results.featureGroupsModal.editMode).toEqual(false);
+ expect(results.featureGroupsList).toEqual([]);
+ });
+
+ it('should return true for show and edit mode and vendorName should be not empty', () => {
+
+ let licenseModel = LicenseModelOverviewFactory.build({
+ featureGroup: {
+ featureGroupEditor: {
+ data: FeatureGroupStoreFactory.build()
+ },
+ featureGroupsList: []
+ }
+ });
+ var results = mapStateToProps({licenseModel});
+ expect(results.featureGroupsModal.show).toEqual(true);
+ expect(results.featureGroupsModal.editMode).toEqual(true);
+ expect(results.vendorName).toEqual(licenseModel.licenseModelEditor.data.vendorName);
+ });
+
+ it('jsx view test', () => {
+ var view = TestUtils.renderIntoDocument(<FeatureGroupsListEditorView vendorName=''
+ licenseModelId=''
+ featureGroupsModal={{show: false, editMode: false}}
+ isReadOnlyMode={false}
+ onAddFeatureGroupClick={()=>{}}
+ featureGroupsList={[]} />);
+ expect(view).toBeTruthy();
+ });
+
+ it('jsx view list test', () => {
+ var view = TestUtils.renderIntoDocument(<FeatureGroupsListEditorView vendorName=''
+ licenseModelId=''
+ featureGroupsModal={{show: false, editMode: true}}
+ isReadOnlyMode={false}
+ onAddFeatureGroupClick={()=>{}}
+ featureGroupsList={buildListFromFactory(FeatureGroupStoreFactory)} />);
+ expect(view).toBeTruthy();
+ });
+
+});
diff --git a/openecomp-ui/test/licenseModel/featureGroups/test.js b/openecomp-ui/test/licenseModel/featureGroups/test.js
index d334ab758e..7d0d7242b5 100644
--- a/openecomp-ui/test/licenseModel/featureGroups/test.js
+++ b/openecomp-ui/test/licenseModel/featureGroups/test.js
@@ -1,75 +1,56 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* 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.
- * ============LICENSE_END=========================================================
+ * 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 {expect} from 'chai';
import deepFreeze from 'deep-freeze';
import mockRest from 'test-utils/MockRest.js';
-import {cloneAndSet} from 'test-utils/Util.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 VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
describe('Feature Groups Module Tests', function () {
const LICENSE_MODEL_ID = '555';
+ const version = VersionControllerUtilsFactory.build().version;
it('Load Feature Groups List', () => {
- const featureGroupsList = [
- {
- name: 'fs1',
- id: 0,
- description: 'fs1-d',
- licenseKeyGroupsIds: [1],
- entitlementPoolsIds: [1],
- refCount: 0
- }
- ];
+
+ const featureGroupsList = buildListFromFactory(FeatureGroupStoreFactory);
deepFreeze(featureGroupsList);
+
const store = storeCreator();
deepFreeze(store.getState());
const expectedStore = cloneAndSet(store.getState(), 'licenseModel.featureGroup.featureGroupsList', featureGroupsList);
mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/feature-groups`);
- expect(data).to.equal(undefined);
- expect(options).to.equal(undefined);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/feature-groups`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
return {results: featureGroupsList};
});
- return FeatureGroupsActionHelper.fetchFeatureGroupsList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ return FeatureGroupsActionHelper.fetchFeatureGroupsList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID, version}).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
});
});
it('Delete Feature Group', () => {
- const featureGroupsList = [
- {
- name: 'fs1',
- id: 0,
- description: 'fs1-d',
- licenseKeyGroupsIds: [1],
- entitlementPoolsIds: [1],
- refCount: 0
- }
- ];
+ const featureGroupsList = buildListFromFactory(FeatureGroupStoreFactory, 1);
deepFreeze(featureGroupsList);
const store = storeCreator({
licenseModel: {
@@ -82,10 +63,12 @@ describe('Feature Groups Module Tests', function () {
const expectedStore = cloneAndSet(store.getState(), 'licenseModel.featureGroup.featureGroupsList', []);
+ const idToDelete = featureGroupsList[0].id;
+
mockRest.addHandler('destroy', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/feature-groups/${featureGroupsList[0].id}`);
- expect(data).to.equal(undefined);
- expect(options).to.equal(undefined);
+ 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'
@@ -95,9 +78,10 @@ describe('Feature Groups Module Tests', function () {
return FeatureGroupsActionHelper.deleteFeatureGroup(store.dispatch, {
licenseModelId: LICENSE_MODEL_ID,
- featureGroupId: featureGroupsList[0].id
+ version,
+ featureGroupId: idToDelete
}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
});
@@ -106,56 +90,62 @@ describe('Feature Groups Module Tests', function () {
const store = storeCreator();
deepFreeze(store.getState());
- const featureGroupPostRequest = {
- name: 'fs1',
- description: 'fs1-d',
- partNumber: '123',
+ const FeatureGroupPostRequest = FeatureGroupPostFactory.build({
addedLicenseKeyGroupsIds: [1],
addedEntitlementPoolsIds: [1]
- };
- const featureGroupToAdd = {
- name: 'fs1',
- description: 'fs1-d',
- partNumber: '123',
+ });
+ const featureGroupToAdd = FeatureGroupDispatchFactory.build({
licenseKeyGroupsIds: [1],
entitlementPoolsIds: [1]
- };
+ });
+
const featureGroupIdFromResponse = 'ADDED_ID';
- const featureGroupAfterAdd = {
+ const featureGroupAfterAdd = FeatureGroupStoreFactory.build({
...featureGroupToAdd,
id: featureGroupIdFromResponse
- };
+ });
const expectedStore = cloneAndSet(store.getState(), 'licenseModel.featureGroup.featureGroupsList', [featureGroupAfterAdd]);
- mockRest.addHandler('create', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/feature-groups`);
- expect(data).to.deep.equal(featureGroupPostRequest);
- expect(options).to.equal(undefined);
+ mockRest.addHandler('post', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/feature-groups`);
+ expect(data).toEqual(FeatureGroupPostRequest);
+ expect(options).toEqual(undefined);
return {
returnCode: 'OK',
value: featureGroupIdFromResponse
};
});
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: []};
+ });
+
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: []};
+ });
+
+
return FeatureGroupsActionHelper.saveFeatureGroup(store.dispatch, {
licenseModelId: LICENSE_MODEL_ID,
+ version,
featureGroup: featureGroupToAdd
}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
});
it('Update Feature Group', () => {
- const featureGroupsList = [{
- name: 'fs1',
- id: 0,
- description: 'fs1-d',
- partNumber: '123',
+ const featureGroupsList = buildListFromFactory(FeatureGroupStoreFactory, 1, {
licenseKeyGroupsIds: [1],
- entitlementPoolsIds: [1],
- refCount: 0
- }];
+ entitlementPoolsIds: [1]
+ });
deepFreeze(featureGroupsList);
const store = storeCreator({
@@ -169,44 +159,92 @@ describe('Feature Groups Module Tests', function () {
const toBeUpdatedFeatureGroupId = featureGroupsList[0].id;
const previousFeatureGroupData = featureGroupsList[0];
- const featureGroupUpdateData = {
- ...featureGroupsList[0],
- name: 'fs_UPDATED',
- description: 'description_UPDATED',
- partNumber: '123_UPDATED',
+
+ const featureGroupUpdateData = FeatureGroupStoreFactory.build({
+ ...previousFeatureGroupData,
licenseKeyGroupsIds: [7],
entitlementPoolsIds: [7]
- };
+ });
deepFreeze(featureGroupUpdateData);
- const featureGroupPutRequest = {
- name: 'fs_UPDATED',
- description: 'description_UPDATED',
- partNumber: '123_UPDATED',
+ const FeatureGroupPutFactoryRequest = FeatureGroupPutFactory.build({
+ name: featureGroupUpdateData.name,
+ description: featureGroupUpdateData.description,
+ partNumber: featureGroupUpdateData.partNumber,
addedLicenseKeyGroupsIds: [7],
addedEntitlementPoolsIds: [7],
removedLicenseKeyGroupsIds: [1],
removedEntitlementPoolsIds: [1]
- };
- deepFreeze(featureGroupPutRequest);
+ });
+ deepFreeze(FeatureGroupPutFactoryRequest);
const expectedStore = cloneAndSet(store.getState(), 'licenseModel.featureGroup.featureGroupsList', [featureGroupUpdateData]);
- mockRest.addHandler('save', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/feature-groups/${toBeUpdatedFeatureGroupId}`);
- expect(data).to.deep.equal(featureGroupPutRequest);
- expect(options).to.equal(undefined);
+ mockRest.addHandler('put', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/feature-groups/${toBeUpdatedFeatureGroupId}`);
+ expect(data).toEqual(FeatureGroupPutFactoryRequest);
+ expect(options).toEqual(undefined);
return {returnCode: 'OK'};
});
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: []};
+ });
+
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: []};
+ });
+
return FeatureGroupsActionHelper.saveFeatureGroup(store.dispatch, {
licenseModelId: LICENSE_MODEL_ID,
+ version,
previousFeatureGroup: previousFeatureGroupData,
featureGroup: featureGroupUpdateData
}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
+
+ });
+
+ it('Open Editor', () => {
+
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const editorData = FeatureGroupStoreFactory.build();
+ deepFreeze(editorData);
+ const expectedStore = cloneAndSet(store.getState(), 'licenseModel.featureGroup.featureGroupEditor.data', 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: []};
+ });
+
+
+ FeatureGroupsActionHelper.openFeatureGroupsEditor(store.dispatch, {featureGroup: editorData, licenseModelId: '123', version});
+ setTimeout(() =>{
+ expect(store.getState()).toEqual(expectedStore);
+ }, 100);
+
+
+
});
});