diff options
Diffstat (limited to 'openecomp-ui')
12 files changed, 570 insertions, 192 deletions
diff --git a/openecomp-ui/resources/scss/modules/_softwareProductValidationResultsPage.scss b/openecomp-ui/resources/scss/modules/_softwareProductValidationResultsPage.scss index 9ff3696dcb..303f1f041d 100644 --- a/openecomp-ui/resources/scss/modules/_softwareProductValidationResultsPage.scss +++ b/openecomp-ui/resources/scss/modules/_softwareProductValidationResultsPage.scss @@ -1,4 +1,20 @@ .validation-results-test-result-label { - padding-left: 10px + padding-left: 10px; +} +.validation-results-test-result-json { + min-height: 50px; + overflow: auto; + min-width: 100px; + height: 100px; + width: 900px; + max-width: 900px; +} +.validation-results-test-result-string { + min-height: 50px; + overflow: auto; + min-width: 100px; + height: 100px; + width: 900px; + max-width: 900px; } diff --git a/openecomp-ui/src/nfvo-utils/i18n/en.json b/openecomp-ui/src/nfvo-utils/i18n/en.json index 1ad23b7a1a..f57b7fdd3c 100644 --- a/openecomp-ui/src/nfvo-utils/i18n/en.json +++ b/openecomp-ui/src/nfvo-utils/i18n/en.json @@ -650,8 +650,10 @@ "Selected Compliance Tests": "Selected Compliance Tests", "Value Should Be Minimum of {minLength} characters and a Maximum of {maxLength} characters": "Value Should Be Minimum of {minLength} characters and a Maximum of {maxLength} characters", "{title} Inputs :": "{title} Inputs :", - "Scenario: {scenario} | Status: {status}": "Scenario: {scenario} | Status: {status}", + "Scenario: {scenario} | Title: {title} | Test Case: {testCaseName} | Status: {status}": "Scenario: {scenario} | Title: {title} | Test Case: {testCaseName} | Status: {status}", "{title} results are not available": "{title} results are not available", "Test Results": "Test Results", - "No Validation Checks Performed": "No Validation Checks Performed" + "No Validation Checks Performed": "No Validation Checks Performed", + "Unknown": "Unknown" + } diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationActionHelper.js b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationActionHelper.js index d19416a2aa..1ebb94b77c 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationActionHelper.js +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationActionHelper.js @@ -32,7 +32,7 @@ function postVSPCertificationChecks(tests) { function fetchVspChecks() { const restPrefix = Configuration.get('restPrefix'); - return RestAPIUtil.get(`${restPrefix}/v1.0/externaltesting/testcasetree`); + return RestAPIUtil.fetch(`${restPrefix}/v1.0/externaltesting/testcasetree`); } const SoftwareProductValidationActionHelper = { diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationView.jsx index 8611c41937..a8ea3804b4 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationView.jsx @@ -210,7 +210,10 @@ class SoftwareProductValidation extends Component { softwareProductValidation.vspChecks ); } - this.setState({ activeTab: tabsMapping.SETUP }); + this.setState({ + activeTab: tabsMapping.SETUP, + goToValidationInput: false + }); setActiveTab({ activeTab: tabsMapping.SETUP }); } } @@ -269,6 +272,20 @@ class SoftwareProductValidation extends Component { } } + fetchDefaultValue(value) { + let { softwareProductId, version } = this.props; + let versionName = parseFloat(version.name).toFixed(1), + versionNumber = + versionName > 1 ? (versionName - 1).toFixed(1) : versionName, + versionUUID = version.id; + value = + value === '$vspid' + ? softwareProductId + : value === '$vspPreviousVersion' ? versionNumber : value; + value = value === '$vspVersionUUID' ? versionUUID : value || ''; + return value; + } + formTestsRequest(item, testsRequest) { let { vspTestsMap } = this.props.softwareProductValidation; testsRequest[item] = { @@ -279,8 +296,9 @@ class SoftwareProductValidation extends Component { endpoint: vspTestsMap[item]['endpoint'] }; vspTestsMap[item].parameters.forEach(parameter => { - testsRequest[item].parameters[parameter.name] = - parameter.defaultValue || ''; + testsRequest[item].parameters[ + parameter.name + ] = this.fetchDefaultValue(parameter.defaultValue); }); return testsRequest; } diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputsView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputsView.jsx index c2990a2058..26a6003b5a 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputsView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputsView.jsx @@ -284,8 +284,8 @@ class VspValidationInputs extends Component { size="default" data-test-id="proceed-to-validation-results-btn" disabled={false} - className="proceed-to-validation-monitor-btn" - onClick={() => this.performVSPTests()}> + type="submit" + className="proceed-to-validation-monitor-btn"> {i18n('Submit')} </Button> </Form> diff --git a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validationResults/SoftwareProductValidationResultsView.jsx b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validationResults/SoftwareProductValidationResultsView.jsx index b6cc1d5bdc..162d281ee4 100644 --- a/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validationResults/SoftwareProductValidationResultsView.jsx +++ b/openecomp-ui/src/sdc-app/onboarding/softwareProduct/validationResults/SoftwareProductValidationResultsView.jsx @@ -74,109 +74,215 @@ class SoftwareProductValidationResultsView extends React.Component { }; } - buildSubAccordions(result) { - if (result.status && result.status.toLowerCase() === 'completed') { - if (!result.results.testResults) { + getTitle(result) { + let { vspTestsMap } = this.props.softwareProductValidation; + let title = vspTestsMap[result.testCaseName] + ? vspTestsMap[result.testCaseName].title + : i18n('Unknown'); + return i18n( + 'Scenario: {scenario} | Title: {title} | Test Case: {testCaseName} | Status: {status}', + { + scenario: result.scenario || i18n('Unknown'), + status: result.status || i18n('Unknown'), + testCaseName: result.testCaseName || i18n('Unknown'), + title: title + } + ); + } + + renderJSON(result) { + return ( + <li type="none"> + <textarea + disabled={true} + className="validation-results-test-result-json" + value={JSON.stringify(result, null, 2)} + /> + </li> + ); + } + + renderError(result) { + if (Array.isArray(result)) { + return result.map((parameter, index) => { return ( - <div - title={i18n('Scenario: {scenario} | Status: {status}', { - scenario: result.scenario, - status: result.status - })}> + <li type="none" key={index}> <SVGIcon color="negative" name="errorCircle" labelPosition="right" /> <span className="validation-results-test-result-label"> - {i18n('{title} results are not available', { - title: result.scenario - })} + {(parameter.code || '') + + ' | ' + + (parameter.advice || parameter.message)} </span> - </div> + </li> ); - } - return ( - <Accordion - dataTestId="vsp-validation-test-result-success" - title={i18n('Scenario: {scenario} | Status: {status}', { - scenario: result.scenario, - status: result.status - })}> - {Object.keys(result.results.testResults).map( - (key, index) => { - let title = unCamelCasedString(key); - if (result.results.testResults[key].length > 0) { - return ( - <Accordion - dataTestId={title} - title={title} - key={index}> - <TestResultComponent - tests={ - result.results.testResults[key] - } - /> - </Accordion> - ); - } else { - return ( - <div> - {i18n( - '{title} results are not available', - { - title: title - } - )} - </div> - ); - } - } - )} - </Accordion> - ); - } else if ( - result.status && - result.status.toLowerCase() === 'failed' && - result.results.errors - ) { + }); + } else { return ( - <Accordion - dataTestId="vsp-validation-test-result-success" - title={i18n('Scenario: {scenario} | Status: {status}', { - scenario: result.scenario, - status: result.status - })}> - {result.results.errors.map((element, index) => { - return ( - <li type="none" key={index}> - <SVGIcon - color="negative" - name="errorCircle" - labelPosition="right" - /> - <span className="validation-results-test-result-label"> - {element.reason + ' | ' + element.advice} - </span> - </li> - ); - })} - </Accordion> + <li type="none"> + <SVGIcon + color="negative" + name="errorCircle" + labelPosition="right" + /> + <span className="validation-results-test-result-label"> + {(result.code || '') + + ' | ' + + (result.advice || result.message)} + </span> + </li> ); - } else if (result.message || result.httpStatus) { + } + } + + renderResults(result) { + if (typeof result === 'string' || result instanceof String) { return ( <div> <SVGIcon - color="negative" + color="warning" name="errorCircle" labelPosition="right" /> <span className="validation-results-test-result-label"> - {result.message + ' | ' + result.httpStatus} + {result} </span> </div> ); } + return Object.keys(result).map((key, index) => { + let title = unCamelCasedString(key); + if ( + typeof result[key] === 'string' || + result[key] instanceof String + ) { + return ( + <Accordion + defaultExpanded + dataTestId={title} + title={title} + key={index}> + {this.renderString(result[key])} + </Accordion> + ); + } else if (Array.isArray(result[key])) { + if (result[key].length > 0) { + return ( + <Accordion + defaultExpanded + dataTestId={title} + title={title} + key={index}> + <TestResultComponent tests={result[key]} /> + </Accordion> + ); + } else { + return ( + <Accordion + defaultExpanded + dataTestId={title} + title={title} + key={index}> + {i18n('{title} results are not available', { + title: title + })} + </Accordion> + ); + } + } else { + return ( + <Accordion + defaultExpanded + dataTestId={title} + title={title} + key={index}> + {this.renderJSON(result[key])} + </Accordion> + ); + } + }); + } + + renderString(result) { + return ( + <li type="none"> + <textarea + type="textarea" + disabled={true} + className="validation-results-test-result-string" + value={result} + /> + </li> + ); + } + + buildSubAccordions(result) { + let results = result.results; + + if (!results) { + return ( + <Accordion + defaultExpanded + dataTestId="vsp-test-no-results" + title={this.getTitle(result)}> + {this.renderJSON(result)} + </Accordion> + ); + } else if (typeof results === 'string' || results instanceof String) { + return ( + <Accordion + defaultExpanded + dataTestId="vsp-test-string-results" + title={this.getTitle(result)}> + {this.renderString(results)} + </Accordion> + ); + } else { + return ( + <Accordion + defaultExpanded + dataTestId="vsp-test-object-results" + title={this.getTitle(result)}> + {Object.keys(results).length === 0 + ? this.renderString( + i18n('{title} results are not available', { + title: 'Test' + }) + ) + : Object.keys(results).map(key => { + if (key === 'errors' || key === 'error') { + return this.renderError(results[key]); + } else if (key === 'testResults') { + return this.renderResults(results[key]); + } else { + let title = unCamelCasedString(key); + if (results[key] instanceof Object) { + return ( + <Accordion + defaultExpanded + dataTestId={title} + title={title}> + {this.renderJSON(results[key])} + </Accordion> + ); + } else { + return ( + <Accordion + defaultExpanded + dataTestId={title} + title={title}> + {this.renderString(results[key])} + </Accordion> + ); + } + } + })} + </Accordion> + ); + } } render() { diff --git a/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js index 2ae9249ff7..c763e9d3e7 100644 --- a/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js +++ b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js @@ -263,7 +263,7 @@ export const VSPTestsMapFactory = new Factory().attrs({ name: 'vspId', description: 'VSP ID', type: 'text', - defaultValue: '', + defaultValue: '$vspid', isOptional: true, metadata: { maxLength: 36, @@ -275,7 +275,7 @@ export const VSPTestsMapFactory = new Factory().attrs({ name: 'vspVersion', description: 'Previous VSP Version', type: 'text', - defaultValue: '', + defaultValue: '$vspPreviousVersion', isOptional: true, metadata: { maxLength: 36, @@ -315,7 +315,7 @@ export const VSPChecksFactory = new Factory().attrs({ name: 'vspId', description: 'VSP ID', type: 'text', - defaultValue: '', + defaultValue: '$vspid', isOptional: true, metadata: { maxLength: 36, @@ -327,7 +327,7 @@ export const VSPChecksFactory = new Factory().attrs({ name: 'vspVersion', description: 'Previous VSP Version', type: 'text', - defaultValue: '', + defaultValue: '$vspPreviousVersion', isOptional: true, metadata: { maxLength: 36, diff --git a/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js index 6728e049b0..a4a069e355 100644 --- a/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js +++ b/openecomp-ui/test-utils/factories/softwareProduct/SoftwareProductValidationResultsFactory.js @@ -18,6 +18,86 @@ import { Factory } from 'rosie'; export const VSPTestResultsFailureFactory = new Factory().attrs({ vspTestResults: [ { + scenario: 'certification', + description: 'Other Certifications', + testCaseName: 'certification.certificationtests.certquery', + testSuiteName: 'certificationtests', + executionId: 'ebaa5f21-ed68-4098-97a9-775ac8800f09-1550575025614', + parameters: { + vspId: 'uuidval', + vspVersion: 'ver', + other: 'values' + }, + results: { + UnknownObject: { + someKeyanotherobject2: 'someValue', + someKey1: 'someValue', + someKey2: 'someValue', + someKey3: 'someValue', + someKey4: 'someValue', + someKey5: 'someValue', + someKey21: 'someValue11', + someKey111: 'someValue11', + someKey222: 'someValue' + }, + StringResult: 'String Value of Result', + EmptyObject: {}, + EmptyArray: [] + }, + status: 'COMPLETED', + startTime: '2019-02-19T11:17:05.670', + endTime: '2019-02-19T11:17:05.683' + }, + { + scenario: 'compliance', + testCaseName: 'compliance.compliancetests.sriov', + description: 'Allow_SR-IOV', + testSuiteName: 'compliancetests', + executionId: 'ebaa5f21-ed68-4098-97a9-775ac8800f09-1550575025614', + parameters: { + vspId: 'uuidval', + vspVersion: 'ver', + other: 'values' + }, + results: { + errors: [ + { + attribute: '', + reason: 'Record Not Found', + advice: + 'User must query with (vspId, vspVersion) values for a certifications record that is present in the Repository', + code: 40 + }, + { + attribute: '', + reason: 'Record Not Found', + advice: + 'User must query with (vspId, vspVersion) values for a certifications record that is present in the Repository', + code: 40 + } + ] + }, + status: 'FAILED', + startTime: '2019-02-19T11:17:05.670', + endTime: '2019-02-19T11:17:05.683' + }, + { + scenario: 'compliance', + testCaseName: ' compliance.compliancetests.computeflavours', + description: 'Allow SR-IOV ', + testSuiteName: 'compliancetests', + executionId: 'ebaa5f21-ed68-4098-97a9-775ac8800f09-1550575025614', + parameters: { + vspId: 'uuidval', + vspVersion: 'ver', + other: 'values' + }, + results: {}, + status: 'COMPLETED', + startTime: '2019-02-19T11:17:05.670', + endTime: '2019-02-19T11:17:05.683' + }, + { code: '500', message: 'VTP Test(s) could not be completed', httpStatus: 500 diff --git a/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationActionHelper.test.js b/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationActionHelper.test.js index ee6ba90cd5..0a8f640426 100644 --- a/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationActionHelper.test.js +++ b/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationActionHelper.test.js @@ -26,83 +26,193 @@ import { VSPComplianceCheckedFactory } from 'test-utils/factories/softwareProduc import { VSPCertificationCheckedFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.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'; describe('Software Product Validation Action Helper Tests', function() { - it('Software Products Validation Action Helper : Dsspatch', () => { - const store = storeCreator(); - deepFreeze(store.getState()); - - const vspChecksList = VSPChecksFactory.build(); - const vspTestsMap = VSPTestsMapFactory.build(); - const certificationChecked = VSPCertificationCheckedFactory.build(); - const complianceChecked = VSPComplianceCheckedFactory.build(); - const activeTab = { activeTab: tabsMapping.INPUTS }; - const errorMessage = { msg: 'Test Error Message' }; - - deepFreeze(vspChecksList); - deepFreeze(vspTestsMap); - deepFreeze(certificationChecked); - deepFreeze(complianceChecked); - deepFreeze(activeTab); + const store = storeCreator(); + deepFreeze(store.getState()); + const vspChecksList = VSPChecksFactory.build(); + const vspTestsMap = VSPTestsMapFactory.build(); + const certificationChecked = VSPCertificationCheckedFactory.build(); + const complianceChecked = VSPComplianceCheckedFactory.build(); + const activeTab = { activeTab: tabsMapping.INPUTS }; + const errorMessage = { msg: 'Test Error Message' }; + const testsRequest = VSPTestsRequestFactory.build(); + const generalInfo = VSPGeneralInfoFactory.build(); + const isValidationDisabled = false; + const vspTestResults = VSPTestResultsSuccessFactory.build(); + 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' + }; + // deepFreeze(vspTestsMap.vspTestsMap); + // deepFreeze(certificationChecked.certificationChecked); + // deepFreeze(complianceChecked.complianceChecked); + // deepFreeze(activeTab); + // deepFreeze(testsRequest); + // deepFreeze(generalInfo.generalInfo); + // deepFreeze(isVspValidationDisabled); + + it('Software Products Validation Action Helper : fetch vsp', () => { let expectedStore = cloneAndSet( store.getState(), 'softwareProduct.softwareProductValidation.vspChecks', vspChecksList ); - expectedStore = cloneAndSet( - store.getState(), - 'softwareProduct.softwareProductValidation.vspTestsMap', - vspTestsMap - ); - expectedStore = cloneAndSet( + mockRest.addHandler('fetch', ({ baseUrl }) => { + expect(baseUrl).toEqual( + `${restPrefix}/v1.0/externaltesting/testcasetree` + ); + return vspChecksList; + }); + return SoftwareProductValidationActionHelper.fetchVspChecks( + store.dispatch + ) + .then(() => { + expect(store.getState()).toEqual(expectedStore); + }) + .catch(() => { + console.log('Fetch VSP returned Error'); + }); + }); + + // 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 : setCertificationChecked', () => { + let expectedStore = cloneAndSet( store.getState(), 'softwareProduct.softwareProductValidation.certificationChecked', - certificationChecked + certificationChecked.certificationChecked ); - expectedStore = cloneAndSet( + mapActionsToProps(store.dispatch).setCertificationChecked({ + checked: certificationChecked.certificationChecked + }); + expect(store.getState()).toEqual(expectedStore); + }); + + it('Software Products Validation Action Helper : onErrorThrown', () => { + let expectedStore = cloneAndSet(store.getState(), 'modal', modal); + mapActionsToProps(store.dispatch).onErrorThrown(errorMessage); + expect(JSON.stringify(store.getState())).toEqual( + JSON.stringify(expectedStore) + ); + }); + + it('Software Products Validation Action Helper : setComplianceChecked', () => { + let expectedStore = cloneAndSet( store.getState(), 'softwareProduct.softwareProductValidation.complianceChecked', - complianceChecked + complianceChecked.complianceChecked ); - expectedStore = cloneAndSet( + mapActionsToProps(store.dispatch).setComplianceChecked({ + checked: complianceChecked.complianceChecked + }); + expect(store.getState()).toEqual(expectedStore); + }); + + it('Software Products Validation Action Helper : setActiveTab', () => { + let expectedStore = cloneAndSet( store.getState(), 'softwareProduct.softwareProductValidation.activeTab', - activeTab + activeTab.activeTab ); - let restPrefix = Configuration.get('restPrefix'); + mapActionsToProps(store.dispatch).setActiveTab(activeTab); + expect(store.getState()).toEqual(expectedStore); + }); - mockRest.addHandler('fetch', ({ options, data, baseUrl }) => { - expect(baseUrl).toEqual(`${restPrefix}/v1.0/externaltesting`); - expect(data).toEqual(undefined); - expect(options).toEqual(undefined); - return { vspChecks: vspChecksList }; - }); + it('Software Products Validation Action Helper : setGeneralInfo', () => { + let expectedStore = cloneAndSet( + store.getState(), + 'softwareProduct.softwareProductValidation.generalInfo', + generalInfo.generalInfo + ); + mapActionsToProps(store.dispatch).setGeneralInfo( + generalInfo.generalInfo + ); + expect(store.getState()).toEqual(expectedStore); + }); - SoftwareProductValidationActionHelper.setVspTestsMap(store.dispatch, { - vspTestsMap - }); - SoftwareProductValidationActionHelper.setComplianceChecked( - store.dispatch, - { complianceChecked } + it('Software Products Validation Action Helper : setIsVspValidationDisabled', () => { + let expectedStore = cloneAndSet( + store.getState(), + 'softwareProduct.softwareProductValidation.isValidationDisabled', + isValidationDisabled ); - SoftwareProductValidationActionHelper.setCertificationChecked( + SoftwareProductValidationActionHelper.setIsVspValidationDisabled( store.dispatch, - { certificationChecked } + { + isValidationDisabled + } ); + expect(store.getState()).toEqual(expectedStore); + }); - SoftwareProductValidationActionHelper.setActiveTab(store.dispatch, { - activeTab - }); + it('Software Products Validation Action Helper : setTestsRequest', () => { + let expectedStore = cloneAndSet( + store.getState(), + 'softwareProduct.softwareProductValidation.testsRequest', + testsRequest.testsRequest + ); + expectedStore = cloneAndSet( + expectedStore, + 'softwareProduct.softwareProductValidation.generalInfo', + generalInfo.generalInfo + ); - SoftwareProductValidationActionHelper.onErrorThrown(store.dispatch, { - errorMessage - }); + mapActionsToProps(store.dispatch).setTestsRequest( + testsRequest.testsRequest, + generalInfo.generalInfo + ); + expect(store.getState()).toEqual(expectedStore); + }); - SoftwareProductValidationActionHelper.fetchVspChecks(store.dispatch) - .then(() => { - expect(store.getState()).toEqual(expectedStore); - }) - .catch(() => {}); + it('Software Products Validation Action Helper : setVspTestsMap', () => { + let expectedStore = cloneAndSet( + store.getState(), + 'softwareProduct.softwareProductValidation.vspTestsMap', + vspTestsMap.vspTestsMap + ); + SoftwareProductValidationActionHelper.setVspTestsMap( + store.dispatch, + vspTestsMap.vspTestsMap + ); + + expect(store.getState()).toEqual(expectedStore); }); }); diff --git a/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationInputView.test.js b/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationInputView.test.js index aa00a5d605..68a8cdd957 100644 --- a/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationInputView.test.js +++ b/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationInputView.test.js @@ -19,6 +19,7 @@ import { mapStateToProps } from 'sdc-app/onboarding/softwareProduct/validation/i import VspValidationInputsView from 'sdc-app/onboarding/softwareProduct/validation/inputs/VspValidationInputsView.jsx'; import TestUtils from 'react-dom/test-utils'; +import { storeCreator } from 'sdc-app/AppStore.js'; import { VSPComplianceCheckedFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js'; import { VSPCertificationCheckedFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js'; @@ -26,6 +27,7 @@ import { VSPChecksFactory } from 'test-utils/factories/softwareProduct/SoftwareP 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 { mapActionsToProps } from 'sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidation.js'; describe('SoftwareProductValidation Mapper and View Classes', () => { it('mapStateToProps mapper exists', () => { @@ -76,22 +78,39 @@ describe('SoftwareProductValidation Mapper and View Classes', () => { const status = 'draft'; var obj = { - version: version, - softwareProductId: softwareProductId, - status: status, - softwareProductValidation: { - complianceChecked: complianceChecked.complianceChecked, - certificationChecked: certificationChecked.certificationChecked, - vspTestsMap: vspTestsMap.vspTestsMap, - vspChecks: vspChecksList, - testsRequest: testsRequest.testsRequest, - generalInfo: generalInfo.generalInfo + softwareProduct: { + version: version, + softwareProductId: softwareProductId, + status: status, + softwareProductValidation: { + complianceChecked: complianceChecked.complianceChecked, + certificationChecked: + certificationChecked.certificationChecked, + vspTestsMap: vspTestsMap.vspTestsMap, + vspChecks: vspChecksList, + testsRequest: testsRequest.testsRequest, + generalInfo: generalInfo.generalInfo + } } }; + const store = storeCreator(); + let dispatch = store.dispatch; + let props = Object.assign( + {}, + mapStateToProps(obj), + mapActionsToProps(dispatch) + ); let vspValidationInputView = TestUtils.renderIntoDocument( - <VspValidationInputsView {...obj} /> + <VspValidationInputsView {...props} /> ); expect(vspValidationInputView).toBeTruthy(); + + let inputForm = TestUtils.findRenderedDOMComponentWithTag( + vspValidationInputView, + 'form' + ); + expect(inputForm).toBeTruthy(); + TestUtils.Simulate.submit(inputForm); }); }); diff --git a/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationView.test.js b/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationView.test.js index 640f9f64be..be84f157b3 100644 --- a/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationView.test.js +++ b/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationView.test.js @@ -24,10 +24,11 @@ import SoftwareProductValidationView from 'sdc-app/onboarding/softwareProduct/va import { VSPComplianceCheckedFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js'; import { VSPCertificationCheckedFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js'; import { VSPChecksFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js'; +import { VSPGeneralInfoFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js'; import { VSPTestsMapFactory } from 'test-utils/factories/softwareProduct/SoftwareProductValidationFactory.js'; import { tabsMapping } from 'sdc-app/onboarding/softwareProduct/validation/SoftwareProductValidationConstants.js'; import TestUtils from 'react-dom/test-utils'; -//import { scryRenderedDOMComponentsWithTestId } from 'test-utils/Util.js'; +import { scryRenderedDOMComponentsWithTestId } from 'test-utils/Util.js'; describe('SoftwareProductValidation Mapper and View Classes', () => { it('mapStateToProps mapper exists', () => { @@ -43,15 +44,18 @@ describe('SoftwareProductValidation Mapper and View Classes', () => { const vspTestsMap = VSPTestsMapFactory.build(); const certificationChecked = VSPCertificationCheckedFactory.build(); const complianceChecked = VSPComplianceCheckedFactory.build(); + const generalInfo = VSPGeneralInfoFactory.build(); var obj = { softwareProduct: { softwareProductValidation: { vspChecks: vspChecksList, vspTestsMap: vspTestsMap.vspTestsMap, - certificationChecked: certificationChecked.certificationChecked, + certificationChecked: + certificationChecked.certificationChecked, complianceChecked: complianceChecked.complianceChecked, - activeTab: tabsMapping.SETUP + activeTab: tabsMapping.SETUP, + generalInfo: generalInfo.generalInfo } } }; @@ -65,6 +69,7 @@ describe('SoftwareProductValidation Mapper and View Classes', () => { results.softwareProductValidation.complianceChecked ).toBeTruthy(); expect(results.softwareProductValidation.activeTab).toBeTruthy(); + expect(results.softwareProductValidation.generalInfo).toBeTruthy(); }); it('SoftwareProductValidationView render test', () => { @@ -72,51 +77,63 @@ describe('SoftwareProductValidation Mapper and View Classes', () => { const vspTestsMap = VSPTestsMapFactory.build(); const certificationChecked = VSPCertificationCheckedFactory.build(); const complianceChecked = VSPComplianceCheckedFactory.build(); - let dummyFunc = () => {}; + // let dummyFunc = () => {}; const version = { + id: 12345, name: 1 }; const softwareProductId = '1234'; const status = 'draft'; var obj = { - version: version, - softwareProductId: softwareProductId, - status: status, - softwareProductValidation: { - vspChecks: vspChecksList, - vspTestsMap: vspTestsMap, - certificationChecked: certificationChecked.certificationChecked, - complianceChecked: complianceChecked.complianceChecked, - activeTab: tabsMapping.SETUP + softwareProduct: { + version: version, + softwareProductId: softwareProductId, + status: status, + softwareProductValidation: { + vspChecks: vspChecksList, + vspTestsMap: vspTestsMap.vspTestsMap, + certificationChecked: + certificationChecked.certificationChecked, + complianceChecked: complianceChecked.complianceChecked, + activeTab: tabsMapping.SETUP + } } }; + const store = storeCreator(); + let dispatch = store.dispatch; + + let props = Object.assign( + {}, + mapStateToProps(obj), + mapActionsToProps(dispatch) + ); + let softwareProductValidationView = TestUtils.renderIntoDocument( <Provider store={store}> - <SoftwareProductValidationView - {...obj} - onErrorThrown={dummyFunc} - onTestSubmit={dummyFunc} - setVspTestsMap={dummyFunc} - setActiveTab={dummyFunc} - setComplianceChecked={dummyFunc} - setCertificationChecked={dummyFunc} - /> + <SoftwareProductValidationView {...props} /> </Provider> ); expect(softwareProductValidationView).toBeTruthy(); - // let goToInput = scryRenderedDOMComponentsWithTestId( - // softwareProductValidationView, - // 'go-to-inputs' - // ); - // expect(goToInput).toBeTruthy(); + let goToInput = scryRenderedDOMComponentsWithTestId( + softwareProductValidationView, + 'go-to-vsp-validation-inputs' + ); + expect(goToInput).toBeTruthy(); // TestUtils.Simulate.click(goToInput[0]); - // let goToInput = TestUtils.findRenderedDOMComponentWithClass( + // expect( + // store.getState().softwareProduct.softwareProductValidation.activeTab + // ).toBe(tabsMapping.INPUTS); + // let goToSetup = scryRenderedDOMComponentsWithTestId( // softwareProductValidationView, - // 'go-to-inputs-btn' + // 'go-to-vsp-validation-setup' // ); - // TestUtils.Simulate.click(goToInput); + // expect(goToSetup).toBeTruthy(); + // TestUtils.Simulate.click(goToSetup[0]); + // expect( + // store.getState().softwareProduct.softwareProductValidation.activeTab + // ).toBe(tabsMapping.SETUP); }); }); diff --git a/openecomp-ui/test/softwareProduct/validationResults/SoftwareProductValidationResultsView.test.js b/openecomp-ui/test/softwareProduct/validationResults/SoftwareProductValidationResultsView.test.js index b2cc2c0985..67e9fcfd89 100644 --- a/openecomp-ui/test/softwareProduct/validationResults/SoftwareProductValidationResultsView.test.js +++ b/openecomp-ui/test/softwareProduct/validationResults/SoftwareProductValidationResultsView.test.js @@ -19,6 +19,8 @@ import { mapStateToProps } from 'sdc-app/onboarding/softwareProduct/validationRe import SoftwareProductValidationResultsView from 'sdc-app/onboarding/softwareProduct/validationResults/SoftwareProductValidationResultsView.jsx'; import { VSPTestResultsSuccessFactory } 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 TestUtils from 'react-dom/test-utils'; describe('SoftwareProductValidationResults Mapper and View Classes', () => { @@ -28,11 +30,13 @@ describe('SoftwareProductValidationResults Mapper and View Classes', () => { it('mapStateToProps fail data test', () => { const vspTestResults = VSPTestResultsFailureFactory.build(); + const vspTestsMap = VSPTestsMapFactory.build(); var obj = { softwareProduct: { softwareProductValidation: { - vspTestResults: vspTestResults.vspTestResults + vspTestResults: vspTestResults.vspTestResults, + vspTestsMap: vspTestsMap.vspTestsMap } } }; @@ -42,11 +46,13 @@ describe('SoftwareProductValidationResults Mapper and View Classes', () => { it('mapStateToProps success data test', () => { const vspTestResults = VSPTestResultsSuccessFactory.build(); + const vspTestsMap = VSPTestsMapFactory.build(); var obj = { softwareProduct: { softwareProductValidation: { - vspTestResults: vspTestResults.vspTestResults + vspTestResults: vspTestResults.vspTestResults, + vspTestsMap: vspTestsMap.vspTestsMap } } }; @@ -56,6 +62,7 @@ describe('SoftwareProductValidationResults Mapper and View Classes', () => { it('SoftwareProductValidationResultsView test fail render test', () => { const vspTestResults = VSPTestResultsFailureFactory.build(); + const vspTestsMap = VSPTestsMapFactory.build(); const version = { name: 1 @@ -65,7 +72,8 @@ describe('SoftwareProductValidationResults Mapper and View Classes', () => { softwareProductId: softwareProductId, version: version, softwareProductValidation: { - vspTestResults: vspTestResults.vspTestResults + vspTestResults: vspTestResults.vspTestResults, + vspTestsMap: vspTestsMap.vspTestsMap } }; let vspValidationResultsView = TestUtils.renderIntoDocument( @@ -76,6 +84,7 @@ describe('SoftwareProductValidationResults Mapper and View Classes', () => { it('SoftwareProductValidationResultsView test success render test', () => { const vspTestResults = VSPTestResultsSuccessFactory.build(); + const vspTestsMap = VSPTestsMapFactory.build(); let version = { name: 1 @@ -85,7 +94,8 @@ describe('SoftwareProductValidationResults Mapper and View Classes', () => { softwareProductId: softwareProductId, version: version, softwareProductValidation: { - vspTestResults: vspTestResults.vspTestResults + vspTestResults: vspTestResults.vspTestResults, + vspTestsMap: vspTestsMap.vspTestsMap } }; let vspValidationResultsView = TestUtils.renderIntoDocument( |