From 280f8015d06af1f41a3ef12e8300801c7a5e0d54 Mon Sep 17 00:00:00 2001 From: AviZi Date: Fri, 9 Jun 2017 02:39:56 +0300 Subject: [SDC-29] Amdocs OnBoard 1707 initial commit. Change-Id: Ie4d12a3f574008b792899b368a0902a8b46b5370 Signed-off-by: AviZi --- .../SoftwareProductAttachmentsView.test.js | 214 ++------- .../SoftwareproductAttachmentsHelper.test.js | 153 ------- .../attachments/setup/heatSetup.test.js | 49 ++ .../setup/heatSetupActionHelper.test.js | 142 ++++++ .../validation/HeatValidationActionHelper.test.js | 144 ++++++ .../validation/HeatValidationView.test.js | 184 ++++++++ .../softwareProduct/components/compute/test.js | 85 ++-- .../SoftwareProductComponentsGeneral.test.js | 90 ++-- .../softwareProductComponentLoadbalancing.test.js | 87 +--- .../SoftwareProductComponentsMonitoring.test.js | 53 +-- .../softwareProduct/components/monitoring/test.js | 73 ++- .../SoftwareProductComponentsNICEditor.test.js | 83 ++-- .../SoftwareProductComponentsNetwork.test.js | 91 ++-- ...areProductComponentsNetworkActionHelper.test.js | 233 +++------- ...oftwareProductComponentsProcessesEditor.test.js | 57 +++ .../SoftwareProductComponentsProcessesView.test.js | 77 ++++ .../softwareProduct/components/processes/test.js | 191 ++++---- .../softwareProduct/components/storage/test.js | 85 ++-- .../test/softwareProduct/components/test.js | 65 +-- .../creation/SoftwareProductCreation.test.js | 105 +++++ .../SoftwareProductDependencies.test.js | 210 +++++++++ .../softwareProduct/details/detailsView.test.js | 415 +++++++---------- openecomp-ui/test/softwareProduct/details/test.js | 494 +++++++++++---------- .../test/softwareProduct/details/vspQschema.js | 20 +- .../landingPage/landingPage.test.js | 177 ++++++++ .../networks/SoftwareProductNetworksView.test.js | 94 +--- .../softwareProductNetworksActionHelper.test.js | 49 +- .../processes/SoftwareProductEditor.test.js | 62 +++ .../processes/SoftwareProductProcessesView.test.js | 75 ++++ .../test/softwareProduct/processes/test.js | 338 ++++++-------- 30 files changed, 2369 insertions(+), 1826 deletions(-) delete mode 100644 openecomp-ui/test/softwareProduct/attachments/SoftwareproductAttachmentsHelper.test.js create mode 100644 openecomp-ui/test/softwareProduct/attachments/setup/heatSetup.test.js create mode 100644 openecomp-ui/test/softwareProduct/attachments/setup/heatSetupActionHelper.test.js create mode 100644 openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationActionHelper.test.js create mode 100644 openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationView.test.js create mode 100644 openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesEditor.test.js create mode 100644 openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesView.test.js create mode 100644 openecomp-ui/test/softwareProduct/creation/SoftwareProductCreation.test.js create mode 100644 openecomp-ui/test/softwareProduct/dependencies/SoftwareProductDependencies.test.js create mode 100644 openecomp-ui/test/softwareProduct/landingPage/landingPage.test.js create mode 100644 openecomp-ui/test/softwareProduct/processes/SoftwareProductEditor.test.js create mode 100644 openecomp-ui/test/softwareProduct/processes/SoftwareProductProcessesView.test.js (limited to 'openecomp-ui/test/softwareProduct') diff --git a/openecomp-ui/test/softwareProduct/attachments/SoftwareProductAttachmentsView.test.js b/openecomp-ui/test/softwareProduct/attachments/SoftwareProductAttachmentsView.test.js index 839176c970..5dfe98f273 100644 --- a/openecomp-ui/test/softwareProduct/attachments/SoftwareProductAttachmentsView.test.js +++ b/openecomp-ui/test/softwareProduct/attachments/SoftwareProductAttachmentsView.test.js @@ -1,198 +1,76 @@ -/*- - * ============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/attachments/SoftwareProductAttachments.js'; +import {VSPAttachmentTreeNodeWithChildrenFactory, VSPAttachmentDetailedError} from 'test-utils/factories/softwareProduct/SoftwareProductAttachmentsFactories.js'; +import {defaultStoreFactory} from 'test-utils/factories/onboard/OnboardingCatalogFactories.js'; +import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachments.js'; import SoftwareProductAttachmentsView from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsView.jsx'; -import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; +import {tabsMapping} from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsConstants.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; - -describe('SoftwareProductAttachments Modal Mapper and View Classes', () => { - - it ('mapStateToProps mapper exists', () => { - expect(mapStateToProps).toExist(); +describe('SoftwareProduct Attachments - View: ', function () { + it('should mapper exist', () => { + expect(mapStateToProps).toBeTruthy(); }); + it('should mapper return default data', () => { - it ('mapStateToProps check data', () => { + let attachmentsTree = VSPAttachmentTreeNodeWithChildrenFactory.build(); + let errorList = VSPAttachmentDetailedError.buildList(3); + let versionControllerData = VersionControllerUtilsFactory.build(); - 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 atTree = { - 'children': [ - { - 'name': 'HEAT', - 'expanded': true, - 'type': 'heat', - 'children': [ - { - 'name': 'heat_zxeyCtMHhf2.yaml', - 'expanded': true, - 'type': 'heat', - 'errors': [ - { - 'level': 'WARNING', - 'message': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4' - } - ], - 'children': [ - { - 'name': 'heat_env_zxeyCtMHhf2.env', - 'type': 'env' - } - ] - } - ] - } - ] - }; - const errorList = [ - { - 'errorLevel': 'WARNING', - 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4', - 'name': 'heat_zxeyCtMHhf2.yaml', - 'hasParent': false, - 'parentName': 'HEAT', - 'type': 'heat' + let softwareProductAttachments = { + heatSetup: {}, + heatValidation: { + attachmentsTree, + errorList }, - { - 'errorLevel': 'WARNING', - 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_3', - 'name': 'heat_zxeyCtMHhf2.yaml', - 'hasParent': false, - 'parentName': 'HEAT', - 'type': 'heat' - } - ]; - - var obj = { - softwareProduct: { - softwareProductEditor: { - data:currentSoftwareProduct - }, softwareProductAttachments: - { - attachmentsTree: atTree, - errorList: errorList - } - } + heatSetupCache: {}, + activeTab: tabsMapping.SETUP }; - - var results = mapStateToProps(obj); - expect(results.attachmentsTree).toExist(); - expect(results.errorList).toExist(); - expect(results.hoveredNode).toBe(undefined); - expect(results.selectedNode).toBe(undefined); + let data = defaultStoreFactory.build({softwareProduct: {softwareProductAttachments, softwareProductEditor: {data: {...versionControllerData}}}}); + var result = mapStateToProps(data); + expect(result).toBeTruthy(); + expect(result.isValidationAvailable).toBe(false); }); + it('view test', () => { - it('function does exist', () => { + let attachmentsTree = VSPAttachmentTreeNodeWithChildrenFactory.build(); + let errorList = VSPAttachmentDetailedError.buildList(3); + let versionControllerData = VersionControllerUtilsFactory.build(); - 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 versionControllerData = { - version: currentSoftwareProduct.version, - viewableVersions:currentSoftwareProduct.viewableVersions, - status: currentSoftwareProduct.status, - isCheckedOut: true - }; - const atTree = { - 'children': [ - { - 'name': 'HEAT', - 'expanded': true, - 'type': 'heat', - 'children': [ - { - 'name': 'heat_zxeyCtMHhf2.yaml', - 'expanded': true, - 'type': 'heat', - 'errors': [ - { - 'level': 'WARNING', - 'message': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4' - } - ], - 'children': [ - { - 'name': 'heat_env_zxeyCtMHhf2.env', - 'type': 'env' - } - ] - } - ] - } - ] - }; - const errorList = [ - { - 'errorLevel': 'WARNING', - 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4', - 'name': 'heat_zxeyCtMHhf2.yaml', - 'hasParent': false, - 'parentName': 'HEAT', - 'type': 'heat' + let softwareProductAttachments = { + heatSetup: {}, + heatValidation: { + attachmentsTree, + errorList }, - { - 'errorLevel': 'WARNING', - 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_3', - 'name': 'heat_zxeyCtMHhf2.yaml', - 'hasParent': false, - 'parentName': 'HEAT', - 'type': 'heat' - } - ]; - + shouldOpenValidationTab: false + }; + let data = defaultStoreFactory.build({softwareProduct: {softwareProductAttachments, softwareProductEditor: {data: {...versionControllerData}}}}); + var params = mapStateToProps(data); var renderer = TestUtils.createRenderer(); - renderer.render(); + renderer.render(); var renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); }); }); diff --git a/openecomp-ui/test/softwareProduct/attachments/SoftwareproductAttachmentsHelper.test.js b/openecomp-ui/test/softwareProduct/attachments/SoftwareproductAttachmentsHelper.test.js deleted file mode 100644 index 851560caa8..0000000000 --- a/openecomp-ui/test/softwareProduct/attachments/SoftwareproductAttachmentsHelper.test.js +++ /dev/null @@ -1,153 +0,0 @@ -/*- - * ============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 - * - * 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========================================================= - */ - -import expect from 'expect'; -import SoftwareProductAttachmentsActionHelper from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsActionHelper.js'; -import {storeCreator} from 'sdc-app/AppStore.js'; -import deepFreeze from 'deep-freeze'; -import {actionTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; - - - - - - -describe('SoftwareProductAttachments ActionHelper', () => { - - it('function does exist', () => { - expect(SoftwareProductAttachmentsActionHelper).toExist(); - }); - - it('toggleExpanded function check', () => { - - - const validationData = { - importStructure: { - HEAT: [ - { - fileName: 'hot-mog-0108-bs1271.yml', - env: { - fileName: 'hot-mog-0108-bs1271.env' - }, - errors: [ - { - 'level': 'WARNING', - 'message': 'Port not bind to any NOVA Server, Resource Id [sm02_port_2]' - }, - { - 'level': 'WARNING', - 'message': 'Port not bind to any NOVA Server, Resource Id [sm01_port_2]' - } - ] - } - ] - } - }; - - 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: 'Locked', - lockingUser: 'cs0008', - validationData - }; - - - const store = storeCreator(); - deepFreeze(store.getState()); - deepFreeze(currentSoftwareProduct); - - store.dispatch({ - type:actionTypes.SOFTWARE_PRODUCT_LOADED, - response: currentSoftwareProduct - }); - - expect(store.getState().softwareProduct.softwareProductAttachments.attachmentsTree.children[0].expanded).toBe(true); - SoftwareProductAttachmentsActionHelper.toggleExpanded(store.dispatch, {path:[0]}); - expect(store.getState().softwareProduct.softwareProductAttachments.attachmentsTree.children[0].expanded).toBe(false); - }); - - it('onSelectNode & onUnselectNode function check', () => { - - - const validationData = { - importStructure: { - HEAT: [ - { - fileName: 'hot-mog-0108-bs1271.yml', - env: { - fileName: 'hot-mog-0108-bs1271.env' - }, - errors: [ - { - 'level': 'WARNING', - 'message': 'Port not bind to any NOVA Server, Resource Id [sm02_port_2]' - }, - { - 'level': 'WARNING', - 'message': 'Port not bind to any NOVA Server, Resource Id [sm01_port_2]' - } - ] - } - ] - } - }; - - 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: 'Locked', - lockingUser: 'cs0008', - validationData - }; - - deepFreeze(currentSoftwareProduct); - - const store = storeCreator(); - deepFreeze(store.getState()); - - store.dispatch({ - type:actionTypes.SOFTWARE_PRODUCT_LOADED, - response: currentSoftwareProduct - }); - let expectedNodeName = 'name'; - expect(store.getState().softwareProduct.softwareProductAttachments.selectedNode).toBe(undefined); - SoftwareProductAttachmentsActionHelper.onSelectNode(store.dispatch, {nodeName:expectedNodeName}); - expect(store.getState().softwareProduct.softwareProductAttachments.selectedNode).toBe(expectedNodeName); - SoftwareProductAttachmentsActionHelper.onUnselectNode(store.dispatch); - expect(store.getState().softwareProduct.softwareProductAttachments.selectedNode).toBe(undefined); - }); - - -}); diff --git a/openecomp-ui/test/softwareProduct/attachments/setup/heatSetup.test.js b/openecomp-ui/test/softwareProduct/attachments/setup/heatSetup.test.js new file mode 100644 index 0000000000..80e9401f1a --- /dev/null +++ b/openecomp-ui/test/softwareProduct/attachments/setup/heatSetup.test.js @@ -0,0 +1,49 @@ +/*! + * 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/attachments/setup/HeatSetup.js'; +import HeatSetupView from 'sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupView.jsx'; +import {storeCreator} from 'sdc-app/AppStore.js'; + +describe('Heat Setup View test: ', function () { + it('should mapper exist', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + it('should mapper return basic data', () => { + + const store = storeCreator(); + + var result = mapStateToProps(store.getState()); + expect(result).toBeTruthy(); + expect(result.modules.length).toEqual(0); + expect(result.unassigned.length).toEqual(0); + expect(result.artifacts.length).toEqual(0); + expect(result.nested.length).toEqual(0); + }); + + it('view test', () => { + + const store = storeCreator(); + + var params = mapStateToProps(store.getState()); + + let heatSetupView = TestUtils.renderIntoDocument(); + expect(heatSetupView).toBeTruthy(); + }); +}); diff --git a/openecomp-ui/test/softwareProduct/attachments/setup/heatSetupActionHelper.test.js b/openecomp-ui/test/softwareProduct/attachments/setup/heatSetupActionHelper.test.js new file mode 100644 index 0000000000..99bbfeac11 --- /dev/null +++ b/openecomp-ui/test/softwareProduct/attachments/setup/heatSetupActionHelper.test.js @@ -0,0 +1,142 @@ +/*! + * 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 HeatSetupActionHelper from 'sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupActionHelper.js'; +import {storeCreator} from 'sdc-app/AppStore.js'; +import deepFreeze from 'deep-freeze'; +import {heatSetupManifest} from 'test-utils/factories/softwareProduct/SoftwareProductAttachmentsFactories.js'; +import {actionTypes as HeatSetupActions, fileTypes as HeatSetupFileTypes} from 'sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupConstants.js'; + +describe('Heat Setup Action Helper test', () => { + + it('function does exist', () => { + expect(HeatSetupActionHelper).toBeTruthy(); + }); + + it('manifest load test', () => { + + const store = storeCreator(); + + const manifest = heatSetupManifest.build(); + store.dispatch({ + type: HeatSetupActions.MANIFEST_LOADED, + response: manifest + }); + + expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.modules.length).toBe(manifest.modules.length); + expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.nested.length).toBe(manifest.nested.length); + expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.unassigned.length).toBe(manifest.unassigned.length); + expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.artifacts.length).toBe(manifest.artifacts.length); + + }); + + it('add module action test', () => { + const store = storeCreator(); + deepFreeze(store.getState()); + + const manifest = heatSetupManifest.build(); + store.dispatch({ + type: HeatSetupActions.MANIFEST_LOADED, + response: manifest + }); + expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.modules.length).toBe(manifest.modules.length); + HeatSetupActionHelper.addModule(store.dispatch); + expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.modules.length).toBe(manifest.modules.length + 1); + + }); + + it('delete module action test', () => { + + const store = storeCreator(); + + const manifest = heatSetupManifest.build(); + store.dispatch({ + type: HeatSetupActions.MANIFEST_LOADED, + response: manifest + }); + HeatSetupActionHelper.deleteModule(store.dispatch, manifest.modules[0].name); + expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.modules.length).toBe(manifest.modules.length - 1); + + }); + + it('rename module action test', () => { + + const store = storeCreator(); + + const manifest = heatSetupManifest.build(); + store.dispatch({ + type: HeatSetupActions.MANIFEST_LOADED, + response: manifest + }); + const newName = 'newName'; + HeatSetupActionHelper.renameModule(store.dispatch, {oldName: manifest.modules[0].name, newName}); + expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.modules[0].name).toBe(newName); + + }); + + it('change module type action test', () => { + + const store = storeCreator(); + + const manifest = heatSetupManifest.build(); + store.dispatch({ + type: HeatSetupActions.MANIFEST_LOADED, + response: manifest + }); + const newValue = 'newvalue.env'; + HeatSetupActionHelper.changeModuleFileType(store.dispatch, + { + module: manifest.modules[0], + value: {value: newValue}, + type: HeatSetupFileTypes.ENV.label + }); + expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.modules[0].env).toBe(newValue); + }); + + it('change artifacts list action test', () => { + + const store = storeCreator(); + + const manifest = heatSetupManifest.build(); + store.dispatch({ + type: HeatSetupActions.MANIFEST_LOADED, + response: manifest + }); + const artifacts = store.getState().softwareProduct.softwareProductAttachments.heatSetup.artifacts; + const newArtifacts = [...artifacts, manifest.unassigned[0]].map(str => (typeof str === 'string' ? {value: str, label: str} : str));; + HeatSetupActionHelper.changeArtifactList(store.dispatch, newArtifacts); + expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.artifacts[1]).toBe(manifest.unassigned[0]); + expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.unassigned.length).toBe(manifest.unassigned.length - 1); + }); + + it('add All Unassigned Files To Artifacts action test', () => { + + const store = storeCreator(); + + const manifest = heatSetupManifest.build(); + store.dispatch({ + type: HeatSetupActions.MANIFEST_LOADED, + response: manifest + }); + const artifacts = store.getState().softwareProduct.softwareProductAttachments.heatSetup.artifacts; + const unassigned = store.getState().softwareProduct.softwareProductAttachments.heatSetup.unassigned; + const newArtifacts = [...artifacts, ...unassigned]; + HeatSetupActionHelper.addAllUnassignedFilesToArtifacts(store.dispatch, true); + expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.artifacts).toEqual(newArtifacts); + expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.unassigned).toEqual([]); + }); + +}); diff --git a/openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationActionHelper.test.js b/openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationActionHelper.test.js new file mode 100644 index 0000000000..d8a5d1fad6 --- /dev/null +++ b/openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationActionHelper.test.js @@ -0,0 +1,144 @@ +/*! + * 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 HeatValidationActionHelper from 'sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationActionHelper.js'; +import {storeCreator} from 'sdc-app/AppStore.js'; +import deepFreeze from 'deep-freeze'; +import {actionTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; +import {nodeFilters} from 'sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationConstants.js'; + +describe('HeatValidationActionHelper ActionHelper', () => { + + it('function does exist', () => { + expect(HeatValidationActionHelper).toBeTruthy(); + }); + + it('toggleExpanded function check', () => { + + + const validationData = { + importStructure: { + HEAT: [ + { + fileName: 'hot-mog-0108-bs1271.yml', + env: { + fileName: 'hot-mog-0108-bs1271.env' + }, + errors: [ + { + 'level': 'WARNING', + 'message': 'Port not bind to any NOVA Server, Resource Id [sm02_port_2]' + }, + { + 'level': 'WARNING', + 'message': 'Port not bind to any NOVA Server, Resource Id [sm01_port_2]' + } + ] + } + ] + } + }; + + 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: 'Locked', + lockingUser: 'cs0008', + validationData + }; + + + const store = storeCreator(); + deepFreeze(store.getState()); + deepFreeze(currentSoftwareProduct); + + store.dispatch({ + type:actionTypes.SOFTWARE_PRODUCT_LOADED, + response: currentSoftwareProduct + }); + + expect(store.getState().softwareProduct.softwareProductAttachments.heatValidation.attachmentsTree.children[0].expanded).toBe(true); + HeatValidationActionHelper.toggleExpanded(store.dispatch, {path:[0]}); + expect(store.getState().softwareProduct.softwareProductAttachments.heatValidation.attachmentsTree.children[0].expanded).toBe(false); + }); + + it('onSelectNode & onUnselectNode function check', () => { + + + const validationData = { + importStructure: { + heat: [ + { + fileName: 'hot-mog-0108-bs1271.yml', + env: { + fileName: 'hot-mog-0108-bs1271.env' + }, + errors: [ + { + 'level': 'WARNING', + 'message': 'Port not bind to any NOVA Server, Resource Id [sm02_port_2]' + }, + { + 'level': 'WARNING', + 'message': 'Port not bind to any NOVA Server, Resource Id [sm01_port_2]' + } + ] + } + ] + } + }; + + 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: 'Locked', + lockingUser: 'cs0008', + validationData + }; + + deepFreeze(currentSoftwareProduct); + + const store = storeCreator(); + deepFreeze(store.getState()); + + store.dispatch({ + type:actionTypes.SOFTWARE_PRODUCT_LOADED, + response: currentSoftwareProduct + }); + let expectedNodeName = 'name'; + expect(store.getState().softwareProduct.softwareProductAttachments.heatValidation.selectedNode).toBe(nodeFilters.ALL); + HeatValidationActionHelper.onSelectNode(store.dispatch, {nodeName:expectedNodeName}); + expect(store.getState().softwareProduct.softwareProductAttachments.heatValidation.selectedNode).toBe(expectedNodeName); + HeatValidationActionHelper.onDeselectNode(store.dispatch); + expect(store.getState().softwareProduct.softwareProductAttachments.heatValidation.selectedNode).toBe(nodeFilters.ALL); + }); + + +}); diff --git a/openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationView.test.js b/openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationView.test.js new file mode 100644 index 0000000000..a5ba297d2b --- /dev/null +++ b/openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationView.test.js @@ -0,0 +1,184 @@ +/*! + * 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/attachments/validation/HeatValidation.js'; + +import HeatValidationView from 'sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationView.jsx'; +import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; + + +describe('SoftwareProductAttachments Modal Mapper and View Classes', () => { + + it ('mapStateToProps mapper exists', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + + it ('mapStateToProps check data', () => { + + 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 atTree = { + 'children': [ + { + 'name': 'HEAT', + 'expanded': true, + 'type': 'heat', + 'children': [ + { + 'name': 'heat_zxeyCtMHhf2.yaml', + 'expanded': true, + 'type': 'heat', + 'errors': [ + { + 'level': 'WARNING', + 'message': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4' + } + ], + 'children': [ + { + 'name': 'heat_env_zxeyCtMHhf2.env', + 'type': 'env' + } + ] + } + ] + } + ] + }; + const errorList = [ + { + 'errorLevel': 'WARNING', + 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4', + 'name': 'heat_zxeyCtMHhf2.yaml', + 'hasParent': false, + 'parentName': 'HEAT', + 'type': 'heat' + }, + { + 'errorLevel': 'WARNING', + 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_3', + 'name': 'heat_zxeyCtMHhf2.yaml', + 'hasParent': false, + 'parentName': 'HEAT', + 'type': 'heat' + } + ]; + + var obj = { + softwareProduct: { + softwareProductEditor: { + data:currentSoftwareProduct + }, softwareProductAttachments: + { + heatValidation: { + attachmentsTree: atTree, + errorList: errorList + } + } + } + }; + + var results = mapStateToProps(obj); + expect(results.attachmentsTree).toBeTruthy(); + expect(results.errorList).toBeTruthy(); + expect(results.currentErrors).toBeTruthy(); + expect(results.currentWarnings).toBeTruthy(); + expect(results.selectedNode).toBe(undefined); + }); + + + it('function does exist', () => { + + const atTree = { + 'children': [ + { + 'name': 'HEAT', + 'expanded': true, + 'type': 'heat', + 'children': [ + { + 'name': 'heat_zxeyCtMHhf2.yaml', + 'expanded': true, + 'type': 'heat', + 'errors': [ + { + 'level': 'WARNING', + 'message': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4' + } + ], + 'children': [ + { + 'name': 'heat_env_zxeyCtMHhf2.env', + 'type': 'env' + } + ] + } + ] + } + ] + }; + const errorList = [ + { + 'errorLevel': 'WARNING', + 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4', + 'name': 'heat_zxeyCtMHhf2.yaml', + 'hasParent': false, + 'parentName': 'HEAT', + 'type': 'heat' + }, + { + 'errorLevel': 'WARNING', + 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_3', + 'name': 'heat_zxeyCtMHhf2.yaml', + 'hasParent': false, + 'parentName': 'HEAT', + 'type': 'heat' + } + ]; + var currentErrors = []; + var currentWarnings = []; + var onSelect = () => { return null; } ; + var onDeSelect = () => { return null; } ; + var onToggle = () => { return null; } ; + + var renderer = TestUtils.createRenderer(); + renderer.render(); + 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/test.js index 925de302b8..8d2d1fbb2f 100644 --- a/openecomp-ui/test/softwareProduct/components/compute/test.js +++ b/openecomp-ui/test/softwareProduct/components/compute/test.js @@ -1,24 +1,19 @@ -/*- - * ============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 deepFreeze from 'deep-freeze'; import mockRest from 'test-utils/MockRest.js'; import {cloneAndSet} from 'test-utils/Util.js'; @@ -26,14 +21,18 @@ 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 = ''; - before(function() { + beforeAll(function() { restPrefix = Configuration.get('restPrefix'); deepFreeze(restPrefix); }); @@ -42,28 +41,32 @@ describe('Software Product Components Compute Module Tests', function () { const store = storeCreator(); deepFreeze(store.getState()); + const compute = VSPComponentsComputeFactory.build(); + const dataMap = VSPComponentsComputeDataMapFactory.build(); + const softwareProductComponentCompute = { - data: JSON.stringify({'vmSizing':{'numOfCPUs':'3','fileSystemSizeGB':'888'},'numOfVMs':{'minimum':'2'}}), - schema: JSON.stringify({'vmSizing':{'numOfCPUs':'3','fileSystemSizeGB':'888'},'numOfVMs':{'minimum':'2'}}) + data: JSON.stringify(compute), + schema: JSON.stringify(compute) }; deepFreeze(softwareProductComponentCompute); const softwareProductComponentComputeData = { - qdata: JSON.parse(softwareProductComponentCompute.data), - qschema: JSON.parse(softwareProductComponentCompute.schema) + 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}/components/${vspComponentId}/questionnaire`); + 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, vspComponentId}).then(() => { + return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, version, vspComponentId}).then(() => { expect(store.getState()).toEqual(expectedStore); }); }); @@ -72,61 +75,33 @@ describe('Software Product Components Compute Module Tests', function () { const store = storeCreator(); deepFreeze(store.getState()); + const compute = VSPComponentsComputeFactory.build(); + const softwareProductComponentQuestionnaire = { data: null, - schema: JSON.stringify({'vmSizing':{'numOfCPUs':'3','fileSystemSizeGB':'888'},'numOfVMs':{'minimum':'2'}}) + schema: JSON.stringify(compute) }; deepFreeze(softwareProductComponentQuestionnaire); const softwareProductComponentQuestionnaireData = { qdata: {}, - qschema: JSON.parse(softwareProductComponentQuestionnaire.schema) + 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}/components/${vspComponentId}/questionnaire`); + 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, vspComponentId}).then(() => { + return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, version, vspComponentId}).then(() => { expect(store.getState()).toEqual(expectedStore); }); }); - it('Update Software Products Components Compute', () => { - const store = storeCreator({ - softwareProduct: { - softwareProductComponents: { - componentEditor: { - qdata: { - numOfCPUs: 3, - fileSystemSizeGB: 999 - }, - qschema: { - type: 'object', - properties: { - numOfCPUs: {type: 'number'}, - fileSystemSizeGB: {type: 'number'} - } - } - } - } - } - }); - deepFreeze(store); - - const data = {numOfCPUs: 5, fileSystemSizeGB: 300}; - deepFreeze(data); - - const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor.qdata', data); - - SoftwareProductComponentsActionHelper.componentQuestionnaireUpdated(store.dispatch, {data}); - - expect(store.getState()).toEqual(expectedStore); - }); }); diff --git a/openecomp-ui/test/softwareProduct/components/general/SoftwareProductComponentsGeneral.test.js b/openecomp-ui/test/softwareProduct/components/general/SoftwareProductComponentsGeneral.test.js index ce2152b29b..4f6512ad15 100644 --- a/openecomp-ui/test/softwareProduct/components/general/SoftwareProductComponentsGeneral.test.js +++ b/openecomp-ui/test/softwareProduct/components/general/SoftwareProductComponentsGeneral.test.js @@ -1,113 +1,73 @@ -/*- - * ============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/general/SoftwareProductComponentsGeneral.js'; import SoftwareProductComponentsGeneralView from 'sdc-app/onboarding/softwareProduct/components/general/SoftwareProductComponentsGeneralView.jsx'; -import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; +//import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; + +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import {VSPComponentsVersionControllerFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js'; +import {SoftwareProductFactory} from 'test-utils/factories/softwareProduct/SoftwareProductFactory.js'; +import VSPQSchemaFactory from 'test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js'; describe('SoftwareProductComponentsGeneral 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: { data: {}, - qdata: {}, - qschema: {} + qdata: {} } } - } + }) }; var results = mapStateToProps(obj); - expect(results.componentData).toExist(); - expect(results.qdata).toExist(); - expect(results.qschema).toExist(); + expect(results.componentData).toBeTruthy(); + expect(results.qdata).toBeTruthy(); }); it('VSP Components general 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_OUT_STATUS, - lockingUser: 'cs0008' - }; + const currentSoftwareProduct = VSPEditorFactory.build(); const softwareProductComponents = { componentEditor: { data: {}, qdata: {}, - qschema: { - $schema: 'http://json-schema.org/draft-04/schema#', - type: 'object', - properties: { - general: { - type: 'object', - properties: {} - } - } - } + qschema: VSPQSchemaFactory.build() } }; - const versionControllerData = { - version: '1', - viewableVersions: [], - status: 'locked', - isCheckedOut: true - }; + const versionControllerData = VSPComponentsVersionControllerFactory.build(); const componentData = { name: '', @@ -122,7 +82,7 @@ describe('SoftwareProductComponentsGeneral Mapper and View Classes', () => { versionControllerData={versionControllerData} currentSoftwareProduct={currentSoftwareProduct}/>); var renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); }); diff --git a/openecomp-ui/test/softwareProduct/components/loadBalancing/softwareProductComponentLoadbalancing.test.js b/openecomp-ui/test/softwareProduct/components/loadBalancing/softwareProductComponentLoadbalancing.test.js index 69a93b69e1..0ee9c76961 100644 --- a/openecomp-ui/test/softwareProduct/components/loadBalancing/softwareProductComponentLoadbalancing.test.js +++ b/openecomp-ui/test/softwareProduct/components/loadBalancing/softwareProductComponentLoadbalancing.test.js @@ -1,110 +1,69 @@ -/*- - * ============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/loadBalancing/SoftwareProductComponentLoadBalancing.js'; import SoftwareProductComponentLoadBalancingView from 'sdc-app/onboarding/softwareProduct/components/loadBalancing/SoftwareProductComponentLoadBalancingRefView.jsx'; -import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; + +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import {SoftwareProductFactory} from 'test-utils/factories/softwareProduct/SoftwareProductFactory.js'; +import {VSPComponentsVersionControllerFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js'; +import VSPQSchemaFactory from 'test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js'; describe('SoftwareProductComponentLoadBalancing 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: {} + qdata: {} } } - } + }) }; var results = mapStateToProps(obj); - expect(results.qdata).toExist(); - expect(results.qschema).toExist(); + expect(results.qdata).toBeTruthy(); }); it('VSP Components LoadBalancing 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_OUT_STATUS, - lockingUser: 'cs0008' - }; + const currentSoftwareProduct = VSPEditorFactory.build(); const softwareProductComponents = { componentEditor: { qdata: {}, - qschema: { - $schema: 'http://json-schema.org/draft-04/schema#', - type: 'object', - properties: { - general: { - type: 'object', - properties: {} - } - } - } + qschema: VSPQSchemaFactory.build() } }; - const versionControllerData = { - version: '1', - viewableVersions: [], - status: 'locked', - isCheckedOut: true - }; + const versionControllerData = VSPComponentsVersionControllerFactory.build(); var renderer = TestUtils.createRenderer(); renderer.render( @@ -115,7 +74,7 @@ describe('SoftwareProductComponentLoadBalancing Mapper and View Classes', () => softwareProductId='123' componentId='321'/>); var renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); }); diff --git a/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js b/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js index 2f1ea12c01..24658f1b30 100644 --- a/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js +++ b/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js @@ -1,57 +1,53 @@ -/*- - * ============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/monitoring/SoftwareProductComponentsMonitoring.js'; import SoftwareProductComponentsMonitoringView from 'sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringView.jsx'; +import {VSPComponentsMonitoringViewFactory} 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', () => { - expect(mapStateToProps).toExist(); + expect(mapStateToProps).toBeTruthy(); }); it('should return empty file names', () => { - let softwareProduct = {softwareProductEditor: {data: {}}, softwareProductComponents: {monitoring: {}}}; + let softwareProduct = {softwareProductEditor: {data: {...version}}, softwareProductComponents: {monitoring: {}}}; var results = mapStateToProps({softwareProduct}); expect(results.trapFilename).toEqual(undefined); expect(results.pollFilename).toEqual(undefined); }); it('should return trap file name', () => { - const monitoring = { - trapFilename: '123' - }; - let softwareProduct = {softwareProductEditor: {data: {}}, softwareProductComponents: {monitoring}}; + const monitoring = VSPComponentsMonitoringViewFactory.build({}, {snmpTrapFlag: true}); + let softwareProduct = {softwareProductEditor: {data: {...version}}, softwareProductComponents: {monitoring}}; var results = mapStateToProps({softwareProduct}); expect(results.trapFilename).toEqual(monitoring.trapFilename); expect(results.pollFilename).toEqual(undefined); }); it('should return poll file names', () => { - const monitoring = { - pollFilename: '123' - }; - let softwareProduct = {softwareProductEditor: {data: {}}, softwareProductComponents: {monitoring}}; + const monitoring = VSPComponentsMonitoringViewFactory.build({}, {snmpPollFlag: true}); + let softwareProduct = {softwareProductEditor: {data: {...version}}, softwareProductComponents: {monitoring}}; var results = mapStateToProps({softwareProduct}); expect(results.trapFilename).toEqual(undefined); expect(results.pollFilename).toEqual(monitoring.pollFilename); @@ -59,15 +55,12 @@ describe('SoftwareProductComponentsMonitoring Module Tests', function () { let renderer = TestUtils.createRenderer(); renderer.render(); let renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); }); it('should return both file names', () => { - const monitoring = { - trapFilename: '1234', - trapFilename: '123' - }; - let softwareProduct = {softwareProductEditor: {data: {}}, softwareProductComponents: {monitoring}}; + const monitoring = VSPComponentsMonitoringViewFactory.build({}, {snmpTrapFlag: true, snmpPollFlag: true}); + let softwareProduct = {softwareProductEditor: {data: {...version}}, softwareProductComponents: {monitoring}}; var results = mapStateToProps({softwareProduct}); expect(results.trapFilename).toEqual(monitoring.trapFilename); expect(results.pollFilename).toEqual(monitoring.pollFilename); @@ -75,7 +68,7 @@ describe('SoftwareProductComponentsMonitoring Module Tests', function () { let renderer = TestUtils.createRenderer(); renderer.render(); let renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); }); it('should change state to dragging', done => { diff --git a/openecomp-ui/test/softwareProduct/components/monitoring/test.js b/openecomp-ui/test/softwareProduct/components/monitoring/test.js index 172db653e9..dd0f850a89 100644 --- a/openecomp-ui/test/softwareProduct/components/monitoring/test.js +++ b/openecomp-ui/test/softwareProduct/components/monitoring/test.js @@ -1,31 +1,30 @@ -/*- - * ============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 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 {VSPComponentsMonitoringRestFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsMonitoringFactories.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; + const softwareProductId = '123'; const componentId = '123'; +const version = VersionControllerUtilsFactory.build().version; describe('Software Product Components Monitoring Module Tests', function () { @@ -38,18 +37,16 @@ describe('Software Product Components Monitoring Module Tests', function () { it('Fetch for existing files - no files', done => { - let emptyResult = Object.freeze({ - snmpTrap: undefined, - snmpPoll: undefined - }); + let emptyResult = VSPComponentsMonitoringRestFactory.build(); mockRest.addHandler('fetch', ({ baseUrl}) => { - expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp`); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp`); return emptyResult; }); SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, { softwareProductId, + version, componentId }); setTimeout(()=> { @@ -62,18 +59,16 @@ describe('Software Product Components Monitoring Module Tests', function () { }); it('Fetch for existing files - only snmp trap file exists', done => { - let response = Object.freeze({ - snmpTrap: 'asdfasdf', - snmpPoll: undefined - }); + let response = VSPComponentsMonitoringRestFactory.build({}, {snmpTrapFlag: true}); mockRest.addHandler('fetch', ({ baseUrl}) => { - expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp`); + 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(()=> { @@ -85,18 +80,16 @@ describe('Software Product Components Monitoring Module Tests', function () { }); it('Fetch for existing files - only snmp poll file exists', done => { - let response = Object.freeze({ - snmpPoll: 'asdfasdf', - snmpTrap: undefined - }); + let response = VSPComponentsMonitoringRestFactory.build({}, {snmpPollFlag: true}); mockRest.addHandler('fetch', ({baseUrl}) => { - expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp`); + 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(()=> { @@ -108,18 +101,16 @@ describe('Software Product Components Monitoring Module Tests', function () { }); it('Fetch for existing files - both files exist', done => { - let response = Object.freeze({ - snmpPoll: 'asdfasdf', - snmpTrap: 'asdfgg' - }); + let response = VSPComponentsMonitoringRestFactory.build({}, {snmpTrapFlag: true, snmpPollFlag: true}); mockRest.addHandler('fetch', ({baseUrl}) => { - expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp`); + 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(()=> { @@ -132,8 +123,8 @@ describe('Software Product Components Monitoring Module Tests', function () { it('Upload snmp trap file', done => { - mockRest.addHandler('create', ({baseUrl}) => { - expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp-trap/upload`); + mockRest.addHandler('post', ({baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp-trap/upload`); return {}; }); var debug = {hello: 'world'}; @@ -142,6 +133,7 @@ describe('Software Product Components Monitoring Module Tests', function () { formData.append('upload', file); SoftwareProductComponentsMonitoringActionHelper.uploadSnmpFile(store.dispatch, { softwareProductId, + version, componentId, formData, fileSize: file.size, @@ -156,8 +148,8 @@ describe('Software Product Components Monitoring Module Tests', function () { }); it('Upload snmp poll file', done => { - mockRest.addHandler('create', ({baseUrl}) => { - expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp/upload`); + 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'}; @@ -166,6 +158,7 @@ describe('Software Product Components Monitoring Module Tests', function () { formData.append('upload', file); SoftwareProductComponentsMonitoringActionHelper.uploadSnmpFile(store.dispatch, { softwareProductId, + version, componentId, formData, fileSize: file.size, @@ -181,11 +174,12 @@ describe('Software Product Components Monitoring Module Tests', function () { it('Delete snmp trap file', done => { mockRest.addHandler('destroy', ({baseUrl}) => { - expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp-trap`); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp-trap`); return {}; }); SoftwareProductComponentsMonitoringActionHelper.deleteSnmpFile(store.dispatch, { softwareProductId, + version, componentId, type: SoftwareProductComponentsMonitoringConstants.SNMP_TRAP }); @@ -198,11 +192,12 @@ describe('Software Product Components Monitoring Module Tests', function () { it('Delete snmp poll file', done => { mockRest.addHandler('destroy', ({baseUrl}) => { - expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp`); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp`); return {}; }); SoftwareProductComponentsMonitoringActionHelper.deleteSnmpFile(store.dispatch, { softwareProductId, + version, componentId, type: SoftwareProductComponentsMonitoringConstants.SNMP_POLL }); 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( - ); + renderer.render(); 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); }); }); diff --git a/openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesEditor.test.js b/openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesEditor.test.js new file mode 100644 index 0000000000..f3653fbcac --- /dev/null +++ b/openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesEditor.test.js @@ -0,0 +1,57 @@ +/*! + * 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/components/processes/SoftwareProductComponentProcessesEditor.js'; +import SoftwareProductComponentProcessesEditorView from 'sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesEditorView.jsx'; + +describe('Software Product Components Processes Editor Module Tests', function () { + + it('should mapper exist', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + it('should return empty data', () => { + + var state = { + softwareProduct: { + softwareProductComponents: { + componentProcesses: { + processesList: [], + processesEditor: {data: {}} + } + } + } + }; + + var results = mapStateToProps(state); + expect(results.data).toEqual({}); + expect(results.previousData).toEqual(undefined); + }); + + it('jsx view test', () => { + var view = TestUtils.renderIntoDocument( + {}} + onSubmit={() => {}} + onClose={() => {}}/>); + expect(view).toBeTruthy(); + }); +}); diff --git a/openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesView.test.js b/openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesView.test.js new file mode 100644 index 0000000000..ac866727a6 --- /dev/null +++ b/openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesView.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/components/processes/SoftwareProductComponentProcessesList.js'; +import SoftwareProductComponentsProcessesView from 'sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentsProcessesListView.jsx'; + +import {VSPProcessStoreFactory} from 'test-utils/factories/softwareProduct/SoftwareProductProcessFactories.js'; +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import {VSPComponentsFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js'; + +describe('SoftwareProductComponetsProcesses Mapper and View Classes', () => { + it('mapStateToProps mapper exists', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + it('mapStateToProps data test', () => { + const currentSoftwareProduct = VSPEditorFactory.build(); + + const processesList = VSPProcessStoreFactory.buildList(2); + + var state = { + softwareProduct: { + softwareProductEditor: { + data: currentSoftwareProduct + }, + softwareProductComponents: { + componentProcesses: { + processesList, + processesEditor: { + data: {} + } + } + } + } + }; + var results = mapStateToProps(state); + expect(results.processesList.length).toBe(2); + }); + + it('view simple test', () => { + const currentSoftwareProduct = VSPEditorFactory.build(); + const currentSoftwareProductComponent = VSPComponentsFactory.build(); + const processesList = VSPProcessStoreFactory.buildList(2); + + var renderer = TestUtils.createRenderer(); + renderer.render( + {}} + onEditProcessClick={() => {}} + onDeleteProcessClick={() => {}} + isDisplayEditor={false} + isReadOnlyMode={false}/> + ); + var renderedOutput = renderer.getRenderOutput(); + expect(renderedOutput).toBeTruthy(); + }); +}); diff --git a/openecomp-ui/test/softwareProduct/components/processes/test.js b/openecomp-ui/test/softwareProduct/components/processes/test.js index 67427d3c05..02009e6542 100644 --- a/openecomp-ui/test/softwareProduct/components/processes/test.js +++ b/openecomp-ui/test/softwareProduct/components/processes/test.js @@ -1,51 +1,43 @@ -/*- - * ============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 {buildFromExistingObject} from 'test-utils/Util.js'; import {cloneAndSet} from 'test-utils/Util.js'; import {storeCreator} from 'sdc-app/AppStore.js'; import SoftwareProductComponentProcessesActionHelper from 'sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesActionHelper.js'; +import { + VSPProcessStoreWithArtifactNameFactory, + VSPProcessPostFactory, + VSPProcessStoreFactory, + VSPProcessPostFactoryWithType, + VSPProcessStoreFactoryWithType} from 'test-utils/factories/softwareProduct/SoftwareProductProcessFactories.js'; + const softwareProductId = '123'; const componentId = '222'; +const versionId = '1'; +const version = {id: versionId, label: versionId}; + describe('Software Product Component Processes Module Tests', function () { it('Get Software Products Processes List', () => { const store = storeCreator(); deepFreeze(store.getState()); - const softwareProductProcessesList = [ - { - name: 'Pr1', - description: 'hjhj', - id: 'EBADF561B7FA4A788075E1840D0B5971', - artifactName: 'artifact' - }, - { - name: 'Pr1', - description: 'hjhj', - id: '2F47447D22DB4C53B020CA1E66201EF2', - artifactName: 'artifact' - } - ]; + const softwareProductProcessesList = VSPProcessStoreWithArtifactNameFactory.buildList(2); deepFreeze(softwareProductProcessesList); @@ -54,25 +46,20 @@ describe('Software Product Component Processes Module Tests', function () { const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentProcesses.processesList', softwareProductProcessesList); mockRest.addHandler('fetch', ({options, data, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/processes`); - expect(data).to.deep.equal(undefined); - expect(options).to.equal(undefined); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components/${componentId}/processes`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); return {results: softwareProductProcessesList}; }); + - return SoftwareProductComponentProcessesActionHelper.fetchProcessesList(store.dispatch, {softwareProductId, componentId}).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + return SoftwareProductComponentProcessesActionHelper.fetchProcessesList(store.dispatch, {softwareProductId, componentId, version}).then(() => { + expect(store.getState()).toEqual(expectedStore); }); }); it('Delete Software Products Processes', () => { - const softwareProductProcessesList = [ - { - name: 'Pr1', - description: 'hjhj', - id: 'EBADF561B7FA4A788075E1840D0B5971', - artifactName: 'artifact' - } - ]; + let process = VSPProcessStoreWithArtifactNameFactory.build(); + const softwareProductProcessesList = [process]; deepFreeze(softwareProductProcessesList); const store = storeCreator({ @@ -83,15 +70,15 @@ describe('Software Product Component Processes Module Tests', function () { } }); - const processId = 'EBADF561B7FA4A788075E1840D0B5971'; + const processId = process.id; deepFreeze(store.getState()); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentProcesses.processesList', []); mockRest.addHandler('destroy', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/processes/${processId}`); - expect(data).to.equal(undefined); - expect(options).to.equal(undefined); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components/${componentId}/processes/${processId}`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); return { results: { returnCode: 'OK' @@ -101,9 +88,10 @@ describe('Software Product Component Processes Module Tests', function () { return SoftwareProductComponentProcessesActionHelper.deleteProcess(store.dispatch, { process: softwareProductProcessesList[0], - softwareProductId, componentId + softwareProductId, componentId, + version }).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); @@ -112,27 +100,18 @@ describe('Software Product Component Processes Module Tests', function () { const store = storeCreator(); deepFreeze(store.getState()); - const softwareProductPostRequest = { - name: 'Pr1', - description: 'string' - }; - const softwareProductProcessToAdd = { - name: 'Pr1', - description: 'string' - }; const softwareProductProcessFromResponse = 'ADDED_ID'; - const softwareProductProcessAfterAdd = { - ...softwareProductProcessToAdd, - id: softwareProductProcessFromResponse - }; + + const softwareProductProcessAfterAdd = VSPProcessStoreFactory.build({id: softwareProductProcessFromResponse}); + const softwareProductPostRequest = buildFromExistingObject(VSPProcessPostFactory, softwareProductProcessAfterAdd); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentProcesses.processesList', [softwareProductProcessAfterAdd]); - mockRest.addHandler('create', ({data, options, baseUrl}) => { + mockRest.addHandler('post', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/processes`); - expect(data).to.deep.equal(softwareProductPostRequest); - expect(options).to.equal(undefined); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components/${componentId}/processes`); + expect(data).toEqual(softwareProductPostRequest); + expect(options).toEqual(undefined); return { returnCode: 'OK', value: softwareProductProcessFromResponse @@ -143,23 +122,55 @@ describe('Software Product Component Processes Module Tests', function () { { softwareProductId, previousProcess: null, - process: softwareProductProcessToAdd, - componentId + process: softwareProductPostRequest, + componentId, + version } ).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); - it('Update Software Products Processes', () => { - const softwareProductProcessesList = [ + it('Add Software Products Processes with type', () => { + + const store = storeCreator(); + deepFreeze(store.getState()); + + const softwareProductPostRequest = VSPProcessPostFactoryWithType.build(); + + const softwareProductProcessAfterAdd = VSPProcessStoreFactoryWithType.build(softwareProductPostRequest); + const softwareProductProcessFromResponse = softwareProductProcessAfterAdd.id; + + const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentProcesses.processesList', [softwareProductProcessAfterAdd]); + + mockRest.addHandler('post', ({data, options, baseUrl}) => { + + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components/${componentId}/processes`); + expect(data).toEqual(softwareProductPostRequest); + expect(options).toEqual(undefined); + return { + returnCode: 'OK', + value: softwareProductProcessFromResponse + }; + }); + + return SoftwareProductComponentProcessesActionHelper.saveProcess(store.dispatch, { - name: 'Pr1', - description: 'string', - id: 'EBADF561B7FA4A788075E1840D0B5971', - artifactName: 'artifact' + softwareProductId, + previousProcess: null, + process: softwareProductPostRequest, + componentId, + version } - ]; + ).then(() => { + expect(store.getState()).toEqual(expectedStore); + }); + }); + + it('Update Software Products Processes', () => { + let process = VSPProcessStoreWithArtifactNameFactory.build(); + + const softwareProductProcessesList = [process]; deepFreeze(softwareProductProcessesList); const store = storeCreator({ @@ -173,28 +184,30 @@ describe('Software Product Component Processes Module Tests', function () { }); deepFreeze(store.getState()); - const toBeUpdatedProcessId = softwareProductProcessesList[0].id; - const previousProcessData = softwareProductProcessesList[0]; - const processUpdateData = { - ...softwareProductProcessesList[0], + const toBeUpdatedProcessId = process.id; + const previousProcessData = process; + const processUpdateData = VSPProcessStoreWithArtifactNameFactory.build({ + ...process, name: 'Pr1_UPDATED', - description: 'string_UPDATED' - }; + description: 'string_UPDATED', + type: 'Other' + }); deepFreeze(processUpdateData); - const processPutRequest = { + const processPutRequest = VSPProcessPostFactory.build({ name: 'Pr1_UPDATED', - description: 'string_UPDATED' - }; + description: 'string_UPDATED', + type: 'Other' + }); deepFreeze(processPutRequest); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentProcesses.processesList', [processUpdateData]); - mockRest.addHandler('save', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/processes/${toBeUpdatedProcessId}`); - expect(data).to.deep.equal(processPutRequest); - expect(options).to.equal(undefined); + mockRest.addHandler('put', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components/${componentId}/processes/${toBeUpdatedProcessId}`); + expect(data).toEqual(processPutRequest); + expect(options).toEqual(undefined); return {returnCode: 'OK'}; }); @@ -203,12 +216,12 @@ describe('Software Product Component Processes Module Tests', function () { softwareProductId: softwareProductId, componentId, previousProcess: previousProcessData, - process: processUpdateData + process: processUpdateData, + version } ).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); }); - diff --git a/openecomp-ui/test/softwareProduct/components/storage/test.js b/openecomp-ui/test/softwareProduct/components/storage/test.js index 87cad368be..138c4da7d6 100644 --- a/openecomp-ui/test/softwareProduct/components/storage/test.js +++ b/openecomp-ui/test/softwareProduct/components/storage/test.js @@ -1,24 +1,19 @@ -/*- - * ============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 deepFreeze from 'deep-freeze'; import mockRest from 'test-utils/MockRest.js'; import {cloneAndSet} from 'test-utils/Util.js'; @@ -26,14 +21,18 @@ 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 VSPComponentsStorageFactory, VSPComponentsStorageDataMapFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsStorageFactory.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 Storage Module Tests', function () { let restPrefix = ''; - before(function() { + beforeAll(function() { restPrefix = Configuration.get('restPrefix'); deepFreeze(restPrefix); }); @@ -42,28 +41,32 @@ describe('Software Product Components Storage Module Tests', function () { const store = storeCreator(); deepFreeze(store.getState()); + const storage = VSPComponentsStorageFactory.build(); + const dataMap = VSPComponentsStorageDataMapFactory.build(); + const softwareProductComponentStorage = { - data: JSON.stringify({'backup':{'backupType':'OnSite','backupSolution':'76333'},'snapshotBackup':{'snapshotFrequency':'2'}}), - schema: JSON.stringify({'backup':{'backupType':'OnSite','backupSolution':'76333'},'snapshotBackup':{'snapshotFrequency':'2'}}) + data: JSON.stringify(storage), + schema: JSON.stringify(storage) }; deepFreeze(softwareProductComponentStorage); const softwareProductComponentStorageData = { - qdata: JSON.parse(softwareProductComponentStorage.data), - qschema: JSON.parse(softwareProductComponentStorage.schema) + qdata: storage, + dataMap: dataMap, + qgenericFieldInfo: {} }; deepFreeze(softwareProductComponentStorageData); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor', softwareProductComponentStorageData); mockRest.addHandler('fetch', ({options, data, baseUrl}) => { - expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/components/${vspComponentId}/questionnaire`); + 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 softwareProductComponentStorage; }); - return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, vspComponentId}).then(() => { + return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, version, vspComponentId}).then(() => { expect(store.getState()).toEqual(expectedStore); }); }); @@ -72,61 +75,33 @@ describe('Software Product Components Storage Module Tests', function () { const store = storeCreator(); deepFreeze(store.getState()); + const storage = VSPComponentsStorageFactory.build(); + const softwareProductComponentQuestionnaire = { data: null, - schema: JSON.stringify({'backup':{'backupType':'OnSite','backupSolution':'76333'},'snapshotBackup':{'snapshotFrequency':'2'}}) + schema: JSON.stringify(storage) }; deepFreeze(softwareProductComponentQuestionnaire); const softwareProductComponentQuestionnaireData = { qdata: {}, - qschema: JSON.parse(softwareProductComponentQuestionnaire.schema) + 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}/components/${vspComponentId}/questionnaire`); + 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, vspComponentId}).then(() => { + return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, version, vspComponentId}).then(() => { expect(store.getState()).toEqual(expectedStore); }); }); - it('Update Software Products Components Storage', () => { - const store = storeCreator({ - softwareProduct: { - softwareProductComponents: { - componentEditor: { - qdata: { - backupType: 'OnSite', - backupStorageSize: 30 - }, - qschema: { - type: 'object', - properties: { - backupType: {type: 'string'}, - backupStorageSize: {type: 'number'} - } - } - } - } - } - }); - deepFreeze(store); - - const data = {backupType: 'OffSite', backupStorageSize: 30}; - deepFreeze(data); - - const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor.qdata', data); - - SoftwareProductComponentsActionHelper.componentQuestionnaireUpdated(store.dispatch, {data}); - - expect(store.getState()).toEqual(expectedStore); - }); }); diff --git a/openecomp-ui/test/softwareProduct/components/test.js b/openecomp-ui/test/softwareProduct/components/test.js index 839e1b7cf7..b3994b1461 100644 --- a/openecomp-ui/test/softwareProduct/components/test.js +++ b/openecomp-ui/test/softwareProduct/components/test.js @@ -1,32 +1,30 @@ -/*- - * ============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 SoftwareProductComponentsActionHelper from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js'; +import {VSPComponentsFactory, VSPComponentsGeneralFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; + const softwareProductId = '123'; const vspComponentId = '321'; +const version = VersionControllerUtilsFactory.build().version; describe('Software Product Components Module Tests', function () { it('Get Software Products Components List', () => { @@ -34,18 +32,8 @@ describe('Software Product Components Module Tests', function () { deepFreeze(store.getState()); const softwareProductComponentsList = [ - { - name: 'com.d2.resource.vfc.nodes.heat.sm_server', - displayName: 'sm_server', - description: 'hjhj', - id: 'EBADF561B7FA4A788075E1840D0B5971' - }, - { - name: 'com.d2.resource.vfc.nodes.heat.pd_server', - displayName: 'pd_server', - description: 'hjhj', - id: '2F47447D22DB4C53B020CA1E66201EF2' - } + VSPComponentsFactory.build({}, {componentName: 'sd', componentType: 'server'}), + VSPComponentsFactory.build({}, {componentName: 'pd', componentType: 'server'}) ]; deepFreeze(softwareProductComponentsList); @@ -55,14 +43,14 @@ describe('Software Product Components Module Tests', function () { const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentsList', softwareProductComponentsList); mockRest.addHandler('fetch', ({options, data, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components`); - 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`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); return {results: softwareProductComponentsList}; }); - return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(store.dispatch, {softwareProductId}).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(store.dispatch, {softwareProductId, version}).then(() => { + expect(store.getState()).toEqual(expectedStore); }); }); @@ -70,27 +58,21 @@ describe('Software Product Components Module Tests', function () { const store = storeCreator(); const qdataUpdated = { - general: { - hypervisor: { - containerFeatureDescription: 'aaaUpdated', - drivers: 'bbbUpdated', - hypervisor: 'cccUpdated' - } - } + general: VSPComponentsGeneralFactory.build() }; const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor.qdata', qdataUpdated); deepFreeze(expectedStore); - mockRest.addHandler('save', ({options, data, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${vspComponentId}/questionnaire`); - expect(data).to.deep.equal(qdataUpdated); - 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/${vspComponentId}/questionnaire`); + expect(data).toEqual(qdataUpdated); + expect(options).toEqual(undefined); return {returnCode: 'OK'}; }); - return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, vspComponentId, qdata: qdataUpdated}).then(() => { + return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, version, vspComponentId, qdata: qdataUpdated}).then(() => { //TODO think should we add here something or not }); @@ -98,4 +80,3 @@ describe('Software Product Components Module Tests', function () { }); }); - diff --git a/openecomp-ui/test/softwareProduct/creation/SoftwareProductCreation.test.js b/openecomp-ui/test/softwareProduct/creation/SoftwareProductCreation.test.js new file mode 100644 index 0000000000..c7c55bdbaf --- /dev/null +++ b/openecomp-ui/test/softwareProduct/creation/SoftwareProductCreation.test.js @@ -0,0 +1,105 @@ +/*! + * 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, mapActionsToProps} from 'sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreation.js'; +import SoftwareProductCreationView from 'sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationView.jsx'; +import {SoftwareProductCreationFactory, SoftwareProductCreationFactoryWithSelectedVendor} from 'test-utils/factories/softwareProduct/SoftwareProductCreationFactories.js'; +import {CategoryWithSubFactory} from 'test-utils/factories/softwareProduct/VSPCategoriesFactory.js'; +import {FinalizedLicenseModelFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js'; +import {storeCreator} from 'sdc-app/AppStore.js'; + +describe('Software Product Creation Module Tests', function() { + it ('mapStateToProps mapper exists', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + it ('should return empty data', () => { + let state = { + softwareProductList: [], + softwareProduct: { + softwareProductCreation: { + data: {} + } + } + }; + let props = mapStateToProps(state); + expect(props.data).toEqual({}); + }); + + it ('should return vsp names list', () => { + let state = { + softwareProductList: [{ + name: 'vsp1', + id: 'vsp1_id' + }, { + name: 'vsp2', + id: 'vsp2_id' + }], + softwareProduct: { + softwareProductCreation: { + data: {} + } + } + }; + let props = mapStateToProps(state); + expect(props.data).toEqual({}); + expect(props.VSPNames).toEqual({vsp1: 'vsp1_id', vsp2: 'vsp2_id'}); + }); + + it('simple jsx test', () => { + const store = storeCreator(); + let dispatch = store.dispatch; + + let state = { + softwareProductList: [], + softwareProduct: { + softwareProductCreation: SoftwareProductCreationFactory.build(), + softwareProductCategories: CategoryWithSubFactory.buildList({}, {quantity: 2}) + }, + finalizedLicenseModelList: FinalizedLicenseModelFactory.buildList(3) + }; + let props = Object.assign({}, mapStateToProps(state), mapActionsToProps(dispatch)); + var renderer = TestUtils.createRenderer(); + renderer.render( + + ); + var renderedOutput = renderer.getRenderOutput(); + expect(renderedOutput).toBeTruthy(); + }); + + it('simple jsx test - with selected vendor', () => { + const store = storeCreator(); + let dispatch = store.dispatch; + let finalizedLicenseModelList = FinalizedLicenseModelFactory.buildList(3); + let state = { + softwareProductList: [], + softwareProduct: { + softwareProductCreation: SoftwareProductCreationFactoryWithSelectedVendor.build({selectedVendorId: finalizedLicenseModelList[0].id}), + softwareProductCategories: CategoryWithSubFactory.buildList({}, {quantity: 2}) + }, + finalizedLicenseModelList + }; + let props = Object.assign({}, mapStateToProps(state), mapActionsToProps(dispatch)); + let renderer = TestUtils.createRenderer(); + renderer.render( + + ); + let renderedOutput = renderer.getRenderOutput(); + expect(renderedOutput).toBeTruthy(); + }); +}); diff --git a/openecomp-ui/test/softwareProduct/dependencies/SoftwareProductDependencies.test.js b/openecomp-ui/test/softwareProduct/dependencies/SoftwareProductDependencies.test.js new file mode 100644 index 0000000000..5325a58959 --- /dev/null +++ b/openecomp-ui/test/softwareProduct/dependencies/SoftwareProductDependencies.test.js @@ -0,0 +1,210 @@ +/*! + * 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 {mount} from 'enzyme'; +import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependencies.js'; +import { + SoftwareProductDependenciesResponseFactory, + SoftwareProductDependenciesStoreFactory} from 'test-utils/factories/softwareProduct/SoftwareProductDependenciesFactories.js'; +import {VSPComponentsFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; +import {storeCreator} from 'sdc-app/AppStore.js'; +import {cloneAndSet} from 'test-utils/Util.js'; +import mockRest from 'test-utils/MockRest.js'; + +import SoftwareProductComponentsActionHelper from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js'; +import SoftwareProductDependenciesActionHelper from 'sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesActionHelper.js'; +import SoftwareProductDependenciesView from 'sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesView.jsx'; +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; + +describe('Software Product Dependencies Module Tests', function () { + const softwareProductId = '555'; + const version = VersionControllerUtilsFactory.build().version; + + it('mapStateToProps mapper exists', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + it('Get Software Product Dependencies List', () => { + const store = storeCreator(); + const dispatch = store.dispatch; + + let DependenciesListResponse = SoftwareProductDependenciesResponseFactory.buildList(2); + let DependenciesListStore = DependenciesListResponse.map(dependency => SoftwareProductDependenciesStoreFactory.build(dependency)); + const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductDependencies', DependenciesListStore); + + mockRest.addHandler('fetch', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/component-dependency-model`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: DependenciesListResponse}; + }); + + return SoftwareProductDependenciesActionHelper.fetchDependencies(dispatch, {softwareProductId, version}).then(() => { + const state = store.getState(); + const depndenciesWithGeneratedId = state.softwareProduct.softwareProductDependencies; + const currentDependencies = expectedStore.softwareProduct.softwareProductDependencies; + let expectedStoreDependencies = currentDependencies.map((dependency, index) => ({...dependency, id: depndenciesWithGeneratedId[index].id})); + + const newExpectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductDependencies', expectedStoreDependencies); + + expect(state).toEqual(newExpectedStore); + }); + }); + + it('Update Software Product Dependencies List', () => { + const store = storeCreator(); + const dispatch = store.dispatch; + + let DependenciesListResponse = SoftwareProductDependenciesResponseFactory.buildList(3); + let DependenciesListStore = DependenciesListResponse.map(dependency => SoftwareProductDependenciesStoreFactory.build(dependency)); + const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductDependencies', DependenciesListStore); + + mockRest.addHandler('fetch', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/component-dependency-model`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: DependenciesListResponse}; + }); + + return SoftwareProductDependenciesActionHelper.fetchDependencies(dispatch, {softwareProductId, version}).then(() => { + + const state = store.getState(); + const depndenciesWithGeneratedId = state.softwareProduct.softwareProductDependencies; + const currentDependencies = expectedStore.softwareProduct.softwareProductDependencies; + let expectedStoreDependencies = currentDependencies.map((dependency, index) => ({...dependency, id: depndenciesWithGeneratedId[index].id})); + + let newDependency = SoftwareProductDependenciesStoreFactory.build(); + expectedStoreDependencies.push(newDependency); + + const newExpectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductDependencies', expectedStoreDependencies); + + SoftwareProductDependenciesActionHelper.updateDependencyList(dispatch, {dependenciesList: expectedStoreDependencies}); + const newState = store.getState(); + expect(newState).toEqual(newExpectedStore); + }); + }); + + it('Add And Save Software Product Dependencies List', () => { + const store = storeCreator(); + const dispatch = store.dispatch; + + let mockServerDependencies = []; + + SoftwareProductDependenciesActionHelper.addDependency(dispatch); + let state = store.getState(); + let dependencies = state.softwareProduct.softwareProductDependencies; + expect(dependencies.length).toEqual(1); + expect(dependencies[0].sourceId).toEqual(null); + expect(dependencies[0].targetId).toEqual(null); + + let newDependencies = SoftwareProductDependenciesStoreFactory.buildList(1); + const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductDependencies', newDependencies); + SoftwareProductDependenciesActionHelper.updateDependencyList(dispatch, {dependenciesList: newDependencies}); + + mockRest.addHandler('post', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/component-dependency-model`); + expect(data).toEqual({componentDependencyModels: newDependencies.map(item => ({sourceId: item.sourceId, targetId: item.targetId, relationType: item.relationType}) )}); + expect(options).toEqual(undefined); + mockServerDependencies = [...data.componentDependencyModels]; + return {returnCode: 'OK'}; + }); + + mockRest.addHandler('fetch', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/component-dependency-model`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: mockServerDependencies}; + }); + + return SoftwareProductDependenciesActionHelper.saveDependencies(dispatch, {softwareProductId, version, dependenciesList: newDependencies}).then(() => { + return SoftwareProductDependenciesActionHelper.fetchDependencies(dispatch, {softwareProductId, version}); + }).then(() => { + const state = store.getState(); + const depndenciesWithGeneratedId = state.softwareProduct.softwareProductDependencies; + const currentDependencies = expectedStore.softwareProduct.softwareProductDependencies; + let expectedStoreDependencies = currentDependencies.map((dependency, index) => ({...dependency, id: depndenciesWithGeneratedId[index].id})); + + const newExpectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductDependencies', expectedStoreDependencies); + + expect(state).toEqual(newExpectedStore); + }); + }); + + it('Get Software Product Dependencies List with loop, and render to JSX', () => { + const store = storeCreator(); + const dispatch = store.dispatch; + + let components = VSPComponentsFactory.buildList(2); + let vspEditor = VSPEditorFactory.build({id: softwareProductId, version}); + + let DependenciesListResponse = SoftwareProductDependenciesResponseFactory.buildList(2); + let firstDependecy = DependenciesListResponse[0]; + let secondDependency = DependenciesListResponse[1]; + firstDependecy.sourceId = components[0].id; + secondDependency.sourceId = components[1].id; + firstDependecy.targetId = secondDependency.sourceId; + secondDependency.targetId = firstDependecy.sourceId; + + let DependenciesListStore = DependenciesListResponse.map(dependency => SoftwareProductDependenciesStoreFactory.build({...dependency, hasCycle: true})); + const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductDependencies', DependenciesListStore); + + mockRest.addHandler('fetch', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/component-dependency-model`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: DependenciesListResponse}; + }); + + 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: components}; + }); + + return SoftwareProductDependenciesActionHelper.fetchDependencies(dispatch, {softwareProductId, version}).then(() => { + return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version}); + }).then(() => { + const state = store.getState(); + state.softwareProduct.softwareProductEditor = {data: vspEditor}; + const depndenciesWithGeneratedId = state.softwareProduct.softwareProductDependencies; + const currentDependencies = expectedStore.softwareProduct.softwareProductDependencies; + let expectedStoreDependencies = currentDependencies.map((dependency, index) => ({...dependency, id: depndenciesWithGeneratedId[index].id})); + + const newExpectedStore = { + ...expectedStore, + softwareProduct: { + ...expectedStore.softwareProduct, + softwareProductDependencies: expectedStoreDependencies, + softwareProductEditor: {data: vspEditor}, + softwareProductComponents: { + ...expectedStore.softwareProduct.softwareProductComponents, + componentsList: components + } + } + }; + + expect(state).toEqual(newExpectedStore); + + const props = mapStateToProps(state); + expect(props.softwareProductDependencies).toEqual(expectedStoreDependencies); + const wrapper = mount(); + expect(wrapper).toBeTruthy(); + }); + }); +}); \ No newline at end of file diff --git a/openecomp-ui/test/softwareProduct/details/detailsView.test.js b/openecomp-ui/test/softwareProduct/details/detailsView.test.js index b6a8ca5d4e..37c5df5079 100644 --- a/openecomp-ui/test/softwareProduct/details/detailsView.test.js +++ b/openecomp-ui/test/softwareProduct/details/detailsView.test.js @@ -1,87 +1,93 @@ -/*- - * ============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/details/SoftwareProductDetails.js'; import SoftwareProductDetailsView from 'sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsView.jsx'; -import {vspQschema as vspQuestionnaireSchema} from './vspQschema.js'; +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import {CategoryWithSubFactory} from 'test-utils/factories/softwareProduct/VSPCategoriesFactory.js'; +import {LicenseAgreementStoreFactory} from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js'; +import {FeatureGroupStoreFactory} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js'; +import {SchemaGenericFieldInfoFactory} from 'test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js'; +import {default as VspQdataFactory, VspDataMapFactory} from 'test-utils/factories/softwareProduct/VspQdataFactory.js'; +import {FinalizedLicenseModelFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js'; describe('Software Product Details: ', function () { - let currentSoftwareProduct = {}, categories = [], finalizedLicenseModelList, licenseAgreementList, featureGroupsList, vspQschema; + let currentSoftwareProduct = {}, currentSoftwareProductWithLicensingData = {}, softwareProductCategories = [], + finalizedLicenseModelList, licenseAgreementList, featureGroupsList, qdata = {}, dataMap = {}, genericFieldInfo = {}, qGenericFieldInfo = {}; let dummyFunc = () => {}; - before(function() { - currentSoftwareProduct = { - id: 'D4774719D085414E9D5642D1ACD59D20', - name: 'VSP', - description: 'dfdf', - category: 'category1', - subCategory: 'category1.subCategory', - vendorId: 'VLM_ID1', - vendorName: 'VLM1', - licensingVersion: '1.0', - licensingData: {} + beforeAll(function() { + finalizedLicenseModelList = FinalizedLicenseModelFactory.buildList(2); + currentSoftwareProduct = VSPEditorFactory.build({ + id: 'RTRTG454545', + vendorId: finalizedLicenseModelList[0].id, + vendorName: finalizedLicenseModelList[0].vendorName + }); + softwareProductCategories = CategoryWithSubFactory.buildList(2, {}, {quantity: 1}); + licenseAgreementList = LicenseAgreementStoreFactory.buildList(2); + featureGroupsList = FeatureGroupStoreFactory.buildList(2, {referencingLicenseAgreements: [licenseAgreementList[0].id]}); + qdata = VspQdataFactory.build(); + dataMap = VspDataMapFactory.build(); + currentSoftwareProductWithLicensingData = { + ...currentSoftwareProduct, + licensingData: { + licenseAgreement: licenseAgreementList[0].id, + featureGroups: [featureGroupsList[0].id] + } + }; + genericFieldInfo = { + 'name': { + isValid: true, + errorText: '', + validations: [{type: 'validateName', data: true}, {type: 'maxLength', data: 120}, { + type: 'required', + data: true + }] + }, + 'description': { + isValid: true, + errorText: '', + validations: [{type: 'required', data: true}] + } }; - categories = [{ - uniqueId: 'category1', - subcategories: [{ - uniqueId: 'subCategory' - }] - }, { - uniqueId: 'category2', - subcategories: [{ - uniqueId: 'subCategory2' - }] - }]; - finalizedLicenseModelList = [{ - id: 'VLM_ID1', - name: 'VLM1' - }]; - licenseAgreementList = [{id: 'LA_ID1'}, {id: 'LA_ID2'}]; - featureGroupsList = [ - {id: 'FG_ID1', name: 'FG1', referencingLicenseAgreements: ['LA_ID1']}, - {id: 'FG_ID2', name: 'FG2', referencingLicenseAgreements: ['LA_ID1']} - ]; - vspQschema = vspQuestionnaireSchema; + qGenericFieldInfo = SchemaGenericFieldInfoFactory.build(); }); it('should mapper exist', () => { - expect(mapStateToProps).toExist(); + expect(mapStateToProps).toBeTruthy(); }); it('should mapper return vsp basic data', () => { + var obj = { softwareProduct: { softwareProductEditor: { - data: currentSoftwareProduct + data: currentSoftwareProduct, + genericFieldInfo }, - softwareProductCategories: categories, + softwareProductCategories, softwareProductQuestionnaire: { - qdata: {}, - qschema: vspQschema + qdata, + genericFieldInfo: qGenericFieldInfo, + dataMap } }, - finalizedLicenseModelList: finalizedLicenseModelList, + finalizedLicenseModelList, licenseModel: { licenseAgreement: { licenseAgreementList: [] @@ -96,35 +102,32 @@ describe('Software Product Details: ', function () { expect(result.currentSoftwareProduct).toEqual(currentSoftwareProduct); expect(result.finalizedLicenseModelList).toEqual(finalizedLicenseModelList); expect(result.finalizedLicenseModelList.length).toBeGreaterThan(0); - expect(finalizedLicenseModelList).toInclude({ + expect(finalizedLicenseModelList[0]).toMatchObject({ id: result.currentSoftwareProduct.vendorId, - name: result.currentSoftwareProduct.vendorName + vendorName: result.currentSoftwareProduct.vendorName }); - expect(result.softwareProductCategories).toEqual(categories); + expect(result.softwareProductCategories).toEqual(softwareProductCategories); expect(result.licenseAgreementList).toEqual([]); expect(result.featureGroupsList).toEqual([]); - expect(result.qdata).toEqual({}); - expect(result.qschema).toEqual(vspQschema); + expect(result.qdata).toEqual(qdata); + expect(result.dataMap).toEqual(dataMap); + expect(result.isFormValid).toEqual(true); expect(result.isReadOnlyMode).toEqual(true); }); it('should mapper return vsp data with selected licenseAgreement and featureGroup', () => { - let vspWithLicensingData = { - ...currentSoftwareProduct, - licensingData: { - licenseAgreement: 'LA_ID1', - featureGroups: [{enum: 'FG_ID1', title: 'FG1'}] - } - }; + var obj = { softwareProduct: { softwareProductEditor: { - data: vspWithLicensingData + data: currentSoftwareProductWithLicensingData, + genericFieldInfo }, - softwareProductCategories: categories, + softwareProductCategories, softwareProductQuestionnaire: { - qdata: {}, - qschema: vspQschema + qdata, + genericFieldInfo: qGenericFieldInfo, + dataMap } }, finalizedLicenseModelList: finalizedLicenseModelList, @@ -139,51 +142,36 @@ describe('Software Product Details: ', function () { }; var result = mapStateToProps(obj); - expect(result.currentSoftwareProduct).toEqual(vspWithLicensingData); + expect(result.currentSoftwareProduct).toEqual(currentSoftwareProductWithLicensingData); expect(result.finalizedLicenseModelList).toEqual(finalizedLicenseModelList); expect(result.finalizedLicenseModelList.length).toBeGreaterThan(0); - expect(result.finalizedLicenseModelList).toInclude({ + expect(result.finalizedLicenseModelList[0]).toMatchObject({ id: result.currentSoftwareProduct.vendorId, - name: result.currentSoftwareProduct.vendorName + vendorName: result.currentSoftwareProduct.vendorName }); - expect(result.softwareProductCategories).toEqual(categories); + expect(result.softwareProductCategories).toEqual(softwareProductCategories); expect(result.licenseAgreementList).toEqual(licenseAgreementList); - expect(result.licenseAgreementList).toInclude({id: result.currentSoftwareProduct.licensingData.licenseAgreement}); + expect(result.licenseAgreementList[0]).toMatchObject({...licenseAgreementList[0], id: result.currentSoftwareProduct.licensingData.licenseAgreement}); result.currentSoftwareProduct.licensingData.featureGroups.forEach(fg => { - expect(featureGroupsList).toInclude({ - id: fg.enum, - name: fg.title, - referencingLicenseAgreements: [result.currentSoftwareProduct.licensingData.licenseAgreement] - }); - expect(result.featureGroupsList).toInclude(fg); + expect(featureGroupsList[0]).toMatchObject({...featureGroupsList[0], id: fg}); }); - expect(result.qdata).toEqual({}); - expect(result.qschema).toEqual(vspQschema); + expect(result.qdata).toEqual(qdata); expect(result.isReadOnlyMode).toEqual(true); }); it('VSP Details view test', () => { + let params = { - currentSoftwareProduct: currentSoftwareProduct, - softwareProductCategories: categories, - qdata: {}, - qschema: vspQschema, - finalizedLicenseModelList: [{ - id: 'VLM_ID1', - vendorName: 'VLM1', - version: '2.0', - viewableVersions: ['1.0', '2.0'] - }, { - id: 'VLM_ID2', - vendorName: 'VLM2', - version: '3.0', - viewableVersions: ['1.0', '2.0', '3.0'] - }], - licenseAgreementList: [{id: 'LA_ID1'}, {id: 'LA_ID2'}], - featureGroupsList: [ - {id: 'FG_ID1', name: 'FG1', referencingLicenseAgreements: ['LA_ID1']}, - {id: 'FG_ID2', name: 'FG2', referencingLicenseAgreements: ['LA_ID1']} - ] + currentSoftwareProduct, + softwareProductCategories, + qdata, + dataMap, + isFormValid: true, + finalizedLicenseModelList, + licenseAgreementList, + featureGroupsList, + genericFieldInfo, + qGenericFieldInfo, }; var renderer = TestUtils.createRenderer(); renderer.render( @@ -196,42 +184,26 @@ describe('Software Product Details: ', function () { onVendorParamChanged = {dummyFunc}/> ); let renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); }); it('in view: should change vendorId and update vsp licensing-version', done => { - let vspWithLicensingData = { - ...currentSoftwareProduct, - licensingData: { - licenseAgreement: 'LA_ID1', - featureGroups: [{enum: 'FG_ID1', title: 'FG1'}] - } - }; + let params = { - currentSoftwareProduct: vspWithLicensingData, - softwareProductCategories: categories, - qdata: {}, - qschema: vspQschema, - finalizedLicenseModelList: [{ - id: 'VLM_ID1', - vendorName: 'VLM1', - version: '2.0', - viewableVersions: ['1.0', '2.0'] - }, { - id: 'VLM_ID2', - vendorName: 'VLM2', - version: '3.0', - viewableVersions: ['1.0', '2.0', '3.0'] - }], - licenseAgreementList: [{id: 'LA_ID1'}, {id: 'LA_ID2'}], - featureGroupsList: [ - {id: 'FG_ID1', name: 'FG1', referencingLicenseAgreements: ['LA_ID1']}, - {id: 'FG_ID2', name: 'FG2', referencingLicenseAgreements: ['LA_ID1']} - ] + currentSoftwareProduct: currentSoftwareProductWithLicensingData, + softwareProductCategories, + qdata, + dataMap, + isFormValid: true, + genericFieldInfo, + qGenericFieldInfo, + finalizedLicenseModelList, + licenseAgreementList, + featureGroupsList }; const onVendorChangedListener = (deltaData) => { - expect(deltaData.vendorId).toEqual('VLM_ID2'); - expect(deltaData.vendorName).toEqual('VLM2'); + expect(deltaData.vendorId).toEqual(finalizedLicenseModelList[1].id); + expect(deltaData.vendorName).toEqual(finalizedLicenseModelList[1].vendorName); expect(deltaData.licensingVersion).toEqual(''); expect(deltaData.licensingData).toEqual({}); done(); @@ -241,7 +213,10 @@ describe('Software Product Details: ', function () { currentSoftwareProduct = {params.currentSoftwareProduct} softwareProductCategories = {params.softwareProductCategories} qdata = {params.qdata} - qschema = {params.qschema} + qGenericFieldInfo = {params.qGenericFieldInfo} + genericFieldInfo = {params.genericFieldInfo} + isFormValid={params.isFormValid} + dataMap={params.dataMap} finalizedLicenseModelList = {params.finalizedLicenseModelList} licenseAgreementList = {params.licenseAgreementList} featureGroupsList = {params.featureGroupsList} @@ -250,37 +225,27 @@ describe('Software Product Details: ', function () { onValidityChanged = {dummyFunc} onQDataChanged = {dummyFunc} onVendorParamChanged = {(deltaData) => onVendorChangedListener(deltaData)}/>); - expect(vspDetailsView).toExist(); - vspDetailsView.onVendorParamChanged({vendorId: 'VLM_ID2'}); + expect(vspDetailsView).toBeTruthy(); + vspDetailsView.onVendorParamChanged({vendorId: finalizedLicenseModelList[1].id}); }); it('in view: should change licensing-version and update licensing data', done => { let params = { currentSoftwareProduct: currentSoftwareProduct, - softwareProductCategories: categories, - qdata: {}, - qschema: vspQschema, - finalizedLicenseModelList: [{ - id: 'VLM_ID1', - vendorName: 'VLM1', - version: '2.0', - viewableVersions: ['1.0', '2.0'] - }, { - id: 'VLM_ID2', - vendorName: 'VLM2', - version: '3.0', - viewableVersions: ['1.0', '2.0', '3.0'] - }], - licenseAgreementList: [{id: 'LA_ID1'}, {id: 'LA_ID2'}], - featureGroupsList: [ - {id: 'FG_ID1', name: 'FG1', referencingLicenseAgreements: ['LA_ID1']}, - {id: 'FG_ID2', name: 'FG2', referencingLicenseAgreements: ['LA_ID1']} - ] + softwareProductCategories, + qdata, + dataMap, + isFormValid: true, + genericFieldInfo, + qGenericFieldInfo, + finalizedLicenseModelList, + licenseAgreementList, + featureGroupsList }; const onVendorChangedListener = (deltaData) => { - expect(deltaData.vendorId).toEqual('VLM_ID2'); - expect(deltaData.vendorName).toEqual('VLM2'); - expect(deltaData.licensingVersion).toEqual('2.0'); + expect(deltaData.vendorId).toEqual(finalizedLicenseModelList[1].id); + expect(deltaData.vendorName).toEqual(finalizedLicenseModelList[1].vendorName); + expect(deltaData.licensingVersion).toEqual(finalizedLicenseModelList[1].viewableVersion[0]); expect(deltaData.licensingData).toEqual({}); done(); }; @@ -292,36 +257,26 @@ describe('Software Product Details: ', function () { onValidityChanged = {dummyFunc} onQDataChanged = {dummyFunc} onVendorParamChanged = {(deltaData) => onVendorChangedListener(deltaData)}/>); - expect(vspDetailsView).toExist(); - vspDetailsView.onVendorParamChanged({vendorId: 'VLM_ID2', licensingVersion: '2.0'}); + expect(vspDetailsView).toBeTruthy(); + vspDetailsView.onVendorParamChanged({vendorId: finalizedLicenseModelList[1].id, licensingVersion: finalizedLicenseModelList[1].viewableVersion[0]}); }); it('in view: should change subcategory', done => { let params = { currentSoftwareProduct: currentSoftwareProduct, - softwareProductCategories: categories, - qdata: {}, - qschema: vspQschema, - finalizedLicenseModelList: [{ - id: 'VLM_ID1', - vendorName: 'VLM1', - version: '2.0', - viewableVersions: ['1.0', '2.0'] - }, { - id: 'VLM_ID2', - vendorName: 'VLM2', - version: '3.0', - viewableVersions: ['1.0', '2.0', '3.0'] - }], - licenseAgreementList: [{id: 'LA_ID1'}, {id: 'LA_ID2'}], - featureGroupsList: [ - {id: 'FG_ID1', name: 'FG1', referencingLicenseAgreements: ['LA_ID1']}, - {id: 'FG_ID2', name: 'FG2', referencingLicenseAgreements: ['LA_ID1']} - ] + softwareProductCategories, + qdata, + dataMap, + isFormValid: true, + genericFieldInfo, + qGenericFieldInfo, + finalizedLicenseModelList, + licenseAgreementList, + featureGroupsList }; const onDataChangedListener = ({category, subCategory}) => { - expect(category).toEqual('category2'); - expect(subCategory).toEqual('subCategory2'); + expect(category).toEqual(softwareProductCategories[1].uniqueId); + expect(subCategory).toEqual(softwareProductCategories[1].subcategories[0].uniqueId); done(); }; @@ -332,45 +287,29 @@ describe('Software Product Details: ', function () { onValidityChanged = {dummyFunc} onQDataChanged = {dummyFunc} onVendorParamChanged = {dummyFunc}/>); - expect(vspDetailsView).toExist(); - vspDetailsView.onSelectSubCategory('subCategory2'); + expect(vspDetailsView).toBeTruthy(); + vspDetailsView.onSelectSubCategory(softwareProductCategories[1].subcategories[0].uniqueId); }); it('in view: should change feature groups', done => { - let vspWithLicensingData = { - ...currentSoftwareProduct, - licensingData: { - licenseAgreement: 'LA_ID1', - featureGroups: [{enum: 'FG_ID1', title: 'FG1'}] - } - }; + let params = { - currentSoftwareProduct: vspWithLicensingData, - softwareProductCategories: categories, - qdata: {}, - qschema: vspQschema, - finalizedLicenseModelList: [{ - id: 'VLM_ID1', - vendorName: 'VLM1', - version: '2.0', - viewableVersions: ['1.0', '2.0'] - }, { - id: 'VLM_ID2', - vendorName: 'VLM2', - version: '3.0', - viewableVersions: ['1.0', '2.0', '3.0'] - }], - licenseAgreementList: [{id: 'LA_ID1'}, {id: 'LA_ID2'}], - featureGroupsList: [ - {id: 'FG_ID1', name: 'FG1', referencingLicenseAgreements: ['LA_ID1']}, - {id: 'FG_ID2', name: 'FG2', referencingLicenseAgreements: ['LA_ID1']} - ] + currentSoftwareProduct: currentSoftwareProductWithLicensingData, + softwareProductCategories, + qdata, + dataMap, + isFormValid: true, + genericFieldInfo, + qGenericFieldInfo, + finalizedLicenseModelList, + licenseAgreementList, + featureGroupsList }; const onDataChangedListener = ({licensingData}) => { - expect(licensingData.licenseAgreement).toEqual('LA_ID1'); + expect(licensingData.licenseAgreement).toEqual(licenseAgreementList[0].id); expect(licensingData.featureGroups).toEqual([ - {enum: 'FG_ID1', title: 'FG1'}, - {enum: 'FG_ID2', title: 'FG2'} + {enum: featureGroupsList[0].id, title: featureGroupsList[0].name}, + {enum: featureGroupsList[1].id, title: featureGroupsList[1].name} ]); done(); }; @@ -382,45 +321,29 @@ describe('Software Product Details: ', function () { onValidityChanged = {dummyFunc} onQDataChanged = {dummyFunc} onVendorParamChanged = {dummyFunc}/>); - expect(vspDetailsView).toExist(); + expect(vspDetailsView).toBeTruthy(); vspDetailsView.onFeatureGroupsChanged({featureGroups: [ - {enum: 'FG_ID1', title: 'FG1'}, - {enum: 'FG_ID2', title: 'FG2'} + {enum: featureGroupsList[0].id, title: featureGroupsList[0].name}, + {enum: featureGroupsList[1].id, title: featureGroupsList[1].name} ]}); }); it('in view: should change license agreement', done => { - let vspWithLicensingData = { - ...currentSoftwareProduct, - licensingData: { - licenseAgreement: 'LA_ID1', - featureGroups: [{enum: 'FG_ID1', title: 'FG1'}] - } - }; + let params = { - currentSoftwareProduct: vspWithLicensingData, - softwareProductCategories: categories, - qdata: {}, - qschema: vspQschema, - finalizedLicenseModelList: [{ - id: 'VLM_ID1', - vendorName: 'VLM1', - version: '2.0', - viewableVersions: ['1.0', '2.0'] - }, { - id: 'VLM_ID2', - vendorName: 'VLM2', - version: '3.0', - viewableVersions: ['1.0', '2.0', '3.0'] - }], - licenseAgreementList: [{id: 'LA_ID1'}, {id: 'LA_ID2'}], - featureGroupsList: [ - {id: 'FG_ID1', name: 'FG1', referencingLicenseAgreements: ['LA_ID1']}, - {id: 'FG_ID2', name: 'FG2', referencingLicenseAgreements: ['LA_ID1']} - ] + currentSoftwareProduct: currentSoftwareProductWithLicensingData, + softwareProductCategories, + qdata, + dataMap, + isFormValid: true, + genericFieldInfo, + qGenericFieldInfo, + finalizedLicenseModelList, + licenseAgreementList, + featureGroupsList }; const onDataChangedListener = ({licensingData}) => { - expect(licensingData.licenseAgreement).toEqual('LA_ID2'); + expect(licensingData.licenseAgreement).toEqual(licenseAgreementList[1].id); expect(licensingData.featureGroups).toEqual([]); done(); }; @@ -432,7 +355,7 @@ describe('Software Product Details: ', function () { onValidityChanged = {dummyFunc} onQDataChanged = {dummyFunc} onVendorParamChanged = {dummyFunc}/>); - expect(vspDetailsView).toExist(); - vspDetailsView.onLicensingDataChanged({licenseAgreement: 'LA_ID2', featureGroups: []}); + expect(vspDetailsView).toBeTruthy(); + vspDetailsView.onLicensingDataChanged({licenseAgreement: licenseAgreementList[1].id, featureGroups: []}); }); }); diff --git a/openecomp-ui/test/softwareProduct/details/test.js b/openecomp-ui/test/softwareProduct/details/test.js index 9803b1611d..df84d184ce 100644 --- a/openecomp-ui/test/softwareProduct/details/test.js +++ b/openecomp-ui/test/softwareProduct/details/test.js @@ -1,84 +1,65 @@ -/*- - * ============LICENSE_START======================================================= - * SDC - * ================================================================================ +/*! * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ + * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * + * + * http://www.apache.org/licenses/LICENSE-2.0 + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express + * or implied. See the License for the specific language governing + * permissions and limitations under the License. */ - -import {expect} from 'chai'; import deepFreeze from 'deep-freeze'; import mockRest from 'test-utils/MockRest.js'; -import {cloneAndSet} from 'test-utils/Util.js'; +import {cloneAndSet, buildFromExistingObject} from 'test-utils/Util.js'; import {storeCreator} from 'sdc-app/AppStore.js'; import SoftwareProductCreationActionHelper from 'sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationActionHelper.js'; import SoftwareProductActionHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js'; import SoftwareProductCategoriesHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductCategoriesHelper.js'; +import {forms} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js'; +import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; + +import {VSPEditorFactory, VSPEditorPostFactory, VSPEditorFactoryWithLicensingData, VSPEditorPostFactoryWithLicensingData} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import {CategoryFactory} from 'test-utils/factories/softwareProduct/VSPCategoriesFactory.js'; +import {heatSetupManifest} from 'test-utils/factories/softwareProduct/SoftwareProductAttachmentsFactories.js'; + +import { FeatureGroupStoreFactory as FeatureGroup} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js'; +import {LicenseAgreementStoreFactory as LicenseAgreement} from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; + describe('Software Product Module Tests', function () { it('Get Software Products List', () => { const store = storeCreator(); deepFreeze(store.getState()); - - const softwareProductList = [ - { - name: 'VSP1', - description: 'hjhj', - version: '0.1', - id: 'EBADF561B7FA4A788075E1840D0B5971', - subCategory: 'resourceNewCategory.network connectivity.virtual links', - category: 'resourceNewCategory.network connectivity', - vendorId: '5259EDE4CC814DC9897BA6F69E2C971B', - vendorName: 'Vendor', - checkinStatus: 'CHECK_OUT', - licensingData: { - 'featureGroups': [] - } - }, - { - name: 'VSP2', - description: 'dfdfdfd', - version: '0.1', - id: '2F47447D22DB4C53B020CA1E66201EF2', - subCategory: 'resourceNewCategory.network connectivity.virtual links', - category: 'resourceNewCategory.network connectivity', - vendorId: '5259EDE4CC814DC9897BA6F69E2C971B', - vendorName: 'Vendor', - checkinStatus: 'CHECK_OUT', - licensingData: { - featureGroups: [] - } - } - ]; - + const softwareProductList = VSPEditorFactory.buildList(2); deepFreeze(softwareProductList); - deepFreeze(store.getState()); - const expectedStore = cloneAndSet(store.getState(), 'softwareProductList', softwareProductList); mockRest.addHandler('fetch', ({options, data, baseUrl}) => { - expect(baseUrl).to.equal('/onboarding-api/v1.0/vendor-software-products/'); - expect(data).to.deep.equal(undefined); - expect(options).to.equal(undefined); + expect(baseUrl).toEqual('/onboarding-api/v1.0/vendor-software-products/'); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); return {results: softwareProductList}; }); + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual('/onboarding-api/v1.0/vendor-software-products/?versionFilter=Final'); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: []}; + }); + return SoftwareProductActionHelper.fetchSoftwareProductList(store.dispatch).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + return SoftwareProductActionHelper.fetchFinalizedSoftwareProductList(store.dispatch); + }).then(() => { + expect(store.getState()).toEqual(expectedStore); }); }); @@ -86,62 +67,195 @@ describe('Software Product Module Tests', function () { const store = storeCreator(); deepFreeze(store.getState()); - const softwareProductPostRequest = deepFreeze({ - name: 'vsp1', - description: 'string', - vendorId: '1', - vendorName: 'Vendor', - icon: 'icon', - subCategory: 'resourceNewCategory.network connectivity.virtual links', - category: 'resourceNewCategory.network connectivity', - licensingData: {} - }); + const softwareProductPostRequest = VSPEditorPostFactory.build(); + deepFreeze(softwareProductPostRequest); + const idFromResponse = '1'; + const expectedVSP = VSPEditorPostFactory.build({id: idFromResponse, vendorId: softwareProductPostRequest.vendorId}); + deepFreeze(expectedVSP); - const softwareProductToAdd = deepFreeze({ - ...softwareProductPostRequest + mockRest.addHandler('post', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual('/onboarding-api/v1.0/vendor-software-products/'); + expect(data).toEqual(softwareProductPostRequest); + expect(options).toEqual(undefined); + return { + vspId: idFromResponse + }; }); - const softwareProductIdFromResponse = 'ADDED_ID'; - const softwareProductAfterAdd = deepFreeze({ - ...softwareProductToAdd, - id: softwareProductIdFromResponse + return SoftwareProductCreationActionHelper.createSoftwareProduct(store.dispatch, { + softwareProduct: softwareProductPostRequest + }).then((response) => { + expect(response.vspId).toEqual(idFromResponse); }); + }); + + it('Fetch Software Product with manifest', () => { + const store = storeCreator(); + deepFreeze(store.getState()); - const expectedStore = cloneAndSet(store.getState(), 'softwareProductList', [softwareProductAfterAdd]); + const softwareProductPostRequest = VSPEditorPostFactory.build(); + deepFreeze(softwareProductPostRequest); + + const expectedGenericInfo = { + 'name': { + isValid: true, + errorText: '', + validations: [{type: 'validateName', data: true}, {type: 'maxLength', data: 25}, { + type: 'required', + data: true + }] + }, + 'description': { + isValid: true, + errorText: '', + validations: [{type: 'required', data: true}] + } + }; + const expectedFormName = forms.VENDOR_SOFTWARE_PRODUCT_DETAILS; + + const idFromResponse = '1'; + const version = { id: '0.1', label: '0.1'}; + const expectedVSP = VSPEditorPostFactory.build({id: idFromResponse, vendorId: softwareProductPostRequest.vendorId}); + deepFreeze(expectedVSP); + let expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductEditor.data', expectedVSP); + expectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductEditor.genericFieldInfo', expectedGenericInfo); + expectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductEditor.formName', expectedFormName); + expectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductQuestionnaire', {qdata: {}, dataMap: {}, qgenericFieldInfo: {}}); + + expectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductAttachments.heatValidation', { + 'attachmentsTree': {}, + 'errorList': [], + 'selectedNode': 'All' + }); + let manifest = heatSetupManifest.build(); + expectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductAttachments.heatSetup', manifest); - mockRest.addHandler('create', ({options, data, baseUrl}) => { - expect(baseUrl).to.equal('/onboarding-api/v1.0/vendor-software-products/'); - expect(data).to.deep.equal(softwareProductPostRequest); - expect(options).to.equal(undefined); + mockRest.addHandler('post', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual('/onboarding-api/v1.0/vendor-software-products/'); + expect(data).toEqual(softwareProductPostRequest); + expect(options).toEqual(undefined); return { - vspId: softwareProductIdFromResponse + vspId: idFromResponse, + version }; }); + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${idFromResponse}/versions/${version.id}`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return expectedVSP; + }); + + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${idFromResponse}/versions/${version.id}/questionnaire`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {data: JSON.stringify({}), schema: JSON.stringify({})}; + }); + + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${idFromResponse}/versions/${version.id}/orchestration-template-candidate/manifest`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return manifest; + }); + return SoftwareProductCreationActionHelper.createSoftwareProduct(store.dispatch, { - softwareProduct: softwareProductToAdd + softwareProduct: softwareProductPostRequest + }).then(() => { + return SoftwareProductActionHelper.fetchSoftwareProduct(store.dispatch, {softwareProductId: idFromResponse, version}); }).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + return SoftwareProductActionHelper.loadSoftwareProductHeatCandidate(store.dispatch, {softwareProductId: idFromResponse, version}); + }).then(() => { + expect(store.getState()).toEqual(expectedStore); + let newName = 'newName'; + expectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductEditor.formReady', null); + ValidationHelper.dataChanged(store.dispatch, {deltaData: {'name': newName}, formName: forms.VENDOR_SOFTWARE_PRODUCT_DETAILS}); + expectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductEditor.data.name', newName); + expect(store.getState()).toEqual(expectedStore); }); }); + + it('Load and edit Software Product licensing data', () => { + const store = storeCreator(); + + const softwareProductPostRequest = VSPEditorPostFactory.build(); + deepFreeze(softwareProductPostRequest); + + const licenseModelId = softwareProductPostRequest.vendorId; + const LMVersion = VersionControllerUtilsFactory.build().version; + const secondLicenseModelId = 'secondLicenseModelId'; + + let FG1 = FeatureGroup.build(); + let LA1 = LicenseAgreement.build({ + featureGroupsIds: [FG1.id] + }); + + let FG2 = FeatureGroup.build(); + let LA2 = LicenseAgreement.build({ + featureGroupsIds: [FG2.id] + }); + + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual('/sdc1/feProxy/rest/v1/categories/resources/'); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return []; + }); + + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual('/onboarding-api/v1.0/vendor-license-models/?versionFilter=Final'); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: []}; + }); + + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${licenseModelId}/versions/${LMVersion.id}/license-agreements`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: [LA1]}; + }); + + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${licenseModelId}/versions/${LMVersion.id}/feature-groups`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: [FG1]}; + }); + + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${secondLicenseModelId}/versions/${LMVersion.id}/license-agreements`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: [LA2]}; + }); + + mockRest.addHandler('fetch', ({options, data, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${secondLicenseModelId}/versions/${LMVersion.id}/feature-groups`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); + return {results: [FG2]}; + }); + + return SoftwareProductActionHelper.loadSoftwareProductDetailsData(store.dispatch, {licenseModelId, licensingVersion: LMVersion}).then(() => { + let state = store.getState(); + expect(state.licenseModel.licenseAgreement.licenseAgreementList).toEqual([LA1]); + expect(state.licenseModel.featureGroup.featureGroupsList).toEqual([FG1]); + return SoftwareProductActionHelper.softwareProductEditorVendorChanged(store.dispatch, + {deltaData: {vendorId: secondLicenseModelId, licensingVersion: LMVersion}, + formName: forms.VENDOR_SOFTWARE_PRODUCT_DETAILS}); + }).then(() => { + let state = store.getState(); + expect(state.licenseModel.licenseAgreement.licenseAgreementList).toEqual([LA2]); + expect(state.licenseModel.featureGroup.featureGroupsList).toEqual([FG2]); + }); + }); + it('Save Software product', () => { - const softwareProduct = { - name: 'VSP5', - id: '4730033D16C64E3CA556AB0AC4478218', - description: 'A software model for Fortigate.', - subCategory: 'resourceNewCategory.network connectivity.virtual links', - category: 'resourceNewCategory.network connectivity', - vendorId: '1', - vendorName: 'Vendor', - licensingVersion: '1.0', - icon: 'icon', - licensingData: { - licenceAgreement: '123', - featureGroups: [ - '123', '234' - ] - } - }; + + const softwareProduct = VSPEditorFactoryWithLicensingData.build(); deepFreeze(softwareProduct); const store = storeCreator({ @@ -152,15 +266,20 @@ describe('Software Product Module Tests', function () { }); deepFreeze(store.getState()); - const toBeUpdatedSoftwareProductId = softwareProduct.id; - const softwareProductUpdateData = { - ...softwareProduct, + const dataForUpdate = { name: 'VSP5_UPDATED', description: 'A software model for Fortigate._UPDATED' }; + + const toBeUpdatedSoftwareProductId = softwareProduct.id; + let softwareProductUpdateData = VSPEditorPostFactoryWithLicensingData.build(dataForUpdate); + delete softwareProductUpdateData.version; + + const softwareProductPutRequest = buildFromExistingObject(VSPEditorFactoryWithLicensingData, softwareProductUpdateData, {id: toBeUpdatedSoftwareProductId, version: softwareProduct.version}); + deepFreeze(softwareProductUpdateData); - const expectedStore = cloneAndSet(store.getState(), 'softwareProductList', [softwareProductUpdateData]); + const expectedStore = cloneAndSet(store.getState(), 'softwareProductList', [softwareProductPutRequest]); const questionnaireData = { general: { affinityData: { @@ -171,60 +290,30 @@ describe('Software Product Module Tests', function () { }; deepFreeze(questionnaireData); - mockRest.addHandler('save', ({data, options, baseUrl}) => { - const expectedData = { - name: 'VSP5_UPDATED', - description: 'A software model for Fortigate._UPDATED', - subCategory: 'resourceNewCategory.network connectivity.virtual links', - category: 'resourceNewCategory.network connectivity', - vendorId: '1', - vendorName: 'Vendor', - licensingVersion: '1.0', - icon: 'icon', - licensingData: { - licenceAgreement: '123', - featureGroups: [ - '123', '234' - ] - } - }; - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}`); - expect(data).to.deep.equal(expectedData); - expect(options).to.equal(undefined); + mockRest.addHandler('put', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/versions/${softwareProduct.version.id}`); + expect(data).toEqual(softwareProductUpdateData); + expect(options).toEqual(undefined); return {returnCode: 'OK'}; }); - mockRest.addHandler('save', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/questionnaire`); - expect(data).to.deep.equal(questionnaireData); - expect(options).to.equal(undefined); + mockRest.addHandler('put', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/versions/${softwareProduct.version.id}/questionnaire`); + expect(data).toEqual(questionnaireData); + expect(options).toEqual(undefined); return {returnCode: 'OK'}; }); return SoftwareProductActionHelper.updateSoftwareProduct(store.dispatch, { - softwareProduct: softwareProductUpdateData, + softwareProduct: softwareProductPutRequest, qdata: questionnaireData }).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); + it('Save Software product data only', () => { - const softwareProduct = { - name: 'VSP5', - id: '4730033D16C64E3CA556AB0AC4478218', - description: 'A software model for Fortigate.', - subCategory: 'resourceNewCategory.network connectivity.virtual links', - category: 'resourceNewCategory.network connectivity', - vendorId: '1', - vendorName: 'Vendor', - licensingVersion: '1.0', - icon: 'icon', - licensingData: { - licenceAgreement: '123', - featureGroups: [ - '123', '234' - ] - } - }; + + const softwareProduct = VSPEditorFactoryWithLicensingData.build(); deepFreeze(softwareProduct); const store = storeCreator({ @@ -236,61 +325,35 @@ describe('Software Product Module Tests', function () { deepFreeze(store.getState()); const expectedStore = store.getState(); - const toBeUpdatedSoftwareProductId = softwareProduct.id; - const softwareProductUpdateData = { - ...softwareProduct, + const dataForUpdate = { name: 'VSP5_UPDATED', description: 'A software model for Fortigate._UPDATED' }; + + const toBeUpdatedSoftwareProductId = softwareProduct.id; + let softwareProductUpdateData = VSPEditorPostFactoryWithLicensingData.build(dataForUpdate); + delete softwareProductUpdateData.version; + + const softwareProductPutRequest = buildFromExistingObject(VSPEditorFactoryWithLicensingData, softwareProductUpdateData, {id: toBeUpdatedSoftwareProductId, version: softwareProduct.version}); + deepFreeze(softwareProductUpdateData); - mockRest.addHandler('save', ({data, options, baseUrl}) => { - const expectedData = { - name: 'VSP5_UPDATED', - description: 'A software model for Fortigate._UPDATED', - subCategory: 'resourceNewCategory.network connectivity.virtual links', - category: 'resourceNewCategory.network connectivity', - vendorId: '1', - vendorName: 'Vendor', - licensingVersion: '1.0', - icon: 'icon', - licensingData: { - licenceAgreement: '123', - featureGroups: [ - '123', '234' - ] - } - }; - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}`); - expect(data).to.deep.equal(expectedData); - expect(options).to.equal(undefined); + mockRest.addHandler('put', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/versions/${softwareProduct.version.id}`); + expect(data).toEqual(softwareProductUpdateData); + expect(options).toEqual(undefined); return {returnCode: 'OK'}; }); return SoftwareProductActionHelper.updateSoftwareProductData(store.dispatch, { - softwareProduct: softwareProductUpdateData + softwareProduct: softwareProductPutRequest }).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); it('Save Software product questionnaire only', () => { - const softwareProduct = { - name: 'VSP5', - id: '4730033D16C64E3CA556AB0AC4478218', - description: 'A software model for Fortigate.', - subCategory: 'resourceNewCategory.network connectivity.virtual links', - category: 'resourceNewCategory.network connectivity', - vendorId: '1', - vendorName: 'Vendor', - icon: 'icon', - licensingData: { - licenceAgreement: '123', - featureGroups: [ - '123', '234' - ] - } - }; + const softwareProduct = VSPEditorFactoryWithLicensingData.build(); deepFreeze(softwareProduct); const store = storeCreator({ @@ -313,71 +376,30 @@ describe('Software Product Module Tests', function () { }; deepFreeze(questionnaireData); - mockRest.addHandler('save', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/questionnaire`); - expect(data).to.deep.equal(questionnaireData); - expect(options).to.equal(undefined); + mockRest.addHandler('put', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/versions/${softwareProduct.version.id}/questionnaire`); + expect(data).toEqual(questionnaireData); + expect(options).toEqual(undefined); return {returnCode: 'OK'}; }); return SoftwareProductActionHelper.updateSoftwareProductQuestionnaire(store.dispatch, { softwareProductId: softwareProduct.id, + version: softwareProduct.version, qdata: questionnaireData }).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); it('Handle category without subcategories', () => { - const categories = deepFreeze([ - { - name: 'Resource Category 1', - normalizedName: 'resource category 1', - uniqueId: 'resourceNewCategory.resource category 1', - subcategories: [ - { - name: 'Sub Category for RC 1', - normalizedName: 'sub category for rc 1', - uniqueId: 'resourceNewCategory.resource category 1.sub category for rc 1' - }, - { - name: 'SC4RC2', - normalizedName: 'sc4rc2', - uniqueId: 'resourceNewCategory.resource category 1.sc4rc2' - }, - { - name: 'SC4RC1', - normalizedName: 'sc4rc1', - uniqueId: 'resourceNewCategory.resource category 1.sc4rc1' - } - ] - }, - { - name: 'Eeeeee', - normalizedName: 'eeeeee', - uniqueId: 'resourceNewCategory.eeeeee' - }, - { - name: 'Some Recource', - normalizedName: 'some recource', - uniqueId: 'resourceNewCategory.some recource', - subcategories: [ - { - name: 'Second Sub Category for S', - normalizedName: 'second sub category for s', - uniqueId: 'resourceNewCategory.some recource.second sub category for s' - }, - { - name: 'Sub Category for Some Rec', - normalizedName: 'sub category for some rec', - uniqueId: 'resourceNewCategory.some recource.sub category for some rec' - } - ] - } - ]); - const category = SoftwareProductCategoriesHelper.getCurrentCategoryOfSubCategory('resourceNewCategory.some recource.sub category for some rec', categories); - expect(category).to.equal('resourceNewCategory.some recource'); + + const categories = CategoryFactory.buildList(3); + categories[0].subcategories = CategoryFactory.buildList(3); + categories[2].subcategories = CategoryFactory.buildList(3); + + const category = SoftwareProductCategoriesHelper.getCurrentCategoryOfSubCategory(categories[2].subcategories[2].uniqueId, categories); + expect(category).toEqual(categories[2].uniqueId); }); }); - diff --git a/openecomp-ui/test/softwareProduct/details/vspQschema.js b/openecomp-ui/test/softwareProduct/details/vspQschema.js index 5612b19991..fb8ac6fd91 100644 --- a/openecomp-ui/test/softwareProduct/details/vspQschema.js +++ b/openecomp-ui/test/softwareProduct/details/vspQschema.js @@ -1,21 +1,17 @@ -/*- - * ============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. */ export const vspQschema = { diff --git a/openecomp-ui/test/softwareProduct/landingPage/landingPage.test.js b/openecomp-ui/test/softwareProduct/landingPage/landingPage.test.js new file mode 100644 index 0000000000..f06ad61e4f --- /dev/null +++ b/openecomp-ui/test/softwareProduct/landingPage/landingPage.test.js @@ -0,0 +1,177 @@ +/*! + * 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 {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import {CategoryWithSubFactory} from 'test-utils/factories/softwareProduct/VSPCategoriesFactory.js'; +import {LicenseAgreementStoreFactory} from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js'; +import {FeatureGroupStoreFactory} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js'; +import {default as SoftwareProductQSchemaFactory} from 'test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js'; +import {default as VspQdataFactory} from 'test-utils/factories/softwareProduct/VspQdataFactory.js'; +import {VSPComponentsFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js'; +import {FinalizedLicenseModelFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js'; + + +import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js'; +import SoftwareProductLandingPageView from 'sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx'; + + +describe('Software Product Landing Page: ', function () { + + let currentSoftwareProduct = {}, softwareProductCategories = [], + finalizedLicenseModelList, licenseAgreementList, featureGroupsList, qschema, qdata = {}; + const dummyFunc = () => {}; + beforeAll(function() { + finalizedLicenseModelList = FinalizedLicenseModelFactory.buildList(2); + currentSoftwareProduct = VSPEditorFactory.build({id:'RTRTG454545', vendorId: finalizedLicenseModelList[0].id, vendorName: finalizedLicenseModelList[0].name}); + softwareProductCategories = CategoryWithSubFactory.buildList(2,{},{quantity: 1}); + licenseAgreementList = LicenseAgreementStoreFactory.buildList(2); + featureGroupsList = FeatureGroupStoreFactory.buildList(2,{referencingLicenseAgreements:[licenseAgreementList[0].id]}); + qdata = VspQdataFactory.build(); + qschema = SoftwareProductQSchemaFactory.build(qdata); + + }); + + + + it('should mapper exist', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + it('should mapper return vsp basic data', () => { + const obj = { + softwareProduct: { + softwareProductEditor: { + data: currentSoftwareProduct + }, + softwareProductCategories, + softwareProductQuestionnaire: { + qdata, + qschema + }, + softwareProductComponents: { + componentsList:[] + } + }, + finalizedLicenseModelList, + licenseModel: { + licenseAgreement: { + licenseAgreementList + }, + featureGroup: { + featureGroupsList + } + } + }; + + const result = mapStateToProps(obj); + expect(result.currentSoftwareProduct).toBeTruthy(); + expect(result.isReadOnlyMode).toEqual(true); + + }); + + it('vsp landing basic view', () => { + + const params = { + currentSoftwareProduct, + isReadOnlyMode: false, + componentsList: VSPComponentsFactory.buildList(2) + }; + + let vspLandingView = TestUtils.renderIntoDocument(); + expect(vspLandingView).toBeTruthy(); + }); + + it('vsp landing handleOnDragEnter test ', () => { + + const params = { + currentSoftwareProduct, + isReadOnlyMode: false, + componentsList: VSPComponentsFactory.buildList(2) + }; + + let vspLandingView = TestUtils.renderIntoDocument(); + expect(vspLandingView).toBeTruthy(); + vspLandingView.handleOnDragEnter(false); + expect(vspLandingView.state.dragging).toEqual(true); + }); + + + it('vsp landing handleImportSubmit test ', () => { + + const params = { + currentSoftwareProduct, + isReadOnlyMode: false, + componentsList: VSPComponentsFactory.buildList(2), + onUploadConfirmation: dummyFunc, + onUpload: dummyFunc, + onInvalidFileSizeUpload: dummyFunc + }; + + let vspLandingView = TestUtils.renderIntoDocument(); + expect(vspLandingView).toBeTruthy(); + const files = [ + { + name: 'aaa', + size: 123 + } + ]; + + vspLandingView.handleImportSubmit(files, false); + expect(vspLandingView.state.dragging).toEqual(false); + expect(vspLandingView.state.fileName).toEqual(files[0].name); + const files1 = [ + { + name: 'bbb', + size: 0 + } + ]; + vspLandingView.handleImportSubmit(files1, false); + }); + + it('vsp landing handleImportSubmit with damaged file test ', () => { + + const params = { + currentSoftwareProduct, + isReadOnlyMode: false, + componentsList: VSPComponentsFactory.buildList(2), + onUploadConfirmation: dummyFunc, + onUpload: dummyFunc, + onInvalidFileSizeUpload: dummyFunc + }; + + let vspLandingView = TestUtils.renderIntoDocument(); + expect(vspLandingView).toBeTruthy(); + const files = [ + { + name: 'aaa', + size: 0 + } + ]; + + vspLandingView.handleImportSubmit(files, false); + expect(vspLandingView.state.dragging).toEqual(false); + expect(vspLandingView.state.fileName).toEqual(''); + }); +}); diff --git a/openecomp-ui/test/softwareProduct/networks/SoftwareProductNetworksView.test.js b/openecomp-ui/test/softwareProduct/networks/SoftwareProductNetworksView.test.js index a7f7b2b0c2..6ef6bcf02a 100644 --- a/openecomp-ui/test/softwareProduct/networks/SoftwareProductNetworksView.test.js +++ b/openecomp-ui/test/softwareProduct/networks/SoftwareProductNetworksView.test.js @@ -1,63 +1,39 @@ -/*- - * ============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/networks/SoftwareProductNetworks.js'; import SoftwareProductNetworksView from 'sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksView.jsx'; -import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; +//import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js'; + +import VSPNetworkFactory from 'test-utils/factories/softwareProduct/SoftwareProductNetworkFactory.js'; +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import {VSPComponentsVersionControllerFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js'; describe('SoftwareProductNetworks 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(); - const networksList = [ - { - name:'dummy_net_1', - dhcp:true, - 'id':'7F60CD390458421DA588AF4AD217B93F' - }, - { - name:'dummy_net_2', - dhcp:true, - 'id':'AD217B93F7F60CD390458421DA588AF4' - } - ]; + const networksList = VSPNetworkFactory.buildList(2); var obj = { softwareProduct: { @@ -71,49 +47,21 @@ describe('SoftwareProductNetworks Mapper and View Classes', () => { } }; var results = mapStateToProps(obj); - expect(results.networksList,).toExist(); + expect(results.networksList).toBeTruthy(); }); it ('view simple 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(); - const networksList = [ - { - name:'dummy_net_1', - dhcp:true, - 'id':'7F60CD390458421DA588AF4AD217B93F' - }, - { - name:'dummy_net_2', - dhcp:true, - 'id':'AD217B93F7F60CD390458421DA588AF4' - } - ]; + const networksList = VSPNetworkFactory.buildList(2); - const versionControllerData = { - version: '1', - viewableVersions: [], - status: 'locked', - isCheckedOut: true - }; + const versionControllerData = VSPComponentsVersionControllerFactory.build(); var renderer = TestUtils.createRenderer(); renderer.render(); var renderedOutput = renderer.getRenderOutput(); - expect(renderedOutput).toExist(); + expect(renderedOutput).toBeTruthy(); }); diff --git a/openecomp-ui/test/softwareProduct/networks/softwareProductNetworksActionHelper.test.js b/openecomp-ui/test/softwareProduct/networks/softwareProductNetworksActionHelper.test.js index 2920803c64..1475ae610e 100644 --- a/openecomp-ui/test/softwareProduct/networks/softwareProductNetworksActionHelper.test.js +++ b/openecomp-ui/test/softwareProduct/networks/softwareProductNetworksActionHelper.test.js @@ -1,62 +1,49 @@ -/*- - * ============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 SoftwareProductNetworksActionHelper from 'sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksActionHelper.js'; +import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js'; + +import VSPNetworkFactory from 'test-utils/factories/softwareProduct/SoftwareProductNetworkFactory.js'; const softwareProductId = '123'; describe('Software Product Networks ActionHelper Tests', function () { it('Get Software Products Networks List', () => { const store = storeCreator(); + const vcData = VersionControllerUtilsFactory.build(); deepFreeze(store.getState()); - const networksList = [ - { - name:'dummy_net_1', - dhcp:true, - 'id':'7F60CD390458421DA588AF4AD217B93F' - }, - { - name:'dummy_net_2', - dhcp:true, - 'id':'AD217B93F7F60CD390458421DA588AF4' - } - ]; + const networksList = VSPNetworkFactory.buildList(2); deepFreeze(networksList); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductNetworks.networksList', networksList); mockRest.addHandler('fetch', ({options, data, baseUrl}) => { - expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/networks`); - expect(data).to.deep.equal(undefined); - expect(options).to.equal(undefined); + expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${vcData.version.id}/networks`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); return {results: networksList}; }); - return SoftwareProductNetworksActionHelper.fetchNetworksList(store.dispatch, {softwareProductId}).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + return SoftwareProductNetworksActionHelper.fetchNetworksList(store.dispatch, {softwareProductId, version: vcData.version}).then(() => { + expect(store.getState()).toEqual(expectedStore); }); }); diff --git a/openecomp-ui/test/softwareProduct/processes/SoftwareProductEditor.test.js b/openecomp-ui/test/softwareProduct/processes/SoftwareProductEditor.test.js new file mode 100644 index 0000000000..b4df9bebd9 --- /dev/null +++ b/openecomp-ui/test/softwareProduct/processes/SoftwareProductEditor.test.js @@ -0,0 +1,62 @@ +/*! + * 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/processes/SoftwareProductProcessesEditor.js'; +import SoftwareProductProcessesEditorView from 'sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesEditorView.jsx'; +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; + +describe('Software Product Processes Editor Module Tests', function () { + + it('should mapper exist', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + it('should return empty data', () => { + + const currentSoftwareProduct = VSPEditorFactory.build(); + + var state = { + softwareProduct: { + softwareProductEditor: { + data: currentSoftwareProduct + }, + softwareProductProcesses: + { + processesList: [], + processesEditor: {data: {}} + } + } + }; + + var results = mapStateToProps(state); + expect(results.data).toEqual({}); + expect(results.previousData).toEqual(undefined); + }); + + it('jsx view test', () => { + var view = TestUtils.renderIntoDocument( {}} + onSubmit={() => {}} + onClose={() => {}}/>); + expect(view).toBeTruthy(); + }); + +}); diff --git a/openecomp-ui/test/softwareProduct/processes/SoftwareProductProcessesView.test.js b/openecomp-ui/test/softwareProduct/processes/SoftwareProductProcessesView.test.js new file mode 100644 index 0000000000..2d7da91cbb --- /dev/null +++ b/openecomp-ui/test/softwareProduct/processes/SoftwareProductProcessesView.test.js @@ -0,0 +1,75 @@ +/*! + * 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/processes/SoftwareProductProcesses.js'; +import SoftwareProductProcessesView from 'sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesView.jsx'; + +import {VSPProcessStoreFactory} from 'test-utils/factories/softwareProduct/SoftwareProductProcessFactories.js'; +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import {VSPComponentsVersionControllerFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js'; + +describe('SoftwareProductProcesses Mapper and View Classes', () => { + it ('mapStateToProps mapper exists', () => { + expect(mapStateToProps).toBeTruthy(); + }); + + it ('mapStateToProps data test', () => { + const currentSoftwareProduct = VSPEditorFactory.build(); + + const processesList = VSPProcessStoreFactory.buildList(2); + + var obj = { + softwareProduct: { + softwareProductEditor: { + data: currentSoftwareProduct + }, + softwareProductProcesses: + { + processesList, + processesEditor: {data: {}} + } + } + }; + var results = mapStateToProps(obj); + expect(results.processesList).toBeTruthy(); + }); + + it ('view simple test', () => { + const currentSoftwareProduct = VSPEditorFactory.build(); + const processesList = VSPProcessStoreFactory.buildList(2); + + const versionControllerData = VSPComponentsVersionControllerFactory.build(); + + + var renderer = TestUtils.createRenderer(); + renderer.render( + {}} + onEditProcess={() => {}} + onDeleteProcess={() => {}} + isDisplayEditor={false} + isReadOnlyMode={false} /> + ); + var renderedOutput = renderer.getRenderOutput(); + expect(renderedOutput).toBeTruthy(); + + }); +}); diff --git a/openecomp-ui/test/softwareProduct/processes/test.js b/openecomp-ui/test/softwareProduct/processes/test.js index 73f22a7898..43110d2e55 100644 --- a/openecomp-ui/test/softwareProduct/processes/test.js +++ b/openecomp-ui/test/softwareProduct/processes/test.js @@ -1,38 +1,44 @@ -/*- - * ============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 Configuration from 'sdc-app/config/Configuration.js'; import SoftwareProductProcessesActionHelper from 'sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesActionHelper.js'; +import { + VSPProcessPostFactory, + VSPProcessStoreFactory, + VSPProcessPostFactoryWithType, + VSPProcessStoreFactoryWithType, + VSPProcessStoreWithFormDataFactory, + VSPProcessPostWithFormDataFactory, + VSPProcessStoreWithArtifactNameFactory } from 'test-utils/factories/softwareProduct/SoftwareProductProcessFactories.js'; +import {buildFromExistingObject} from 'test-utils/Util.js'; +import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; +import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; const softwareProductId = '123'; +const version = VSPEditorFactory.build().version; describe('Software Product Processes Module Tests', function () { let restPrefix = ''; - before(function() { + beforeAll(function() { restPrefix = Configuration.get('restPrefix'); deepFreeze(restPrefix); }); @@ -45,27 +51,18 @@ describe('Software Product Processes Module Tests', function () { const store = storeCreator(); deepFreeze(store.getState()); - const softwareProductPostRequest = { - name: 'Pr1', - description: 'string' - }; - const softwareProductProcessToAdd = { - name: 'Pr1', - description: 'string' - }; const softwareProductProcessFromResponse = 'ADDED_ID'; - const softwareProductProcessAfterAdd = { - ...softwareProductProcessToAdd, - id: softwareProductProcessFromResponse - }; + + const softwareProductProcessAfterAdd = VSPProcessStoreFactory.build({id: softwareProductProcessFromResponse}); + const softwareProductPostRequest = buildFromExistingObject(VSPProcessPostFactory, softwareProductProcessAfterAdd); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', [softwareProductProcessAfterAdd]); - mockRest.addHandler('create', ({data, options, baseUrl}) => { + mockRest.addHandler('post', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes`); - expect(data).to.deep.equal(softwareProductPostRequest); - expect(options).to.equal(undefined); + expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes`); + expect(data).toEqual(softwareProductPostRequest); + expect(options).toEqual(undefined); return { returnCode: 'OK', value: softwareProductProcessFromResponse @@ -74,64 +71,88 @@ describe('Software Product Processes Module Tests', function () { return SoftwareProductProcessesActionHelper.saveProcess(store.dispatch, { - softwareProductId: softwareProductId, + softwareProductId, + version, previousProcess: null, - process: softwareProductProcessToAdd + process: softwareProductPostRequest } ).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); - it('Add Software Products Processes with uploaded file', () => { + it('Add Software Products Processes with type', () => { const store = storeCreator(); deepFreeze(store.getState()); - const softwareProductPostRequest = { - name: 'Pr1', - description: 'string' - }; - const softwareProductProcessToAdd = { - name: 'Pr1', - description: 'string', - formData: { - name: 'new artifact name' - } - }; const softwareProductProcessFromResponse = 'ADDED_ID'; - const softwareProductProcessAfterAdd = { - ...softwareProductProcessToAdd, - id: softwareProductProcessFromResponse - }; + + const softwareProductProcessAfterAdd = VSPProcessStoreFactoryWithType.build({id: softwareProductProcessFromResponse}); + const softwareProductPostRequest = buildFromExistingObject(VSPProcessPostFactoryWithType, softwareProductProcessAfterAdd); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', [softwareProductProcessAfterAdd]); - mockRest.addHandler('create', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes`); - expect(data).to.deep.equal(softwareProductPostRequest); - expect(options).to.equal(undefined); + mockRest.addHandler('post', ({data, options, baseUrl}) => { + + expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes`); + expect(data).toEqual(softwareProductPostRequest); + expect(options).toEqual(undefined); return { returnCode: 'OK', value: softwareProductProcessFromResponse }; }); - mockRest.addHandler('create', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes/${softwareProductProcessAfterAdd.id}/upload`); - expect(data).to.deep.equal(softwareProductProcessToAdd.formData); - expect(options).to.equal(undefined); + return SoftwareProductProcessesActionHelper.saveProcess(store.dispatch, + { + softwareProductId, + version, + previousProcess: null, + process: softwareProductPostRequest + } + ).then(() => { + expect(store.getState()).toEqual(expectedStore); + }); + }); + + it('Add Software Products Processes with uploaded file', () => { + + const store = storeCreator(); + deepFreeze(store.getState()); + + const softwareProductPostRequest = VSPProcessPostFactoryWithType.build(); + const softwareProductProcessToAdd = VSPProcessPostWithFormDataFactory.build(softwareProductPostRequest); + const softwareProductProcessAfterAdd = VSPProcessStoreWithFormDataFactory.build(); + + const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', [softwareProductProcessAfterAdd]); + + mockRest.addHandler('post', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes`); + expect(data).toEqual(softwareProductPostRequest); + expect(options).toEqual(undefined); + return { + returnCode: 'OK', + value: softwareProductProcessAfterAdd.id + }; + }); + + mockRest.addHandler('post', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes/${softwareProductProcessAfterAdd.id}/upload`); + expect(data).toEqual(softwareProductProcessToAdd.formData); + expect(options).toEqual(undefined); return {returnCode: 'OK'}; }); return SoftwareProductProcessesActionHelper.saveProcess(store.dispatch, { - softwareProductId: softwareProductId, + softwareProductId, + version, previousProcess: null, process: softwareProductProcessToAdd } ).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); @@ -139,14 +160,7 @@ describe('Software Product Processes Module Tests', function () { //** UPDATE //** it('Update Software Products Processes', () => { - const softwareProductProcessesList = [ - { - name: 'Pr1', - description: 'string', - id: 'EBADF561B7FA4A788075E1840D0B5971', - artifactName: 'artifact' - } - ]; + const softwareProductProcessesList = VSPProcessStoreWithArtifactNameFactory.buildList(1); deepFreeze(softwareProductProcessesList); const store = storeCreator({ @@ -160,47 +174,47 @@ describe('Software Product Processes Module Tests', function () { const toBeUpdatedProcessId = softwareProductProcessesList[0].id; const previousProcessData = softwareProductProcessesList[0]; - const processUpdateData = { - ...softwareProductProcessesList[0], - name: 'Pr1_UPDATED', - description: 'string_UPDATED' - }; + const processUpdateData = VSPProcessStoreWithArtifactNameFactory.build( + {...previousProcessData, + name: 'Pr1_UPDATED', + description: 'string_UPDATED', + type: 'Other' + } + ); + deepFreeze(processUpdateData); - const processPutRequest = { + const processPutRequest = VSPProcessPostFactory.build({ name: 'Pr1_UPDATED', - description: 'string_UPDATED' - }; + description: 'string_UPDATED', + type: 'Other' + }); deepFreeze(processPutRequest); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', [processUpdateData]); - mockRest.addHandler('save', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes/${toBeUpdatedProcessId}`); - expect(data).to.deep.equal(processPutRequest); - expect(options).to.equal(undefined); + mockRest.addHandler('put', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes/${toBeUpdatedProcessId}`); + expect(data).toEqual(processPutRequest); + expect(options).toEqual(undefined); return {returnCode: 'OK'}; }); return SoftwareProductProcessesActionHelper.saveProcess(store.dispatch, { - softwareProductId: softwareProductId, + softwareProductId, + version, previousProcess: previousProcessData, process: processUpdateData } ).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); it('Update Software Products Processes and uploaded file', () => { - const previousProcessData = { - id: 'EBADF561B7FA4A788075E1840D0B5971', - name: 'p1', - description: 'string', - artifactName: 'artifact' - }; + const previousProcessData = VSPProcessStoreWithArtifactNameFactory.build(); deepFreeze(previousProcessData); const store = storeCreator({ @@ -212,45 +226,47 @@ describe('Software Product Processes Module Tests', function () { }); deepFreeze(store.getState()); - const newProcessToUpdate = { + const newProcessToUpdate = VSPProcessStoreWithFormDataFactory.build({ ...previousProcessData, name: 'new name', formData: { name: 'new artifact name' } - }; + }); deepFreeze(newProcessToUpdate); - const newProcessToPutRequest = { + const newProcessToPutRequest = VSPProcessPostFactory.build({ name: newProcessToUpdate.name, - description: previousProcessData.description - }; + description: previousProcessData.description, + type: previousProcessData.type + }); deepFreeze(newProcessToPutRequest); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', [newProcessToUpdate]); - mockRest.addHandler('save', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes/${previousProcessData.id}`); - expect(data).to.deep.equal(newProcessToPutRequest); - expect(options).to.equal(undefined); + mockRest.addHandler('put', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes/${newProcessToUpdate.id}`); + expect(data).toEqual(newProcessToPutRequest); + expect(options).toEqual(undefined); return {returnCode: 'OK'}; }); - mockRest.addHandler('create', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes/${previousProcessData.id}/upload`); - expect(data).to.deep.equal(newProcessToUpdate.formData); - expect(options).to.equal(undefined); + mockRest.addHandler('post', ({data, options, baseUrl}) => { + expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes/${newProcessToUpdate.id}/upload`); + expect(data).toEqual(newProcessToUpdate.formData); + expect(options).toEqual(undefined); return {returnCode: 'OK'}; }); return SoftwareProductProcessesActionHelper.saveProcess(store.dispatch, { - softwareProductId: softwareProductId, + softwareProductId, + version, previousProcess: previousProcessData, process: newProcessToUpdate } ).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); @@ -261,20 +277,7 @@ describe('Software Product Processes Module Tests', function () { const store = storeCreator(); deepFreeze(store.getState()); - const softwareProductProcessesList = [ - { - name: 'Pr1', - description: 'hjhj', - id: 'EBADF561B7FA4A788075E1840D0B5971', - artifactName: 'artifact' - }, - { - name: 'Pr1', - description: 'hjhj', - id: '2F47447D22DB4C53B020CA1E66201EF2', - artifactName: 'artifact' - } - ]; + const softwareProductProcessesList = VSPProcessStoreFactory.buildList(2); deepFreeze(softwareProductProcessesList); @@ -283,14 +286,14 @@ describe('Software Product Processes Module Tests', function () { const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', softwareProductProcessesList); mockRest.addHandler('fetch', ({options, data, baseUrl}) => { - expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes`); - expect(data).to.deep.equal(undefined); - expect(options).to.equal(undefined); + expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); return {results: softwareProductProcessesList}; }); - return SoftwareProductProcessesActionHelper.fetchProcessesList(store.dispatch, {softwareProductId}).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + return SoftwareProductProcessesActionHelper.fetchProcessesList(store.dispatch, {softwareProductId, version}).then(() => { + expect(store.getState()).toEqual(expectedStore); }); }); @@ -298,33 +301,32 @@ describe('Software Product Processes Module Tests', function () { //** DELETE //** it('Delete Software Products Processes', () => { - const softwareProductProcessesList = [ - { - name: 'Pr1', - description: 'hjhj', - id: 'EBADF561B7FA4A788075E1840D0B5971', - artifactName: 'artifact' - } - ]; + const softwareProductProcessesList = VSPProcessStoreWithArtifactNameFactory.buildList(1); + const currentSoftwareProduct = VSPEditorFactory.build(); deepFreeze(softwareProductProcessesList); const store = storeCreator({ softwareProduct: { softwareProductProcesses: { processesList: softwareProductProcessesList + }, + softwareProductEditor: { + data: currentSoftwareProduct } } }); - const processId = 'EBADF561B7FA4A788075E1840D0B5971'; + const processId = softwareProductProcessesList[0].id; + const version = store.getState().softwareProduct.softwareProductEditor.data.version; + const versionId = version.id; deepFreeze(store.getState()); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', []); mockRest.addHandler('destroy', ({data, options, baseUrl}) => { - expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes/${processId}`); - expect(data).to.equal(undefined); - expect(options).to.equal(undefined); + expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/processes/${processId}`); + expect(data).toEqual(undefined); + expect(options).toEqual(undefined); return { results: { returnCode: 'OK' @@ -334,9 +336,10 @@ describe('Software Product Processes Module Tests', function () { return SoftwareProductProcessesActionHelper.deleteProcess(store.dispatch, { process: softwareProductProcessesList[0], - softwareProductId + softwareProductId, + version }).then(() => { - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); }); }); @@ -344,10 +347,7 @@ describe('Software Product Processes Module Tests', function () { const store = storeCreator(); deepFreeze(store.getState()); - let process = { - id: 'p_id', - name: 'p_name' - }; + let process = VSPProcessStoreFactory.build(); deepFreeze(process); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processToDelete', process); @@ -355,7 +355,7 @@ describe('Software Product Processes Module Tests', function () { SoftwareProductProcessesActionHelper.openDeleteProcessesConfirm(store.dispatch, {process}); setTimeout(function(){ - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); done(); }, 100); }); @@ -369,7 +369,7 @@ describe('Software Product Processes Module Tests', function () { SoftwareProductProcessesActionHelper.hideDeleteConfirm(store.dispatch); setTimeout(function(){ - expect(store.getState()).to.deep.equal(expectedStore); + expect(store.getState()).toEqual(expectedStore); done(); }, 100); }); @@ -377,7 +377,7 @@ describe('Software Product Processes Module Tests', function () { //** //** CREATE/EDIT //** - it('Validating open Software Products Processes for create', done => { + it('Validating open Software Products Processes for create', () => { const store = storeCreator(); deepFreeze(store.getState()); @@ -387,28 +387,20 @@ describe('Software Product Processes Module Tests', function () { const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesEditor.data', process); SoftwareProductProcessesActionHelper.openEditor(store.dispatch); - - setTimeout(function(){ - expect(store.getState()).to.deep.equal(expectedStore); - done(); - }, 100); + expect(store.getState().softwareProduct.softwareProductProcesses.processesEditor.data).toEqual(expectedStore.softwareProduct.softwareProductProcesses.processesEditor.data); }); - it('Validating close Software Products Processes from editing mode', done => { + it('Validating close Software Products Processes from editing mode', () => { const store = storeCreator(); deepFreeze(store.getState()); const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesEditor', {}); SoftwareProductProcessesActionHelper.closeEditor(store.dispatch); - - setTimeout(function(){ - expect(store.getState()).to.deep.equal(expectedStore); - done(); - }, 100); + expect(store.getState()).toEqual(expectedStore); }); - it('Validating open Software Products Processes for editing', done => { + it('Validating open Software Products Processes for editing', () => { const store = storeCreator(); deepFreeze(store.getState()); @@ -418,42 +410,8 @@ describe('Software Product Processes Module Tests', function () { const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesEditor.data', process); SoftwareProductProcessesActionHelper.openEditor(store.dispatch, process); + expect(store.getState().softwareProduct.softwareProductProcesses.processesEditor.data).toEqual(expectedStore.softwareProduct.softwareProductProcesses.processesEditor.data); - setTimeout(function(){ - expect(store.getState()).to.deep.equal(expectedStore); - done(); - }, 100); }); - it('Validating Software Products Processes dataChanged event', done => { - let process = {name: 'aa', description: 'xx'}; - deepFreeze(process); - - const store = storeCreator({ - softwareProduct: { - softwareProductProcesses: { - processesEditor: { - data: process - } - } - } - }); - deepFreeze(store.getState()); - - let deltaData = {name: 'bb'}; - deepFreeze(deltaData); - - let expectedProcess = {name: 'bb', description: 'xx'}; - deepFreeze(expectedProcess); - - const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesEditor.data', expectedProcess); - - SoftwareProductProcessesActionHelper.processEditorDataChanged(store.dispatch, {deltaData}); - - setTimeout(function(){ - expect(store.getState()).to.deep.equal(expectedStore); - done(); - }, 100); - }); }); - -- cgit 1.2.3-korg