VSP Compliance Check for Compute Flavor
Change-Id: I04768a20413393026606a3f5b200e959e37c1410
Issue-ID: SDC-2051
Co-authored-by: rahul.ghugikar@vodafone.com, soumyarup.paul@vodafone.com
Signed-off-by: Vodafone <onap@vodafone.com>
diff --git a/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationActionHelper.test.js b/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationActionHelper.test.js
index ee6ba90..0a8f640 100644
--- a/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationActionHelper.test.js
+++ b/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationActionHelper.test.js
@@ -26,83 +26,193 @@
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 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 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 = () => {};
- deepFreeze(vspChecksList);
- deepFreeze(vspTestsMap);
- deepFreeze(certificationChecked);
- deepFreeze(complianceChecked);
- deepFreeze(activeTab);
+ 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(
- store.getState(),
- 'softwareProduct.softwareProductValidation.certificationChecked',
- certificationChecked
- );
- expectedStore = cloneAndSet(
- store.getState(),
- 'softwareProduct.softwareProductValidation.complianceChecked',
- complianceChecked
- );
- expectedStore = cloneAndSet(
- store.getState(),
- 'softwareProduct.softwareProductValidation.activeTab',
- activeTab
- );
- let restPrefix = Configuration.get('restPrefix');
-
- mockRest.addHandler('fetch', ({ options, data, baseUrl }) => {
- expect(baseUrl).toEqual(`${restPrefix}/v1.0/externaltesting`);
- expect(data).toEqual(undefined);
- expect(options).toEqual(undefined);
- return { vspChecks: vspChecksList };
+ mockRest.addHandler('fetch', ({ baseUrl }) => {
+ expect(baseUrl).toEqual(
+ `${restPrefix}/v1.0/externaltesting/testcasetree`
+ );
+ return vspChecksList;
});
-
- SoftwareProductValidationActionHelper.setVspTestsMap(store.dispatch, {
- vspTestsMap
- });
- SoftwareProductValidationActionHelper.setComplianceChecked(
- store.dispatch,
- { complianceChecked }
- );
- SoftwareProductValidationActionHelper.setCertificationChecked(
- store.dispatch,
- { certificationChecked }
- );
-
- SoftwareProductValidationActionHelper.setActiveTab(store.dispatch, {
- activeTab
- });
-
- SoftwareProductValidationActionHelper.onErrorThrown(store.dispatch, {
- errorMessage
- });
-
- SoftwareProductValidationActionHelper.fetchVspChecks(store.dispatch)
+ return SoftwareProductValidationActionHelper.fetchVspChecks(
+ store.dispatch
+ )
.then(() => {
expect(store.getState()).toEqual(expectedStore);
})
- .catch(() => {});
+ .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
+ );
+ 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
+ );
+ 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
+ );
+ mapActionsToProps(store.dispatch).setActiveTab(activeTab);
+ expect(store.getState()).toEqual(expectedStore);
+ });
+
+ 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);
+ });
+
+ it('Software Products Validation Action Helper : setIsVspValidationDisabled', () => {
+ let expectedStore = cloneAndSet(
+ store.getState(),
+ 'softwareProduct.softwareProductValidation.isValidationDisabled',
+ isValidationDisabled
+ );
+ SoftwareProductValidationActionHelper.setIsVspValidationDisabled(
+ store.dispatch,
+ {
+ isValidationDisabled
+ }
+ );
+ expect(store.getState()).toEqual(expectedStore);
+ });
+
+ 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
+ );
+
+ mapActionsToProps(store.dispatch).setTestsRequest(
+ testsRequest.testsRequest,
+ generalInfo.generalInfo
+ );
+ expect(store.getState()).toEqual(expectedStore);
+ });
+
+ 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 aa00a5d..68a8cdd 100644
--- a/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationInputView.test.js
+++ b/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationInputView.test.js
@@ -19,6 +19,7 @@
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 { 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 @@
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 640f9f6..be84f15 100644
--- a/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationView.test.js
+++ b/openecomp-ui/test/softwareProduct/validation/SoftwareProductValidationView.test.js
@@ -24,10 +24,11 @@
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 @@
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 @@
results.softwareProductValidation.complianceChecked
).toBeTruthy();
expect(results.softwareProductValidation.activeTab).toBeTruthy();
+ expect(results.softwareProductValidation.generalInfo).toBeTruthy();
});
it('SoftwareProductValidationView render test', () => {
@@ -72,51 +77,63 @@
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 b2cc2c0..67e9fcf 100644
--- a/openecomp-ui/test/softwareProduct/validationResults/SoftwareProductValidationResultsView.test.js
+++ b/openecomp-ui/test/softwareProduct/validationResults/SoftwareProductValidationResultsView.test.js
@@ -19,6 +19,8 @@
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 @@
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 @@
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 @@
it('SoftwareProductValidationResultsView test fail render test', () => {
const vspTestResults = VSPTestResultsFailureFactory.build();
+ const vspTestsMap = VSPTestsMapFactory.build();
const version = {
name: 1
@@ -65,7 +72,8 @@
softwareProductId: softwareProductId,
version: version,
softwareProductValidation: {
- vspTestResults: vspTestResults.vspTestResults
+ vspTestResults: vspTestResults.vspTestResults,
+ vspTestsMap: vspTestsMap.vspTestsMap
}
};
let vspValidationResultsView = TestUtils.renderIntoDocument(
@@ -76,6 +84,7 @@
it('SoftwareProductValidationResultsView test success render test', () => {
const vspTestResults = VSPTestResultsSuccessFactory.build();
+ const vspTestsMap = VSPTestsMapFactory.build();
let version = {
name: 1
@@ -85,7 +94,8 @@
softwareProductId: softwareProductId,
version: version,
softwareProductValidation: {
- vspTestResults: vspTestResults.vspTestResults
+ vspTestResults: vspTestResults.vspTestResults,
+ vspTestsMap: vspTestsMap.vspTestsMap
}
};
let vspValidationResultsView = TestUtils.renderIntoDocument(