diff options
Diffstat (limited to 'openecomp-ui/test/softwareProduct/components/network')
3 files changed, 129 insertions, 278 deletions
diff --git a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js index c9760f7799..094b95a091 100644 --- a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js +++ b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js @@ -1,55 +1,42 @@ -/*- - * ============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 'expect'; import React from 'react'; import TestUtils from 'react-addons-test-utils'; import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNICEditor.js'; import SoftwareProductComponentsNICEditorView from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNICEditorView.jsx'; - +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import {SoftwareProductFactory} from 'test-utils/factories/softwareProduct/SoftwareProductFactory.js'; +import {VSPComponentsNicFactory, VSPComponentsNetworkQDataFactory, VSPComponentsNicFactoryQGenericFieldInfo, + VSPComponentsNicFactoryGenericFieldInfo, VSPComponentsNetworkDataMapFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js'; describe('Software Product Component Network NIC Editor and View Classes', () => { it('mapStateToProps mapper exists', () => { - expect(mapStateToProps).toExist(); + expect(mapStateToProps).toBeTruthy(); }); it('mapStateToProps data test', () => { - const currentSoftwareProduct = { - name: 'VSp', - description: 'dfdf', - vendorName: 'V1', - vendorId: '97B3E2525E0640ACACF87CE6B3753E80', - category: 'resourceNewCategory.application l4+', - subCategory: 'resourceNewCategory.application l4+.database', - id: 'D4774719D085414E9D5642D1ACD59D20', - version: '0.10', - viewableVersions: ['0.1', '0.2'], - lockingUser: 'cs0008' - }; + const currentSoftwareProduct = VSPEditorFactory.build(); var obj = { - softwareProduct: { + softwareProduct: SoftwareProductFactory.build({ softwareProductEditor: { data: currentSoftwareProduct }, @@ -58,40 +45,42 @@ describe('Software Product Component Network NIC Editor and View Classes', () => nicEditor: { data: {}, qdata: {}, - qschema: {} + dataMap: {}, + qgenericFieldInfo: {}, + genericFieldInfo: {} } } } - } + }) }; var results = mapStateToProps(obj); - expect(results.currentSoftwareProduct).toExist(); - expect(results.qdata).toExist(); - expect(results.qschema).toExist(); - expect(results.data).toExist(); + expect(results.currentSoftwareProduct).toBeTruthy(); + expect(results.qdata).toBeTruthy(); + expect(results.dataMap).toBeTruthy(); + expect(results.genericFieldInfo).toBeTruthy(); + expect(results.qgenericFieldInfo).toBeTruthy(); + expect(results.data).toBeTruthy(); }); it('Software Product Component Network NIC Editor View Test', () => { - const data = { - name: '', - description: '', - networkName: '' + const props = { + data: VSPComponentsNicFactory.build(), + qdata: VSPComponentsNetworkQDataFactory.build(), + dataMap: VSPComponentsNetworkDataMapFactory.build(), + genericFieldInfo: VSPComponentsNicFactoryGenericFieldInfo.build(), + qgenericFieldInfo: VSPComponentsNicFactoryQGenericFieldInfo.build(), + isFormValid: true, + formReady: false, + protocols: [] }; - const qdata = {}; - const qschema = {}; - var renderer = TestUtils.createRenderer(); - renderer.render( - <SoftwareProductComponentsNICEditorView - data={data} - qdata={qdata} - qschema={qschema}/>); + renderer.render(<SoftwareProductComponentsNICEditorView {...props}/>); var renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); }); }); diff --git a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetwork.test.js b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetwork.test.js index 520fde7403..d35659c93b 100644 --- a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetwork.test.js +++ b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetwork.test.js @@ -1,110 +1,75 @@ -/*- - * ============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 'expect'; import React from 'react'; import TestUtils from 'react-addons-test-utils'; import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkList.js'; import SoftwareProductComponentsNetworkListView from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkListView.jsx'; -import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; +import {SoftwareProductFactory} from 'test-utils/factories/softwareProduct/SoftwareProductFactory.js'; +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import {VSPComponentsNicWithIdFactory, VSPComponentsVersionControllerFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js'; describe('Software Product Component Network Mapper and View Classes', () => { it('mapStateToProps mapper exists', () => { - expect(mapStateToProps).toExist(); + expect(mapStateToProps).toBeTruthy(); }); it('mapStateToProps data test', () => { - const currentSoftwareProduct = { - name: 'VSp', - description: 'dfdf', - vendorName: 'V1', - vendorId: '97B3E2525E0640ACACF87CE6B3753E80', - category: 'resourceNewCategory.application l4+', - subCategory: 'resourceNewCategory.application l4+.database', - id: 'D4774719D085414E9D5642D1ACD59D20', - version: '0.10', - viewableVersions: ['0.1', '0.2'], - status: versionStatusEnum.CHECK_OUT_STATUS, - lockingUser: 'cs0008' - }; + const currentSoftwareProduct = VSPEditorFactory.build(); var obj = { - softwareProduct: { + softwareProduct: SoftwareProductFactory.build({ softwareProductEditor: { data: currentSoftwareProduct }, softwareProductComponents: { componentEditor: { qdata: {}, - qschema: {}, - data: {} + data: {}, + dataMap: {}, + qgenericFieldInfo: {}, + isFormValid: true, + formReady: false }, network: { nicEditor: {}, nicList: [] } } - } + }) }; var results = mapStateToProps(obj); - expect(results.qdata).toExist(); - expect(results.qschema).toExist(); - expect(results.componentData).toExist(); + expect(results.qdata).toBeTruthy(); + expect(results.dataMap).toBeTruthy(); + expect(results.qgenericFieldInfo).toBeTruthy(); + expect(results.componentData).toBeTruthy(); }); it('Software Product Component Network List View Test', () => { - const currentSoftwareProduct = { - name: 'VSp', - description: 'dfdf', - vendorName: 'V1', - vendorId: '97B3E2525E0640ACACF87CE6B3753E80', - category: 'resourceNewCategory.application l4+', - subCategory: 'resourceNewCategory.application l4+.database', - id: 'D4774719D085414E9D5642D1ACD59D20', - version: '0.10', - viewableVersions: ['0.1', '0.2'], - status: versionStatusEnum.CHECK_IN_STATUS, - lockingUser: 'cs0008' - }; + const currentSoftwareProduct = VSPEditorFactory.build(); - const versionControllerData = { - version: '1', - viewableVersions: [], - status: 'locked', - isCheckedOut: true - }; + const versionControllerData = VSPComponentsVersionControllerFactory.build(); - const nicList = [ - { - name: 'name', - networkId: 'network', - id: '122', - networkName: 'nname' - } - ]; + const nicList = VSPComponentsNicWithIdFactory.buildList(1); var renderer = TestUtils.createRenderer(); renderer.render( @@ -115,7 +80,7 @@ describe('Software Product Component Network Mapper and View Classes', () => { componentId='321' nicList={nicList}/>); var renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); diff --git a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js index 8c23267c89..f5a10e23c9 100644 --- a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js +++ b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js @@ -1,33 +1,33 @@ -/*- - * ============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 {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 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'; + const softwareProductId = '123'; const componentId = '321'; const nicId = '111'; +const version = VersionControllerUtilsFactory.build().version; describe('Software Product Components Network Action Helper Tests', function () { @@ -35,23 +35,7 @@ describe('Software Product Components Network Action Helper Tests', function () const store = storeCreator(); deepFreeze(store.getState()); - const NICList = [ - { - name:'oam01_port_0', - description:'bbbbbbb', - networkId:'A0E578751B284D518ED764D5378EA97C', - id:'96D3648338F94DAA9889E9FBB8E59895', - networkName:'csb_net' - }, - { - name:'oam01_port_1', - description:'bbbbbbb', - networkId:'378EA97CA0E578751B284D518ED764D5', - id:'8E5989596D3648338F94DAA9889E9FBB', - networkName:'csb_net_2' - } - - ]; + const NICList = VSPComponentsNicFactory.buildList(2); deepFreeze(NICList); @@ -60,14 +44,14 @@ describe('Software Product Components Network Action Helper Tests', function () const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network.nicList', NICList); mockRest.addHandler('fetch', ({options, data, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/nics`); - expect(data).to.deep.equal(undefined); - expect(options).to.equal(undefined); + 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: NICList}; }); - return SoftwareProductComponentsNetworkActionHelper.fetchNICsList(store.dispatch, {softwareProductId, componentId}).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + return SoftwareProductComponentsNetworkActionHelper.fetchNICsList(store.dispatch, {softwareProductId, version, componentId}).then(() => { + expect(store.getState()).toEqual(expectedStore); }); }); @@ -76,12 +60,8 @@ describe('Software Product Components Network Action Helper Tests', function () const store = storeCreator(); deepFreeze(store.getState()); - const data = { - name: 'oam01_port_0', - description: 'bbbbbbb', - networkId: 'A0E578751B284D518ED764D5378EA97C', - networkName: 'csb_net' - }; + const data = VSPComponentsNicFactory.build(); + const genericFieldInfo = VSPComponentsNicFactoryGenericFieldInfo.build(); const nic = {id: '444'}; deepFreeze(data); @@ -91,20 +71,19 @@ describe('Software Product Components Network Action Helper Tests', function () deepFreeze(expectedData); - const network = { + const network = VSPComponentsNetworkFactory.build({ nicEditor: { - data: expectedData - }, - nicList: [] - }; + data: expectedData, + formName: forms.NIC_EDIT_FORM, + genericFieldInfo + } + }); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', network); SoftwareProductComponentsNetworkActionHelper.openNICEditor(store.dispatch, {nic, data}); - return setTimeout(() => { - expect(store.getState()).to.deep.equal(expectedStore); - }, 100); + expect(store.getState()).toEqual(expectedStore); }); it('close NICE editor', () => { @@ -112,41 +91,31 @@ describe('Software Product Components Network Action Helper Tests', function () const store = storeCreator(); deepFreeze(store.getState()); - const network = { - nicEditor: {}, - nicList: [] - }; + const network = VSPComponentsNetworkFactory.build(); deepFreeze(network); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', network); SoftwareProductComponentsNetworkActionHelper.closeNICEditor(store.dispatch); - return setTimeout(() => { - expect(store.getState()).to.deep.equal(expectedStore); - }, 100); + expect(store.getState()).toEqual(expectedStore); }); it('Load NIC data', () => { - const expectedData = { - description: 'bbbbbbb', - name: 'oam01_port_0', - networkId: 'A0E578751B284D518ED764D5378EA97C', - networkName: 'csb_net' - }; + const expectedData = VSPComponentsNicFactory.build(); deepFreeze(expectedData); mockRest.addHandler('fetch', ({options, data, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/nics/${nicId}`); - expect(data).to.deep.equal(undefined); - expect(options).to.equal(undefined); + 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 (expectedData); }); - return SoftwareProductComponentsNetworkActionHelper.loadNICData({softwareProductId, componentId, nicId}).then((data) => { - expect(data).to.deep.equal(expectedData); + return SoftwareProductComponentsNetworkActionHelper.loadNICData({softwareProductId, version, componentId, nicId}).then((data) => { + expect(data).toEqual(expectedData); }); }); @@ -156,119 +125,47 @@ describe('Software Product Components Network Action Helper Tests', function () const store = storeCreator(); deepFreeze(store.getState()); - const qdata = { - protocols: { - protocolWithHighestTrafficProfile: 'UDP', - protocols: ['UDP'] - }, - ipConfiguration: { - ipv4Required: true - } - }; - - const qschema = { - $schema: 'http://json-schema.org/draft-04/schema#', - type: 'object', - properties: { - 'protocols': { - type: 'object', - properties: {} - } - } - }; + const qdata = VSPComponentsNetworkQDataFactory.build(); + const dataMap = VSPComponentsNetworkDataMapFactory.build(); + const qgenericFieldInfo = {}; + const qschema = VSPQSchemaFactory.build(); deepFreeze(qdata); + deepFreeze(dataMap); deepFreeze(qschema); - const network = { + const network = VSPComponentsNetworkFactory.build({ nicEditor: { qdata, - qschema - }, - nicList: [] - }; + dataMap, + qgenericFieldInfo + } + }); deepFreeze(network); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', network); mockRest.addHandler('fetch', ({options, data, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/nics/${nicId}/questionnaire`); - expect(data).to.deep.equal(undefined); - expect(options).to.equal(undefined); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics/${nicId}/questionnaire`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); return ({data: JSON.stringify(qdata), schema: JSON.stringify(qschema)}); }); - return SoftwareProductComponentsNetworkActionHelper.loadNICQuestionnaire(store.dispatch, {softwareProductId, componentId, nicId}).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + return SoftwareProductComponentsNetworkActionHelper.loadNICQuestionnaire(store.dispatch, {softwareProductId, version, componentId, nicId}).then(() => { + expect(store.getState()).toEqual(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); - it('update NIC Data', () => { - const store = storeCreator(); - deepFreeze(store.getState()); - - const data = {test: '123'}; - deepFreeze(data); - - const network = { - nicEditor: { - data - }, - nicList: [] - }; - - deepFreeze(network); - - const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', network); - - SoftwareProductComponentsNetworkActionHelper.updateNICData(store.dispatch, {deltaData:data}); - - return setTimeout(() => { - expect(store.getState()).to.deep.equal(expectedStore); - }, 100); - - }); - - it('update NIC Questionnaire', () => { - const store = storeCreator(); - deepFreeze(store.getState()); - - const qdata = { - test: '123' - }; - const network = { - nicEditor: { - qdata, - qschema: undefined - }, - nicList: [] - }; - deepFreeze(network); - - const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', network); - - SoftwareProductComponentsNetworkActionHelper.updateNICQuestionnaire(store.dispatch, {data:qdata}); - - return setTimeout(() => { - expect(store.getState()).to.deep.equal(expectedStore); - }, 100); - - }); - it('save NIC Data And Questionnaire', () => { const store = storeCreator(); deepFreeze(store.getState()); - const qdata = { - qtest: '111' - }; - const data = { - name: '2222', - description: 'blabla', - networkId: '123445' - }; + const qdata = VSPComponentsNetworkQDataFactory.build(); + const data = VSPComponentsNicFactory.build(); const expectedData = {...data, id: nicId}; @@ -282,22 +179,22 @@ describe('Software Product Components Network Action Helper Tests', function () const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', network); deepFreeze(expectedStore); - mockRest.addHandler('save', ({options, data, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/nics/${nicId}/questionnaire`); - expect(data).to.deep.equal(qdata); - expect(options).to.equal(undefined); + mockRest.addHandler('put', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics/${nicId}/questionnaire`); + expect(data).toEqual(qdata); + expect(options).toEqual(undefined); return {returnCode: 'OK'}; }); - mockRest.addHandler('save', ({options, data, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/nics/${nicId}`); - expect(data).to.deep.equal(data); - expect(options).to.equal(undefined); + mockRest.addHandler('put', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics/${nicId}`); + expect(data).toEqual(data); + expect(options).toEqual(undefined); return {returnCode: 'OK'}; }); - return SoftwareProductComponentsNetworkActionHelper.saveNICDataAndQuestionnaire(store.dispatch, {softwareProductId, componentId, qdata, data: expectedData}).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + return SoftwareProductComponentsNetworkActionHelper.saveNICDataAndQuestionnaire(store.dispatch, {softwareProductId, version, componentId, qdata, data: expectedData}).then(() => { + expect(store.getState()).toEqual(expectedStore); }); }); |