summaryrefslogtreecommitdiffstats
path: root/openecomp-ui/test/softwareProduct
diff options
context:
space:
mode:
authortalig <talig@amdocs.com>2017-12-20 14:30:43 +0200
committerVitaly Emporopulo <Vitaliy.Emporopulo@amdocs.com>2017-12-21 11:12:33 +0000
commit8e9c0653dd6c6862123c9609ae34e1206d86456e (patch)
tree5eeef00ec0677133baa439ca8d7ffd7aca4804b6 /openecomp-ui/test/softwareProduct
parent785ebcc95de3e064e843bec04ba7a209d854fc7c (diff)
Add collaboration feature
Issue-ID: SDC-767 Change-Id: I14fb4c1f54086ed03a56a7ff7fab9ecd40381795 Signed-off-by: talig <talig@amdocs.com>
Diffstat (limited to 'openecomp-ui/test/softwareProduct')
-rw-r--r--openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationView.test.js3
-rw-r--r--openecomp-ui/test/softwareProduct/components/compute/SoftwareProductComponentComputeEditor.test.js5
-rw-r--r--openecomp-ui/test/softwareProduct/components/compute/VSPComponentComputeActionHelperHeatMode.test.js4
-rw-r--r--openecomp-ui/test/softwareProduct/components/compute/VSPComponentComputeActionHelperManualMode.test.js29
-rw-r--r--openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js14
-rw-r--r--openecomp-ui/test/softwareProduct/components/monitoring/test.js8
-rw-r--r--openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js5
-rw-r--r--openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js118
-rw-r--r--openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesView.test.js4
-rw-r--r--openecomp-ui/test/softwareProduct/components/storage/test.js4
-rw-r--r--openecomp-ui/test/softwareProduct/components/test.js4
-rw-r--r--openecomp-ui/test/softwareProduct/creation/SoftwareProductCreation.test.js16
-rw-r--r--openecomp-ui/test/softwareProduct/dependencies/SoftwareProductDependencies.test.js216
-rw-r--r--openecomp-ui/test/softwareProduct/deployment/SoftwareProductDeploymentEditor.test.js3
-rw-r--r--openecomp-ui/test/softwareProduct/details/detailsView.test.js52
-rw-r--r--openecomp-ui/test/softwareProduct/details/test.js70
-rw-r--r--openecomp-ui/test/softwareProduct/landingPage/landingPage.test.js61
-rw-r--r--openecomp-ui/test/softwareProduct/networks/SoftwareProductNetworksView.test.js3
-rw-r--r--openecomp-ui/test/softwareProduct/processes/test.js21
-rw-r--r--openecomp-ui/test/softwareProduct/test.js116
20 files changed, 532 insertions, 224 deletions
diff --git a/openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationView.test.js b/openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationView.test.js
index a5ba297d2b..a0a8a42660 100644
--- a/openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationView.test.js
+++ b/openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationView.test.js
@@ -19,8 +19,6 @@ 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', () => {
@@ -41,7 +39,6 @@ describe('SoftwareProductAttachments Modal Mapper and View Classes', () => {
id: 'D4774719D085414E9D5642D1ACD59D20',
version: '0.10',
viewableVersions: ['0.1', '0.2'],
- status: versionStatusEnum.CHECK_OUT_STATUS,
lockingUser: 'cs0008'
};
const atTree = {
diff --git a/openecomp-ui/test/softwareProduct/components/compute/SoftwareProductComponentComputeEditor.test.js b/openecomp-ui/test/softwareProduct/components/compute/SoftwareProductComponentComputeEditor.test.js
index c14246f810..07268e514c 100644
--- a/openecomp-ui/test/softwareProduct/components/compute/SoftwareProductComponentComputeEditor.test.js
+++ b/openecomp-ui/test/softwareProduct/components/compute/SoftwareProductComponentComputeEditor.test.js
@@ -21,7 +21,7 @@ import ComputeEditorView from 'sdc-app/onboarding/softwareProduct/components/com
import {SoftwareProductFactory} from 'test-utils/factories/softwareProduct/SoftwareProductFactory.js';
import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
import {ComputeFlavorBaseData, ComputeFlavorQData, VSPComponentsComputeDataMapFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsComputeFactory.js';
-
+import CurrentScreenFactory from 'test-utils/factories/common/CurrentScreenFactory.js';
describe('Software Product Component Compute-Editor Mapper and View Classes.', () => {
@@ -33,6 +33,7 @@ describe('Software Product Component Compute-Editor Mapper and View Classes.', (
const currentSoftwareProduct = VSPEditorFactory.build();
var obj = {
+ currentScreen: CurrentScreenFactory.build(),
softwareProduct: SoftwareProductFactory.build({
softwareProductEditor: {
data: currentSoftwareProduct
@@ -58,7 +59,7 @@ describe('Software Product Component Compute-Editor Mapper and View Classes.', (
expect(results.qgenericFieldInfo).toBeTruthy();
expect(results.dataMap).toBeTruthy();
expect(results.genericFieldInfo).toBeTruthy();
- expect(results.isReadOnlyMode).toBeTruthy();
+ expect(results.isReadOnlyMode).toBe(false);
expect(results.isFormValid).toBeTruthy();
expect(results.formReady).toBeTruthy();
});
diff --git a/openecomp-ui/test/softwareProduct/components/compute/VSPComponentComputeActionHelperHeatMode.test.js b/openecomp-ui/test/softwareProduct/components/compute/VSPComponentComputeActionHelperHeatMode.test.js
index 4fe9408e34..e8195314b4 100644
--- a/openecomp-ui/test/softwareProduct/components/compute/VSPComponentComputeActionHelperHeatMode.test.js
+++ b/openecomp-ui/test/softwareProduct/components/compute/VSPComponentComputeActionHelperHeatMode.test.js
@@ -22,11 +22,11 @@ import Configuration from 'sdc-app/config/Configuration.js';
import SoftwareProductComponentsActionHelper from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js';
import {ComputeFlavorQData, VSPComponentsComputeDataMapFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsComputeFactory.js';
-import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
+import VersionFactory from 'test-utils/factories/common/VersionFactory.js';
const softwareProductId = '123';
const vspComponentId = '111';
-const version = VersionControllerUtilsFactory.build().version;
+const version = VersionFactory.build();
describe('Software Product Components Compute Module Tests - HEAT mode', function () {
diff --git a/openecomp-ui/test/softwareProduct/components/compute/VSPComponentComputeActionHelperManualMode.test.js b/openecomp-ui/test/softwareProduct/components/compute/VSPComponentComputeActionHelperManualMode.test.js
index ca3d12f3e9..addd800c43 100644
--- a/openecomp-ui/test/softwareProduct/components/compute/VSPComponentComputeActionHelperManualMode.test.js
+++ b/openecomp-ui/test/softwareProduct/components/compute/VSPComponentComputeActionHelperManualMode.test.js
@@ -19,14 +19,14 @@ import {cloneAndSet} from 'test-utils/Util.js';
import {storeCreator} from 'sdc-app/AppStore.js';
import Configuration from 'sdc-app/config/Configuration.js';
import ComputeFlavorActionHelper from 'sdc-app/onboarding/softwareProduct/components/compute/ComputeFlavorActionHelper.js';
-import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
+import VersionFactory from 'test-utils/factories/common/VersionFactory.js';
import {ComputeFlavorQData, ComputeFlavorBaseData, ComponentComputeFactory, VSPComponentsComputeDataMapFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsComputeFactory.js';
const softwareProductId = '123';
const vspComponentId = '111';
const computeId = '111';
-const version = VSPEditorFactory.build().version;
+const version = VersionFactory.build();
describe('Software Product Components Compute Module Tests - Manual mode', function () {
@@ -92,16 +92,6 @@ describe('Software Product Components Compute Module Tests - Manual mode', funct
};
deepFreeze(softwareProductComponentCompute);
-
- const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.computeFlavor.computeEditor', {
- data: computeData,
- qdata,
- dataMap,
- qgenericFieldInfo: {},
- genericFieldInfo: {},
- formReady: true
- });
-
mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/compute-flavors/${computeId}`);
expect(data).toEqual(undefined);
@@ -109,15 +99,18 @@ describe('Software Product Components Compute Module Tests - Manual mode', funct
return {data: computeData};
});
mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/compute-flavors/${computeId}/questionnaire`);
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/compute-flavors/${computeId}/questionnaire`
+ );
expect(data).toEqual(undefined);
expect(options).toEqual(undefined);
return softwareProductComponentCompute;
});
- return ComputeFlavorActionHelper.loadComputeData({softwareProductId, componentId: vspComponentId, version, computeId}).then(() => {
- ComputeFlavorActionHelper.loadComputeQuestionnaire(store.dispatch, {softwareProductId, componentId: vspComponentId, computeId, version}).then(() =>
- expect(store.getState()).toEqual(expectedStore));
+ return ComputeFlavorActionHelper.loadCompute(store.dispatch, {softwareProductId, componentId: vspComponentId, version, computeId}).then(() => {
+ expect(store.getState().softwareProduct.softwareProductComponents.computeFlavor.computeEditor.data).toEqual(computeData);
+ expect(store.getState().softwareProduct.softwareProductComponents.computeFlavor.computeEditor.qdata).toEqual(qdata);
+ expect(store.getState().softwareProduct.softwareProductComponents.computeFlavor.computeEditor.dataMap).toEqual(dataMap);
});
});
@@ -142,7 +135,9 @@ describe('Software Product Components Compute Module Tests - Manual mode', funct
deepFreeze(expectedStore);
mockRest.addHandler('put', ({options, data, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/compute-flavors/${computeId}/questionnaire`);
+ expect(baseUrl).toEqual(
+ `/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/compute-flavors/${computeId}/questionnaire`
+ );
expect(data).toEqual(qdata);
expect(options).toEqual(undefined);
return {returnCode: 'OK'};
diff --git a/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js b/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js
index 423a7b39f6..21e58057e9 100644
--- a/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js
+++ b/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js
@@ -85,24 +85,18 @@ describe('SoftwareProductComponentsMonitoring Module Tests', function () {
expect(renderedOutput).toBeTruthy();
});
- it('should change state to dragging', done => {
+ it('should change state to dragging', () => {
var view = TestUtils.renderIntoDocument(<SoftwareProductComponentsMonitoringView />);
expect(view.state.dragging).toBe(false);
view.handleOnDragEnter(false);
- setTimeout(()=> {
- expect(view.state.dragging).toBe(true);
- done();
- }, 100);
+ expect(view.state.dragging).toBe(true);
});
- it('should not change state to dragging', done => {
+ it('should not change state to dragging', () => {
var view = TestUtils.renderIntoDocument(<SoftwareProductComponentsMonitoringView />);
expect(view.state.dragging).toBe(false);
view.handleOnDragEnter(true);
- setTimeout(()=> {
- expect(view.state.dragging).toBe(false);
- done();
- }, 0);
+ expect(view.state.dragging).toBe(false);
});
});
diff --git a/openecomp-ui/test/softwareProduct/components/monitoring/test.js b/openecomp-ui/test/softwareProduct/components/monitoring/test.js
index 8fafcdb968..50fda91871 100644
--- a/openecomp-ui/test/softwareProduct/components/monitoring/test.js
+++ b/openecomp-ui/test/softwareProduct/components/monitoring/test.js
@@ -16,16 +16,14 @@
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 {fileTypes} from 'sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringConstants.js';
-
+import VersionFactory from 'test-utils/factories/common/VersionFactory.js';
import {VSPComponentsMonitoringRestFactory, trap, poll, ves} 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;
+const version = VersionFactory.build();
describe('Software Product Components Monitoring Module Tests', function () {
@@ -132,7 +130,7 @@ describe('Software Product Components Monitoring Module Tests', function () {
version,
componentId,
type: fileTypes.SNMP_TRAP
- }).then((dispatch) => {
+ }).then(() => {
var {softwareProduct: {softwareProductComponents: {monitoring}}} = store.getState();
expect(monitoring[trap]).toEqual(undefined);
done();
diff --git a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js
index 094b95a091..78d88b008a 100644
--- a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js
+++ b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js
@@ -23,6 +23,7 @@ import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwarePro
import {SoftwareProductFactory} from 'test-utils/factories/softwareProduct/SoftwareProductFactory.js';
import {VSPComponentsNicFactory, VSPComponentsNetworkQDataFactory, VSPComponentsNicFactoryQGenericFieldInfo,
VSPComponentsNicFactoryGenericFieldInfo, VSPComponentsNetworkDataMapFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js';
+import CurrentScreenFactory from 'test-utils/factories/common/CurrentScreenFactory.js';
describe('Software Product Component Network NIC Editor and View Classes', () => {
it('mapStateToProps mapper exists', () => {
@@ -34,8 +35,8 @@ describe('Software Product Component Network NIC Editor and View Classes', () =>
const currentSoftwareProduct = VSPEditorFactory.build();
-
var obj = {
+ currentScreen: CurrentScreenFactory.build(),
softwareProduct: SoftwareProductFactory.build({
softwareProductEditor: {
data: currentSoftwareProduct
@@ -55,12 +56,14 @@ describe('Software Product Component Network NIC Editor and View Classes', () =>
};
var results = mapStateToProps(obj);
+ expect(results.isReadOnlyMode).toBe(false);
expect(results.currentSoftwareProduct).toBeTruthy();
expect(results.qdata).toBeTruthy();
expect(results.dataMap).toBeTruthy();
expect(results.genericFieldInfo).toBeTruthy();
expect(results.qgenericFieldInfo).toBeTruthy();
expect(results.data).toBeTruthy();
+
});
diff --git a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js
index b6050265a6..11a0ca787f 100644
--- a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js
+++ b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js
@@ -19,15 +19,20 @@ 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 {VSPComponentsNicPostFactory, VSPComponentsNicFactory, VSPComponentsNetworkFactory, VSPComponentsNetworkQDataFactory, VSPComponentsNetworkDataMapFactory, VSPComponentsNicFactoryGenericFieldInfo} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js';
-import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
+import {VSPComponentsNicFactory,
+ VSPComponentsNicPostFactory,
+ VSPComponentsNetworkFactory,
+ VSPComponentsNetworkQDataFactory,
+ VSPComponentsNetworkDataMapFactory,
+ VSPComponentsNicFactoryGenericFieldInfo} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js';
+import VersionFactory from 'test-utils/factories/common/VersionFactory.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;
+const version = VersionFactory.build();
describe('Software Product Components Network Action Helper Tests', function () {
@@ -55,60 +60,62 @@ describe('Software Product Components Network Action Helper Tests', function ()
});
});
+
it('Add NIC', () => {
- const store = storeCreator();
- deepFreeze(store.getState());
-
- const NICPostRequest = VSPComponentsNicPostFactory.build();
-
- const expectedNIC = VSPComponentsNicFactory.build({...NICPostRequest, id: nicId});
-
- mockRest.addHandler('post', ({options, data, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics`);
- expect(data).toEqual(NICPostRequest);
- expect(options).toEqual(undefined);
- return {
- nicId
- };
- });
-
- mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
- 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: [expectedNIC]};
- });
-
- mockRest.addHandler('destroy', ({options, data, baseUrl}) => {
- 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 {};
- });
-
- mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
- 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: []};
- });
-
- const network = VSPComponentsNetworkFactory.build({
- nicList: [expectedNIC]
- });
-
- const networkAfterDelete = VSPComponentsNetworkFactory.build();
-
- let expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', network);
-
- return SoftwareProductComponentsNetworkActionHelper.createNIC(store.dispatch, {nic: NICPostRequest, softwareProductId, componentId, version}).then(() => {
- expect(store.getState()).toEqual(expectedStore);
- return SoftwareProductComponentsNetworkActionHelper.deleteNIC(store.dispatch, {softwareProductId, componentId, nicId, version});
- }).then(() => {
- let expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', networkAfterDelete);
- expect(store.getState()).toEqual(expectedStore);
- });
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const NICPostRequest = VSPComponentsNicPostFactory.build();
+
+ const expectedNIC = VSPComponentsNicFactory.build({...NICPostRequest, id: nicId});
+
+ mockRest.addHandler('post', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics`);
+ expect(data).toEqual(NICPostRequest);
+ expect(options).toEqual(undefined);
+ return {
+ nicId
+ };
+ });
+
+ mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ 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: [expectedNIC]};
+ });
+
+ mockRest.addHandler('destroy', ({options, data, baseUrl}) => {
+ 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 {};
});
+
+ mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ 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: []};
+ });
+
+ const network = VSPComponentsNetworkFactory.build({
+ nicList: [expectedNIC]
+ });
+
+ const networkAfterDelete = VSPComponentsNetworkFactory.build();
+
+ let expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', network);
+
+ return SoftwareProductComponentsNetworkActionHelper.createNIC(store.dispatch, {nic: NICPostRequest, softwareProductId, componentId, version}).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ return SoftwareProductComponentsNetworkActionHelper.deleteNIC(store.dispatch, {softwareProductId, componentId, nicId, version});
+ }).then(() => {
+ let expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', networkAfterDelete);
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
it('open NICE editor', () => {
const store = storeCreator();
@@ -172,7 +179,6 @@ describe('Software Product Components Network Action Helper Tests', function ()
});
});
-
it('load NIC Questionnaire', () => {
mockRest.resetQueue();
const store = storeCreator();
diff --git a/openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesView.test.js b/openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesView.test.js
index ac866727a6..921d1bbc90 100644
--- a/openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesView.test.js
+++ b/openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesView.test.js
@@ -66,8 +66,8 @@ describe('SoftwareProductComponetsProcesses Mapper and View Classes', () => {
softwareProductId={currentSoftwareProduct.id}
componentId={currentSoftwareProductComponent.id}
onAddProcess={() => {}}
- onEditProcessClick={() => {}}
- onDeleteProcessClick={() => {}}
+ onEditProcess={() => {}}
+ onDeleteProcess={() => {}}
isDisplayEditor={false}
isReadOnlyMode={false}/>
);
diff --git a/openecomp-ui/test/softwareProduct/components/storage/test.js b/openecomp-ui/test/softwareProduct/components/storage/test.js
index 138c4da7d6..1cc0c7b636 100644
--- a/openecomp-ui/test/softwareProduct/components/storage/test.js
+++ b/openecomp-ui/test/softwareProduct/components/storage/test.js
@@ -22,11 +22,11 @@ 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';
+import VersionFactory from 'test-utils/factories/common/VersionFactory.js';
const softwareProductId = '123';
const vspComponentId = '111';
-const version = VersionControllerUtilsFactory.build().version;
+const version = VersionFactory.build();
describe('Software Product Components Storage Module Tests', function () {
diff --git a/openecomp-ui/test/softwareProduct/components/test.js b/openecomp-ui/test/softwareProduct/components/test.js
index b3994b1461..ab379937c0 100644
--- a/openecomp-ui/test/softwareProduct/components/test.js
+++ b/openecomp-ui/test/softwareProduct/components/test.js
@@ -20,11 +20,11 @@ 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';
+import VersionFactory from 'test-utils/factories/common/VersionFactory.js';
const softwareProductId = '123';
const vspComponentId = '321';
-const version = VersionControllerUtilsFactory.build().version;
+const version = VersionFactory.build();
describe('Software Product Components Module Tests', function () {
it('Get Software Products Components List', () => {
diff --git a/openecomp-ui/test/softwareProduct/creation/SoftwareProductCreation.test.js b/openecomp-ui/test/softwareProduct/creation/SoftwareProductCreation.test.js
index c7c55bdbaf..0b46721da0 100644
--- a/openecomp-ui/test/softwareProduct/creation/SoftwareProductCreation.test.js
+++ b/openecomp-ui/test/softwareProduct/creation/SoftwareProductCreation.test.js
@@ -35,6 +35,9 @@ describe('Software Product Creation Module Tests', function() {
softwareProductCreation: {
data: {}
}
+ },
+ users: {
+ usersList: []
}
};
let props = mapStateToProps(state);
@@ -54,6 +57,9 @@ describe('Software Product Creation Module Tests', function() {
softwareProductCreation: {
data: {}
}
+ },
+ users: {
+ usersList: []
}
};
let props = mapStateToProps(state);
@@ -71,7 +77,10 @@ describe('Software Product Creation Module Tests', function() {
softwareProductCreation: SoftwareProductCreationFactory.build(),
softwareProductCategories: CategoryWithSubFactory.buildList({}, {quantity: 2})
},
- finalizedLicenseModelList: FinalizedLicenseModelFactory.buildList(3)
+ finalizedLicenseModelList: FinalizedLicenseModelFactory.buildList(3),
+ users: {
+ usersList: []
+ }
};
let props = Object.assign({}, mapStateToProps(state), mapActionsToProps(dispatch));
var renderer = TestUtils.createRenderer();
@@ -92,7 +101,10 @@ describe('Software Product Creation Module Tests', function() {
softwareProductCreation: SoftwareProductCreationFactoryWithSelectedVendor.build({selectedVendorId: finalizedLicenseModelList[0].id}),
softwareProductCategories: CategoryWithSubFactory.buildList({}, {quantity: 2})
},
- finalizedLicenseModelList
+ finalizedLicenseModelList,
+ users: {
+ usersList: []
+ }
};
let props = Object.assign({}, mapStateToProps(state), mapActionsToProps(dispatch));
let renderer = TestUtils.createRenderer();
diff --git a/openecomp-ui/test/softwareProduct/dependencies/SoftwareProductDependencies.test.js b/openecomp-ui/test/softwareProduct/dependencies/SoftwareProductDependencies.test.js
index 5325a58959..595a93fe60 100644
--- a/openecomp-ui/test/softwareProduct/dependencies/SoftwareProductDependencies.test.js
+++ b/openecomp-ui/test/softwareProduct/dependencies/SoftwareProductDependencies.test.js
@@ -21,34 +21,45 @@ 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 VersionFactory from 'test-utils/factories/common/VersionFactory.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 {relationTypes, NEW_RULE_TEMP_ID} from 'sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesConstants.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';
+function addNewRowElement(arr, data) {
+ if (data === undefined) {
+ arr.push({id: NEW_RULE_TEMP_ID, targetId: null, sourceId: null, relationType: relationTypes.DEPENDS_ON});
+ } else {
+ arr.push(data);
+ }
+}
+
describe('Software Product Dependencies Module Tests', function () {
const softwareProductId = '555';
- const version = VersionControllerUtilsFactory.build().version;
+ const version = VersionFactory.build();
+
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));
+ addNewRowElement(DependenciesListStore);
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(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/component-dependencies`);
expect(data).toEqual(undefined);
expect(options).toEqual(undefined);
return {results: DependenciesListResponse};
@@ -59,92 +70,201 @@ describe('Software Product Dependencies Module Tests', function () {
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', () => {
+ /*
+ Test update:
+ - fetch initial item
+ - update existing item
+ - auto fetch again
+ */
+ it('Update Software Product Dependency', () => {
const store = storeCreator();
const dispatch = store.dispatch;
- let DependenciesListResponse = SoftwareProductDependenciesResponseFactory.buildList(3);
+ let DependenciesListResponse = SoftwareProductDependenciesResponseFactory.buildList(1);
let DependenciesListStore = DependenciesListResponse.map(dependency => SoftwareProductDependenciesStoreFactory.build(dependency));
+ addNewRowElement(DependenciesListStore);
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(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/component-dependencies`);
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);
-
+ let item = expectedStoreDependencies.find((dep) => dep.id !== NEW_RULE_TEMP_ID);
+ item.targetId = 'testChangeTarget';
+ item.sourceId = 'testChangesource';
+ // removing 'new row' from response
+ expectedStoreDependencies = expectedStoreDependencies.slice(0, expectedStoreDependencies.length - 1);
+ let expDependenciesListStore = expectedStoreDependencies.map(dependency => SoftwareProductDependenciesStoreFactory.build(dependency));
+
+ mockRest.addHandler('put', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/component-dependencies/${item.id}`);
+ expect(data.targetId).toEqual('testChangeTarget');
+ expect(data.sourceId).toEqual('testChangesource');
+ expect(options).toEqual(undefined);
+ return {results: null};
+ });
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/component-dependencies`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: expDependenciesListStore};
+ });
+
+ addNewRowElement(expectedStoreDependencies);
const newExpectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductDependencies', expectedStoreDependencies);
+ return SoftwareProductDependenciesActionHelper.updateDependency(dispatch, {softwareProductId, version, item}).then(() => {
+ const newState = store.getState();
+ expect(newState).toEqual(newExpectedStore);
- SoftwareProductDependenciesActionHelper.updateDependencyList(dispatch, {dependenciesList: expectedStoreDependencies});
- const newState = store.getState();
- expect(newState).toEqual(newExpectedStore);
+ });
});
});
- it('Add And Save Software Product Dependencies List', () => {
+ /*
+ - Fetch item list
+ - Delete item from list
+ - Fetch again
+ */
+ it('Delete Software Product Dependency', () => {
const store = storeCreator();
const dispatch = store.dispatch;
+ let DependenciesListResponse = SoftwareProductDependenciesResponseFactory.buildList(1);
+ let DependenciesListStore = DependenciesListResponse.map(dependency => SoftwareProductDependenciesStoreFactory.build(dependency));
+ addNewRowElement(DependenciesListStore);
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductDependencies', DependenciesListStore);
- let mockServerDependencies = [];
+ let deleteItem = DependenciesListStore.find((dep) => dep.id !== NEW_RULE_TEMP_ID);
- 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);
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/component-dependencies`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: DependenciesListResponse};
+ });
+ mockRest.addHandler('destroy', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/component-dependencies/${deleteItem.id}`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: null};
+ });
+ 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 newDependencies = SoftwareProductDependenciesStoreFactory.buildList(1);
- const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductDependencies', newDependencies);
- SoftwareProductDependenciesActionHelper.updateDependencyList(dispatch, {dependenciesList: newDependencies});
+ const newExpectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductDependencies', expectedStoreDependencies);
+ expect(state).toEqual(newExpectedStore);
- 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'};
+ expectedStoreDependencies = expectedStoreDependencies.filter((dep) => dep.id !== deleteItem.id);
+ const postDeleteExpectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductDependencies', expectedStoreDependencies);
+
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/component-dependencies`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: []};
+ });
+
+ return SoftwareProductDependenciesActionHelper.removeDependency(dispatch, {softwareProductId, version, item: deleteItem}).then(() => {
+ const state = store.getState();
+ const depndenciesWithGeneratedId = state.softwareProduct.softwareProductDependencies;
+ const currentDependencies = postDeleteExpectedStore.softwareProduct.softwareProductDependencies;
+ expect(depndenciesWithGeneratedId).toEqual(currentDependencies);
+ });
});
+ });
+
+ /*
+ - Create initial list
+ - Update the new row and make sure there is no API call
+ - Submit the new row
+ - Getch data with reset new row and new entity with info from the new item
+ */
+
+ it('Create Software Product Dependency', () => {
+ const store = storeCreator();
+ const dispatch = store.dispatch;
+
+ let DependenciesListResponse = SoftwareProductDependenciesResponseFactory.buildList(1);
+ let DependenciesListStore = DependenciesListResponse.map(dependency => SoftwareProductDependenciesStoreFactory.build(dependency));
+ addNewRowElement(DependenciesListStore);
+ 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(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/component-dependencies`);
expect(data).toEqual(undefined);
expect(options).toEqual(undefined);
- return {results: mockServerDependencies};
+ return {results: DependenciesListResponse};
});
+ return SoftwareProductDependenciesActionHelper.fetchDependencies(dispatch, {softwareProductId, version}).then(() => {
+ // setting properties on the 'new role' should not call an API
+ let addItem = {id: NEW_RULE_TEMP_ID, sourceId: 'sId', targetId : 'tId',relationType: relationTypes.DEPENDS_ON};
+ try {
+ SoftwareProductDependenciesActionHelper.updateDependency(dispatch, {softwareProductId, version, item: addItem}).then(()=> {
+ //go to error that fetch was not defined
+ });
+ } catch (error) {
+ if(error.name === 'TypeError') {
+ // Expected error because we expected there is no promise
+ } else {
+ fail('Error:' + error);
+ }
+ }
- 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}));
+ // creating the new item
+ let item = SoftwareProductDependenciesResponseFactory.buildList(1,
+ {sourceId: 'sId', targetId : 'tId',relationType: relationTypes.DEPENDS_ON})[0];
+ addNewRowElement(expectedStoreDependencies, item);
+ expectedStoreDependencies = expectedStoreDependencies.filter((dep) => dep.id !== NEW_RULE_TEMP_ID);
+
+ mockRest.addHandler('post', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/component-dependencies`);
+ expect(data.targetId).toEqual('tId');
+ expect(data.sourceId).toEqual('sId');
+ expect(data.id).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: item.id};
+ });
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/component-dependencies`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: expectedStoreDependencies};
+ });
+
+ let PostCreateItemListStore = expectedStoreDependencies.map(dependency => SoftwareProductDependenciesStoreFactory.build(dependency));
+ addNewRowElement(PostCreateItemListStore);
+ const newExpectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductDependencies', PostCreateItemListStore);
+
+ return SoftwareProductDependenciesActionHelper.createDependency(dispatch, {softwareProductId, version, item: addItem}).then(() => {
+ const newState = store.getState();
+ expect(newState.softwareProduct.softwareProductDependencies.length).toEqual(3);
+ expect(newState).toEqual(newExpectedStore);
+ });
- 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;
@@ -161,10 +281,11 @@ describe('Software Product Dependencies Module Tests', function () {
secondDependency.targetId = firstDependecy.sourceId;
let DependenciesListStore = DependenciesListResponse.map(dependency => SoftwareProductDependenciesStoreFactory.build({...dependency, hasCycle: true}));
+ addNewRowElement(DependenciesListStore);
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(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/component-dependencies`);
expect(data).toEqual(undefined);
expect(options).toEqual(undefined);
return {results: DependenciesListResponse};
@@ -187,9 +308,9 @@ describe('Software Product Dependencies Module Tests', function () {
let expectedStoreDependencies = currentDependencies.map((dependency, index) => ({...dependency, id: depndenciesWithGeneratedId[index].id}));
const newExpectedStore = {
- ...expectedStore,
+ ...expectedStore,
softwareProduct: {
- ...expectedStore.softwareProduct,
+ ...expectedStore.softwareProduct,
softwareProductDependencies: expectedStoreDependencies,
softwareProductEditor: {data: vspEditor},
softwareProductComponents: {
@@ -207,4 +328,5 @@ describe('Software Product Dependencies Module Tests', function () {
expect(wrapper).toBeTruthy();
});
});
-}); \ No newline at end of file
+
+});
diff --git a/openecomp-ui/test/softwareProduct/deployment/SoftwareProductDeploymentEditor.test.js b/openecomp-ui/test/softwareProduct/deployment/SoftwareProductDeploymentEditor.test.js
index 4277f28ee8..c355d9d273 100644
--- a/openecomp-ui/test/softwareProduct/deployment/SoftwareProductDeploymentEditor.test.js
+++ b/openecomp-ui/test/softwareProduct/deployment/SoftwareProductDeploymentEditor.test.js
@@ -20,6 +20,7 @@ import SoftwareProductDeploymentEditorView from 'sdc-app/onboarding/softwareProd
import { VSPComponentsFactory } from 'test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js';
import { VSPEditorFactoryWithLicensingData } from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
import { FeatureGroupStoreFactory } from 'test-utils/factories/licenseModel/FeatureGroupFactories.js';
+import CurrentScreenFactory from 'test-utils/factories/common/CurrentScreenFactory.js';
describe('Software Product Deployment Editor Module Tests', function () {
@@ -32,8 +33,10 @@ describe('Software Product Deployment Editor Module Tests', function () {
const currentSoftwareProduct = VSPEditorFactoryWithLicensingData.build();
const componentsList = VSPComponentsFactory.buildList(1);
const featureGroupsList = FeatureGroupStoreFactory.buildList(2);
+ const currentScreen = CurrentScreenFactory.build();
var state = {
+ currentScreen,
softwareProduct: {
softwareProductEditor: {
data: currentSoftwareProduct
diff --git a/openecomp-ui/test/softwareProduct/details/detailsView.test.js b/openecomp-ui/test/softwareProduct/details/detailsView.test.js
index 37c5df5079..d83fedaf7d 100644
--- a/openecomp-ui/test/softwareProduct/details/detailsView.test.js
+++ b/openecomp-ui/test/softwareProduct/details/detailsView.test.js
@@ -24,10 +24,12 @@ import {FeatureGroupStoreFactory} from 'test-utils/factories/licenseModel/Featu
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';
+import VersionFactory from 'test-utils/factories/common/VersionFactory.js';
+import CurrentScreenFactory from 'test-utils/factories/common/CurrentScreenFactory.js';
describe('Software Product Details: ', function () {
- let currentSoftwareProduct = {}, currentSoftwareProductWithLicensingData = {}, softwareProductCategories = [],
+ let currentSoftwareProduct = {}, currentSoftwareProductWithLicensingData = {}, softwareProductCategories = [], licensingVersionsList = [], currentScreen = {},
finalizedLicenseModelList, licenseAgreementList, featureGroupsList, qdata = {}, dataMap = {}, genericFieldInfo = {}, qGenericFieldInfo = {};
let dummyFunc = () => {};
@@ -35,11 +37,18 @@ describe('Software Product Details: ', function () {
finalizedLicenseModelList = FinalizedLicenseModelFactory.buildList(2);
currentSoftwareProduct = VSPEditorFactory.build({
id: 'RTRTG454545',
+ licensingVersion: undefined,
vendorId: finalizedLicenseModelList[0].id,
- vendorName: finalizedLicenseModelList[0].vendorName
+ vendorName: finalizedLicenseModelList[0].name
});
softwareProductCategories = CategoryWithSubFactory.buildList(2, {}, {quantity: 1});
licenseAgreementList = LicenseAgreementStoreFactory.buildList(2);
+ licensingVersionsList = [
+ {
+ "id":"0127b419e9574a11aab8e031a78fc534",
+ "name":"1.0","description":"Initial version",
+ "baseId":"","status":"Certified","creationTime":1506409288390,"modificationTime":1506409288390,"additionalInfo":{"OptionalCreationMethods":["minor"]}},{"id":"ea159ffedd9a4f9a8a56d53ba66b7314","name":"2.0","description":"ggggg","baseId":"0127b419e9574a11aab8e031a78fc534","status":"Draft","creationTime":1508839019802,"modificationTime":1508839019802,"additionalInfo":{"OptionalCreationMethods":[]}}
+ ];
featureGroupsList = FeatureGroupStoreFactory.buildList(2, {referencingLicenseAgreements: [licenseAgreementList[0].id]});
qdata = VspQdataFactory.build();
dataMap = VspDataMapFactory.build();
@@ -48,7 +57,8 @@ describe('Software Product Details: ', function () {
licensingData: {
licenseAgreement: licenseAgreementList[0].id,
featureGroups: [featureGroupsList[0].id]
- }
+ },
+ licensingVersion : licensingVersionsList[0].id
};
genericFieldInfo = {
'name': {
@@ -66,6 +76,7 @@ describe('Software Product Details: ', function () {
}
};
qGenericFieldInfo = SchemaGenericFieldInfoFactory.build();
+ currentScreen = CurrentScreenFactory.build();
});
it('should mapper exist', () => {
@@ -75,10 +86,12 @@ describe('Software Product Details: ', function () {
it('should mapper return vsp basic data', () => {
var obj = {
+ currentScreen,
softwareProduct: {
softwareProductEditor: {
data: currentSoftwareProduct,
- genericFieldInfo
+ genericFieldInfo,
+ licensingVersionsList
},
softwareProductCategories,
softwareProductQuestionnaire: {
@@ -104,7 +117,7 @@ describe('Software Product Details: ', function () {
expect(result.finalizedLicenseModelList.length).toBeGreaterThan(0);
expect(finalizedLicenseModelList[0]).toMatchObject({
id: result.currentSoftwareProduct.vendorId,
- vendorName: result.currentSoftwareProduct.vendorName
+ name: result.currentSoftwareProduct.vendorName
});
expect(result.softwareProductCategories).toEqual(softwareProductCategories);
expect(result.licenseAgreementList).toEqual([]);
@@ -112,16 +125,17 @@ describe('Software Product Details: ', function () {
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', () => {
var obj = {
+ currentScreen,
softwareProduct: {
softwareProductEditor: {
data: currentSoftwareProductWithLicensingData,
- genericFieldInfo
+ genericFieldInfo,
+ licensingVersionsList
},
softwareProductCategories,
softwareProductQuestionnaire: {
@@ -147,7 +161,7 @@ describe('Software Product Details: ', function () {
expect(result.finalizedLicenseModelList.length).toBeGreaterThan(0);
expect(result.finalizedLicenseModelList[0]).toMatchObject({
id: result.currentSoftwareProduct.vendorId,
- vendorName: result.currentSoftwareProduct.vendorName
+ name: result.currentSoftwareProduct.vendorName
});
expect(result.softwareProductCategories).toEqual(softwareProductCategories);
expect(result.licenseAgreementList).toEqual(licenseAgreementList);
@@ -156,12 +170,12 @@ describe('Software Product Details: ', function () {
expect(featureGroupsList[0]).toMatchObject({...featureGroupsList[0], id: fg});
});
expect(result.qdata).toEqual(qdata);
- expect(result.isReadOnlyMode).toEqual(true);
});
it('VSP Details view test', () => {
let params = {
+ ...currentScreen.props,
currentSoftwareProduct,
softwareProductCategories,
qdata,
@@ -170,6 +184,7 @@ describe('Software Product Details: ', function () {
finalizedLicenseModelList,
licenseAgreementList,
featureGroupsList,
+ licensingVersionsList,
genericFieldInfo,
qGenericFieldInfo,
};
@@ -185,6 +200,8 @@ describe('Software Product Details: ', function () {
);
let renderedOutput = renderer.getRenderOutput();
expect(renderedOutput).toBeTruthy();
+ expect(renderedOutput.props.children.props.isReadOnlyMode).toBe(false);
+
});
it('in view: should change vendorId and update vsp licensing-version', done => {
@@ -199,11 +216,12 @@ describe('Software Product Details: ', function () {
qGenericFieldInfo,
finalizedLicenseModelList,
licenseAgreementList,
+ licensingVersionsList,
featureGroupsList
};
const onVendorChangedListener = (deltaData) => {
expect(deltaData.vendorId).toEqual(finalizedLicenseModelList[1].id);
- expect(deltaData.vendorName).toEqual(finalizedLicenseModelList[1].vendorName);
+ expect(deltaData.vendorName).toEqual(finalizedLicenseModelList[1].name);
expect(deltaData.licensingVersion).toEqual('');
expect(deltaData.licensingData).toEqual({});
done();
@@ -215,6 +233,7 @@ describe('Software Product Details: ', function () {
qdata = {params.qdata}
qGenericFieldInfo = {params.qGenericFieldInfo}
genericFieldInfo = {params.genericFieldInfo}
+ licensingVersionsList={params.licensingVersionsList}
isFormValid={params.isFormValid}
dataMap={params.dataMap}
finalizedLicenseModelList = {params.finalizedLicenseModelList}
@@ -235,6 +254,7 @@ describe('Software Product Details: ', function () {
softwareProductCategories,
qdata,
dataMap,
+ licensingVersionsList,
isFormValid: true,
genericFieldInfo,
qGenericFieldInfo,
@@ -244,8 +264,8 @@ describe('Software Product Details: ', function () {
};
const onVendorChangedListener = (deltaData) => {
expect(deltaData.vendorId).toEqual(finalizedLicenseModelList[1].id);
- expect(deltaData.vendorName).toEqual(finalizedLicenseModelList[1].vendorName);
- expect(deltaData.licensingVersion).toEqual(finalizedLicenseModelList[1].viewableVersion[0]);
+ expect(deltaData.vendorName).toEqual(finalizedLicenseModelList[1].name);
+ expect(deltaData.licensingVersion).toEqual(licensingVersionsList[1]);
expect(deltaData.licensingData).toEqual({});
done();
};
@@ -258,7 +278,7 @@ describe('Software Product Details: ', function () {
onQDataChanged = {dummyFunc}
onVendorParamChanged = {(deltaData) => onVendorChangedListener(deltaData)}/>);
expect(vspDetailsView).toBeTruthy();
- vspDetailsView.onVendorParamChanged({vendorId: finalizedLicenseModelList[1].id, licensingVersion: finalizedLicenseModelList[1].viewableVersion[0]});
+ vspDetailsView.onVendorParamChanged({vendorId: finalizedLicenseModelList[1].id, licensingVersion: licensingVersionsList[1]});
});
it('in view: should change subcategory', done => {
@@ -270,6 +290,7 @@ describe('Software Product Details: ', function () {
isFormValid: true,
genericFieldInfo,
qGenericFieldInfo,
+ licensingVersionsList,
finalizedLicenseModelList,
licenseAgreementList,
featureGroupsList
@@ -301,6 +322,7 @@ describe('Software Product Details: ', function () {
isFormValid: true,
genericFieldInfo,
qGenericFieldInfo,
+ licensingVersionsList,
finalizedLicenseModelList,
licenseAgreementList,
featureGroupsList
@@ -328,8 +350,8 @@ describe('Software Product Details: ', function () {
]});
});
- it('in view: should change license agreement', done => {
+ it('in view: should change license agreement', done => {
let params = {
currentSoftwareProduct: currentSoftwareProductWithLicensingData,
softwareProductCategories,
@@ -338,6 +360,7 @@ describe('Software Product Details: ', function () {
isFormValid: true,
genericFieldInfo,
qGenericFieldInfo,
+ licensingVersionsList,
finalizedLicenseModelList,
licenseAgreementList,
featureGroupsList
@@ -358,4 +381,5 @@ describe('Software Product Details: ', function () {
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 df84d184ce..27cbaa40ef 100644
--- a/openecomp-ui/test/softwareProduct/details/test.js
+++ b/openecomp-ui/test/softwareProduct/details/test.js
@@ -30,10 +30,11 @@ import {heatSetupManifest} from 'test-utils/factories/softwareProduct/SoftwarePr
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';
+import VersionFactory from 'test-utils/factories/common/VersionFactory.js';
+import {InitializedCurrentScreenFactory} from 'test-utils/factories/common/CurrentScreenFactory.js';
-describe('Software Product Module Tests', function () {
+describe('Software Product Details Module Tests', function () {
it('Get Software Products List', () => {
const store = storeCreator();
deepFreeze(store.getState());
@@ -43,14 +44,14 @@ describe('Software Product Module Tests', function () {
const expectedStore = cloneAndSet(store.getState(), 'softwareProductList', softwareProductList);
mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
- expect(baseUrl).toEqual('/onboarding-api/v1.0/vendor-software-products/');
+ expect(baseUrl).toEqual('/onboarding-api/v1.0/vendor-software-products/?versionFilter=Draft');
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(baseUrl).toEqual('/onboarding-api/v1.0/vendor-software-products/?versionFilter=Certified');
expect(data).toEqual(undefined);
expect(options).toEqual(undefined);
return {results: []};
@@ -130,6 +131,10 @@ describe('Software Product Module Tests', function () {
let manifest = heatSetupManifest.build();
expectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductAttachments.heatSetup', manifest);
+ const expectedCurrentScreen = InitializedCurrentScreenFactory.build();
+ expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreen.itemPermission);
+ expectedStore = cloneAndSet(expectedStore, 'currentScreen.props', expectedCurrentScreen.props);
+
mockRest.addHandler('post', ({options, data, baseUrl}) => {
expect(baseUrl).toEqual('/onboarding-api/v1.0/vendor-software-products/');
expect(data).toEqual(softwareProductPostRequest);
@@ -184,7 +189,7 @@ describe('Software Product Module Tests', function () {
deepFreeze(softwareProductPostRequest);
const licenseModelId = softwareProductPostRequest.vendorId;
- const LMVersion = VersionControllerUtilsFactory.build().version;
+ const LMVersion = VersionFactory.build();
const secondLicenseModelId = 'secondLicenseModelId';
let FG1 = FeatureGroup.build();
@@ -205,13 +210,20 @@ describe('Software Product Module Tests', function () {
});
mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
- expect(baseUrl).toEqual('/onboarding-api/v1.0/vendor-license-models/?versionFilter=Final');
+ expect(baseUrl).toEqual('/onboarding-api/v1.0/vendor-license-models/?versionFilter=Certified');
expect(data).toEqual(undefined);
expect(options).toEqual(undefined);
return {results: []};
});
mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${licenseModelId}/versions/${LMVersion.id}`);
+ 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);
@@ -226,6 +238,13 @@ describe('Software Product Module Tests', function () {
});
mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${secondLicenseModelId}/versions/${LMVersion.id}`);
+ 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/${secondLicenseModelId}/versions/${LMVersion.id}/license-agreements`);
expect(data).toEqual(undefined);
expect(options).toEqual(undefined);
@@ -239,17 +258,18 @@ describe('Software Product Module Tests', function () {
return {results: [FG2]};
});
- return SoftwareProductActionHelper.loadSoftwareProductDetailsData(store.dispatch, {licenseModelId, licensingVersion: LMVersion}).then(() => {
+ return SoftwareProductActionHelper.loadSoftwareProductDetailsData(store.dispatch, {licenseModelId, licensingVersion: LMVersion.id}).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]);
+ {deltaData: {vendorId: secondLicenseModelId, licensingVersion: LMVersion.id},
+ 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]);
+ });
});
});
@@ -258,6 +278,8 @@ describe('Software Product Module Tests', function () {
const softwareProduct = VSPEditorFactoryWithLicensingData.build();
deepFreeze(softwareProduct);
+ const version = VersionFactory.build();
+
const store = storeCreator({
softwareProduct: {
softwareProductEditor: {data: softwareProduct},
@@ -291,13 +313,13 @@ describe('Software Product Module Tests', function () {
deepFreeze(questionnaireData);
mockRest.addHandler('put', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/versions/${softwareProduct.version.id}`);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/versions/${version.id}`);
expect(data).toEqual(softwareProductUpdateData);
expect(options).toEqual(undefined);
return {returnCode: 'OK'};
});
mockRest.addHandler('put', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/versions/${softwareProduct.version.id}/questionnaire`);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/versions/${version.id}/questionnaire`);
expect(data).toEqual(questionnaireData);
expect(options).toEqual(undefined);
return {returnCode: 'OK'};
@@ -305,7 +327,8 @@ describe('Software Product Module Tests', function () {
return SoftwareProductActionHelper.updateSoftwareProduct(store.dispatch, {
softwareProduct: softwareProductPutRequest,
- qdata: questionnaireData
+ qdata: questionnaireData,
+ version
}).then(() => {
expect(store.getState()).toEqual(expectedStore);
});
@@ -316,6 +339,8 @@ describe('Software Product Module Tests', function () {
const softwareProduct = VSPEditorFactoryWithLicensingData.build();
deepFreeze(softwareProduct);
+ const version = VersionFactory.build();
+
const store = storeCreator({
softwareProduct: {
softwareProductEditor: {data: softwareProduct},
@@ -334,19 +359,20 @@ describe('Software Product Module Tests', function () {
let softwareProductUpdateData = VSPEditorPostFactoryWithLicensingData.build(dataForUpdate);
delete softwareProductUpdateData.version;
- const softwareProductPutRequest = buildFromExistingObject(VSPEditorFactoryWithLicensingData, softwareProductUpdateData, {id: toBeUpdatedSoftwareProductId, version: softwareProduct.version});
+ const softwareProductPutRequest = buildFromExistingObject(VSPEditorFactoryWithLicensingData, softwareProductUpdateData, {id: toBeUpdatedSoftwareProductId});
deepFreeze(softwareProductUpdateData);
mockRest.addHandler('put', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/versions/${softwareProduct.version.id}`);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/versions/${version.id}`);
expect(data).toEqual(softwareProductUpdateData);
expect(options).toEqual(undefined);
return {returnCode: 'OK'};
});
return SoftwareProductActionHelper.updateSoftwareProductData(store.dispatch, {
- softwareProduct: softwareProductPutRequest
+ softwareProduct: softwareProductPutRequest,
+ version
}).then(() => {
expect(store.getState()).toEqual(expectedStore);
});
@@ -356,6 +382,8 @@ describe('Software Product Module Tests', function () {
const softwareProduct = VSPEditorFactoryWithLicensingData.build();
deepFreeze(softwareProduct);
+ const version = VersionFactory.build();
+
const store = storeCreator({
softwareProduct: {
softwareProductEditor: {data: softwareProduct},
@@ -377,7 +405,7 @@ describe('Software Product Module Tests', function () {
deepFreeze(questionnaireData);
mockRest.addHandler('put', ({data, options, baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/versions/${softwareProduct.version.id}/questionnaire`);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/versions/${version.id}/questionnaire`);
expect(data).toEqual(questionnaireData);
expect(options).toEqual(undefined);
return {returnCode: 'OK'};
@@ -385,7 +413,7 @@ describe('Software Product Module Tests', function () {
return SoftwareProductActionHelper.updateSoftwareProductQuestionnaire(store.dispatch, {
softwareProductId: softwareProduct.id,
- version: softwareProduct.version,
+ version,
qdata: questionnaireData
}).then(() => {
expect(store.getState()).toEqual(expectedStore);
diff --git a/openecomp-ui/test/softwareProduct/landingPage/landingPage.test.js b/openecomp-ui/test/softwareProduct/landingPage/landingPage.test.js
index 4da0ec98d4..c53919b802 100644
--- a/openecomp-ui/test/softwareProduct/landingPage/landingPage.test.js
+++ b/openecomp-ui/test/softwareProduct/landingPage/landingPage.test.js
@@ -19,6 +19,9 @@
import React from 'react';
import TestUtils from 'react-addons-test-utils';
+import {Provider} from 'react-redux';
+import {storeCreator} from 'sdc-app/AppStore.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';
@@ -27,9 +30,7 @@ import {default as SoftwareProductQSchemaFactory} from 'test-utils/factories/so
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 { Provider } from 'react-redux';
-import {storeCreator} from 'sdc-app/AppStore.js';
+import CurrentScreenFactory from 'test-utils/factories/common/CurrentScreenFactory.js';
import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js';
import SoftwareProductLandingPageView from 'sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx';
@@ -37,28 +38,28 @@ import SoftwareProductLandingPageView from 'sdc-app/onboarding/softwareProduct/l
describe('Software Product Landing Page: ', function () {
- let currentSoftwareProduct = {}, softwareProductCategories = [],
+ let currentSoftwareProduct = {}, softwareProductCategories = [], currentScreen = {},
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});
+ currentSoftwareProduct = VSPEditorFactory.build({id:'RTRTG454545', vendorId: finalizedLicenseModelList[0].id, vendorName: finalizedLicenseModelList[0].name, onBoardingMethod: 'HEAT'});
softwareProductCategories = CategoryWithSubFactory.buildList(2,{},{quantity: 1});
licenseAgreementList = LicenseAgreementStoreFactory.buildList(2);
featureGroupsList = FeatureGroupStoreFactory.buildList(2,{referencingLicenseAgreements:[licenseAgreementList[0].id]});
+ currentScreen = CurrentScreenFactory.build();
qdata = VspQdataFactory.build();
qschema = SoftwareProductQSchemaFactory.build(qdata);
-
});
-
-
it('should mapper exist', () => {
expect(mapStateToProps).toBeTruthy();
});
it('should mapper return vsp basic data', () => {
- const obj = {
+ const state = {
+ currentScreen,
softwareProduct: {
softwareProductEditor: {
data: currentSoftwareProduct
@@ -70,6 +71,9 @@ describe('Software Product Landing Page: ', function () {
},
softwareProductComponents: {
componentsList:[]
+ },
+ softwareProductAttachments: {
+ heatSetup: {}
}
},
finalizedLicenseModelList,
@@ -83,23 +87,25 @@ describe('Software Product Landing Page: ', function () {
}
};
- const result = mapStateToProps(obj);
+ const result = mapStateToProps(state);
expect(result.currentSoftwareProduct).toBeTruthy();
- expect(result.isReadOnlyMode).toEqual(true);
});
it('vsp landing basic view', () => {
const params = {
+ ...currentScreen.props,
currentSoftwareProduct,
- isReadOnlyMode: false,
componentsList: VSPComponentsFactory.buildList(2)
};
const store = storeCreator();
- let vspLandingView = TestUtils.renderIntoDocument(<Provider store={store}><SoftwareProductLandingPageView
- {...params}/></Provider>);
+ let vspLandingView = TestUtils.renderIntoDocument(
+ <Provider store={store}>
+ <SoftwareProductLandingPageView {...params}/>
+ </Provider>
+ );
expect(vspLandingView).toBeTruthy();
});
@@ -107,13 +113,16 @@ describe('Software Product Landing Page: ', function () {
const params = {
currentSoftwareProduct,
- isReadOnlyMode: false,
+ ...currentScreen.props,
componentsList: VSPComponentsFactory.buildList(2)
};
const store = storeCreator();
- let vspLandingView = TestUtils.renderIntoDocument(<Provider store={store}><SoftwareProductLandingPageView
- {...params}/></Provider>);
+ let vspLandingView = TestUtils.renderIntoDocument(
+ <Provider store={store}>
+ <SoftwareProductLandingPageView {...params}/>
+ </Provider>
+ );
let vspLandingViewWrapper = TestUtils.findRenderedComponentWithType(
vspLandingView,
SoftwareProductLandingPageView
@@ -127,8 +136,8 @@ describe('Software Product Landing Page: ', function () {
it('vsp landing handleImportSubmit test ', () => {
const params = {
+ ...currentScreen.props,
currentSoftwareProduct,
- isReadOnlyMode: false,
componentsList: VSPComponentsFactory.buildList(2),
onUploadConfirmation: dummyFunc,
onUpload: dummyFunc,
@@ -144,7 +153,12 @@ describe('Software Product Landing Page: ', function () {
const store = storeCreator();
- let vspLandingView = TestUtils.renderIntoDocument(<Provider store={store}><SoftwareProductLandingPageView {...params}/></Provider>);
+ let vspLandingView = TestUtils.renderIntoDocument(
+ <Provider store={store}>
+ <SoftwareProductLandingPageView {...params}/>
+ </Provider>
+ );
+
let vspLandingViewWrapper = TestUtils.findRenderedComponentWithType(
vspLandingView,
SoftwareProductLandingPageView
@@ -166,7 +180,7 @@ describe('Software Product Landing Page: ', function () {
const params = {
currentSoftwareProduct,
- isReadOnlyMode: false,
+ ...currentScreen.props,
componentsList: VSPComponentsFactory.buildList(2),
onUploadConfirmation: dummyFunc,
onUpload: dummyFunc,
@@ -175,8 +189,11 @@ describe('Software Product Landing Page: ', function () {
const store = storeCreator();
- let vspLandingView = TestUtils.renderIntoDocument(<Provider store={store}><SoftwareProductLandingPageView
- {...params}/></Provider>);
+ let vspLandingView = TestUtils.renderIntoDocument(
+ <Provider store={store}>
+ <SoftwareProductLandingPageView {...params}/>
+ </Provider>
+ );
let vspLandingViewWrapper = TestUtils.findRenderedComponentWithType(
vspLandingView,
diff --git a/openecomp-ui/test/softwareProduct/networks/SoftwareProductNetworksView.test.js b/openecomp-ui/test/softwareProduct/networks/SoftwareProductNetworksView.test.js
index 6ef6bcf02a..b4ea4049a6 100644
--- a/openecomp-ui/test/softwareProduct/networks/SoftwareProductNetworksView.test.js
+++ b/openecomp-ui/test/softwareProduct/networks/SoftwareProductNetworksView.test.js
@@ -57,9 +57,8 @@ describe('SoftwareProductNetworks Mapper and View Classes', () => {
const networksList = VSPNetworkFactory.buildList(2);
const versionControllerData = VSPComponentsVersionControllerFactory.build();
-
var renderer = TestUtils.createRenderer();
- renderer.render(<SoftwareProductNetworksView networksList={networksList} versionControllerData={versionControllerData} currentSoftwareProduct={currentSoftwareProduct}/>);
+ renderer.render(<SoftwareProductNetworksView isReadOnlyMode={true} networksList={networksList} versionControllerData={versionControllerData} currentSoftwareProduct={currentSoftwareProduct}/>);
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 43110d2e55..6ad696ae85 100644
--- a/openecomp-ui/test/softwareProduct/processes/test.js
+++ b/openecomp-ui/test/softwareProduct/processes/test.js
@@ -29,10 +29,10 @@ import {
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';
+import VersionFactory from 'test-utils/factories/common/VersionFactory.js';
const softwareProductId = '123';
-const version = VSPEditorFactory.build().version;
+const version = VersionFactory.build();
describe('Software Product Processes Module Tests', function () {
@@ -317,7 +317,6 @@ describe('Software Product Processes Module Tests', function () {
});
const processId = softwareProductProcessesList[0].id;
- const version = store.getState().softwareProduct.softwareProductEditor.data.version;
const versionId = version.id;
deepFreeze(store.getState());
@@ -343,7 +342,7 @@ describe('Software Product Processes Module Tests', function () {
});
});
- it('Validating Software Products Processes Delete confirmation', done => {
+ it('Validating Software Products Processes Delete confirmation', () => {
const store = storeCreator();
deepFreeze(store.getState());
@@ -352,15 +351,12 @@ describe('Software Product Processes Module Tests', function () {
const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processToDelete', process);
- SoftwareProductProcessesActionHelper.openDeleteProcessesConfirm(store.dispatch, {process});
+ return SoftwareProductProcessesActionHelper.openDeleteProcessesConfirm(store.dispatch, {process});
- setTimeout(function(){
- expect(store.getState()).toEqual(expectedStore);
- done();
- }, 100);
+ expect(store.getState()).toEqual(expectedStore);
});
- it('Validating Software Products Processes Cancel Delete', done => {
+ it('Validating Software Products Processes Cancel Delete', () => {
const store = storeCreator();
deepFreeze(store.getState());
@@ -368,10 +364,7 @@ describe('Software Product Processes Module Tests', function () {
SoftwareProductProcessesActionHelper.hideDeleteConfirm(store.dispatch);
- setTimeout(function(){
- expect(store.getState()).toEqual(expectedStore);
- done();
- }, 100);
+ expect(store.getState()).toEqual(expectedStore);
});
//**
diff --git a/openecomp-ui/test/softwareProduct/test.js b/openecomp-ui/test/softwareProduct/test.js
new file mode 100644
index 0000000000..15f7a21866
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/test.js
@@ -0,0 +1,116 @@
+/*!
+ * 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 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 SoftwareProductActionHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js';
+import {VSPEditorFactoryWithLicensingData} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
+import VersionFactory from 'test-utils/factories/common/VersionFactory.js';
+import {default as CurrentScreenFactory} from 'test-utils/factories/common/CurrentScreenFactory.js';
+import {actionsEnum as VersionControllerActionsEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
+import {SyncStates} from 'sdc-app/common/merge/MergeEditorConstants.js';
+import {itemTypes} from 'sdc-app/onboarding/versionsPage/VersionsPageConstants.js';
+
+describe('Software Product Module Tests', function () {
+ it('Validating readonly screen after submit', () => {
+ const version = VersionFactory.build({}, {isCertified: false});
+ const itemPermissionAndProps = CurrentScreenFactory.build({}, {version});
+ const softwareProduct = VSPEditorFactoryWithLicensingData.build();
+ deepFreeze(softwareProduct);
+
+ const store = storeCreator({
+ currentScreen: {...itemPermissionAndProps},
+ softwareProduct: {
+ softwareProductEditor: {data: softwareProduct},
+ softwareProductQuestionnaire: {qdata: 'test', qschema: {type: 'string'}}
+ }
+ });
+ deepFreeze(store.getState());
+
+ const certifiedVersion = {
+ ...itemPermissionAndProps.props.version,
+ status: 'Certified'
+ };
+
+ const versionsList = {
+ itemType: itemTypes.SOFTWARE_PRODUCT,
+ itemId: softwareProduct.id,
+ versions: [{...certifiedVersion}]
+ };
+ const expectedCurrentScreenProps = {
+ itemPermission: {
+ ...itemPermissionAndProps.itemPermission,
+ isCertified: true
+ },
+ props: {
+ isReadOnlyMode: true,
+ version: certifiedVersion
+ }
+ };
+ const expectedSuccessModal = {
+ cancelButtonText: 'OK',
+ modalClassName: 'notification-modal',
+ msg: 'This software product successfully submitted',
+ timeout: 2000,
+ title: 'Submit Succeeded',
+ type: 'success'
+ };
+
+ let expectedStore = store.getState();
+ expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreenProps.itemPermission);
+ expectedStore = cloneAndSet(expectedStore, 'currentScreen.props', expectedCurrentScreenProps.props);
+ expectedStore = cloneAndSet(expectedStore, 'modal', expectedSuccessModal);
+ expectedStore = cloneAndSet(expectedStore, 'versionsPage.versionsList', versionsList );
+
+ mockRest.addHandler('put', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProduct.id}/versions/${version.id}/actions`);
+ expect(data).toEqual({action: VersionControllerActionsEnum.SUBMIT});
+ expect(options).toEqual(undefined);
+ return {returnCode: 'OK'};
+ });
+
+ mockRest.addHandler('put', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProduct.id}/versions/${version.id}/actions`);
+ expect(data).toEqual({action: VersionControllerActionsEnum.CREATE_PACKAGE});
+ expect(options).toEqual(undefined);
+ return {returnCode: 'OK'};
+ });
+
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${softwareProduct.id}/versions/${version.id}`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {...certifiedVersion, state: {synchronizationState: SyncStates.UP_TO_DATE, dirty: false}};
+ });
+
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${softwareProduct.id}/versions`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: [{...certifiedVersion}]};
+ });
+
+ return SoftwareProductActionHelper.performSubmitAction(store.dispatch, {
+ softwareProductId: softwareProduct.id,
+ version
+ }).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+}); \ No newline at end of file