From b8e2faf476202b6ffe61bc3a9a37df1304881d40 Mon Sep 17 00:00:00 2001 From: Avi Ziv Date: Tue, 18 Jul 2017 19:45:38 +0300 Subject: [SDC] Onboarding 1710 rebase. Change-Id: If3b6b81d221fde13908f1e8160db6f7d9433c535 Signed-off-by: Avi Ziv --- .../SoftwareProductComponentComputeEditor.test.js | 85 +++++++++ .../SoftwareProductComponentsComputes.test.js | 48 +++++ ...VSPComponentComputeActionHelperHeatMode.test.js | 107 +++++++++++ ...PComponentComputeActionHelperManualMode.test.js | 198 +++++++++++++++++++++ .../softwareProduct/components/compute/test.js | 107 ----------- 5 files changed, 438 insertions(+), 107 deletions(-) create mode 100644 openecomp-ui/test/softwareProduct/components/compute/SoftwareProductComponentComputeEditor.test.js create mode 100644 openecomp-ui/test/softwareProduct/components/compute/SoftwareProductComponentsComputes.test.js create mode 100644 openecomp-ui/test/softwareProduct/components/compute/VSPComponentComputeActionHelperHeatMode.test.js create mode 100644 openecomp-ui/test/softwareProduct/components/compute/VSPComponentComputeActionHelperManualMode.test.js delete mode 100644 openecomp-ui/test/softwareProduct/components/compute/test.js (limited to 'openecomp-ui/test/softwareProduct/components/compute') diff --git a/openecomp-ui/test/softwareProduct/components/compute/SoftwareProductComponentComputeEditor.test.js b/openecomp-ui/test/softwareProduct/components/compute/SoftwareProductComponentComputeEditor.test.js new file mode 100644 index 0000000000..c14246f810 --- /dev/null +++ b/openecomp-ui/test/softwareProduct/components/compute/SoftwareProductComponentComputeEditor.test.js @@ -0,0 +1,85 @@ +/*! + * 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 as computeEditorMapStateToProps} from 'sdc-app/onboarding/softwareProduct/components/compute/computeComponents/computeFlavor/ComputeFlavorEditor.js'; +import ComputeEditorView from 'sdc-app/onboarding/softwareProduct/components/compute/computeComponents/computeFlavor/ComputeFlavorEditorView.jsx'; + +import {SoftwareProductFactory} from 'test-utils/factories/softwareProduct/SoftwareProductFactory.js'; +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import {ComputeFlavorBaseData, ComputeFlavorQData, VSPComponentsComputeDataMapFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsComputeFactory.js'; + + +describe('Software Product Component Compute-Editor Mapper and View Classes.', () => { + + it('Compute Editor - mapStateToProps mapper exists', () => { + expect(computeEditorMapStateToProps).toBeTruthy(); + }); + + it('Compute Editor - mapStateToProps data test', () => { + const currentSoftwareProduct = VSPEditorFactory.build(); + + var obj = { + softwareProduct: SoftwareProductFactory.build({ + softwareProductEditor: { + data: currentSoftwareProduct + }, + softwareProductComponents: { + computeFlavor: { + computeEditor: { + data: {}, + qdata: {}, + qgenericFieldInfo: {}, + dataMap: {}, + genericFieldInfo: {}, + formReady: true + } + } + } + }) + }; + + var results = computeEditorMapStateToProps(obj); + expect(results.data).toBeTruthy(); + expect(results.qdata).toBeTruthy(); + expect(results.qgenericFieldInfo).toBeTruthy(); + expect(results.dataMap).toBeTruthy(); + expect(results.genericFieldInfo).toBeTruthy(); + expect(results.isReadOnlyMode).toBeTruthy(); + expect(results.isFormValid).toBeTruthy(); + expect(results.formReady).toBeTruthy(); + }); + + it('Compute Editor - View Test', () => { + + const props = { + data: ComputeFlavorBaseData.build(), + qdata: ComputeFlavorQData.build(), + dataMap: VSPComponentsComputeDataMapFactory.build(), + isReadOnlyMode: false, + onDataChanged: () => {}, + onQDataChanged: () => {}, + onSubmit: () => {}, + onCancel: () => {} + }; + + var renderer = TestUtils.createRenderer(); + renderer.render(); + var renderedOutput = renderer.getRenderOutput(); + expect(renderedOutput).toBeTruthy(); + + }); +}); diff --git a/openecomp-ui/test/softwareProduct/components/compute/SoftwareProductComponentsComputes.test.js b/openecomp-ui/test/softwareProduct/components/compute/SoftwareProductComponentsComputes.test.js new file mode 100644 index 0000000000..6d2361b20d --- /dev/null +++ b/openecomp-ui/test/softwareProduct/components/compute/SoftwareProductComponentsComputes.test.js @@ -0,0 +1,48 @@ +/*! + * 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 deepFreeze from 'deep-freeze'; +import React from 'react'; +import TestUtils from 'react-addons-test-utils'; +import {storeCreator} from 'sdc-app/AppStore.js'; +import ComputeFlavors from 'sdc-app/onboarding/softwareProduct/components/compute/computeComponents/ComputeFlavors.js'; +import {ComputeFlavorBaseData} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsComputeFactory.js'; + +const softwareProductId = '123'; +const componentId = '111'; + +describe('Software Product Component ComputeFlavors - View Classes.', () => { + + it('ComputeFlavors List View Test', () => { + const store = storeCreator(); + deepFreeze(store.getState()); + + const ComputeFlavorsList = ComputeFlavorBaseData.buildList(1); + + var renderer = TestUtils.createRenderer(); + renderer.render( + + ); + var renderedOutput = renderer.getRenderOutput(); + expect(renderedOutput).toBeTruthy(); + }); +}); + diff --git a/openecomp-ui/test/softwareProduct/components/compute/VSPComponentComputeActionHelperHeatMode.test.js b/openecomp-ui/test/softwareProduct/components/compute/VSPComponentComputeActionHelperHeatMode.test.js new file mode 100644 index 0000000000..4fe9408e34 --- /dev/null +++ b/openecomp-ui/test/softwareProduct/components/compute/VSPComponentComputeActionHelperHeatMode.test.js @@ -0,0 +1,107 @@ +/*! + * 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 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 Configuration from 'sdc-app/config/Configuration.js'; +import SoftwareProductComponentsActionHelper from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js'; + +import {ComputeFlavorQData, VSPComponentsComputeDataMapFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsComputeFactory.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; + +const softwareProductId = '123'; +const vspComponentId = '111'; +const version = VersionControllerUtilsFactory.build().version; + +describe('Software Product Components Compute Module Tests - HEAT mode', function () { + + let restPrefix = ''; + + beforeAll(function() { + restPrefix = Configuration.get('restPrefix'); + deepFreeze(restPrefix); + }); + + it('Get Software Products Components Compute', () => { + const store = storeCreator(); + deepFreeze(store.getState()); + + const compute = ComputeFlavorQData.build(); + const dataMap = VSPComponentsComputeDataMapFactory.build(); + + const softwareProductComponentCompute = { + data: JSON.stringify(compute), + schema: JSON.stringify(compute) + }; + deepFreeze(softwareProductComponentCompute); + + const softwareProductComponentComputeData = { + qdata: compute, + dataMap, + qgenericFieldInfo: {} + }; + deepFreeze(softwareProductComponentComputeData); + + const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor', softwareProductComponentComputeData); + + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/questionnaire`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return softwareProductComponentCompute; + }); + + return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, version, vspComponentId}).then(() => { + expect(store.getState()).toEqual(expectedStore); + }); + }); + + it('Get Empty Software Products Components Compute', () => { + const store = storeCreator(); + deepFreeze(store.getState()); + + const compute = ComputeFlavorQData.build(); + + const softwareProductComponentQuestionnaire = { + data: null, + schema: JSON.stringify(compute) + }; + deepFreeze(softwareProductComponentQuestionnaire); + + const softwareProductComponentQuestionnaireData = { + qdata: {}, + dataMap: {}, + qgenericFieldInfo: {} + }; + deepFreeze(softwareProductComponentQuestionnaireData); + + const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor', softwareProductComponentQuestionnaireData); + + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/questionnaire`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return softwareProductComponentQuestionnaire; + }); + + return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, version, vspComponentId}).then(() => { + expect(store.getState()).toEqual(expectedStore); + }); + }); + +}); diff --git a/openecomp-ui/test/softwareProduct/components/compute/VSPComponentComputeActionHelperManualMode.test.js b/openecomp-ui/test/softwareProduct/components/compute/VSPComponentComputeActionHelperManualMode.test.js new file mode 100644 index 0000000000..ca3d12f3e9 --- /dev/null +++ b/openecomp-ui/test/softwareProduct/components/compute/VSPComponentComputeActionHelperManualMode.test.js @@ -0,0 +1,198 @@ +/*! + * 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 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 Configuration from 'sdc-app/config/Configuration.js'; +import ComputeFlavorActionHelper from 'sdc-app/onboarding/softwareProduct/components/compute/ComputeFlavorActionHelper.js'; +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; + +import {ComputeFlavorQData, ComputeFlavorBaseData, ComponentComputeFactory, VSPComponentsComputeDataMapFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsComputeFactory.js'; + +const softwareProductId = '123'; +const vspComponentId = '111'; +const computeId = '111'; +const version = VSPEditorFactory.build().version; + + +describe('Software Product Components Compute Module Tests - Manual mode', function () { + + let restPrefix = ''; + + beforeAll(function() { + restPrefix = Configuration.get('restPrefix'); + deepFreeze(restPrefix); + }); + + + it('Close Compute Flavor editor', () => { + + const store = storeCreator(); + deepFreeze(store.getState()); + + const compute = ComponentComputeFactory.build(); + deepFreeze(compute); + + const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.computeFlavor', compute); + + ComputeFlavorActionHelper.closeComputeEditor(store.dispatch); + expect(store.getState()).toEqual(expectedStore); + }); + + it('Get Computes List', () => { + const store = storeCreator(); + deepFreeze(store.getState()); + + const computesList = ComputeFlavorBaseData.buildList(2); + deepFreeze(computesList); + + const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.computeFlavor.computesList', computesList); + + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/compute-flavors`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: computesList}; + }); + + return ComputeFlavorActionHelper.fetchComputesList(store.dispatch, {softwareProductId, componentId: vspComponentId, version}).then(() => { + expect(store.getState()).toEqual(expectedStore); + }); + }); + + it('Load Compute data & Questionnaire', () => { + const store = storeCreator(); + deepFreeze(store.getState()); + + const computeData = { + ...ComputeFlavorBaseData.build(), + id: computeId + }; + deepFreeze(computeData); + const qdata = ComputeFlavorQData.build(); + const dataMap = VSPComponentsComputeDataMapFactory.build(); + + const softwareProductComponentCompute = { + data: JSON.stringify(qdata), + schema: JSON.stringify(qdata) + }; + deepFreeze(softwareProductComponentCompute); + + + const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.computeFlavor.computeEditor', { + data: computeData, + qdata, + dataMap, + qgenericFieldInfo: {}, + genericFieldInfo: {}, + formReady: true + }); + + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/compute-flavors/${computeId}`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {data: computeData}; + }); + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/compute-flavors/${computeId}/questionnaire`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return softwareProductComponentCompute; + }); + + return ComputeFlavorActionHelper.loadComputeData({softwareProductId, componentId: vspComponentId, version, computeId}).then(() => { + ComputeFlavorActionHelper.loadComputeQuestionnaire(store.dispatch, {softwareProductId, componentId: vspComponentId, computeId, version}).then(() => + expect(store.getState()).toEqual(expectedStore)); + }); + }); + + it('Save Compute Flavor data and questionnaire', () => { + + const store = storeCreator(); + deepFreeze(store.getState()); + + const qdata = ComputeFlavorQData.build(); + const data = ComputeFlavorBaseData.build(); + + const compute = {...data, id: computeId}; + + const computeObj = { + computeEditor: {}, + computesList: [ + compute + ] + }; + + const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.computeFlavor', computeObj); + deepFreeze(expectedStore); + + mockRest.addHandler('put', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/compute-flavors/${computeId}/questionnaire`); + expect(data).toEqual(qdata); + expect(options).toEqual(undefined); + return {returnCode: 'OK'}; + }); + + mockRest.addHandler('put', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/compute-flavors/${computeId}`); + expect(data).toEqual(data); + expect(options).toEqual(undefined); + return {returnCode: 'OK'}; + }); + + return ComputeFlavorActionHelper.saveComputeDataAndQuestionnaire(store.dispatch, {softwareProductId, componentId: vspComponentId, qdata, data: compute, version}).then(() => { + expect(store.getState()).toEqual(expectedStore); + }); + }); + + it('Delete Compute Flavor', () => { + const compute = ComponentComputeFactory.build(); + const computesList = [compute]; + deepFreeze(computesList); + + const store = storeCreator({ + softwareProduct: { + softwareProductComponents: { + computeFlavor: { + computesList: computesList + } + } + } + }); + deepFreeze(store.getState()); + + const computeId = compute.id; + + const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.computeFlavor.computesList', []); + + mockRest.addHandler('destroy', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/compute-flavors/${computeId}`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return { + results: { + returnCode: 'OK' + } + }; + }); + + return ComputeFlavorActionHelper.deleteCompute(store.dispatch, {softwareProductId, componentId: vspComponentId, computeId, version}).then(() => { + expect(store.getState()).toEqual(expectedStore); + }); + }); +}); diff --git a/openecomp-ui/test/softwareProduct/components/compute/test.js b/openecomp-ui/test/softwareProduct/components/compute/test.js deleted file mode 100644 index 8d2d1fbb2f..0000000000 --- a/openecomp-ui/test/softwareProduct/components/compute/test.js +++ /dev/null @@ -1,107 +0,0 @@ -/*! - * 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 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 Configuration from 'sdc-app/config/Configuration.js'; -import SoftwareProductComponentsActionHelper from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js'; - -import {default as VSPComponentsComputeFactory, VSPComponentsComputeDataMapFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsComputeFactory.js'; -import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; - -const softwareProductId = '123'; -const vspComponentId = '111'; -const version = VersionControllerUtilsFactory.build().version; - -describe('Software Product Components Compute Module Tests', function () { - - let restPrefix = ''; - - beforeAll(function() { - restPrefix = Configuration.get('restPrefix'); - deepFreeze(restPrefix); - }); - - it('Get Software Products Components Compute', () => { - const store = storeCreator(); - deepFreeze(store.getState()); - - const compute = VSPComponentsComputeFactory.build(); - const dataMap = VSPComponentsComputeDataMapFactory.build(); - - const softwareProductComponentCompute = { - data: JSON.stringify(compute), - schema: JSON.stringify(compute) - }; - deepFreeze(softwareProductComponentCompute); - - const softwareProductComponentComputeData = { - qdata: compute, - dataMap, - qgenericFieldInfo: {} - }; - deepFreeze(softwareProductComponentComputeData); - - const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor', softwareProductComponentComputeData); - - mockRest.addHandler('fetch', ({options, data, baseUrl}) => { - expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/questionnaire`); - expect(data).toEqual(undefined); - expect(options).toEqual(undefined); - return softwareProductComponentCompute; - }); - - return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, version, vspComponentId}).then(() => { - expect(store.getState()).toEqual(expectedStore); - }); - }); - - it('Get Empty Software Products Components Compute', () => { - const store = storeCreator(); - deepFreeze(store.getState()); - - const compute = VSPComponentsComputeFactory.build(); - - const softwareProductComponentQuestionnaire = { - data: null, - schema: JSON.stringify(compute) - }; - deepFreeze(softwareProductComponentQuestionnaire); - - const softwareProductComponentQuestionnaireData = { - qdata: {}, - dataMap: {}, - qgenericFieldInfo: {} - }; - deepFreeze(softwareProductComponentQuestionnaireData); - - const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor', softwareProductComponentQuestionnaireData); - - mockRest.addHandler('fetch', ({options, data, baseUrl}) => { - expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/questionnaire`); - expect(data).toEqual(undefined); - expect(options).toEqual(undefined); - return softwareProductComponentQuestionnaire; - }); - - return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, version, vspComponentId}).then(() => { - expect(store.getState()).toEqual(expectedStore); - }); - }); - -}); -- cgit 1.2.3-korg