diff options
author | Avi Ziv <avi.ziv@amdocs.com> | 2017-07-18 19:45:38 +0300 |
---|---|---|
committer | Avi Ziv <avi.ziv@amdocs.com> | 2017-07-18 19:45:38 +0300 |
commit | b8e2faf476202b6ffe61bc3a9a37df1304881d40 (patch) | |
tree | f78b8c0517d8e16c5ae610bf8b49f68ea8a312a1 /openecomp-ui/test | |
parent | 75aacbbe1acf78fa53378f07f0a8c7769449a17e (diff) |
[SDC] Onboarding 1710 rebase.
Change-Id: If3b6b81d221fde13908f1e8160db6f7d9433c535
Signed-off-by: Avi Ziv <avi.ziv@amdocs.com>
Diffstat (limited to 'openecomp-ui/test')
15 files changed, 716 insertions, 160 deletions
diff --git a/openecomp-ui/test/nfvo-components/activity-log/ActivityLog.test.js b/openecomp-ui/test/activity-log/ActivityLog.test.js index 2f377a3539..00aff49b26 100644 --- a/openecomp-ui/test/nfvo-components/activity-log/ActivityLog.test.js +++ b/openecomp-ui/test/activity-log/ActivityLog.test.js @@ -17,10 +17,10 @@ import React from 'react'; import {mount} from 'enzyme'; import {cloneAndSet} from 'test-utils/Util.js'; -import ActivityLogView, {ActivityListItem} from 'nfvo-components/activity-log/ActivityLogView.jsx'; +import ActivityLogView, {ActivityListItem} from 'sdc-app/common/activity-log/ActivityLogView.jsx'; import ListEditorView from 'nfvo-components/listEditor/ListEditorView.jsx'; -import ActivityLogActionHelper from 'nfvo-components/activity-log/ActivityLogActionHelper.js'; -import {mapStateToProps} from 'nfvo-components/activity-log/ActivityLog.js'; +import ActivityLogActionHelper from 'sdc-app/common/activity-log/ActivityLogActionHelper.js'; +import {mapStateToProps} from 'sdc-app/common/activity-log/ActivityLog.js'; import {storeCreator} from 'sdc-app/AppStore.js'; import mockRest from 'test-utils/MockRest.js'; import {ActivityLogStoreFactory} from 'test-utils/factories/activity-log/ActivityLogFactories.js'; diff --git a/openecomp-ui/test/nfvo-components/listEditor/listEditor.test.js b/openecomp-ui/test/nfvo-components/listEditor/listEditor.test.js index c1f823c3fc..029ea31889 100644 --- a/openecomp-ui/test/nfvo-components/listEditor/listEditor.test.js +++ b/openecomp-ui/test/nfvo-components/listEditor/listEditor.test.js @@ -71,7 +71,7 @@ describe('listEditor Module Tests', function () { </ListEditorItemView> ); expect(itemView).toBeTruthy(); - let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'trash-o'); + let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'trashO'); TestUtils.Simulate.click(sliderIcon); }); 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 8f2b7e7e88..7d4d57eb35 100644 --- a/openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js +++ b/openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js @@ -131,8 +131,7 @@ 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('.version-controller-lock-closed'); - + let svgIcon = versionController.find('.versionControllerLockClosed'); expect(elem).toBeTruthy(); expect(elem.length).toEqual(1); expect(svgIcon.hasClass('disabled')).toBe(true); @@ -142,7 +141,7 @@ describe('versionController UI Component', () => { 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('.version-controller-lock-closed'); + let svgIcon = versionController.find('.versionControllerLockClosed'); expect(elem).toBeTruthy(); expect(elem.length).toBe(1); 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(<ComputeEditorView {...props}/>); + 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( + <ComputeFlavors + store={store} + ComputeFlavorsList={ComputeFlavorsList} + softwareProductId={softwareProductId} + componentId={componentId} + isReadOnlyMode={false}/> + ); + var renderedOutput = renderer.getRenderOutput(); + expect(renderedOutput).toBeTruthy(); + }); +}); + diff --git a/openecomp-ui/test/softwareProduct/components/compute/test.js b/openecomp-ui/test/softwareProduct/components/compute/VSPComponentComputeActionHelperHeatMode.test.js index 8d2d1fbb2f..4fe9408e34 100644 --- a/openecomp-ui/test/softwareProduct/components/compute/test.js +++ b/openecomp-ui/test/softwareProduct/components/compute/VSPComponentComputeActionHelperHeatMode.test.js @@ -21,14 +21,14 @@ 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 {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', function () { +describe('Software Product Components Compute Module Tests - HEAT mode', function () { let restPrefix = ''; @@ -41,7 +41,7 @@ describe('Software Product Components Compute Module Tests', function () { const store = storeCreator(); deepFreeze(store.getState()); - const compute = VSPComponentsComputeFactory.build(); + const compute = ComputeFlavorQData.build(); const dataMap = VSPComponentsComputeDataMapFactory.build(); const softwareProductComponentCompute = { @@ -75,7 +75,7 @@ describe('Software Product Components Compute Module Tests', function () { const store = storeCreator(); deepFreeze(store.getState()); - const compute = VSPComponentsComputeFactory.build(); + const compute = ComputeFlavorQData.build(); const softwareProductComponentQuestionnaire = { data: null, 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/general/ComponentGeneralActionHelper.test.js b/openecomp-ui/test/softwareProduct/components/general/ComponentGeneralActionHelper.test.js new file mode 100644 index 0000000000..cef4b3a16e --- /dev/null +++ b/openecomp-ui/test/softwareProduct/components/general/ComponentGeneralActionHelper.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 mockRest from 'test-utils/MockRest.js'; +import {storeCreator} from 'sdc-app/AppStore.js'; +import SoftwareProductComponentsActionHelper from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; +import {VSPComponentsFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js'; + +const softwareProductId = '123'; +const version = VersionControllerUtilsFactory.build().version; + +describe('Software Product Components Action Helper Tests', function () { + + it('Load components list', () => { + const store = storeCreator(); + deepFreeze(store.getState()); + + const expectedComponentData = VSPComponentsFactory.build(); + deepFreeze(expectedComponentData); + + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return ({results: [expectedComponentData]}); + }); + + return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(store.dispatch, {softwareProductId, version}).then(() => { + expect(store.getState().softwareProduct.softwareProductComponents.componentsList).toEqual([expectedComponentData]); + }); + + }); +}); diff --git a/openecomp-ui/test/softwareProduct/components/general/SoftwareProductComponentsGeneral.test.js b/openecomp-ui/test/softwareProduct/components/general/SoftwareProductComponentsGeneral.test.js index 4f6512ad15..edc7fca6a1 100644 --- a/openecomp-ui/test/softwareProduct/components/general/SoftwareProductComponentsGeneral.test.js +++ b/openecomp-ui/test/softwareProduct/components/general/SoftwareProductComponentsGeneral.test.js @@ -70,8 +70,7 @@ describe('SoftwareProductComponentsGeneral Mapper and View Classes', () => { const versionControllerData = VSPComponentsVersionControllerFactory.build(); const componentData = { - name: '', - description: '' + name: '' }; var renderer = TestUtils.createRenderer(); diff --git a/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js b/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js index 24658f1b30..423a7b39f6 100644 --- a/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js +++ b/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js @@ -19,11 +19,12 @@ import TestUtils from 'react-addons-test-utils'; import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.js'; import SoftwareProductComponentsMonitoringView from 'sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringView.jsx'; -import {VSPComponentsMonitoringViewFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsMonitoringFactories.js'; +import {VSPComponentsMonitoringViewFactory, trap, poll, ves} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsMonitoringFactories.js'; import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; const version = VersionControllerUtilsFactory.build(); + describe('SoftwareProductComponentsMonitoring Module Tests', function () { it('should mapper exist', () => { @@ -33,24 +34,36 @@ describe('SoftwareProductComponentsMonitoring Module Tests', function () { it('should return empty file names', () => { let softwareProduct = {softwareProductEditor: {data: {...version}}, softwareProductComponents: {monitoring: {}}}; var results = mapStateToProps({softwareProduct}); - expect(results.trapFilename).toEqual(undefined); - expect(results.pollFilename).toEqual(undefined); + expect(results.filenames[trap]).toEqual(undefined); + expect(results.filenames[poll]).toEqual(undefined); + expect(results.filenames[ves]).toEqual(undefined); }); it('should return trap file name', () => { - const monitoring = VSPComponentsMonitoringViewFactory.build({}, {snmpTrapFlag: true}); + const monitoring = VSPComponentsMonitoringViewFactory.build({}, {createTrap: true}); + let softwareProduct = {softwareProductEditor: {data: {...version}}, softwareProductComponents: {monitoring}}; + var results = mapStateToProps({softwareProduct}); + expect(results.filenames[trap]).toEqual(monitoring[trap]); + expect(results.filenames[poll]).toEqual(undefined); + expect(results.filenames[ves]).toEqual(undefined); + }); + + it('should return ves events file name', () => { + const monitoring = VSPComponentsMonitoringViewFactory.build({}, {createVes: true}); let softwareProduct = {softwareProductEditor: {data: {...version}}, softwareProductComponents: {monitoring}}; var results = mapStateToProps({softwareProduct}); - expect(results.trapFilename).toEqual(monitoring.trapFilename); - expect(results.pollFilename).toEqual(undefined); + expect(results.filenames[ves]).toEqual(monitoring[ves]); + expect(results.filenames[poll]).toEqual(undefined); + expect(results.filenames[trap]).toEqual(undefined); }); it('should return poll file names', () => { - const monitoring = VSPComponentsMonitoringViewFactory.build({}, {snmpPollFlag: true}); + const monitoring = VSPComponentsMonitoringViewFactory.build({}, {createPoll: true}); let softwareProduct = {softwareProductEditor: {data: {...version}}, softwareProductComponents: {monitoring}}; var results = mapStateToProps({softwareProduct}); - expect(results.trapFilename).toEqual(undefined); - expect(results.pollFilename).toEqual(monitoring.pollFilename); + expect(results.filenames[poll]).toEqual(monitoring[poll]); + expect(results.filenames[trap]).toEqual(undefined); + expect(results.filenames[ves]).toEqual(undefined); let renderer = TestUtils.createRenderer(); renderer.render(<SoftwareProductComponentsMonitoringView {...results} />); @@ -58,12 +71,13 @@ describe('SoftwareProductComponentsMonitoring Module Tests', function () { expect(renderedOutput).toBeTruthy(); }); - it('should return both file names', () => { - const monitoring = VSPComponentsMonitoringViewFactory.build({}, {snmpTrapFlag: true, snmpPollFlag: true}); + it('should return all file names', () => { + const monitoring = VSPComponentsMonitoringViewFactory.build({}, {createTrap: true, createVes: true, createPoll: true}); let softwareProduct = {softwareProductEditor: {data: {...version}}, softwareProductComponents: {monitoring}}; var results = mapStateToProps({softwareProduct}); - expect(results.trapFilename).toEqual(monitoring.trapFilename); - expect(results.pollFilename).toEqual(monitoring.pollFilename); + expect(results.filenames[poll]).toEqual(monitoring[poll]); + expect(results.filenames[trap]).toEqual(monitoring[trap]); + expect(results.filenames[ves]).toEqual(monitoring[ves]); let renderer = TestUtils.createRenderer(); renderer.render(<SoftwareProductComponentsMonitoringView {...results} />); diff --git a/openecomp-ui/test/softwareProduct/components/monitoring/test.js b/openecomp-ui/test/softwareProduct/components/monitoring/test.js index dd0f850a89..8fafcdb968 100644 --- a/openecomp-ui/test/softwareProduct/components/monitoring/test.js +++ b/openecomp-ui/test/softwareProduct/components/monitoring/test.js @@ -18,8 +18,9 @@ import mockRest from 'test-utils/MockRest.js'; import {storeCreator} from 'sdc-app/AppStore.js'; import SoftwareProductComponentsMonitoringConstants from 'sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringConstants.js'; import SoftwareProductComponentsMonitoringActionHelper from 'sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringActionHelper.js'; +import {fileTypes} from 'sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringConstants.js'; -import {VSPComponentsMonitoringRestFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsMonitoringFactories.js'; +import {VSPComponentsMonitoringRestFactory, trap, poll, ves} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsMonitoringFactories.js'; import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; const softwareProductId = '123'; @@ -40,171 +41,103 @@ describe('Software Product Components Monitoring Module Tests', function () { let emptyResult = VSPComponentsMonitoringRestFactory.build(); mockRest.addHandler('fetch', ({ baseUrl}) => { - expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp`); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/uploads`); return emptyResult; }); - SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, { - softwareProductId, - version, - componentId - }); - setTimeout(()=> { + return SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, {softwareProductId, version, componentId}).then(() => { var {softwareProduct: {softwareProductComponents: {monitoring}}} = store.getState(); - expect(monitoring.pollFilename).toEqual(emptyResult.snmpPoll); - expect(monitoring.trapFilename).toEqual(emptyResult.snmpTrap); + expect(monitoring[trap]).toEqual(emptyResult[trap]); + expect(monitoring[poll]).toEqual(emptyResult[poll]); + expect(monitoring[ves]).toEqual(emptyResult[ves]); done(); - }, 0); + }); + }); it('Fetch for existing files - only snmp trap file exists', done => { - let response = VSPComponentsMonitoringRestFactory.build({}, {snmpTrapFlag: true}); + let response = VSPComponentsMonitoringRestFactory.build({}, {createTrap: true}); mockRest.addHandler('fetch', ({ baseUrl}) => { - expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp`); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/uploads`); return response; }); - SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, { - softwareProductId, - version, - componentId - }); - setTimeout(()=> { - var {softwareProduct: {softwareProductComponents: {monitoring}}} = store.getState(); - expect(monitoring.pollFilename).toEqual(response.snmpPoll); - expect(monitoring.trapFilename).toEqual(response.snmpTrap); - done(); - }, 0); - }); - - it('Fetch for existing files - only snmp poll file exists', done => { - let response = VSPComponentsMonitoringRestFactory.build({}, {snmpPollFlag: true}); + return SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, {softwareProductId, version, componentId}).then(() => { - mockRest.addHandler('fetch', ({baseUrl}) => { - expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp`); - return response; - }); - - SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, { - softwareProductId, - version, - componentId - }); - setTimeout(()=> { var {softwareProduct: {softwareProductComponents: {monitoring}}} = store.getState(); - expect(monitoring.pollFilename).toEqual(response.snmpPoll); - expect(monitoring.trapFilename).toEqual(response.snmpTrap); + expect(monitoring[poll]).toEqual(undefined); + expect(monitoring[trap]).toEqual(response[trap]); + expect(monitoring[ves]).toEqual(undefined); done(); - }, 0); + }); }); - it('Fetch for existing files - both files exist', done => { - let response = VSPComponentsMonitoringRestFactory.build({}, {snmpTrapFlag: true, snmpPollFlag: true}); + + it('Fetch for existing files - all files exist', done => { + let response = VSPComponentsMonitoringRestFactory.build({}, {createSnmp: true, createPoll: true, createVes: true}); mockRest.addHandler('fetch', ({baseUrl}) => { - expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp`); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/uploads`); return response; }); - SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, { - softwareProductId, - version, - componentId - }); - setTimeout(()=> { + return SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, {softwareProductId, version, componentId}).then(() => { + var {softwareProduct: {softwareProductComponents: {monitoring}}} = store.getState(); - expect(monitoring.pollFilename).toEqual(response.snmpPoll); - expect(monitoring.trapFilename).toEqual(response.snmpTrap); + expect(monitoring[trap]).toEqual(response[trap]); + expect(monitoring[poll]).toEqual(response[poll]); + expect(monitoring[ves]).toEqual(response[ves]); done(); - }, 0); + }); }); - it('Upload snmp trap file', done => { + it('Upload file', done => { mockRest.addHandler('post', ({baseUrl}) => { - expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp-trap/upload`); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/uploads/types/${fileTypes.SNMP_TRAP}`); return {}; }); var debug = {hello: 'world'}; let file = new Blob([JSON.stringify(debug, null, 2)], {type: 'application/json'});; let formData = new FormData(); formData.append('upload', file); - SoftwareProductComponentsMonitoringActionHelper.uploadSnmpFile(store.dispatch, { + return SoftwareProductComponentsMonitoringActionHelper.uploadFile(store.dispatch, { softwareProductId, version, componentId, formData, fileSize: file.size, - type: SoftwareProductComponentsMonitoringConstants.SNMP_TRAP - }); - setTimeout(()=> { + type: fileTypes.SNMP_TRAP + }).then(() => { var {softwareProduct: {softwareProductComponents: {monitoring}}} = store.getState(); - expect(monitoring.pollFilename).toEqual(undefined); - expect(monitoring.trapFilename).toEqual('blob'); + expect(monitoring[poll]).toEqual(undefined); + expect(monitoring[ves]).toEqual(undefined); + expect(monitoring[trap]).toEqual('blob'); done(); - }, 0); - }); - it('Upload snmp poll file', done => { - mockRest.addHandler('post', ({baseUrl}) => { - expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp/upload`); - return {}; - }); - var debug = {hello: 'world'}; - let file = new Blob([JSON.stringify(debug, null, 2)], {type: 'application/json'});; - let formData = new FormData(); - formData.append('upload', file); - SoftwareProductComponentsMonitoringActionHelper.uploadSnmpFile(store.dispatch, { - softwareProductId, - version, - componentId, - formData, - fileSize: file.size, - type: SoftwareProductComponentsMonitoringConstants.SNMP_POLL }); - setTimeout(()=> { - var {softwareProduct: {softwareProductComponents: {monitoring}}} = store.getState(); - expect(monitoring.pollFilename).toEqual('blob'); - expect(monitoring.trapFilename).toEqual(undefined); - done(); - }, 0); }); it('Delete snmp trap file', done => { mockRest.addHandler('destroy', ({baseUrl}) => { - expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp-trap`); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/uploads/types/${fileTypes.SNMP_TRAP}`); return {}; }); - SoftwareProductComponentsMonitoringActionHelper.deleteSnmpFile(store.dispatch, { - softwareProductId, - version, - componentId, - type: SoftwareProductComponentsMonitoringConstants.SNMP_TRAP - }); - setTimeout(()=> { - var {softwareProduct: {softwareProductComponents: {monitoring}}} = store.getState(); - expect(monitoring.trapFilename).toEqual(undefined); - done(); - }, 0); - }); - it('Delete snmp poll file', done => { - mockRest.addHandler('destroy', ({baseUrl}) => { - expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp`); - return {}; - }); - SoftwareProductComponentsMonitoringActionHelper.deleteSnmpFile(store.dispatch, { + + return SoftwareProductComponentsMonitoringActionHelper.deleteFile(store.dispatch, { softwareProductId, version, componentId, - type: SoftwareProductComponentsMonitoringConstants.SNMP_POLL - }); - setTimeout(()=> { + type: fileTypes.SNMP_TRAP + }).then((dispatch) => { var {softwareProduct: {softwareProductComponents: {monitoring}}} = store.getState(); - expect(monitoring.pollFilename).toEqual(undefined); + expect(monitoring[trap]).toEqual(undefined); done(); - }, 0); + }); }); + + }); diff --git a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js index f5a10e23c9..b6050265a6 100644 --- a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js +++ b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js @@ -19,7 +19,7 @@ import {cloneAndSet} from 'test-utils/Util.js'; import {storeCreator} from 'sdc-app/AppStore.js'; import SoftwareProductComponentsNetworkActionHelper from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.js'; -import {VSPComponentsNicFactory, VSPComponentsNetworkFactory, VSPComponentsNetworkQDataFactory, VSPComponentsNetworkDataMapFactory, VSPComponentsNicFactoryGenericFieldInfo} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js'; +import {VSPComponentsNicPostFactory, VSPComponentsNicFactory, VSPComponentsNetworkFactory, VSPComponentsNetworkQDataFactory, VSPComponentsNetworkDataMapFactory, VSPComponentsNicFactoryGenericFieldInfo} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js'; import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; import VSPQSchemaFactory from 'test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js'; import {forms} from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js'; @@ -55,7 +55,60 @@ describe('Software Product Components Network Action Helper Tests', function () }); }); - + it('Add NIC', () => { + const store = storeCreator(); + deepFreeze(store.getState()); + + const NICPostRequest = VSPComponentsNicPostFactory.build(); + + const expectedNIC = VSPComponentsNicFactory.build({...NICPostRequest, id: nicId}); + + mockRest.addHandler('post', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics`); + expect(data).toEqual(NICPostRequest); + expect(options).toEqual(undefined); + return { + nicId + }; + }); + + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: [expectedNIC]}; + }); + + mockRest.addHandler('destroy', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics/${nicId}`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {}; + }); + + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: []}; + }); + + const network = VSPComponentsNetworkFactory.build({ + nicList: [expectedNIC] + }); + + const networkAfterDelete = VSPComponentsNetworkFactory.build(); + + let expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', network); + + return SoftwareProductComponentsNetworkActionHelper.createNIC(store.dispatch, {nic: NICPostRequest, softwareProductId, componentId, version}).then(() => { + expect(store.getState()).toEqual(expectedStore); + return SoftwareProductComponentsNetworkActionHelper.deleteNIC(store.dispatch, {softwareProductId, componentId, nicId, version}); + }).then(() => { + let expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', networkAfterDelete); + expect(store.getState()).toEqual(expectedStore); + }); + }); it('open NICE editor', () => { const store = storeCreator(); @@ -83,7 +136,7 @@ describe('Software Product Components Network Action Helper Tests', function () SoftwareProductComponentsNetworkActionHelper.openNICEditor(store.dispatch, {nic, data}); - expect(store.getState()).toEqual(expectedStore); + expect(store.getState().softwareProduct.softwareProductComponents.network).toEqual(expectedStore.softwareProduct.softwareProductComponents.network); }); it('close NICE editor', () => { @@ -102,7 +155,7 @@ describe('Software Product Components Network Action Helper Tests', function () }); it('Load NIC data', () => { - + mockRest.resetQueue(); const expectedData = VSPComponentsNicFactory.build(); deepFreeze(expectedData); @@ -121,7 +174,7 @@ describe('Software Product Components Network Action Helper Tests', function () it('load NIC Questionnaire', () => { - + mockRest.resetQueue(); const store = storeCreator(); deepFreeze(store.getState()); @@ -171,6 +224,7 @@ describe('Software Product Components Network Action Helper Tests', function () const network = { nicEditor: {}, + nicCreation: {}, nicList: [ expectedData ] diff --git a/openecomp-ui/test/softwareProduct/deployment/SoftwareProductDeploymentEditor.test.js b/openecomp-ui/test/softwareProduct/deployment/SoftwareProductDeploymentEditor.test.js new file mode 100644 index 0000000000..4277f28ee8 --- /dev/null +++ b/openecomp-ui/test/softwareProduct/deployment/SoftwareProductDeploymentEditor.test.js @@ -0,0 +1,81 @@ +/*! + * 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/softwareProduct/deployment/editor/SoftwareProductDeploymentEditor.js'; +import SoftwareProductDeploymentEditorView from 'sdc-app/onboarding/softwareProduct/deployment/editor/SoftwareProductDeploymentEditorView.jsx'; +import { VSPComponentsFactory } from 'test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js'; +import { VSPEditorFactoryWithLicensingData } from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import { FeatureGroupStoreFactory } from 'test-utils/factories/licenseModel/FeatureGroupFactories.js'; + +describe('Software Product Deployment Editor Module Tests', function () { + + it('should mapper exist', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + it('should return empty data', () => { + + const currentSoftwareProduct = VSPEditorFactoryWithLicensingData.build(); + const componentsList = VSPComponentsFactory.buildList(1); + const featureGroupsList = FeatureGroupStoreFactory.buildList(2); + + var state = { + softwareProduct: { + softwareProductEditor: { + data: currentSoftwareProduct + }, + softwareProductDeployment: + { + deploymentFlavors: [], + deploymentFlavorEditor: {data: {}} + }, + softwareProductComponents: { + componentsList, + computeFlavor: { + computesList: [] + } + } + }, + licenseModel: { + featureGroup: { + featureGroupsList + } + } + }; + + var results = mapStateToProps(state); + expect(results.data).toEqual({}); + }); + + it('jsx view test', () => { + const componentsList = VSPComponentsFactory.buildList(1); + var renderer = TestUtils.createRenderer(); + renderer.render( + <SoftwareProductDeploymentEditorView + isReadOnlyMode={true} + selectedFeatureGroupsList={[]} + componentsList={componentsList} + data={{}} + onDataChanged={() => {}} + onSubmit={() => {}} + onClose={() => {}}/> + ); + var renderedOutput = renderer.getRenderOutput(); + expect(renderedOutput).toBeTruthy(); + }); + +}); diff --git a/openecomp-ui/test/softwareProduct/deployment/SoftwareProductDeploymentView.test.js b/openecomp-ui/test/softwareProduct/deployment/SoftwareProductDeploymentView.test.js new file mode 100644 index 0000000000..9700efe98a --- /dev/null +++ b/openecomp-ui/test/softwareProduct/deployment/SoftwareProductDeploymentView.test.js @@ -0,0 +1,77 @@ +/*! + * 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/softwareProduct/deployment/SoftwareProductDeployment.js'; +import SoftwareProductDeploymentView from 'sdc-app/onboarding/softwareProduct/deployment/SoftwareProductDeploymentView.jsx'; + +import {VSPDeploymentStoreFactory} from 'test-utils/factories/softwareProduct/SoftwareProductDeploymentFactories.js'; +import {VSPComponentsFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js'; +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; + +describe('SoftwareProductDeployment Mapper and View Classes', () => { + it ('mapStateToProps mapper exists', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + it ('mapStateToProps data test', () => { + + const currentSoftwareProduct = VSPEditorFactory.build(); + + const deploymentFlavors = VSPDeploymentStoreFactory.buildList(2); + + const componentsList = VSPComponentsFactory.buildList(1); + + var state = { + softwareProduct: { + softwareProductEditor: { + data: currentSoftwareProduct + }, + softwareProductDeployment: + { + deploymentFlavors, + deploymentFlavorsEditor: {data: {}} + }, + softwareProductComponents: { + componentsList + } + } + }; + var results = mapStateToProps(state); + expect(results.deploymentFlavors).toBeTruthy(); + }); + + it ('view simple test', () => { + + const currentSoftwareProduct = VSPEditorFactory.build(); + + const deploymentFlavors = VSPDeploymentStoreFactory.buildList(2); + + var renderer = TestUtils.createRenderer(); + renderer.render( + <SoftwareProductDeploymentView + deploymentFlavors={deploymentFlavors} + currentSoftwareProduct={currentSoftwareProduct} + onAddDeployment={() => {}} + onEditDeployment={() => {}} + onDeleteDeployment={() => {}} + isReadOnlyMode={false} /> + ); + var renderedOutput = renderer.getRenderOutput(); + expect(renderedOutput).toBeTruthy(); + + }); +}); diff --git a/openecomp-ui/test/softwareProduct/landingPage/landingPage.test.js b/openecomp-ui/test/softwareProduct/landingPage/landingPage.test.js index f06ad61e4f..4da0ec98d4 100644 --- a/openecomp-ui/test/softwareProduct/landingPage/landingPage.test.js +++ b/openecomp-ui/test/softwareProduct/landingPage/landingPage.test.js @@ -28,6 +28,8 @@ import {default as VspQdataFactory} from 'test-utils/factories/softwareProduct/ import {VSPComponentsFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js'; import {FinalizedLicenseModelFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js'; +import { Provider } from 'react-redux'; +import {storeCreator} from 'sdc-app/AppStore.js'; import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js'; import SoftwareProductLandingPageView from 'sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx'; @@ -95,8 +97,9 @@ describe('Software Product Landing Page: ', function () { componentsList: VSPComponentsFactory.buildList(2) }; - let vspLandingView = TestUtils.renderIntoDocument(<SoftwareProductLandingPageView - {...params}/>); + const store = storeCreator(); + let vspLandingView = TestUtils.renderIntoDocument(<Provider store={store}><SoftwareProductLandingPageView + {...params}/></Provider>); expect(vspLandingView).toBeTruthy(); }); @@ -108,11 +111,16 @@ describe('Software Product Landing Page: ', function () { componentsList: VSPComponentsFactory.buildList(2) }; - let vspLandingView = TestUtils.renderIntoDocument(<SoftwareProductLandingPageView - {...params}/>); + const store = storeCreator(); + let vspLandingView = TestUtils.renderIntoDocument(<Provider store={store}><SoftwareProductLandingPageView + {...params}/></Provider>); + let vspLandingViewWrapper = TestUtils.findRenderedComponentWithType( + vspLandingView, + SoftwareProductLandingPageView + ); expect(vspLandingView).toBeTruthy(); - vspLandingView.handleOnDragEnter(false); - expect(vspLandingView.state.dragging).toEqual(true); + vspLandingViewWrapper.handleOnDragEnter(false); + expect(vspLandingViewWrapper.state.dragging).toEqual(true); }); @@ -126,10 +134,7 @@ describe('Software Product Landing Page: ', function () { onUpload: dummyFunc, onInvalidFileSizeUpload: dummyFunc }; - - let vspLandingView = TestUtils.renderIntoDocument(<SoftwareProductLandingPageView - {...params}/>); - expect(vspLandingView).toBeTruthy(); + const files = [ { name: 'aaa', @@ -137,16 +142,24 @@ describe('Software Product Landing Page: ', function () { } ]; - vspLandingView.handleImportSubmit(files, false); - expect(vspLandingView.state.dragging).toEqual(false); - expect(vspLandingView.state.fileName).toEqual(files[0].name); + const store = storeCreator(); + + let vspLandingView = TestUtils.renderIntoDocument(<Provider store={store}><SoftwareProductLandingPageView {...params}/></Provider>); + let vspLandingViewWrapper = TestUtils.findRenderedComponentWithType( + vspLandingView, + SoftwareProductLandingPageView + ); + expect(vspLandingView).toBeTruthy(); + vspLandingViewWrapper.handleImportSubmit(files, false); + expect(vspLandingViewWrapper.state.dragging).toEqual(false); + expect(vspLandingViewWrapper.state.fileName).toEqual(files[0].name); const files1 = [ { name: 'bbb', size: 0 } ]; - vspLandingView.handleImportSubmit(files1, false); + vspLandingViewWrapper.handleImportSubmit(files1, false); }); it('vsp landing handleImportSubmit with damaged file test ', () => { @@ -160,8 +173,15 @@ describe('Software Product Landing Page: ', function () { onInvalidFileSizeUpload: dummyFunc }; - let vspLandingView = TestUtils.renderIntoDocument(<SoftwareProductLandingPageView - {...params}/>); + const store = storeCreator(); + + let vspLandingView = TestUtils.renderIntoDocument(<Provider store={store}><SoftwareProductLandingPageView + {...params}/></Provider>); + + let vspLandingViewWrapper = TestUtils.findRenderedComponentWithType( + vspLandingView, + SoftwareProductLandingPageView + ); expect(vspLandingView).toBeTruthy(); const files = [ { @@ -170,8 +190,8 @@ describe('Software Product Landing Page: ', function () { } ]; - vspLandingView.handleImportSubmit(files, false); - expect(vspLandingView.state.dragging).toEqual(false); - expect(vspLandingView.state.fileName).toEqual(''); + vspLandingViewWrapper.handleImportSubmit(files, false); + expect(vspLandingViewWrapper.state.dragging).toEqual(false); + expect(vspLandingViewWrapper.state.fileName).toEqual(''); }); }); |