diff options
author | atulpurohit <atul.purohit1@vodafone.com> | 2019-11-05 14:31:56 +0530 |
---|---|---|
committer | Ofir Sonsino <ofir.sonsino@intl.att.com> | 2020-01-13 09:33:40 +0000 |
commit | 8b346842194edb8a9e8c4cd2764ae8ebbce988f0 (patch) | |
tree | 3ea20981d4cdd5858c4a99eb49c0370503c3c6cb /openecomp-ui/test | |
parent | 0ef638b2eb44c9f473e5ad8bea119845d968fde7 (diff) |
Refresh option in validation result page
Issue-ID: SDC-2585
Co-authored-by: nikhil.soni@vodafone.com
Signed-off-by: atulpurohit <atul.purohit1@vodafone.com>
Change-Id: I78f1385d219837c300cb33aff82b7459f137babb
Signed-off-by: atulpurohit <atul.purohit1@vodafone.com>
Diffstat (limited to 'openecomp-ui/test')
4 files changed, 220 insertions, 43 deletions
diff --git a/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationActionHelper.test.js b/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationActionHelper.test.js index 0a8f640426..3be1d68bbc 100644 --- a/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationActionHelper.test.js +++ b/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationActionHelper.test.js @@ -24,12 +24,14 @@ import Configuration from 'sdc-app/config/Configuration.js'; import { VSPComplianceCheckedFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js'; import { VSPCertificationCheckedFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js'; +import { VSPTestResultKeysFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js'; import { VSPChecksFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js'; import { VSPTestsMapFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js'; import { VSPTestsRequestFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js'; import { VSPGeneralInfoFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js'; import { VSPTestResultsSuccessFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js'; import { mapActionsToProps } from 'sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidation.js'; +import { VSPTestRequestFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js'; describe('Software Product Validation Action Helper Tests', function() { const store = storeCreator(); @@ -45,8 +47,10 @@ describe('Software Product Validation Action Helper Tests', function() { const generalInfo = VSPGeneralInfoFactory.build(); const isValidationDisabled = false; const vspTestResults = VSPTestResultsSuccessFactory.build(); + const testResultKeys = VSPTestResultKeysFactory.build(); let restPrefix = Configuration.get('restPrefix'); let onClose = () => {}; + const vspTestRequest = VSPTestRequestFactory.build(); const modal = { type: 'error', @@ -91,28 +95,50 @@ describe('Software Product Validation Action Helper Tests', function() { }); }); - // it('Software Products Validation Action Helper : post test', () => { - // mockRest.addHandler('post', ({ options, data, baseUrl }) => { - // expect(baseUrl).toEqual( - // `${restPrefix}/v1.0/externaltesting/executions` - // ); - // //expect(data).toEqual(testsRequest); - // expect(options).toEqual(undefined); - // return { vspTestResults: vspTestResults }; - // }); - // const version = { - // id: 12345, - // name: 1 - // }; - // const softwareProductId = '1234'; - // const status = 'draft'; - // mapActionsToProps(store.dispatch).onTestSubmit( - // softwareProductId, - // version, - // status, - // testsRequest - // ); - // }); + it('Software Products Validation Action Helper : post test', () => { + + const str = storeCreator({ + softwareProduct: { + softwareProductValidation: { + testResultKeys: testResultKeys.testResultKeys + } + } + }); + deepFreeze(str.getState()); + let expectedStore = cloneAndSet( + str.getState(), + 'softwareProduct.softwareProductValidation.vspTestResults', + vspTestResults.vspTestResults + ); + const version = { + id: 12345, + name: 1 + }; + const requestId = "1" + const softwareProductId = '1234'; + const status = 'success'; + mockRest.addHandler('post', ({ options, data, baseUrl }) => { + expect(baseUrl).toEqual( + `${restPrefix}/v1.0/externaltesting/executions?vspId=${softwareProductId}&vspVersionId=${version.id}&requestId=${requestId}` + ); + return vspTestResults.vspTestResults ; + }); + SoftwareProductValidationActionHelper.navigateToSoftwareProductValidationResults( + str.dispatch,{ + softwareProductId: softwareProductId, + version: version, + status: status, + tests :vspTestRequest.vspTestRequest, + requestId: requestId + } + ).then(() => { + expect(str.getState()).toEqual(expectedStore); + }) + .catch((e) => { + console.log('Executions test returned Error'); + }); + + }); it('Software Products Validation Action Helper : setCertificationChecked', () => { let expectedStore = cloneAndSet( diff --git a/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationInputView.test.js b/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationInputView.test.js index 68a8cdd957..c66cf91df4 100644 --- a/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationInputView.test.js +++ b/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationInputView.test.js @@ -112,5 +112,9 @@ describe('SoftwareProductValidation Mapper and View Classes', () => { ); expect(inputForm).toBeTruthy(); TestUtils.Simulate.submit(inputForm); + let result = TestUtils.scryRenderedDOMComponentsWithTag(vspValidationInputView, 'input'); + expect(result).toBeTruthy(); + expect(result.length).toBeTruthy(); + TestUtils.Simulate.change(result[0]); }); }); diff --git a/openecomp-ui/test/softwareProduct/validationResults/SoftwareProductValidationResultsView.test.js b/openecomp-ui/test/softwareProduct/validationResults/SoftwareProductValidationResultsView.test.js index 67e9fcfd89..8bd3779ea2 100644 --- a/openecomp-ui/test/softwareProduct/validationResults/SoftwareProductValidationResultsView.test.js +++ b/openecomp-ui/test/softwareProduct/validationResults/SoftwareProductValidationResultsView.test.js @@ -18,64 +18,93 @@ import React from 'react'; import { mapStateToProps } from 'sdc-app/onboarding/softwareProduct/validationResults/SoftwareProductValidationResults.js'; import SoftwareProductValidationResultsView from 'sdc-app/onboarding/softwareProduct/validationResults/SoftwareProductValidationResultsView.jsx'; import { VSPTestResultsSuccessFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js'; +import { VSPTestResultKeysFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js'; import { VSPTestResultsFailureFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js'; import { VSPTestsMapFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js'; +import { VSPChecksFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js'; import TestUtils from 'react-dom/test-utils'; describe('SoftwareProductValidationResults Mapper and View Classes', () => { - it('mapStateToProps mapper exists', () => { + it('mapStateToProps mapper exists', () => { expect(mapStateToProps).toBeTruthy(); }); it('mapStateToProps fail data test', () => { const vspTestResults = VSPTestResultsFailureFactory.build(); const vspTestsMap = VSPTestsMapFactory.build(); - + const testResultKeys = VSPTestResultKeysFactory.build(); + const version = { + name: 1 + }; + const softwareProductId = '1234'; + var testResultToDisplay = {}; + var vspIdAndVer = softwareProductId+version.name; + testResultToDisplay[vspIdAndVer] = vspTestResults.vspTestResults; + var testResultKeyByVspId = {}; + testResultKeyByVspId[vspIdAndVer] = testResultKeys.testResultKeys; var obj = { softwareProduct: { softwareProductValidation: { - vspTestResults: vspTestResults.vspTestResults, - vspTestsMap: vspTestsMap.vspTestsMap + testResultKeys: testResultKeys.testResultKeys + }, + softwareProductValidationResult: { + testResultToDisplay: testResultToDisplay, } } }; var results = mapStateToProps(obj); - expect(results.softwareProductValidation.vspTestResults).toBeTruthy(); + expect(results.softwareProductValidationResult.testResultToDisplay[vspIdAndVer]).toBeTruthy(); }); - it('mapStateToProps success data test', () => { + it('mapStateToProps success data test', () => { const vspTestResults = VSPTestResultsSuccessFactory.build(); const vspTestsMap = VSPTestsMapFactory.build(); - + const vspChecksList = VSPChecksFactory.build(); var obj = { softwareProduct: { softwareProductValidation: { + }, + softwareProductValidationResult: { vspTestResults: vspTestResults.vspTestResults, - vspTestsMap: vspTestsMap.vspTestsMap + vspChecks: vspChecksList, + refreshValidationResults: [] } } }; var results = mapStateToProps(obj); - expect(results.softwareProductValidation.vspTestResults).toBeTruthy(); + expect(results.softwareProductValidationResult.vspTestResults).toBeTruthy(); }); it('SoftwareProductValidationResultsView test fail render test', () => { const vspTestResults = VSPTestResultsFailureFactory.build(); const vspTestsMap = VSPTestsMapFactory.build(); + const testResultKeys = VSPTestResultKeysFactory.build(); + const vspChecksList = VSPChecksFactory.build(); const version = { name: 1 }; const softwareProductId = '1234'; - var obj = { - softwareProductId: softwareProductId, - version: version, - softwareProductValidation: { - vspTestResults: vspTestResults.vspTestResults, - vspTestsMap: vspTestsMap.vspTestsMap - } - }; + var testResultToDisplay = {}; + var vspIdAndVer = softwareProductId+version.name; + testResultToDisplay[vspIdAndVer] = vspTestResults.vspTestResults; + var testResultKeyByVspId = {}; + testResultKeyByVspId[vspIdAndVer] = testResultKeys.testResultKeys; + var obj = { + softwareProductId: softwareProductId, + version: version, + softwareProductValidation:{ + testResultKeys: testResultKeys.testResultKeys + }, + softwareProductValidationResult: { + testResultToDisplay: testResultToDisplay, + vspChecks: vspChecksList, + refreshValidationResults: [], + testResultKeys: testResultKeyByVspId + } + }; + let vspValidationResultsView = TestUtils.renderIntoDocument( <SoftwareProductValidationResultsView {...obj} /> ); @@ -84,18 +113,29 @@ describe('SoftwareProductValidationResults Mapper and View Classes', () => { it('SoftwareProductValidationResultsView test success render test', () => { const vspTestResults = VSPTestResultsSuccessFactory.build(); + const testResultKeys = VSPTestResultKeysFactory.build(); const vspTestsMap = VSPTestsMapFactory.build(); - + const vspChecksList = VSPChecksFactory.build(); let version = { name: 1 }; + const softwareProductId = '1234'; + var testResultToDisplay = {}; + var vspIdAndVer = softwareProductId+version.name; + testResultToDisplay[vspIdAndVer] = vspTestResults.vspTestResults; + var testResultKeyByVspId = {}; + testResultKeyByVspId[vspIdAndVer] = testResultKeys.testResultKeys; + var obj = { softwareProductId: softwareProductId, version: version, - softwareProductValidation: { - vspTestResults: vspTestResults.vspTestResults, - vspTestsMap: vspTestsMap.vspTestsMap + softwareProductValidation:{ + testResultKeys: testResultKeys.testResultKeys + }, + softwareProductValidationResult: { + testResultToDisplay: testResultToDisplay, + vspChecks: vspChecksList } }; let vspValidationResultsView = TestUtils.renderIntoDocument( diff --git a/openecomp-ui/test/softwareProduct/validationResults/SoftwareProductValidationResultsViewActionHelper.test.js b/openecomp-ui/test/softwareProduct/validationResults/SoftwareProductValidationResultsViewActionHelper.test.js new file mode 100644 index 0000000000..064a32312c --- /dev/null +++ b/openecomp-ui/test/softwareProduct/validationResults/SoftwareProductValidationResultsViewActionHelper.test.js @@ -0,0 +1,107 @@ +/* + * Copyright © 2019 Vodafone Group + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import deepFreeze from 'deep-freeze'; +import mockRest from 'test-utils/MockRest.js'; +import { cloneAndSet } from 'test-utils/Util.js'; +import { storeCreator } from 'sdc-app/AppStore.js'; +import SoftwareProductValidationResultsViewActionHelper from 'sdc-app/onboarding/softwareProduct/validationResults/SoftwareProductValidationResultsViewActionHelper.js'; +import { tabsMapping } from 'sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationConstants.js'; +import Configuration from 'sdc-app/config/Configuration.js'; +import { VSPTestResultsSuccessFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js'; +import { VSPTestResultsFailureFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js'; +import { VSPTestResultKeysFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js'; +import { VSPTestsMapFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js'; +import { VSPChecksFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js'; +import { VSPTestsRequestFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js'; +import { VSPGeneralInfoFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js'; +import VersionFactory from 'test-utils/factories/common/VersionFactory.js'; + + +describe('Software Product Validation Test Result Action Helper Tests', function() { + const store = storeCreator(); + deepFreeze(store.getState()); + const version = VersionFactory.build(); + const vspId = 10000; + const vspChecksList = VSPChecksFactory.build(); + const vspTestsMap = VSPTestsMapFactory.build(); + + const errorMessage = { msg: 'Test Error Message' }; + const testsRequest = VSPTestsRequestFactory.build(); + const generalInfo = VSPGeneralInfoFactory.build(); + const isValidationDisabled = false; + const testResultKeys = VSPTestResultKeysFactory.build(); + const vspTestResults = VSPTestResultsSuccessFactory.build(); + const requestQuery = "requestId="+testResultKeys.testResultKeys.requestId + + "&" + "endPoint=" + testResultKeys.testResultKeys.endPoints[0]; + let restPrefix = Configuration.get('restPrefix'); + let onClose = () => {}; + + const modal = { + type: 'error', + title: 'Error', + modalComponentName: 'Error', + modalComponentProps: { + onClose: onClose + }, + msg: { + msg: 'Test Error Message' + }, + cancelButtonText: 'OK' + }; + + it('Software Products Validation Test Result Action Helper : fetch vsp', () => { + let expectedStore = cloneAndSet( + store.getState(), + 'softwareProduct.softwareProductValidationResult.vspChecks', + vspChecksList + ); + mockRest.addHandler('fetch', ({ baseUrl }) => { + expect(baseUrl).toEqual( + `${restPrefix}/v1.0/externaltesting/testcasetree` + ); + return vspChecksList; + }); + return SoftwareProductValidationResultsViewActionHelper.fetchVspChecks( + store.dispatch + ).then(() => { + var stat = store.getState(); + expect(stat).toEqual(expectedStore); + }) + }); + + it('Software Products Validation Test Result Action Helper : RefreshValidationResults', () => { + let expectedStore = cloneAndSet( + store.getState(), + 'softwareProduct.softwareProductValidationResult.vspTestResults', + vspTestResults.vspTestResults + ); + mockRest.addHandler('fetch', ({ baseUrl }) => { + expect(baseUrl).toEqual( + `${restPrefix}/v1.0/externaltesting/executions?${requestQuery}` + ); + return vspTestResults.vspTestResults; + }); + return SoftwareProductValidationResultsViewActionHelper.refreshValidationResults( + store.dispatch, { + requestId: testResultKeys.testResultKeys.requestId, + endPoints: testResultKeys.testResultKeys.endPoints + } + ).then(() => { + var stt = store.getState(); + expect(stt).toEqual(expectedStore); + }) + }); +}) |