summaryrefslogtreecommitdiffstats
path: root/openecomp-ui/test
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-ui/test')
-rw-r--r--openecomp-ui/test/flows/FlowsListEditor.test.js255
-rw-r--r--openecomp-ui/test/flows/flowsEditorModal.test.js50
-rw-r--r--openecomp-ui/test/flows/test.js442
-rw-r--r--openecomp-ui/test/licenseModel/creation/LicenseModelCreation.test.js75
-rw-r--r--openecomp-ui/test/licenseModel/entitlementPools/test.js177
-rw-r--r--openecomp-ui/test/licenseModel/featureGroups/LicenseModelFeatureGroupEditor.test.js74
-rw-r--r--openecomp-ui/test/licenseModel/featureGroups/LicenseModelFeatureGroupListEditor.test.js90
-rw-r--r--openecomp-ui/test/licenseModel/featureGroups/test.js212
-rw-r--r--openecomp-ui/test/licenseModel/licenseAgreement/test.js172
-rw-r--r--openecomp-ui/test/licenseModel/licenseKeyGroups/test.js169
-rw-r--r--openecomp-ui/test/licenseModel/overview/listItems/EntitlementPool.test.js31
-rw-r--r--openecomp-ui/test/licenseModel/overview/listItems/FeatureGroup.test.js58
-rw-r--r--openecomp-ui/test/licenseModel/overview/listItems/LicenseAgreement.test.js54
-rw-r--r--openecomp-ui/test/licenseModel/overview/listItems/LicenseKeyGroup.test.js31
-rw-r--r--openecomp-ui/test/licenseModel/overview/summary/SummaryCountList.test.js87
-rw-r--r--openecomp-ui/test/licenseModel/overview/summary/VendorDataView.test.js48
-rw-r--r--openecomp-ui/test/licenseModel/overview/test.js355
-rw-r--r--openecomp-ui/test/licenseModel/overview/views.test.js159
-rw-r--r--openecomp-ui/test/licenseModel/test.js55
-rw-r--r--openecomp-ui/test/nfvo-components/SubmitErrorResponse.test.js33
-rw-r--r--openecomp-ui/test/nfvo-components/__snapshots__/storyshots.test.js.snap686
-rw-r--r--openecomp-ui/test/nfvo-components/activity-log/ActivityLog.test.js89
-rw-r--r--openecomp-ui/test/nfvo-components/editor/TabulatedEditor.test.js52
-rw-r--r--openecomp-ui/test/nfvo-components/input/dualListBox/dualListbox.test.js85
-rw-r--r--openecomp-ui/test/nfvo-components/input/validation/input.test.js141
-rw-r--r--openecomp-ui/test/nfvo-components/listEditor/listEditor.test.js60
-rw-r--r--openecomp-ui/test/nfvo-components/modal/globalModal.test.js92
-rw-r--r--openecomp-ui/test/nfvo-components/notifications/notificationsModal.test.js144
-rw-r--r--openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js145
-rw-r--r--openecomp-ui/test/nfvo-components/panel/VersionController/versionControllerUtils.test.js132
-rw-r--r--openecomp-ui/test/nfvo-components/storyshots.test.js2
-rw-r--r--openecomp-ui/test/onboard/onboardingCatalog/test.js63
-rw-r--r--openecomp-ui/test/onboard/onboardingCatalog/views.test.js143
-rw-r--r--openecomp-ui/test/onboard/test.js62
-rw-r--r--openecomp-ui/test/setup.test.js25
-rw-r--r--openecomp-ui/test/softwareProduct/attachments/SoftwareProductAttachmentsView.test.js214
-rw-r--r--openecomp-ui/test/softwareProduct/attachments/setup/heatSetup.test.js49
-rw-r--r--openecomp-ui/test/softwareProduct/attachments/setup/heatSetupActionHelper.test.js142
-rw-r--r--openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationActionHelper.test.js (renamed from openecomp-ui/test/softwareProduct/attachments/SoftwareproductAttachmentsHelper.test.js)53
-rw-r--r--openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationView.test.js184
-rw-r--r--openecomp-ui/test/softwareProduct/components/compute/test.js85
-rw-r--r--openecomp-ui/test/softwareProduct/components/general/SoftwareProductComponentsGeneral.test.js90
-rw-r--r--openecomp-ui/test/softwareProduct/components/loadBalancing/softwareProductComponentLoadbalancing.test.js87
-rw-r--r--openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js53
-rw-r--r--openecomp-ui/test/softwareProduct/components/monitoring/test.js73
-rw-r--r--openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js83
-rw-r--r--openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetwork.test.js91
-rw-r--r--openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js233
-rw-r--r--openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesEditor.test.js57
-rw-r--r--openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesView.test.js77
-rw-r--r--openecomp-ui/test/softwareProduct/components/processes/test.js191
-rw-r--r--openecomp-ui/test/softwareProduct/components/storage/test.js85
-rw-r--r--openecomp-ui/test/softwareProduct/components/test.js65
-rw-r--r--openecomp-ui/test/softwareProduct/creation/SoftwareProductCreation.test.js105
-rw-r--r--openecomp-ui/test/softwareProduct/dependencies/SoftwareProductDependencies.test.js210
-rw-r--r--openecomp-ui/test/softwareProduct/details/detailsView.test.js415
-rw-r--r--openecomp-ui/test/softwareProduct/details/test.js494
-rw-r--r--openecomp-ui/test/softwareProduct/details/vspQschema.js20
-rw-r--r--openecomp-ui/test/softwareProduct/landingPage/landingPage.test.js177
-rw-r--r--openecomp-ui/test/softwareProduct/networks/SoftwareProductNetworksView.test.js94
-rw-r--r--openecomp-ui/test/softwareProduct/networks/softwareProductNetworksActionHelper.test.js49
-rw-r--r--openecomp-ui/test/softwareProduct/processes/SoftwareProductEditor.test.js62
-rw-r--r--openecomp-ui/test/softwareProduct/processes/SoftwareProductProcessesView.test.js75
-rw-r--r--openecomp-ui/test/softwareProduct/processes/test.js338
-rw-r--r--openecomp-ui/test/utils/errorResponseHandler.test.js76
-rw-r--r--openecomp-ui/test/utils/restApiUtil.test.js149
-rw-r--r--openecomp-ui/test/utils/uuid.test.js33
-rw-r--r--openecomp-ui/test/utils/validator.test.js69
68 files changed, 5518 insertions, 3308 deletions
diff --git a/openecomp-ui/test/flows/FlowsListEditor.test.js b/openecomp-ui/test/flows/FlowsListEditor.test.js
index 534253567e..007b137ab0 100644
--- a/openecomp-ui/test/flows/FlowsListEditor.test.js
+++ b/openecomp-ui/test/flows/FlowsListEditor.test.js
@@ -1,33 +1,30 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-import expect from 'expect';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import {mapStateToProps} from 'sdc-app/flows/FlowsListEditor.js';
import FlowsListEditorView from 'sdc-app/flows/FlowsListEditorView.jsx';
+import {FlowUpdateRequestFactory, FlowBasicFactory} from 'test-utils/factories/flows/FlowsFactories.js';
+
describe('Flows List Editor Mapper and View Classes: ', function () {
it('mapStateToProps mapper exists', () => {
- expect(mapStateToProps).toExist();
+ expect(mapStateToProps).toBeTruthy();
});
it('mapStateToProps mapper - without flowList', () => {
@@ -37,242 +34,106 @@ describe('Flows List Editor Mapper and View Classes: ', function () {
shouldShowWorkflowsEditor: undefined
};
let results = mapStateToProps({flows});
- expect(results.flowList).toExist();
+ expect(results.flowList).toBeTruthy();
expect(results.flowList.length).toEqual(0);
expect(results.shouldShowWorkflowsEditor).toBe(true);
});
it('mapStateToProps mapper - populated flowList', () => {
- let artifactName = 'test1', description = 'desc';
let flows = {
- flowList: [{artifactName, description}],
+ flowList: FlowBasicFactory.buildList(1),
isDisplayModal: true,
isModalInEditMode: false,
shouldShowWorkflowsEditor: false
};
let results = mapStateToProps({flows});
- expect(results.flowList).toExist();
+ expect(results.flowList).toBeTruthy();
expect(results.flowList.length).toEqual(1);
expect(results.shouldShowWorkflowsEditor).toBe(false);
});
it('mapStateToProps mapper - populated flowList and currentFlow is in readonly', () => {
- let artifactName = 'test1', description = 'desc';
- let currentFlow = {artifactName, description, readonly: true};
+ let currentFlow = FlowBasicFactory.build();
+ currentFlow.readonly = true;
let flows = {
flowList: [currentFlow],
- currentFlow,
+ data: currentFlow,
isDisplayModal: true,
isModalInEditMode: false,
shouldShowWorkflowsEditor: false
};
let results = mapStateToProps({flows});
- expect(results.currentFlow).toExist();
+ expect(results.currentFlow).toBeTruthy();
expect(results.isCheckedOut).toEqual(false);
});
it('mapStateToProps mapper - populated flowList and currentFlow is in not readonly', () => {
- let artifactName = 'test1', description = 'desc';
- let currentFlow = {artifactName, description, readonly: false};
+ let currentFlow = FlowBasicFactory.build();
+ currentFlow.readonly = false;
let flows = {
flowList: [currentFlow],
- currentFlow,
+ data: currentFlow,
isDisplayModal: true,
isModalInEditMode: false,
shouldShowWorkflowsEditor: false
};
let results = mapStateToProps({flows});
- expect(results.currentFlow).toExist();
+ expect(results.currentFlow).toBeTruthy();
+ expect(results.isCheckedOut).toEqual(true);
+ });
+
+ it('mapStateToProps mapper - populated flowList and service is in readonly', () => {
+ let currentFlow = FlowBasicFactory.build();
+ let flows = {
+ flowList: [currentFlow],
+ data: currentFlow,
+ isDisplayModal: true,
+ isModalInEditMode: false,
+ shouldShowWorkflowsEditor: false,
+ readonly: true
+ };
+ let results = mapStateToProps({flows});
+ expect(results.currentFlow).toBeTruthy();
+ expect(results.isCheckedOut).toEqual(false);
+ });
+
+ it('mapStateToProps mapper - populated flowList and service is in not readonly', () => {
+ let currentFlow = FlowBasicFactory.build();
+ let flows = {
+ flowList: [currentFlow],
+ data: currentFlow,
+ isDisplayModal: true,
+ isModalInEditMode: false,
+ shouldShowWorkflowsEditor: false,
+ readonly: false
+ };
+ let results = mapStateToProps({flows});
+ expect(results.currentFlow).toBeTruthy();
expect(results.isCheckedOut).toEqual(true);
});
it('basic view component run with empty flowList and should show the list', () => {
let renderer = TestUtils.createRenderer();
- let artifactName = 'test1', description = 'desc';
- let currentFlow = {artifactName, description, readonly: false};
+ let currentFlow = FlowBasicFactory.build();
renderer.render(<FlowsListEditorView shouldShowWorkflowsEditor={true} flowList={[currentFlow]}/>);
let renderedOutput = renderer.getRenderOutput();
- expect(renderedOutput).toExist();
+ expect(renderedOutput).toBeTruthy();
});
it('basic view component run with empty flowList and should show the diagram', () => {
- const flow = {
- 'artifactType': 'WORKFLOW',
- 'participants': [
- {
- 'id': '1',
- 'name': 'Customer'
- },
- {
- 'id': '2',
- 'name': 'CCD'
- },
- {
- 'id': '3',
- 'name': 'Infrastructure'
- },
- {
- 'id': '4',
- 'name': 'MSO'
- },
- {
- 'id': '5',
- 'name': 'SDN-C'
- },
- {
- 'id': '6',
- 'name': 'A&AI'
- },
- {
- 'id': '7',
- 'name': 'APP-C'
- },
- {
- 'id': '8',
- 'name': 'Cloud'
- },
- {
- 'id': '9',
- 'name': 'DCAE'
- },
- {
- 'id': '10',
- 'name': 'ALTS'
- },
- {
- 'id': '11',
- 'name': 'VF'
- }
- ],
- 'serviceID': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b',
- 'artifactDisplayName': 'zizizi',
- 'artifactGroupType': 'INFORMATIONAL',
- 'uniqueId': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
- 'artifactName': 'zizizi',
- 'artifactLabel': 'zizizi',
- 'artifactUUID': '0295a7cc-8c02-4105-9d7e-c30ce67ecd07',
- 'artifactVersion': '1',
- 'creationDate': 1470144601623,
- 'lastUpdateDate': 1470144601623,
- 'description': 'aslkjdfl asfdasdf',
- 'mandatory': false,
- 'timeout': 0,
- 'esId': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
- 'artifactChecksum': 'NjBmYjc4NGM5MWIwNmNkMDhmMThhMDAwYmQxYjBiZTU=',
- 'heatParameters': [],
- 'sequenceDiagramModel': {
- 'diagram': {
- 'metadata': {
- 'id': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
- 'name': 'zizizi',
- 'ref': 'BLANK'
- },
- 'lifelines': [
- {
- 'id': '1',
- 'name': 'Customer',
- 'index': 1,
- 'x': 175
- },
- {
- 'id': '2',
- 'name': 'CCD',
- 'index': 2,
- 'x': 575
- },
- {
- 'id': '3',
- 'name': 'Infrastructure',
- 'index': 3,
- 'x': 975
- },
- {
- 'id': '4',
- 'name': 'MSO',
- 'index': 4,
- 'x': 1375
- },
- {
- 'id': '5',
- 'name': 'SDN-C',
- 'index': 5,
- 'x': 1775
- },
- {
- 'id': '6',
- 'name': 'A&AI',
- 'index': 6,
- 'x': 2175
- },
- {
- 'id': '7',
- 'name': 'APP-C',
- 'index': 7,
- 'x': 2575
- },
- {
- 'id': '8',
- 'name': 'Cloud',
- 'index': 8,
- 'x': 2975
- },
- {
- 'id': '9',
- 'name': 'DCAE',
- 'index': 9,
- 'x': 3375
- },
- {
- 'id': '10',
- 'name': 'ALTS',
- 'index': 10,
- 'x': 3775
- },
- {
- 'id': '11',
- 'name': 'VF',
- 'index': 11,
- 'x': 4175
- }
- ],
- 'steps': [
- {
- 'message': {
- 'id': '9377-5036-c011-cb95-3a8b-82c6-bbb5-bc84',
- 'name': '[Unnamed Message]',
- 'type': 'request',
- 'from': '1',
- 'to': '2',
- 'index': 1
- }
- },
- {
- 'message': {
- 'id': '64c4-4fd1-b1da-4355-a060-6e48-ee47-c85c',
- 'name': '[Unnamed Message]',
- 'type': 'request',
- 'from': '1',
- 'to': '2',
- 'index': 2
- }
- }
- ]
- }
- }
- };
+ const flow = FlowUpdateRequestFactory.build();
let renderer = TestUtils.createRenderer();
renderer.render(<FlowsListEditorView currentFlow={flow} shouldShowWorkflowsEditor={false} flowList={[flow]}/>);
let renderedOutput = renderer.getRenderOutput();
- expect(renderedOutput).toExist();
+ expect(renderedOutput).toBeTruthy();
});
it('basic view component run with empty flowList and should show popup modal', () => {
let renderer = TestUtils.createRenderer();
- let artifactName = 'test1', description = 'desc';
- let currentFlow = {artifactName, description, readonly: false};
+ let currentFlow = FlowBasicFactory.build();
renderer.render(<FlowsListEditorView isDisplayModal={true} shouldShowWorkflowsEditor={true} flowList={[currentFlow]}/>);
let renderedOutput = renderer.getRenderOutput();
- expect(renderedOutput).toExist();
+ expect(renderedOutput).toBeTruthy();
});
diff --git a/openecomp-ui/test/flows/flowsEditorModal.test.js b/openecomp-ui/test/flows/flowsEditorModal.test.js
index d8da97af4e..8371432032 100644
--- a/openecomp-ui/test/flows/flowsEditorModal.test.js
+++ b/openecomp-ui/test/flows/flowsEditorModal.test.js
@@ -1,33 +1,30 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-import expect from 'expect';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import {mapStateToProps} from 'sdc-app/flows/FlowsEditorModal.js';
import FlowsEditorModalView from 'sdc-app/flows/FlowsEditorModalView.jsx';
+import {FlowBasicFactory} from 'test-utils/factories/flows/FlowsFactories.js';
+
describe('Flows Editor Modal Mapper and View Classes: ', function () {
it('mapStateToProps mapper exists', () => {
- expect(mapStateToProps).toExist();
+ expect(mapStateToProps).toBeTruthy();
});
it('mapStateToProps mapper - without currentFlow', () => {
@@ -36,22 +33,22 @@ describe('Flows Editor Modal Mapper and View Classes: ', function () {
diagramType: 'SOME_TYPE'
};
var results = mapStateToProps({flows});
- expect(results.currentFlow).toExist();
+ expect(results.currentFlow).toBeTruthy();
expect(results.currentFlow.artifactName).toBe('');
expect(results.currentFlow.description).toBe('');
});
it('mapStateToProps mapper - populated currentFlow', () => {
- let artifactName = 'test1', description = 'desc';
+ const currentFlow = FlowBasicFactory.build({artifactType: 'WORKFLOW'});
var flows = {
- currentFlow: {artifactName, description},
+ data: currentFlow,
serviceID: '123',
- diagramType: 'SOME_TYPE'
+ diagramType: 'WORKFLOW'
};
var results = mapStateToProps({flows});
- expect(results.currentFlow).toExist();
- expect(results.currentFlow.artifactName).toBe(artifactName);
- expect(results.currentFlow.description).toBe(description);
+ expect(results.currentFlow).toBeTruthy();
+ expect(results.currentFlow.artifactName).toBe(currentFlow.artifactName);
+ expect(results.currentFlow.description).toBe(currentFlow.description);
expect(results.currentFlow.serviceID).toBe(flows.serviceID);
expect(results.currentFlow.artifactType).toBe(flows.diagramType);
});
@@ -62,9 +59,9 @@ describe('Flows Editor Modal Mapper and View Classes: ', function () {
<FlowsEditorModalView
onCancel={()=>{}}
onDataChanged={()=>{}}
- currentFlow={{artifactName: '', description: ''}}/>);
+ currentFlow={FlowBasicFactory.build({artifactName: '', description: ''})}/>);
let renderedOutput = renderer.getRenderOutput();
- expect(renderedOutput).toExist();
+ expect(renderedOutput).toBeTruthy();
});
it('modal view component run with data changed handler', done => {
@@ -73,10 +70,11 @@ describe('Flows Editor Modal Mapper and View Classes: ', function () {
<FlowsEditorModalView
onCancel={()=>{}}
onDataChanged={handler}
- currentFlow={{artifactName: '', description: ''}}/>);
+ currentFlow={FlowBasicFactory.build({artifactName: '', description: ''})}
+ genericFieldInfo={{artifactName : {isValid: true, errorText: ''}, description: {isValid: true, errorText: ''}}} />);
let result = TestUtils.scryRenderedDOMComponentsWithTag(document, 'input');
- expect(result).toExist();
- expect(result.length).toExist();
+ expect(result).toBeTruthy();
+ expect(result.length).toBeTruthy();
TestUtils.Simulate.change(result[0]);
});
diff --git a/openecomp-ui/test/flows/test.js b/openecomp-ui/test/flows/test.js
index 4c5ab78640..6e02e54816 100644
--- a/openecomp-ui/test/flows/test.js
+++ b/openecomp-ui/test/flows/test.js
@@ -1,30 +1,36 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-import expect from 'expect';
import deepFreeze from 'deep-freeze';
import mockRest from 'test-utils/MockRest.js';
import store from 'sdc-app/AppStore.js';
import FlowsActions from 'sdc-app/flows/FlowsActions.js';
import {enums} from 'sdc-app/flows/FlowsConstants.js';
+import {
+ FlowCreateFactory,
+ FlowPostRequestFactory,
+ FlowPostResponseFactory,
+ FlowFetchRequestFactory,
+ FlowFetchResponseFactory,
+ FlowDeleteRequestFactory,
+ FlowUpdateRequestFactory } from 'test-utils/factories/flows/FlowsFactories.js';
+
+import {buildFromExistingObject} from 'test-utils/Util.js';
+
const NEW_FLOW = true;
let assertFlowDataAfterCreateFetchAndUpdate = (data) => {
@@ -33,13 +39,13 @@ let assertFlowDataAfterCreateFetchAndUpdate = (data) => {
expect(diagramType).toBe(data.artifactType);
let uniqueId = data.uniqueId || `${data.serviceID}.${data.artifactName}`;
let index = flowList.findIndex(flow => flow.uniqueId === uniqueId);
- expect(index).toNotBe(-1);
+ expect(index).not.toBe(-1);
};
describe('Workflows and Management Flows Module Tests:', function () {
- it('empty artifact should open flow creation modal', done => {
+ it('empty artifact should open flow creation modal', () => {
const artifacts = {};
@@ -51,96 +57,30 @@ describe('Workflows and Management Flows Module Tests:', function () {
participants: [],
serviceID: '1234'
});
- setTimeout(() => {
- let state = store.getState();
- expect(state.flows.isDisplayModal).toBe(true);
- expect(state.flows.isModalInEditMode).toBe(false);
- done();
- }, 50);
+ let state = store.getState();
+ expect(state.flows.isDisplayModal).toBe(true);
+ expect(state.flows.isModalInEditMode).toBe(false);
});
- it('Close flow details editor modal', done => {
+ it('Close flow details editor modal', () => {
deepFreeze(store.getState());
FlowsActions.closeFlowDetailsEditor(store.dispatch);
- setTimeout(() => {
- let state = store.getState();
- expect(state.flows.isDisplayModal).toBe(false);
- expect(state.flows.isModalInEditMode).toBe(false);
- done();
- }, 50);
+ let state = store.getState();
+ expect(state.flows.isDisplayModal).toBe(false);
+ expect(state.flows.isModalInEditMode).toBe(false);
});
- it('Get Flows List from loaded artifact', done => {
+ it('Get Flows List from loaded artifact', () => {
deepFreeze(store.getState());
const artifacts = {
- 'test1': {
- 'uniqueId': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.test1',
- 'artifactType': 'NETWORK_CALL_FLOW',
- 'artifactName': 'test1',
- 'artifactChecksum': 'MzYxZGIyNjlkNjRmMTM4ZWMxM2FjNDUyNDQwMTI3NzM=',
- 'attUidLastUpdater': 'cs0008',
- 'updaterFullName': 'Carlos Santana',
- 'creationDate': 1468164899724,
- 'lastUpdateDate': 1468164899724,
- 'esId': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.test1',
- 'artifactLabel': 'test1',
- 'artifactCreator': 'cs0008',
- 'description': 'www',
- 'mandatory': false,
- 'artifactDisplayName': 'test1',
- 'serviceApi': false,
- 'artifactGroupType': 'INFORMATIONAL',
- 'timeout': 0,
- 'artifactVersion': '1',
- 'artifactUUID': '28d4cb95-bb46-4666-b858-e333671e6444',
- 'payloadUpdateDate': 1468164900232
- },
- 'kukuriku': {
- 'uniqueId': '0280b577-2c7b-426e-b7a2-f0dc16508c37.kukuriku',
+ 'test1': FlowPostResponseFactory.build({artifactName: 'test1'}),
+ 'kukuriku': FlowPostResponseFactory.build({
'artifactType': 'PUPPET',
- 'artifactName': 'fuel.JPG',
- 'artifactChecksum': 'OWEyYTVjMWFiNWQ4ZDIwZDUxYTE3Y2EzZmI3YTYyMjA=',
- 'attUidLastUpdater': 'cs0008',
- 'updaterFullName': 'Carlos Santana',
- 'creationDate': 1467877631512,
- 'lastUpdateDate': 1467877631512,
- 'esId': '0280b577-2c7b-426e-b7a2-f0dc16508c37.kukuriku',
- 'artifactLabel': 'kukuriku',
- 'artifactCreator': 'cs0008',
- 'description': 'asdfasdf',
- 'mandatory': false,
- 'artifactDisplayName': 'kukuriku',
- 'serviceApi': false,
- 'artifactGroupType': 'INFORMATIONAL',
- 'timeout': 0,
- 'artifactVersion': '1',
- 'artifactUUID': 'c1e98336-03f4-4b2a-b6a5-08eca44fe3c4',
- 'payloadUpdateDate': 1467877632722
- },
- 'test3': {
- 'uniqueId': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.test3',
- 'artifactType': 'NETWORK_CALL_FLOW',
- 'artifactName': 'test3',
- 'artifactChecksum': 'ZmJkZGU1M2M2ZWUxZTdmNGU5NTNiNTdiYTAzMmM1YzU=',
- 'attUidLastUpdater': 'cs0008',
- 'updaterFullName': 'Carlos Santana',
- 'creationDate': 1468165068570,
- 'lastUpdateDate': 1468165128827,
- 'esId': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.test3',
- 'artifactLabel': 'test3',
- 'artifactCreator': 'cs0008',
- 'description': '333',
- 'mandatory': false,
- 'artifactDisplayName': 'test3',
- 'serviceApi': false,
- 'artifactGroupType': 'INFORMATIONAL',
- 'timeout': 0,
- 'artifactVersion': '2',
- 'artifactUUID': '0988027c-d19c-43db-8315-2c68fc773775',
- 'payloadUpdateDate': 1468165129335
- }
+ 'artifactName': 'kukuriku',
+ }),
+ 'test3': FlowPostResponseFactory.build({artifactName: 'test3'})
};
const artifactsArray = Object.keys(artifacts).map(artifact => artifact);
@@ -157,41 +97,25 @@ describe('Workflows and Management Flows Module Tests:', function () {
};
FlowsActions.fetchFlowArtifacts(store.dispatch, actionData);
- setTimeout(() => {
- let state = store.getState();
- expect(state.flows.isDisplayModal).toBe(false);
- expect(state.flows.isModalInEditMode).toBe(false);
- expect(state.flows.flowList.length).toEqual(artifactsArray.length);
- expect(state.flows.flowParticipants).toEqual(actionData.participants);
- expect(state.flows.serviceID).toBe(actionData.serviceID);
- expect(state.flows.diagramType).toBe(actionData.diagramType);
- done();
- }, 50);
+ let state = store.getState();
+ expect(state.flows.isDisplayModal).toBe(false);
+ expect(state.flows.isModalInEditMode).toBe(false);
+ expect(state.flows.flowList.length).toEqual(artifactsArray.length);
+ expect(state.flows.flowParticipants).toEqual(actionData.participants);
+ expect(state.flows.serviceID).toBe(actionData.serviceID);
+ expect(state.flows.diagramType).toBe(actionData.diagramType);
});
- it('Add New Flow', done => {
+ it('Add New Flow', () => {
deepFreeze(store.getState());
- const flowCreateData = deepFreeze({
- artifactName: 'zizizi',
- artifactType: 'WORKFLOW',
- description: 'aslkjdfl asfdasdf',
- serviceID: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b',
- });
-
+ const flowCreateData = FlowCreateFactory.build();
+ let expectedDataToBeSentInTheRequest = buildFromExistingObject(FlowPostRequestFactory, flowCreateData);
- let expectedDataToBeSentInTheRequest = {
- artifactGroupType: 'INFORMATIONAL',
- artifactLabel: 'zizizi',
- artifactName: 'zizizi',
- artifactType: 'WORKFLOW',
- description: 'aslkjdfl asfdasdf',
- payloadData: 'eyJWRVJTSU9OIjp7Im1ham9yIjoxLCJtaW5vciI6MH0sImRlc2NyaXB0aW9uIjoiYXNsa2pkZmwgYXNmZGFzZGYifQ=='
- };
- mockRest.addHandler('create', ({data, baseUrl, options}) => {
+ mockRest.addHandler('post', ({data, baseUrl, options}) => {
expect(baseUrl).toBe(`/sdc1/feProxy/rest/v1/catalog/services/${flowCreateData.serviceID}/artifacts/`);
expect(data.artifactLabel).toBe(expectedDataToBeSentInTheRequest.artifactLabel);
expect(data.artifactName).toBe(expectedDataToBeSentInTheRequest.artifactName);
@@ -199,299 +123,65 @@ describe('Workflows and Management Flows Module Tests:', function () {
expect(data.description).toBe(expectedDataToBeSentInTheRequest.description);
expect(data.payloadData).toBe(expectedDataToBeSentInTheRequest.payloadData);
expect(options.md5).toBe(true);
- return {
- artifactChecksum: 'NjBmYjc4NGM5MWIwNmNkMDhmMThhMDAwYmQxYjBiZTU=',
- artifactCreator: 'cs0008',
- artifactDisplayName: 'zizizi',
- artifactGroupType: 'INFORMATIONAL',
- artifactLabel: 'zizizi',
- artifactName: 'zizizi',
- artifactType: 'WORKFLOW',
- artifactUUID: '0295a7cc-8c02-4105-9d7e-c30ce67ecd07',
- artifactVersion: '1',
- attUidLastUpdater: 'cs0008',
- creationDate: 1470144601623,
- description: 'aslkjdfl asfdasdf',
- esId: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
- lastUpdateDate: 1470144601623,
- mandatory: false,
- payloadUpdateDate: 1470144602131,
- serviceApi: false,
- timeout: 0,
- uniqueId: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
- updaterFullName: 'Carlos Santana',
- };
+ return buildFromExistingObject(FlowPostResponseFactory, expectedDataToBeSentInTheRequest);
});
- FlowsActions.createOrUpdateFlow(store.dispatch, {flow: flowCreateData}, NEW_FLOW);
-
- setTimeout(() => {
+ return FlowsActions.createOrUpdateFlow(store.dispatch, {flow: flowCreateData}, NEW_FLOW).then(() => {
assertFlowDataAfterCreateFetchAndUpdate(flowCreateData);
- done();
- }, 50);
+ });
+
+
});
- it('Fetch Flow', done => {
+ it('Fetch Flow', () => {
deepFreeze(store.getState());
- const flowFetchData = {
- artifactName: 'zizizi',
- artifactType: 'WORKFLOW',
- description: 'aslkjdfl asfdasdf',
- serviceID: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b',
- uniqueId: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
- participants: []
- };
+ const flowFetchData = FlowFetchRequestFactory.build();
mockRest.addHandler('fetch', ({baseUrl}) => {
//sdc1/feProxy/rest/v1/catalog/services/338d75f0-aec8-4eb4-89c9-8733fcd9bf3b/artifacts/338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi
expect(baseUrl).toBe(`/sdc1/feProxy/rest/v1/catalog/services/${flowFetchData.serviceID}/artifacts/${flowFetchData.uniqueId}`);
- return {
- artifactName: 'zizizi',
- base64Contents: 'eyJWRVJTSU9OIjp7Im1ham9yIjoxLCJtaW5vciI6MH0sImRlc2NyaXB0aW9uIjoiYXNsa2pkZmwgYXNmZGFzZGYifQ=='
- };
+ return buildFromExistingObject(FlowFetchResponseFactory, flowFetchData);
});
- FlowsActions.fetchArtifact(store.dispatch, {flow: flowFetchData});
-
- setTimeout(() => {
+ return FlowsActions.fetchArtifact(store.dispatch, {flow: flowFetchData}).then(() => {
assertFlowDataAfterCreateFetchAndUpdate(flowFetchData);
- done();
- }, 50);
+ });
});
- it('Update Existing Flow', done => {
+ it('Update Existing Flow', () => {
deepFreeze(store.getState());
+ const flowUpdateData = FlowUpdateRequestFactory.build();
- const flowUpdateData = {
- 'artifactType': 'WORKFLOW',
- 'participants': [
- {
- 'id': '1',
- 'name': 'Customer'
- },
- {
- 'id': '2',
- 'name': 'CCD'
- },
- {
- 'id': '3',
- 'name': 'Infrastructure'
- },
- {
- 'id': '4',
- 'name': 'MSO'
- },
- {
- 'id': '5',
- 'name': 'SDN-C'
- },
- {
- 'id': '6',
- 'name': 'A&AI'
- },
- {
- 'id': '7',
- 'name': 'APP-C'
- },
- {
- 'id': '8',
- 'name': 'Cloud'
- },
- {
- 'id': '9',
- 'name': 'DCAE'
- },
- {
- 'id': '10',
- 'name': 'ALTS'
- },
- {
- 'id': '11',
- 'name': 'VF'
- }
- ],
- 'serviceID': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b',
- 'artifactDisplayName': 'zizizi',
- 'artifactGroupType': 'INFORMATIONAL',
- 'uniqueId': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
- 'artifactName': 'zizizi',
- 'artifactLabel': 'zizizi',
- 'artifactUUID': '0295a7cc-8c02-4105-9d7e-c30ce67ecd07',
- 'artifactVersion': '1',
- 'creationDate': 1470144601623,
- 'lastUpdateDate': 1470144601623,
- 'description': 'aslkjdfl asfdasdf',
- 'mandatory': false,
- 'timeout': 0,
- 'esId': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
- 'artifactChecksum': 'NjBmYjc4NGM5MWIwNmNkMDhmMThhMDAwYmQxYjBiZTU=',
- 'heatParameters': [],
- 'sequenceDiagramModel': {
- 'diagram': {
- 'metadata': {
- 'id': '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
- 'name': 'zizizi',
- 'ref': 'BLANK'
- },
- 'lifelines': [
- {
- 'id': '1',
- 'name': 'Customer',
- 'index': 1,
- 'x': 175
- },
- {
- 'id': '2',
- 'name': 'CCD',
- 'index': 2,
- 'x': 575
- },
- {
- 'id': '3',
- 'name': 'Infrastructure',
- 'index': 3,
- 'x': 975
- },
- {
- 'id': '4',
- 'name': 'MSO',
- 'index': 4,
- 'x': 1375
- },
- {
- 'id': '5',
- 'name': 'SDN-C',
- 'index': 5,
- 'x': 1775
- },
- {
- 'id': '6',
- 'name': 'A&AI',
- 'index': 6,
- 'x': 2175
- },
- {
- 'id': '7',
- 'name': 'APP-C',
- 'index': 7,
- 'x': 2575
- },
- {
- 'id': '8',
- 'name': 'Cloud',
- 'index': 8,
- 'x': 2975
- },
- {
- 'id': '9',
- 'name': 'DCAE',
- 'index': 9,
- 'x': 3375
- },
- {
- 'id': '10',
- 'name': 'ALTS',
- 'index': 10,
- 'x': 3775
- },
- {
- 'id': '11',
- 'name': 'VF',
- 'index': 11,
- 'x': 4175
- }
- ],
- 'steps': [
- {
- 'message': {
- 'id': '9377-5036-c011-cb95-3a8b-82c6-bbb5-bc84',
- 'name': '[Unnamed Message]',
- 'type': 'request',
- 'from': '1',
- 'to': '2',
- 'index': 1
- }
- },
- {
- 'message': {
- 'id': '64c4-4fd1-b1da-4355-a060-6e48-ee47-c85c',
- 'name': '[Unnamed Message]',
- 'type': 'request',
- 'from': '1',
- 'to': '2',
- 'index': 2
- }
- }
- ]
- }
- }
- };
-
- mockRest.addHandler('create', ({baseUrl}) => {
+ mockRest.addHandler('post', ({baseUrl}) => {
expect(baseUrl).toBe(`/sdc1/feProxy/rest/v1/catalog/services/${flowUpdateData.serviceID}/artifacts/${flowUpdateData.uniqueId}`);
- return {
- artifactChecksum: 'MmE5MWJmN2ZlN2FhM2JhMzA0NGQ1ODMyOWFhNWI0NDA=',
- artifactCreator: 'cs0008',
- artifactDisplayName: 'zizizi',
- artifactGroupType: 'INFORMATIONAL',
- artifactLabel: 'zizizi',
- artifactName: 'zizizi',
- artifactType: 'WORKFLOW',
- artifactUUID: '3319335b-969e-4d72-b5a2-409645de6d64',
- artifactVersion: '3',
- attUidLastUpdater: 'cs0008',
- creationDate: 1470144601623,
- description: 'aslkjdfl asfdasdf',
- esId: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
- lastUpdateDate: 1470208425904,
- mandatory: false,
- payloadUpdateDate: 1470208426424,
- serviceApi: false,
- timeout: 0,
- uniqueId: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
- updaterFullName: 'Carlos Santana'
- };
+ return buildFromExistingObject(FlowPostResponseFactory, flowUpdateData);
});
- FlowsActions.createOrUpdateFlow(store.dispatch, {flow: flowUpdateData}, !NEW_FLOW);
-
- setTimeout(() => {
+ return FlowsActions.createOrUpdateFlow(store.dispatch, {flow: flowUpdateData}, !NEW_FLOW).then(() => {
assertFlowDataAfterCreateFetchAndUpdate(flowUpdateData);
- done();
- }, 50);
+ });
+
});
- it('Delete Flow', done => {
+ it('Delete Flow', () => {
deepFreeze(store.getState());
- const flowDeleteData = deepFreeze({
- artifactName: 'zizizi',
- artifactType: 'WORKFLOW',
- description: 'aslkjdfl asfdasdf',
- serviceID: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b',
- uniqueId: '338d75f0-aec8-4eb4-89c9-8733fcd9bf3b.zizizi',
- participants: []
- });
+ const flowDeleteData = FlowDeleteRequestFactory.build();
mockRest.addHandler('destroy', ({baseUrl}) => {
expect(baseUrl).toBe(`/sdc1/feProxy/rest/v1/catalog/services/${flowDeleteData.serviceID}/artifacts/${flowDeleteData.uniqueId}`);
return {};
});
- FlowsActions.deleteFlow(store.dispatch, {flow: flowDeleteData});
-
- setTimeout(() => {
+ return FlowsActions.deleteFlow(store.dispatch, {flow: flowDeleteData}).then(() => {
let {flowList} = store.getState().flows;
let index = flowList.findIndex(flow => flow.uniqueId === flowDeleteData.uniqueId);
expect(index).toBe(-1);
- done();
- }, 50);
+ });
});
-
});
-
diff --git a/openecomp-ui/test/licenseModel/creation/LicenseModelCreation.test.js b/openecomp-ui/test/licenseModel/creation/LicenseModelCreation.test.js
new file mode 100644
index 0000000000..0d8ce945c8
--- /dev/null
+++ b/openecomp-ui/test/licenseModel/creation/LicenseModelCreation.test.js
@@ -0,0 +1,75 @@
+/*!
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import {mapStateToProps } from 'sdc-app/onboarding/licenseModel/creation/LicenseModelCreation.js';
+import LicenseModelCreationView from 'sdc-app/onboarding/licenseModel/creation/LicenseModelCreationView.jsx';
+import {LicenseModelCreationFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
+
+describe('License Model Creation Module Tests', function() {
+ it ('mapStateToProps mapper exists', () => {
+ expect(mapStateToProps).toBeTruthy();
+ });
+
+ it ('should return empty data', () => {
+ let state = {
+ licenseModelList: [],
+ licenseModel: {
+ licenseModelCreation: {
+ data: {}
+ }
+ }
+ };
+ let props = mapStateToProps(state);
+ expect(props.data).toEqual({});
+ });
+
+ it ('should return vlm names list', () => {
+ let state = {
+ licenseModelList: [{
+ vendorName: 'vlm1',
+ id: 'vlm1_id'
+ }, {
+ vendorName: 'vlm2',
+ id: 'vlm2_id'
+ }],
+ licenseModel: {
+ licenseModelCreation: {
+ data: {}
+ }
+ }
+ };
+ let props = mapStateToProps(state);
+ expect(props.data).toEqual({});
+ expect(props.VLMNames).toEqual({vlm1: 'vlm1_id', vlm2: 'vlm2_id'});
+ });
+
+ it('simple jsx test', () => {
+ let data = LicenseModelCreationFactory.build();
+ var renderer = TestUtils.createRenderer();
+ renderer.render(
+ <LicenseModelCreationView
+ data={data}
+ onDataChanged={() => {}}
+ onValidateForm={() => {}}
+ onSubmit={() => {}}
+ onCancel={() => {}}/>
+ );
+ var renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toBeTruthy();
+ });
+});
diff --git a/openecomp-ui/test/licenseModel/entitlementPools/test.js b/openecomp-ui/test/licenseModel/entitlementPools/test.js
index 32705385b4..15e1deecd6 100644
--- a/openecomp-ui/test/licenseModel/entitlementPools/test.js
+++ b/openecomp-ui/test/licenseModel/entitlementPools/test.js
@@ -1,52 +1,34 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-
import deepFreeze from 'deep-freeze';
-import {expect} from 'chai';
import mockRest from 'test-utils/MockRest.js';
-import {cloneAndSet} from 'test-utils/Util.js';
+import {cloneAndSet, buildListFromFactory} from 'test-utils/Util.js';
import {storeCreator} from 'sdc-app/AppStore.js';
import EntitlementPoolsActionHelper from 'sdc-app/onboarding/licenseModel/entitlementPools/EntitlementPoolsActionHelper.js';
+import {EntitlementPoolStoreFactory, EntitlementPoolPostFactory} from 'test-utils/factories/licenseModel/EntitlementPoolFactories.js';
+import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
describe('Entitlement Pools Module Tests', function () {
const LICENSE_MODEL_ID = '555';
+ const version = VersionControllerUtilsFactory.build().version;
it('Load Entitlement Pools List', () => {
- const entitlementPoolsList = [
- {
- name: 'ep1',
- description: 'string',
- thresholdValue: 75,
- thresholdUnits: '%',
- entitlementMetric: {'choice': 'User', 'other': ''},
- increments: 'string',
- aggregationFunction: {'choice': 'Average', 'other': ''},
- operationalScope: {'choices': ['Other'], 'other': 'blabla'},
- time: {'choice': 'Hour', 'other': ''},
- sku: 'DEF2-385A-4521-AAAA',
- id: '1',
- referencingFeatureGroups: [],
- partNumber: '51529'
- }
- ];
+
+ const entitlementPoolsList = buildListFromFactory(EntitlementPoolStoreFactory);
deepFreeze(entitlementPoolsList);
const store = storeCreator();
deepFreeze(store.getState());
@@ -54,36 +36,20 @@ describe('Entitlement Pools Module Tests', function () {
const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', entitlementPoolsList);
mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/entitlement-pools`);
- expect(data).to.equal(undefined);
- expect(options).to.equal(undefined);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
return {results: entitlementPoolsList};
});
- return EntitlementPoolsActionHelper.fetchEntitlementPoolsList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ return EntitlementPoolsActionHelper.fetchEntitlementPoolsList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID, version}).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
});
});
it('Delete Entitlement Pool', () => {
- const entitlementPoolsList = [
- {
- name: 'ep1',
- description: 'string',
- thresholdValue: 75,
- thresholdUnits: '%',
- entitlementMetric: {'choice': 'User', 'other': ''},
- increments: 'string',
- aggregationFunction: {'choice': 'Average', 'other': ''},
- operationalScope: {'choices': ['Other'], 'other': 'blabla'},
- time: {'choice': 'Hour', 'other': ''},
- sku: 'DEF2-385A-4521-AAAA',
- id: '1',
- referencingFeatureGroups: [],
- partNumber: '51529'
- }
- ];
+ const entitlementPoolsList = buildListFromFactory(EntitlementPoolStoreFactory,1);
deepFreeze(entitlementPoolsList);
const store = storeCreator({
licenseModel: {
@@ -97,9 +63,9 @@ describe('Entitlement Pools Module Tests', function () {
const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', []);
mockRest.addHandler('destroy', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/entitlement-pools/${entitlementPoolsList[0].id}`);
- expect(data).to.equal(undefined);
- expect(options).to.equal(undefined);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools/${entitlementPoolsList[0].id}`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
return {
results: {
returnCode: 'OK'
@@ -109,9 +75,10 @@ describe('Entitlement Pools Module Tests', function () {
return EntitlementPoolsActionHelper.deleteEntitlementPool(store.dispatch, {
licenseModelId: LICENSE_MODEL_ID,
+ version,
entitlementPoolId: entitlementPoolsList[0].id
}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
});
@@ -120,43 +87,20 @@ describe('Entitlement Pools Module Tests', function () {
const store = storeCreator();
deepFreeze(store.getState());
- const entitlementPoolPostRequest = {
- name: 'ep1',
- description: 'string',
- thresholdValue: 75,
- thresholdUnits: '%',
- entitlementMetric: {'choice': 'User', 'other': ''},
- increments: 'string',
- aggregationFunction: {'choice': 'Average', 'other': ''},
- operationalScope: {'choices': ['Other'], 'other': 'blabla'},
- time: {'choice': 'Hour', 'other': ''},
- manufacturerReferenceNumber: 'DEF2-385A-4521-AAAA',
- };
- const entitlementPoolToAdd = {
- name: 'ep1',
- description: 'string',
- thresholdValue: 75,
- thresholdUnits: '%',
- entitlementMetric: {'choice': 'User', 'other': ''},
- increments: 'string',
- aggregationFunction: {'choice': 'Average', 'other': ''},
- operationalScope: {'choices': ['Other'], 'other': 'blabla'},
- time: {'choice': 'Hour', 'other': ''},
- manufacturerReferenceNumber: 'DEF2-385A-4521-AAAA',
- referencingFeatureGroups: []
- };
+ const EntitlementPoolPostRequest = EntitlementPoolPostFactory.build();
+
+ deepFreeze(EntitlementPoolPostRequest);
+
const entitlementPoolIdFromResponse = 'ADDED_ID';
- const entitlementPoolAfterAdd = {
- ...entitlementPoolToAdd,
- id: entitlementPoolIdFromResponse
- };
+ const entitlementPoolAfterAdd = EntitlementPoolStoreFactory.build({id: entitlementPoolIdFromResponse});
+ deepFreeze(entitlementPoolAfterAdd);
const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', [entitlementPoolAfterAdd]);
- mockRest.addHandler('create', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/entitlement-pools`);
- expect(data).to.deep.equal(entitlementPoolPostRequest);
- expect(options).to.equal(undefined);
+ mockRest.addHandler('post', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools`);
+ expect(data).toEqual(EntitlementPoolPostRequest);
+ expect(options).toEqual(undefined);
return {
returnCode: 'OK',
value: entitlementPoolIdFromResponse
@@ -166,28 +110,18 @@ describe('Entitlement Pools Module Tests', function () {
return EntitlementPoolsActionHelper.saveEntitlementPool(store.dispatch,
{
licenseModelId: LICENSE_MODEL_ID,
+ version,
previousEntitlementPool: null,
- entitlementPool: entitlementPoolToAdd
+ entitlementPool: EntitlementPoolPostRequest
}
).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
});
it('Update Entitlement Pool', () => {
- const entitlementPoolsList = [{
- name: 'ep1',
- id: '0',
- description: 'string',
- thresholdValue: 75,
- thresholdUnits: '%',
- entitlementMetric: {'choice': 'User', 'other': ''},
- increments: 'string',
- aggregationFunction: {'choice': 'Average', 'other': ''},
- operationalScope: {'choices': ['Other'], 'other': 'blabla'},
- time: {'choice': 'Hour', 'other': ''},
- manufacturerReferenceNumber: 'DEF2-385A-4521-AAAA'
- }];
+
+ const entitlementPoolsList = buildListFromFactory(EntitlementPoolStoreFactory, 1);
deepFreeze(entitlementPoolsList);
const store = storeCreator({
@@ -197,47 +131,34 @@ describe('Entitlement Pools Module Tests', function () {
}
}
});
+
deepFreeze(store.getState());
const toBeUpdatedEntitlementPoolId = entitlementPoolsList[0].id;
const previousEntitlementPoolData = entitlementPoolsList[0];
- const entitlementPoolUpdateData = {
- ...entitlementPoolsList[0],
- name: 'ep1_UPDATED',
- description: 'string_UPDATED'
- };
+ const entitlementPoolUpdateData = EntitlementPoolStoreFactory.build({name: 'ep1_UPDATED', description: 'string_UPDATED', id: toBeUpdatedEntitlementPoolId});
deepFreeze(entitlementPoolUpdateData);
- const entitlementPoolPutRequest = {
- name: 'ep1_UPDATED',
- description: 'string_UPDATED',
- thresholdValue: 75,
- thresholdUnits: '%',
- entitlementMetric: {'choice': 'User', 'other': ''},
- increments: 'string',
- aggregationFunction: {'choice': 'Average', 'other': ''},
- operationalScope: {'choices': ['Other'], 'other': 'blabla'},
- time: {'choice': 'Hour', 'other': ''},
- manufacturerReferenceNumber: 'DEF2-385A-4521-AAAA'
- };
+ const entitlementPoolPutRequest = EntitlementPoolPostFactory.build({name: 'ep1_UPDATED', description: 'string_UPDATED'});
deepFreeze(entitlementPoolPutRequest);
const expectedStore = cloneAndSet(store.getState(), 'licenseModel.entitlementPool.entitlementPoolsList', [entitlementPoolUpdateData]);
- mockRest.addHandler('save', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/entitlement-pools/${toBeUpdatedEntitlementPoolId}`);
- expect(data).to.deep.equal(entitlementPoolPutRequest);
- expect(options).to.equal(undefined);
+ mockRest.addHandler('put', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools/${toBeUpdatedEntitlementPoolId}`);
+ expect(data).toEqual(entitlementPoolPutRequest);
+ expect(options).toEqual(undefined);
return {returnCode: 'OK'};
});
return EntitlementPoolsActionHelper.saveEntitlementPool(store.dispatch, {
licenseModelId: LICENSE_MODEL_ID,
+ version,
previousEntitlementPool: previousEntitlementPoolData,
entitlementPool: entitlementPoolUpdateData
}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
});
diff --git a/openecomp-ui/test/licenseModel/featureGroups/LicenseModelFeatureGroupEditor.test.js b/openecomp-ui/test/licenseModel/featureGroups/LicenseModelFeatureGroupEditor.test.js
new file mode 100644
index 0000000000..5f5e2a0c9e
--- /dev/null
+++ b/openecomp-ui/test/licenseModel/featureGroups/LicenseModelFeatureGroupEditor.test.js
@@ -0,0 +1,74 @@
+/*!
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import {mapStateToProps} from 'sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditor.js';
+import FeatureGroupEditorView from 'sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupEditorView.jsx';
+import {LicenseModelOverviewFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
+import {FeatureGroupStoreFactory} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js';
+
+describe('License Model Feature Groups Editor Module Tests', function () {
+
+ it('should mapper exist', () => {
+ expect(mapStateToProps).toBeTruthy();
+ });
+
+ it('should return empty data', () => {
+
+ let licenseModel = LicenseModelOverviewFactory.build({
+ featureGroup: {
+ featureGroupEditor: {
+ data: FeatureGroupStoreFactory.build()
+ },
+ featureGroupsList: []
+ }
+ });
+
+ var results = mapStateToProps({licenseModel});
+ expect(results.entitlementPoolsList).toEqual([]);
+ expect(results.licenseKeyGroupsList).toEqual([]);
+ });
+
+ it ('should return fg names list', () => {
+ let licenseModel = LicenseModelOverviewFactory.build({
+ featureGroup: {
+ featureGroupEditor: {
+ data: FeatureGroupStoreFactory.build()
+ },
+ featureGroupsList: [{
+ name: 'fg1',
+ id: 'fg1_id'
+ }, {
+ name: 'fg2',
+ id: 'fg2_id'
+ }]
+ }
+ });
+ var results = mapStateToProps({licenseModel});
+ expect(results.FGNames).toEqual({fg1: 'fg1_id', fg2: 'fg2_id'});
+ });
+
+ it('jsx view test', () => {
+ var view = TestUtils.renderIntoDocument(<FeatureGroupEditorView
+ isReadOnlyMode={true}
+ onTabSelect={() => {}}
+ entitlementPoolsList={[{id: '1', name: '1'}]}
+ licenseKeyGroupsList={[{id: '1', name: '1'}]}/>);
+ expect(view).toBeTruthy();
+ });
+
+});
diff --git a/openecomp-ui/test/licenseModel/featureGroups/LicenseModelFeatureGroupListEditor.test.js b/openecomp-ui/test/licenseModel/featureGroups/LicenseModelFeatureGroupListEditor.test.js
new file mode 100644
index 0000000000..5dc20047bc
--- /dev/null
+++ b/openecomp-ui/test/licenseModel/featureGroups/LicenseModelFeatureGroupListEditor.test.js
@@ -0,0 +1,90 @@
+/*!
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import {mapStateToProps} from 'sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditor.js';
+import FeatureGroupsListEditorView from 'sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupListEditorView.jsx';
+import { FeatureGroupStoreFactory } from 'test-utils/factories/licenseModel/FeatureGroupFactories.js';
+import {LicenseModelOverviewFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
+import { buildListFromFactory } from 'test-utils/Util.js';
+import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
+
+describe('License Model Feature Group List Module Tests', function () {
+
+ it('should mapper exist', () => {
+ expect(mapStateToProps).toBeTruthy();
+ });
+
+
+ it('should return empty data', () => {
+
+
+ let licenseModel = LicenseModelOverviewFactory.build({
+ featureGroup: {
+ featureGroupEditor: {},
+ featureGroupsList: []
+ },
+ licenseModelEditor: {
+ data:{
+ ...VersionControllerUtilsFactory.build()
+ }
+ }
+ });
+ var results = mapStateToProps({licenseModel});
+ expect(results.vendorName).toEqual(undefined);
+ expect(results.featureGroupsModal.show).toEqual(false);
+ expect(results.featureGroupsModal.editMode).toEqual(false);
+ expect(results.featureGroupsList).toEqual([]);
+ });
+
+ it('should return true for show and edit mode and vendorName should be not empty', () => {
+
+ let licenseModel = LicenseModelOverviewFactory.build({
+ featureGroup: {
+ featureGroupEditor: {
+ data: FeatureGroupStoreFactory.build()
+ },
+ featureGroupsList: []
+ }
+ });
+ var results = mapStateToProps({licenseModel});
+ expect(results.featureGroupsModal.show).toEqual(true);
+ expect(results.featureGroupsModal.editMode).toEqual(true);
+ expect(results.vendorName).toEqual(licenseModel.licenseModelEditor.data.vendorName);
+ });
+
+ it('jsx view test', () => {
+ var view = TestUtils.renderIntoDocument(<FeatureGroupsListEditorView vendorName=''
+ licenseModelId=''
+ featureGroupsModal={{show: false, editMode: false}}
+ isReadOnlyMode={false}
+ onAddFeatureGroupClick={()=>{}}
+ featureGroupsList={[]} />);
+ expect(view).toBeTruthy();
+ });
+
+ it('jsx view list test', () => {
+ var view = TestUtils.renderIntoDocument(<FeatureGroupsListEditorView vendorName=''
+ licenseModelId=''
+ featureGroupsModal={{show: false, editMode: true}}
+ isReadOnlyMode={false}
+ onAddFeatureGroupClick={()=>{}}
+ featureGroupsList={buildListFromFactory(FeatureGroupStoreFactory)} />);
+ expect(view).toBeTruthy();
+ });
+
+});
diff --git a/openecomp-ui/test/licenseModel/featureGroups/test.js b/openecomp-ui/test/licenseModel/featureGroups/test.js
index d334ab758e..7d0d7242b5 100644
--- a/openecomp-ui/test/licenseModel/featureGroups/test.js
+++ b/openecomp-ui/test/licenseModel/featureGroups/test.js
@@ -1,75 +1,56 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-
-import {expect} from 'chai';
import deepFreeze from 'deep-freeze';
import mockRest from 'test-utils/MockRest.js';
-import {cloneAndSet} from 'test-utils/Util.js';
+import {cloneAndSet, buildListFromFactory} from 'test-utils/Util.js';
import {storeCreator} from 'sdc-app/AppStore.js';
import FeatureGroupsActionHelper from 'sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js';
+import { FeatureGroupStoreFactory, FeatureGroupPostFactory, FeatureGroupDispatchFactory, FeatureGroupPutFactory } from 'test-utils/factories/licenseModel/FeatureGroupFactories.js';
+import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
describe('Feature Groups Module Tests', function () {
const LICENSE_MODEL_ID = '555';
+ const version = VersionControllerUtilsFactory.build().version;
it('Load Feature Groups List', () => {
- const featureGroupsList = [
- {
- name: 'fs1',
- id: 0,
- description: 'fs1-d',
- licenseKeyGroupsIds: [1],
- entitlementPoolsIds: [1],
- refCount: 0
- }
- ];
+
+ const featureGroupsList = buildListFromFactory(FeatureGroupStoreFactory);
deepFreeze(featureGroupsList);
+
const store = storeCreator();
deepFreeze(store.getState());
const expectedStore = cloneAndSet(store.getState(), 'licenseModel.featureGroup.featureGroupsList', featureGroupsList);
mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/feature-groups`);
- expect(data).to.equal(undefined);
- expect(options).to.equal(undefined);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/feature-groups`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
return {results: featureGroupsList};
});
- return FeatureGroupsActionHelper.fetchFeatureGroupsList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ return FeatureGroupsActionHelper.fetchFeatureGroupsList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID, version}).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
});
});
it('Delete Feature Group', () => {
- const featureGroupsList = [
- {
- name: 'fs1',
- id: 0,
- description: 'fs1-d',
- licenseKeyGroupsIds: [1],
- entitlementPoolsIds: [1],
- refCount: 0
- }
- ];
+ const featureGroupsList = buildListFromFactory(FeatureGroupStoreFactory, 1);
deepFreeze(featureGroupsList);
const store = storeCreator({
licenseModel: {
@@ -82,10 +63,12 @@ describe('Feature Groups Module Tests', function () {
const expectedStore = cloneAndSet(store.getState(), 'licenseModel.featureGroup.featureGroupsList', []);
+ const idToDelete = featureGroupsList[0].id;
+
mockRest.addHandler('destroy', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/feature-groups/${featureGroupsList[0].id}`);
- expect(data).to.equal(undefined);
- expect(options).to.equal(undefined);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/feature-groups/${idToDelete}`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
return {
results: {
returnCode: 'OK'
@@ -95,9 +78,10 @@ describe('Feature Groups Module Tests', function () {
return FeatureGroupsActionHelper.deleteFeatureGroup(store.dispatch, {
licenseModelId: LICENSE_MODEL_ID,
- featureGroupId: featureGroupsList[0].id
+ version,
+ featureGroupId: idToDelete
}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
});
@@ -106,56 +90,62 @@ describe('Feature Groups Module Tests', function () {
const store = storeCreator();
deepFreeze(store.getState());
- const featureGroupPostRequest = {
- name: 'fs1',
- description: 'fs1-d',
- partNumber: '123',
+ const FeatureGroupPostRequest = FeatureGroupPostFactory.build({
addedLicenseKeyGroupsIds: [1],
addedEntitlementPoolsIds: [1]
- };
- const featureGroupToAdd = {
- name: 'fs1',
- description: 'fs1-d',
- partNumber: '123',
+ });
+ const featureGroupToAdd = FeatureGroupDispatchFactory.build({
licenseKeyGroupsIds: [1],
entitlementPoolsIds: [1]
- };
+ });
+
const featureGroupIdFromResponse = 'ADDED_ID';
- const featureGroupAfterAdd = {
+ const featureGroupAfterAdd = FeatureGroupStoreFactory.build({
...featureGroupToAdd,
id: featureGroupIdFromResponse
- };
+ });
const expectedStore = cloneAndSet(store.getState(), 'licenseModel.featureGroup.featureGroupsList', [featureGroupAfterAdd]);
- mockRest.addHandler('create', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/feature-groups`);
- expect(data).to.deep.equal(featureGroupPostRequest);
- expect(options).to.equal(undefined);
+ mockRest.addHandler('post', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/feature-groups`);
+ expect(data).toEqual(FeatureGroupPostRequest);
+ expect(options).toEqual(undefined);
return {
returnCode: 'OK',
value: featureGroupIdFromResponse
};
});
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: []};
+ });
+
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: []};
+ });
+
+
return FeatureGroupsActionHelper.saveFeatureGroup(store.dispatch, {
licenseModelId: LICENSE_MODEL_ID,
+ version,
featureGroup: featureGroupToAdd
}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
});
it('Update Feature Group', () => {
- const featureGroupsList = [{
- name: 'fs1',
- id: 0,
- description: 'fs1-d',
- partNumber: '123',
+ const featureGroupsList = buildListFromFactory(FeatureGroupStoreFactory, 1, {
licenseKeyGroupsIds: [1],
- entitlementPoolsIds: [1],
- refCount: 0
- }];
+ entitlementPoolsIds: [1]
+ });
deepFreeze(featureGroupsList);
const store = storeCreator({
@@ -169,44 +159,92 @@ describe('Feature Groups Module Tests', function () {
const toBeUpdatedFeatureGroupId = featureGroupsList[0].id;
const previousFeatureGroupData = featureGroupsList[0];
- const featureGroupUpdateData = {
- ...featureGroupsList[0],
- name: 'fs_UPDATED',
- description: 'description_UPDATED',
- partNumber: '123_UPDATED',
+
+ const featureGroupUpdateData = FeatureGroupStoreFactory.build({
+ ...previousFeatureGroupData,
licenseKeyGroupsIds: [7],
entitlementPoolsIds: [7]
- };
+ });
deepFreeze(featureGroupUpdateData);
- const featureGroupPutRequest = {
- name: 'fs_UPDATED',
- description: 'description_UPDATED',
- partNumber: '123_UPDATED',
+ const FeatureGroupPutFactoryRequest = FeatureGroupPutFactory.build({
+ name: featureGroupUpdateData.name,
+ description: featureGroupUpdateData.description,
+ partNumber: featureGroupUpdateData.partNumber,
addedLicenseKeyGroupsIds: [7],
addedEntitlementPoolsIds: [7],
removedLicenseKeyGroupsIds: [1],
removedEntitlementPoolsIds: [1]
- };
- deepFreeze(featureGroupPutRequest);
+ });
+ deepFreeze(FeatureGroupPutFactoryRequest);
const expectedStore = cloneAndSet(store.getState(), 'licenseModel.featureGroup.featureGroupsList', [featureGroupUpdateData]);
- mockRest.addHandler('save', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/feature-groups/${toBeUpdatedFeatureGroupId}`);
- expect(data).to.deep.equal(featureGroupPutRequest);
- expect(options).to.equal(undefined);
+ mockRest.addHandler('put', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/feature-groups/${toBeUpdatedFeatureGroupId}`);
+ expect(data).toEqual(FeatureGroupPutFactoryRequest);
+ expect(options).toEqual(undefined);
return {returnCode: 'OK'};
});
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: []};
+ });
+
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: []};
+ });
+
return FeatureGroupsActionHelper.saveFeatureGroup(store.dispatch, {
licenseModelId: LICENSE_MODEL_ID,
+ version,
previousFeatureGroup: previousFeatureGroupData,
featureGroup: featureGroupUpdateData
}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
+
+ });
+
+ it('Open Editor', () => {
+
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const editorData = FeatureGroupStoreFactory.build();
+ deepFreeze(editorData);
+ const expectedStore = cloneAndSet(store.getState(), 'licenseModel.featureGroup.featureGroupEditor.data', editorData);
+ const LICENSE_MODEL_ID = '123';
+
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/entitlement-pools`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: []};
+ });
+
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: []};
+ });
+
+
+ FeatureGroupsActionHelper.openFeatureGroupsEditor(store.dispatch, {featureGroup: editorData, licenseModelId: '123', version});
+ setTimeout(() =>{
+ expect(store.getState()).toEqual(expectedStore);
+ }, 100);
+
+
+
});
});
diff --git a/openecomp-ui/test/licenseModel/licenseAgreement/test.js b/openecomp-ui/test/licenseModel/licenseAgreement/test.js
index a6e8a3d363..442f7bf91f 100644
--- a/openecomp-ui/test/licenseModel/licenseAgreement/test.js
+++ b/openecomp-ui/test/licenseModel/licenseAgreement/test.js
@@ -1,75 +1,54 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-
-import {expect} from 'chai';
import deepFreeze from 'deep-freeze';
+import pickBy from 'lodash/pickBy';
import mockRest from 'test-utils/MockRest.js';
-import {cloneAndSet} from 'test-utils/Util.js';
+import {cloneAndSet, buildListFromFactory} from 'test-utils/Util.js';
import {storeCreator} from 'sdc-app/AppStore.js';
import LicenseAgreementActionHelper from 'sdc-app/onboarding/licenseModel/licenseAgreement/LicenseAgreementActionHelper.js';
+import { LicenseAgreementStoreFactory, LicenseAgreementDispatchFactory, LicenseAgreementPostFactory, LicenseAgreementPutFactory } from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js';
+import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
describe('License Agreement Module Tests', () => {
const LICENSE_MODEL_ID = '777';
+ const version = VersionControllerUtilsFactory.build().version;
it('Load License Agreement List', () => {
- const licenseAgreementList = [
- {
- id: '0',
- name: 'name0',
- description: 'description0',
- licenseTerm: 'licenseTerm0',
- requirementsAndConstrains: 'req_and_constraints0',
- featureGroupsIds: ['77']
- }
- ];
- deepFreeze(licenseAgreementList);
+ const licenseAgreementList = buildListFromFactory(LicenseAgreementStoreFactory);
+
const store = storeCreator();
deepFreeze(store.getState());
const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseAgreement.licenseAgreementList', licenseAgreementList);
mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/license-agreements`);
- expect(data).to.equal(undefined);
- expect(options).to.equal(undefined);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-agreements`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
return {results: licenseAgreementList};
});
- return LicenseAgreementActionHelper.fetchLicenseAgreementList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ return LicenseAgreementActionHelper.fetchLicenseAgreementList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID, version}).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
});
});
it('Delete License Agreement', () => {
- const licenseAgreementList = [
- {
- id: '0',
- name: 'name0',
- description: 'description0',
- licenseTerm: 'licenseTerm0',
- requirementsAndConstrains: 'req_and_constraints0',
- featureGroupsIds: ['77']
- }
- ];
- deepFreeze(licenseAgreementList);
+ const licenseAgreementList = buildListFromFactory(LicenseAgreementStoreFactory, 1);
const store = storeCreator({
licenseModel: {
licenseAgreement: {
@@ -78,57 +57,49 @@ describe('License Agreement Module Tests', () => {
}
});
deepFreeze(store.getState());
- const toBeDeletedLicenseAgreementId = '0';
+ const toBeDeletedLicenseAgreementId = licenseAgreementList[0].id;
const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseAgreement.licenseAgreementList', []);
mockRest.addHandler('destroy', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/license-agreements/${toBeDeletedLicenseAgreementId}`);
- expect(data).to.equal(undefined);
- expect(options).to.equal(undefined);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-agreements/${toBeDeletedLicenseAgreementId}`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
});
return LicenseAgreementActionHelper.deleteLicenseAgreement(store.dispatch, {
licenseAgreementId: toBeDeletedLicenseAgreementId,
- licenseModelId: LICENSE_MODEL_ID
+ licenseModelId: LICENSE_MODEL_ID,
+ version
}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
});
it('Add License Agreement', () => {
const store = storeCreator();
deepFreeze(store.getState());
- const licenseAgreementPostRequest = {
- name: 'name_ADDED_LA',
- description: 'description_ADDED_LA',
- licenseTerm: 'licenseTerm_ADDED_LA',
- requirementsAndConstrains: 'req_and_constraints_ADDED_LA',
- addedFeatureGroupsIds: []
- };
- deepFreeze(licenseAgreementPostRequest);
-
- const licenseAgreementToAdd = {
- name: 'name_ADDED_LA',
- description: 'description_ADDED_LA',
- licenseTerm: 'licenseTerm_ADDED_LA',
- requirementsAndConstrains: 'req_and_constraints_ADDED_LA',
- featureGroupsIds: []
- };
- deepFreeze(licenseAgreementToAdd);
+
+ const licenseAgreementToAdd = LicenseAgreementDispatchFactory.build();
+
+ const LicenseAgreementPostRequest = LicenseAgreementPostFactory.build(
+ pickBy(licenseAgreementToAdd, (val, key) => key !== 'featureGroupsIds')
+ );
+
+ deepFreeze(LicenseAgreementPostRequest);
const licenseAgreementIdFromResponse = 'ADDED_ID';
- const licenseAgreementAfterAdd = {
+ const licenseAgreementAfterAdd = LicenseAgreementStoreFactory.build({
...licenseAgreementToAdd,
id: licenseAgreementIdFromResponse
- };
+ });
deepFreeze(licenseAgreementAfterAdd);
const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseAgreement.licenseAgreementList', [licenseAgreementAfterAdd]);
- mockRest.addHandler('create', ({options, data, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/license-agreements`);
- expect(data).to.deep.equal(licenseAgreementPostRequest);
- expect(options).to.equal(undefined);
+ mockRest.addHandler('post', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-agreements`);
+ expect(data).toEqual(LicenseAgreementPostRequest);
+ expect(options).toEqual(undefined);
return {
value: licenseAgreementIdFromResponse
};
@@ -136,23 +107,15 @@ describe('License Agreement Module Tests', () => {
return LicenseAgreementActionHelper.saveLicenseAgreement(store.dispatch, {
licenseAgreement: licenseAgreementToAdd,
- licenseModelId: LICENSE_MODEL_ID
+ licenseModelId: LICENSE_MODEL_ID,
+ version
}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
});
it('Update License Agreement', () => {
- const licenseAgreementList = [
- {
- id: '0',
- name: 'name0',
- description: 'description0',
- licenseTerm: 'licenseTerm0',
- requirementsAndConstrains: 'req_and_constraints0',
- featureGroupsIds: ['77']
- }
- ];
+ const licenseAgreementList = buildListFromFactory(LicenseAgreementStoreFactory, 1, {featureGroupsIds: ['77']});
const store = storeCreator({
licenseModel: {
licenseAgreement: {
@@ -162,43 +125,40 @@ describe('License Agreement Module Tests', () => {
});
deepFreeze(store.getState());
- const toBeUpdatedLicenseAgreementId = licenseAgreementList[0].id;
const previousLicenseAgreementData = licenseAgreementList[0];
+ const toBeUpdatedLicenseAgreementId = previousLicenseAgreementData.id;
+ const oldFeatureGroupIds = previousLicenseAgreementData.featureGroupsIds;
+
+ const newFeatureGroupsIds = ['update_id_1', 'update_id_2'];
- const licenseAgreementUpdateData = {
- ...licenseAgreementList[0],
- name: 'name_UPDATED',
- description: 'description_UPDATED',
- licenseTerm: 'licenseTerm_UPDATED_LA',
- requirementsAndConstrains: 'req_and_constraints_UPDATED_LA',
- featureGroupsIds: ['update_id_1', 'update_id_2']
- };
+ const licenseAgreementUpdateData = LicenseAgreementStoreFactory.build({
+ id: toBeUpdatedLicenseAgreementId,
+ featureGroupsIds: newFeatureGroupsIds
+ });
deepFreeze(licenseAgreementUpdateData);
- const licenseAgreementPutRequest = {
- name: 'name_UPDATED',
- description: 'description_UPDATED',
- licenseTerm: 'licenseTerm_UPDATED_LA',
- requirementsAndConstrains: 'req_and_constraints_UPDATED_LA',
- addedFeatureGroupsIds: ['update_id_1', 'update_id_2'],
- removedFeatureGroupsIds: ['77']
- };
- deepFreeze(licenseAgreementPutRequest);
+ const LicenseAgreementPutFactoryRequest = LicenseAgreementPutFactory.build({
+ addedFeatureGroupsIds: newFeatureGroupsIds,
+ removedFeatureGroupsIds: oldFeatureGroupIds
+ });
+
+ deepFreeze(LicenseAgreementPutFactoryRequest);
const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseAgreement.licenseAgreementList', [licenseAgreementUpdateData]);
- mockRest.addHandler('save', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/license-agreements/${toBeUpdatedLicenseAgreementId}`);
- expect(data).to.deep.equal(licenseAgreementPutRequest);
- expect(options).to.equal(undefined);
+ mockRest.addHandler('put', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-agreements/${toBeUpdatedLicenseAgreementId}`);
+ expect(data).toEqual(LicenseAgreementPutFactoryRequest);
+ expect(options).toEqual(undefined);
});
return LicenseAgreementActionHelper.saveLicenseAgreement(store.dispatch, {
licenseModelId: LICENSE_MODEL_ID,
+ version,
previousLicenseAgreement: previousLicenseAgreementData,
licenseAgreement: licenseAgreementUpdateData
}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
});
diff --git a/openecomp-ui/test/licenseModel/licenseKeyGroups/test.js b/openecomp-ui/test/licenseModel/licenseKeyGroups/test.js
index 944bd44e49..dd09030f4f 100644
--- a/openecomp-ui/test/licenseModel/licenseKeyGroups/test.js
+++ b/openecomp-ui/test/licenseModel/licenseKeyGroups/test.js
@@ -1,44 +1,36 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-
-import {expect} from 'chai';
import deepFreeze from 'deep-freeze';
import mockRest from 'test-utils/MockRest.js';
-import {cloneAndSet} from 'test-utils/Util.js';
+import {cloneAndSet, buildListFromFactory} from 'test-utils/Util.js';
import {storeCreator} from 'sdc-app/AppStore.js';
+import {LicenseKeyGroupStoreFactory, LicenseKeyGroupPostFactory} from 'test-utils/factories/licenseModel/LicenseKeyGroupFactories.js';
import LicenseKeyGroupsActionHelper from 'sdc-app/onboarding/licenseModel/licenseKeyGroups/LicenseKeyGroupsActionHelper.js';
+import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
describe('License Key Groups Module Tests', function () {
const LICENSE_MODEL_ID = '555';
+ const version = VersionControllerUtilsFactory.build().version;
+
it('Load License Key Group', () => {
- const licenseKeyGroupsList = [
- {
- name: 'lsk1',
- description: 'string',
- type: 'Unique',
- operationalScope: {'choices': ['Data_Center'], 'other': ''},
- id: '0'
- }
- ];
+
+ const licenseKeyGroupsList = buildListFromFactory(LicenseKeyGroupStoreFactory);
+
deepFreeze(licenseKeyGroupsList);
const store = storeCreator();
deepFreeze(store.getState());
@@ -46,27 +38,21 @@ describe('License Key Groups Module Tests', function () {
const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', licenseKeyGroupsList);
mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/license-key-groups`);
- expect(data).to.equal(undefined);
- expect(options).to.equal(undefined);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
return {results: licenseKeyGroupsList};
});
- return LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ return LicenseKeyGroupsActionHelper.fetchLicenseKeyGroupsList(store.dispatch, {licenseModelId: LICENSE_MODEL_ID, version}).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
});
});
it('Delete License Key Group', () => {
- const licenseKeyGroupsList = [
- {
- name: 'lsk1',
- description: 'string',
- type: 'Unique',
- operationalScope: {'choices': ['Data_Center'], 'other': ''},
- id: '0'
- }
- ];
+
+ const licenseKeyGroupsList = buildListFromFactory(LicenseKeyGroupStoreFactory, 1);
+
deepFreeze(licenseKeyGroupsList);
const store = storeCreator({
licenseModel: {
@@ -76,20 +62,21 @@ describe('License Key Groups Module Tests', function () {
}
});
deepFreeze(store.getState());
- const toBeDeletedLicenseKeyGroupId = '0';
+ const toBeDeletedLicenseKeyGroupId = licenseKeyGroupsList[0].id;
const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', []);
mockRest.addHandler('destroy', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/license-key-groups/${toBeDeletedLicenseKeyGroupId}`);
- expect(data).to.equal(undefined);
- expect(options).to.equal(undefined);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups/${toBeDeletedLicenseKeyGroupId}`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
});
return LicenseKeyGroupsActionHelper.deleteLicenseKeyGroup(store.dispatch, {
licenseKeyGroupId: toBeDeletedLicenseKeyGroupId,
- licenseModelId: LICENSE_MODEL_ID
+ licenseModelId: LICENSE_MODEL_ID,
+ version
}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
});
@@ -98,56 +85,34 @@ describe('License Key Groups Module Tests', function () {
const store = storeCreator();
deepFreeze(store.getState());
- const licenseKeyGroupPostRequest = {
- name: 'lsk1_ADDED',
- description: 'string_ADDED',
- type: 'Unique_ADDED',
- operationalScope: {'choices': ['Data_Center'], 'other': ''}
- };
- deepFreeze(licenseKeyGroupPostRequest);
-
- const licenseKeyGroupToAdd = {
- ...licenseKeyGroupPostRequest
- };
-
- deepFreeze(licenseKeyGroupToAdd);
-
- const licenseKeyGroupIdFromResponse = 'ADDED_ID';
- const licenseKeyGroupAfterAdd = {
- ...licenseKeyGroupToAdd,
- id: licenseKeyGroupIdFromResponse
- };
- deepFreeze(licenseKeyGroupAfterAdd);
-
- const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', [licenseKeyGroupAfterAdd]);
-
- mockRest.addHandler('create', ({options, data, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/license-key-groups`);
- expect(data).to.deep.equal(licenseKeyGroupPostRequest);
- expect(options).to.equal(undefined);
+ const LicenseKeyGroupPost = LicenseKeyGroupPostFactory.build();
+ deepFreeze(LicenseKeyGroupPost);
+
+ const LicenseKeyGroupStore = LicenseKeyGroupStoreFactory.build();
+ deepFreeze(LicenseKeyGroupStore);
+
+ const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', [LicenseKeyGroupStore]);
+
+ mockRest.addHandler('post', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups`);
+ expect(data).toEqual(LicenseKeyGroupPost);
+ expect(options).toEqual(undefined);
return {
- value: licenseKeyGroupIdFromResponse
+ value: LicenseKeyGroupStore.id
};
});
return LicenseKeyGroupsActionHelper.saveLicenseKeyGroup(store.dispatch, {
- licenseKeyGroup: licenseKeyGroupToAdd,
- licenseModelId: LICENSE_MODEL_ID
+ licenseKeyGroup: LicenseKeyGroupPost,
+ licenseModelId: LICENSE_MODEL_ID,
+ version
}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
});
it('Update License Key Group', () => {
- const licenseKeyGroupsList = [
- {
- name: 'lsk1',
- description: 'string',
- type: 'Unique',
- operationalScope: {'choices': ['Data_Center'], 'other': ''},
- id: '0'
- }
- ];
+ const licenseKeyGroupsList = buildListFromFactory(LicenseKeyGroupStoreFactory, 1);
deepFreeze(licenseKeyGroupsList);
const store = storeCreator({
licenseModel: {
@@ -160,37 +125,35 @@ describe('License Key Groups Module Tests', function () {
const toBeUpdatedLicenseKeyGroupId = licenseKeyGroupsList[0].id;
const previousLicenseKeyGroupData = licenseKeyGroupsList[0];
- const licenseKeyGroupUpdateData = {
- ...licenseKeyGroupsList[0],
+ const licenseKeyGroupUpdatedData = LicenseKeyGroupPostFactory.build({
name: 'lsk1_UPDATE',
description: 'string_UPDATE',
- type: 'Unique',
- operationalScope: {'choices': ['Data_Center'], 'other': ''}
- };
- deepFreeze(licenseKeyGroupUpdateData);
+ id: toBeUpdatedLicenseKeyGroupId
+ });
+ deepFreeze(licenseKeyGroupUpdatedData);
- const licenseKeyGroupPutRequest = {
+ const licenseKeyGroupPutRequest = LicenseKeyGroupPostFactory.build({
name: 'lsk1_UPDATE',
- description: 'string_UPDATE',
- type: 'Unique',
- operationalScope: {'choices': ['Data_Center'], 'other': ''}
- };
+ description: 'string_UPDATE'
+ });
+
deepFreeze(licenseKeyGroupPutRequest);
- const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', [licenseKeyGroupUpdateData]);
+ const expectedStore = cloneAndSet(store.getState(), 'licenseModel.licenseKeyGroup.licenseKeyGroupsList', [licenseKeyGroupUpdatedData]);
- mockRest.addHandler('save', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/license-key-groups/${toBeUpdatedLicenseKeyGroupId}`);
- expect(data).to.deep.equal(licenseKeyGroupPutRequest);
- expect(options).to.equal(undefined);
+ mockRest.addHandler('put', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${version.id}/license-key-groups/${toBeUpdatedLicenseKeyGroupId}`);
+ expect(data).toEqual(licenseKeyGroupPutRequest);
+ expect(options).toEqual(undefined);
});
return LicenseKeyGroupsActionHelper.saveLicenseKeyGroup(store.dispatch, {
previousLicenseKeyGroup: previousLicenseKeyGroupData,
- licenseKeyGroup: licenseKeyGroupUpdateData,
- licenseModelId: LICENSE_MODEL_ID
+ licenseKeyGroup: licenseKeyGroupUpdatedData,
+ licenseModelId: LICENSE_MODEL_ID,
+ version
}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
});
diff --git a/openecomp-ui/test/licenseModel/overview/listItems/EntitlementPool.test.js b/openecomp-ui/test/licenseModel/overview/listItems/EntitlementPool.test.js
new file mode 100644
index 0000000000..6c4a05eb16
--- /dev/null
+++ b/openecomp-ui/test/licenseModel/overview/listItems/EntitlementPool.test.js
@@ -0,0 +1,31 @@
+/*!
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import EntitlementPool from 'src/sdc-app/onboarding/licenseModel/overview/listItems/EntitlementPool.jsx';
+import {EntitlementPoolListItemFactory} from 'test-utils/factories/licenseModel/EntitlementPoolFactories.js';
+
+describe('Entitlement Pool List Item Module Tests', function () {
+ it('Entitlement Pool List Item should exist', () => {
+ expect(EntitlementPool).toBeTruthy();
+ });
+ it('renders Entitlement Pool List Item', () => {
+ const epData = EntitlementPoolListItemFactory.build();
+ const itemView = TestUtils.renderIntoDocument( <EntitlementPool epData={epData} /> );
+ expect(itemView).toBeTruthy();
+ });
+});
diff --git a/openecomp-ui/test/licenseModel/overview/listItems/FeatureGroup.test.js b/openecomp-ui/test/licenseModel/overview/listItems/FeatureGroup.test.js
new file mode 100644
index 0000000000..10b7801889
--- /dev/null
+++ b/openecomp-ui/test/licenseModel/overview/listItems/FeatureGroup.test.js
@@ -0,0 +1,58 @@
+/*!
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import FeatureGroup from 'src/sdc-app/onboarding/licenseModel/overview/listItems/FeatureGroup.jsx';
+import {scryRenderedDOMComponentsWithTestId} from 'test-utils/Util.js';
+import {FeatureGroupListItemFactory} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js';
+import {EntitlementPoolListItemFactory} from 'test-utils/factories/licenseModel/EntitlementPoolFactories.js';
+import {LicenseKeyGroupListItemFactory} from 'test-utils/factories/licenseModel/LicenseKeyGroupFactories.js';
+
+describe('Feature Group List Item Module Tests', function () {
+ it('Feature Group List Item should exist', () => {
+ expect(FeatureGroup).toBeTruthy();
+ });
+
+ it('renders Feature Group List Item Collapsed', () => {
+ const fgData = FeatureGroupListItemFactory.build();
+ const itemView = TestUtils.renderIntoDocument( <FeatureGroup fgData={fgData} /> );
+ expect(itemView).toBeTruthy();
+ const elem = TestUtils.scryRenderedDOMComponentsWithClass(itemView,'down');
+ expect(elem).toBeTruthy();
+ });
+
+ it('renders Feature Group List Item Expanded', () => {
+ const fgData = FeatureGroupListItemFactory.build({isCollpased: false});
+ const itemView = TestUtils.renderIntoDocument( <FeatureGroup fgData={fgData} /> );
+ expect(itemView).toBeTruthy();
+ const elem = TestUtils.scryRenderedDOMComponentsWithClass(itemView,'right');
+ expect(elem).toBeTruthy();
+ });
+
+ it('renders Feature Group List Item with Children Count', () => {
+ const children = [EntitlementPoolListItemFactory.build(), LicenseKeyGroupListItemFactory.build()];
+ const fgData = FeatureGroupListItemFactory.build({children: children, isCollpased: false});
+ const itemView = TestUtils.renderIntoDocument( <FeatureGroup fgData={fgData} /> );
+ expect(itemView).toBeTruthy();
+ let elem = scryRenderedDOMComponentsWithTestId(itemView,'vlm-list-ep-count-value');
+ expect(elem).toBeTruthy();
+ expect(elem[0].innerHTML).toBe('1');
+ elem = scryRenderedDOMComponentsWithTestId(itemView,'vlm-list-lkg-count-value');
+ expect(elem).toBeTruthy();
+ expect(elem[0].innerHTML).toBe('1');
+ });
+});
diff --git a/openecomp-ui/test/licenseModel/overview/listItems/LicenseAgreement.test.js b/openecomp-ui/test/licenseModel/overview/listItems/LicenseAgreement.test.js
new file mode 100644
index 0000000000..608a76965f
--- /dev/null
+++ b/openecomp-ui/test/licenseModel/overview/listItems/LicenseAgreement.test.js
@@ -0,0 +1,54 @@
+/*!
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import LicenseAgreement from 'src/sdc-app/onboarding/licenseModel/overview/listItems/LicenseAgreement.jsx';
+import {scryRenderedDOMComponentsWithTestId} from 'test-utils/Util.js';
+import {LicenseAgreementListItemFactory} from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js';
+import {FeatureGroupListItemFactory} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js';
+
+describe('License Agreement List Item Module Tests', function () {
+ it('License Agreement List Item should exist', () => {
+ expect(LicenseAgreement).toBeTruthy();
+ });
+
+ it('renders License Agreement List Item Collapsed', () => {
+ const laData = LicenseAgreementListItemFactory.build();
+ const itemView = TestUtils.renderIntoDocument( <LicenseAgreement laData={laData} /> );
+ expect(itemView).toBeTruthy();
+ const elem = TestUtils.scryRenderedDOMComponentsWithClass(itemView,'down');
+ expect(elem).toBeTruthy();
+ });
+
+ it('renders License Agreement List Item Expanded', () => {
+ const laData = LicenseAgreementListItemFactory.build({isCollpased: false});
+ const itemView = TestUtils.renderIntoDocument( <LicenseAgreement laData={laData} /> );
+ expect(itemView).toBeTruthy();
+ const elem = TestUtils.scryRenderedDOMComponentsWithClass(itemView,'right');
+ expect(elem).toBeTruthy();
+ });
+
+ it('renders License Agreement List Item with Children Count', () => {
+ const fgData = FeatureGroupListItemFactory.build();
+ const laData = LicenseAgreementListItemFactory.build({children: [fgData]});
+ const itemView = TestUtils.renderIntoDocument( <LicenseAgreement laData={laData} /> );
+ expect(itemView).toBeTruthy();
+ const elem = scryRenderedDOMComponentsWithTestId(itemView,'vlm-list-fg-count-value');
+ expect(elem).toBeTruthy();
+ expect(elem[0].innerHTML).toBe('1');
+ });
+});
diff --git a/openecomp-ui/test/licenseModel/overview/listItems/LicenseKeyGroup.test.js b/openecomp-ui/test/licenseModel/overview/listItems/LicenseKeyGroup.test.js
new file mode 100644
index 0000000000..b9c097b0b1
--- /dev/null
+++ b/openecomp-ui/test/licenseModel/overview/listItems/LicenseKeyGroup.test.js
@@ -0,0 +1,31 @@
+/*!
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import LicenseKeyGroup from 'src/sdc-app/onboarding/licenseModel/overview/listItems/LicenseKeyGroup.jsx';
+import {LicenseKeyGroupListItemFactory} from 'test-utils/factories/licenseModel/LicenseKeyGroupFactories.js';
+
+describe('LicenseKeyGroup List Item Module Tests', function () {
+ it('LicenseKeyGroup List Item should exist', () => {
+ expect(LicenseKeyGroup).toBeTruthy();
+ });
+ it('renders LicenseKeyGroup List Item', () => {
+ const lkgData = LicenseKeyGroupListItemFactory.build();
+ const itemView = TestUtils.renderIntoDocument( <LicenseKeyGroup lkgData={lkgData} /> );
+ expect(itemView).toBeTruthy();
+ });
+});
diff --git a/openecomp-ui/test/licenseModel/overview/summary/SummaryCountList.test.js b/openecomp-ui/test/licenseModel/overview/summary/SummaryCountList.test.js
new file mode 100644
index 0000000000..27f7aa68fd
--- /dev/null
+++ b/openecomp-ui/test/licenseModel/overview/summary/SummaryCountList.test.js
@@ -0,0 +1,87 @@
+/*!
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+
+import {mapStateToProps, SummaryCountList} from 'sdc-app/onboarding/licenseModel/overview/summary/SummaryCountList.js';
+import LicenseModelDescriptionEdit from 'sdc-app/onboarding/licenseModel/overview/summary/LicenseModelDescriptionEdit.jsx';
+import {overviewItems} from 'sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewConstants.js';
+import {LicenseModelOverviewFactory, LicenseModelStoreFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
+
+describe('License Model Overview Summary Count List module test', () => {
+
+ it('should mapper exist', () => {
+ expect(mapStateToProps).toBeTruthy();
+ });
+
+ it('mapper data return test',() => {
+
+ var obj = {
+ licenseModel: LicenseModelOverviewFactory.build({
+ entitlementPool: {
+ entitlementPoolsList: []
+ },
+ licenseAgreement: {
+ licenseAgreementList: []
+ },
+ featureGroup: {
+ featureGroupsList: []
+ },
+ licenseKeyGroup: {
+ licenseKeyGroupsList: []
+ }
+ })
+ };
+
+ let counts = [
+ {name: overviewItems.LICENSE_AGREEMENTS, count: 0},
+ {name: overviewItems.FEATURE_GROUPS, count: 0},
+ {name: overviewItems.ENTITLEMENT_POOLS, count: 0},
+ {name: overviewItems.LICENSE_KEY_GROUPS, count: 0},
+ ];
+
+ var result = mapStateToProps(obj);
+ expect(result.isReadOnlyMode).toEqual(true);
+ expect(result.description).toEqual(obj.licenseModel.licenseModelEditor.data.description);
+ expect(result.counts).toEqual(counts);
+ });
+
+ it('jsx view test', () => {
+
+ var counts = [
+ {name: overviewItems.LICENSE_AGREEMENTS, count: 0},
+ {name: overviewItems.FEATURE_GROUPS, count: 0},
+ {name: overviewItems.ENTITLEMENT_POOLS, count: 0},
+ {name: overviewItems.LICENSE_KEY_GROUPS, count: 0},
+ ];
+
+ var view = TestUtils.renderIntoDocument(<SummaryCountList counts={counts} licenseModelId='1' isReadOnlyMode={false}/>);
+ expect(view).toBeTruthy();
+ });
+
+ it('description editor jsx view test', () => {
+ var data = LicenseModelStoreFactory.build();
+ var genericFieldInfo = {
+ description: {
+ isValid : true
+ }
+ }
+ var view = TestUtils.renderIntoDocument(<LicenseModelDescriptionEdit data={data} genericFieldInfo={genericFieldInfo} description='desc'/>);
+ expect(view).toBeTruthy();
+ });
+
+});
diff --git a/openecomp-ui/test/licenseModel/overview/summary/VendorDataView.test.js b/openecomp-ui/test/licenseModel/overview/summary/VendorDataView.test.js
new file mode 100644
index 0000000000..8fea3e4b90
--- /dev/null
+++ b/openecomp-ui/test/licenseModel/overview/summary/VendorDataView.test.js
@@ -0,0 +1,48 @@
+/*!
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import {mapStateToProps, VendorDataView} from 'sdc-app/onboarding/licenseModel/overview/summary/VendorDataView.js';
+import {LicenseModelOverviewFactory, LicenseModelStoreFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
+
+
+describe('License Model Overview Summary module test', () => {
+
+ it('should mapper exist', () => {
+ expect(mapStateToProps).toBeTruthy();
+ });
+
+ it('mapper data return test',() => {
+
+ var state = {
+ licenseModel: LicenseModelOverviewFactory.build()
+ };
+
+ var props = mapStateToProps(state);
+ expect(props.isReadOnlyMode).toEqual(true);
+ expect(props.description).toEqual(null);
+ expect(props.data).toEqual(state.licenseModel.licenseModelEditor.data);
+
+ });
+
+ it('jsx view test', () => {
+ var data = LicenseModelStoreFactory.build();
+ var view = TestUtils.renderIntoDocument(<VendorDataView isReadOnlyMode={false} description='' data={data} />);
+ expect(view).toBeTruthy();
+ });
+
+});
diff --git a/openecomp-ui/test/licenseModel/overview/test.js b/openecomp-ui/test/licenseModel/overview/test.js
new file mode 100644
index 0000000000..c78c3e47b1
--- /dev/null
+++ b/openecomp-ui/test/licenseModel/overview/test.js
@@ -0,0 +1,355 @@
+/*!
+ * 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 {mapStateToProps} from 'sdc-app/onboarding/licenseModel/overview/LicenseModelOverview.js';
+import {overviewEditorHeaders, selectedButton} from 'sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewConstants.js';
+
+import {LicenseModelOverviewFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
+import { EntitlementPoolStoreFactory as EntitlementPool, EntitlementPoolDataListFactory } from 'test-utils/factories/licenseModel/EntitlementPoolFactories.js';
+import { FeatureGroupStoreFactory as FeatureGroup, FeatureGroupDataListFactory} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js';
+import {LicenseAgreementStoreFactory as LicenseAgreement, LicenseAgreementDataListFactory} from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js';
+import { LicenseKeyGroupStoreFactory as LicenseKeyGroup, LicenseKeyGroupDataListFactory} from 'test-utils/factories/licenseModel/LicenseKeyGroupFactories.js';
+
+describe('License Model Overview: ', function () {
+
+ it('should mapper exist', () => {
+ expect(mapStateToProps).toBeTruthy();
+ });
+
+ const VLM1 = LicenseModelOverviewFactory.build();
+
+ it('should mapper return vlm overview basic data', () => {
+ const state = {
+ licenseModel: VLM1
+ };
+
+ var props = mapStateToProps(state);
+ expect(props.isReadOnlyMode).toEqual(true);
+ expect(props.isDisplayModal).toEqual(false);
+ expect(props.modalHeader).toEqual(undefined);
+ expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id);
+ expect(props.licensingDataList).toEqual([]);
+ expect(props.selectedTab).toEqual(selectedButton.VLM_LIST_VIEW);
+ });
+
+ it('should mapper return overview data for show LA modal', () => {
+ const VLM1 = LicenseModelOverviewFactory.build({
+ licenseAgreement: {
+ licenseAgreementEditor: {
+ data: LicenseAgreement.build()
+ }
+ }
+ });
+
+ var state = {
+ licenseModel: VLM1
+ };
+
+ var props = mapStateToProps(state);
+ expect(props.isReadOnlyMode).toEqual(true);
+ expect(props.isDisplayModal).toEqual(true);
+ expect(props.modalHeader).toEqual(overviewEditorHeaders.LICENSE_AGREEMENT);
+ expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id);
+ expect(props.licensingDataList).toEqual([]);
+ expect(props.selectedTab).toEqual(selectedButton.VLM_LIST_VIEW);
+ });
+
+ it('should mapper return overview data for show FG modal', () => {
+
+ const VLM1 = LicenseModelOverviewFactory.build({
+ featureGroup: {
+ featureGroupsList: [],
+ featureGroupEditor: {
+ data: FeatureGroup.build()
+ }
+ },
+ entitlementPool: {
+ entitlementPoolsList: []
+ },
+ licenseKeyGroup: {
+ licenseKeyGroupsList: []
+ },
+ licenseModelOverview: {
+ selectedTab: selectedButton.NOT_IN_USE
+ }
+ });
+
+ var state = {
+ licenseModel: VLM1
+ };
+
+ var props = mapStateToProps(state);
+ expect(props.isReadOnlyMode).toEqual(true);
+ expect(props.isDisplayModal).toEqual(true);
+ expect(props.modalHeader).toEqual(overviewEditorHeaders.FEATURE_GROUP);
+ expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id);
+ expect(props.licensingDataList).toEqual([]);
+ expect(props.selectedTab).toEqual(selectedButton.NOT_IN_USE);
+ });
+
+ it('should mapper return overview data for show EP modal', () => {
+ const VLM1 = LicenseModelOverviewFactory.build({
+ entitlementPool: {
+ entitlementPoolEditor: {
+ data: EntitlementPool.build()
+ }
+ }
+ });
+
+ var state = {
+ licenseModel: VLM1
+ };
+
+ var props = mapStateToProps(state);
+ expect(props.isReadOnlyMode).toEqual(true);
+ expect(props.isDisplayModal).toEqual(true);
+ expect(props.modalHeader).toEqual(overviewEditorHeaders.ENTITLEMENT_POOL);
+ expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id);
+ expect(props.licensingDataList).toEqual([]);
+ expect(props.selectedTab).toEqual(selectedButton.VLM_LIST_VIEW);
+ });
+
+ it('should mapper return overview data for show LKG modal', () => {
+ const VLM1 = LicenseModelOverviewFactory.build({
+ licenseKeyGroup: {
+ licenseKeyGroupsList: [],
+ licenseKeyGroupsEditor: {
+ data: LicenseKeyGroup.build()
+ }
+ },
+ entitlementPool: {
+ entitlementPoolsList: []
+ },
+ featureGroup: {
+ featureGroupsList: []
+ },
+ licenseModelOverview: {
+ selectedTab: selectedButton.NOT_IN_USE
+ }
+ });
+
+ var state = {
+ licenseModel: VLM1
+ };
+
+ var props = mapStateToProps(state);
+ expect(props.isReadOnlyMode).toEqual(true);
+ expect(props.isDisplayModal).toEqual(true);
+ expect(props.modalHeader).toEqual(overviewEditorHeaders.LICENSE_KEY_GROUP);
+ expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id);
+ expect(props.licensingDataList).toEqual([]);
+ expect(props.selectedTab).toEqual(selectedButton.NOT_IN_USE);
+ });
+
+ it('should mapper return overview data for Full-hierarchy list view', () => {
+ let EP1 = EntitlementPool.build();
+ let LKG1 = LicenseKeyGroup.build();
+ let FG1 = FeatureGroup.build({
+ entitlementPoolsIds: [EP1.id],
+ licenseKeyGroupsIds: [LKG1.id]
+ });
+ EP1.referencingFeatureGroups = [FG1.id];
+ LKG1.referencingFeatureGroups = [FG1.id];
+ let LA1 = LicenseAgreement.build({
+ featureGroupsIds: [FG1.id]
+ });
+ FG1.referencingLicenseAgreements = LA1.id;
+ let LA2 = LicenseAgreement.build();
+
+ const VLM1 = LicenseModelOverviewFactory.build({
+ licenseAgreement: {
+ licenseAgreementList: [LA1, LA2]
+ },
+ featureGroup: {
+ featureGroupsList: [FG1]
+ },
+ entitlementPool: {
+ entitlementPoolsList: [EP1]
+ },
+ licenseKeyGroup: {
+ licenseKeyGroupsList: [LKG1]
+ },
+ });
+
+ const state = {
+ licenseModel: VLM1
+ };
+
+ const expectedLicensingDataList = [
+ LicenseAgreementDataListFactory.build({
+ ...LA1,
+ children: [
+ FeatureGroupDataListFactory.build({
+ ...FG1,
+ children: [
+ EntitlementPoolDataListFactory.build(EP1),
+ LicenseKeyGroupDataListFactory.build(LKG1)
+ ]
+ })
+ ]
+ }),
+ LicenseAgreementDataListFactory.build(LA2)
+ ];
+
+ var props = mapStateToProps(state);
+
+ expect(props.isReadOnlyMode).toEqual(true);
+ expect(props.isDisplayModal).toEqual(false);
+ expect(props.modalHeader).toEqual(undefined);
+ expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id);
+ expect(props.licensingDataList).toEqual(expectedLicensingDataList);
+ expect(props.selectedTab).toEqual(selectedButton.VLM_LIST_VIEW);
+ });
+
+ it('should mapper return overview data for list view with 2 levels', () => {
+ let EP1 = EntitlementPool.build();
+ let LKG1 = LicenseKeyGroup.build();
+ let FG1 = FeatureGroup.build();
+ let LA1 = LicenseAgreement.build({
+ featureGroupsIds: [FG1.id]
+ });
+ let LA2 = LicenseAgreement.build();
+ FG1.referencingLicenseAgreements = [LA1.id];
+
+ const VLM1 = LicenseModelOverviewFactory.build({
+ licenseAgreement: {
+ licenseAgreementList: [LA1, LA2]
+ },
+ featureGroup: {
+ featureGroupsList: [FG1]
+ },
+ entitlementPool: {
+ entitlementPoolsList: [EP1]
+ },
+ licenseKeyGroup: {
+ licenseKeyGroupsList: [LKG1]
+ },
+ });
+
+ const state = {
+ licenseModel: VLM1
+ };
+
+ const expectedLicensingDataList = [
+ LicenseAgreementDataListFactory.build({
+ ...LA1,
+ children: [
+ FeatureGroupDataListFactory.build(FG1)
+ ]
+ }),
+ LicenseAgreementDataListFactory.build(LA2)
+ ];
+
+ var props = mapStateToProps(state);
+
+ expect(props.isReadOnlyMode).toEqual(true);
+ expect(props.isDisplayModal).toEqual(false);
+ expect(props.modalHeader).toEqual(undefined);
+ expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id);
+ expect(props.licensingDataList).toEqual(expectedLicensingDataList);
+ expect(props.selectedTab).toEqual(selectedButton.VLM_LIST_VIEW);
+ });
+
+ it('should mapper return overview data for Full NOT-IN-USE list view', () => {
+ let EP1 = EntitlementPool.build();
+ let LKG1 = LicenseKeyGroup.build();
+ let FG1 = FeatureGroup.build();
+
+ const VLM1 = LicenseModelOverviewFactory.build({
+ licenseAgreement: { licenseAgreementList: [] },
+ featureGroup: {
+ featureGroupsList: [FG1]
+ },
+ entitlementPool: {
+ entitlementPoolsList: [EP1]
+ },
+ licenseKeyGroup: {
+ licenseKeyGroupsList: [LKG1]
+ },
+ licenseModelOverview: {
+ selectedTab: selectedButton.NOT_IN_USE
+ }
+ });
+
+ const state = {
+ licenseModel: VLM1
+ };
+
+ const expectedLicensingDataList = [
+ FeatureGroupDataListFactory.build(FG1),
+ EntitlementPoolDataListFactory.build(EP1),
+ LicenseKeyGroupDataListFactory.build(LKG1)
+ ];
+
+ var props = mapStateToProps(state);
+
+ expect(props.isReadOnlyMode).toEqual(true);
+ expect(props.isDisplayModal).toEqual(false);
+ expect(props.modalHeader).toEqual(undefined);
+ expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id);
+ expect(props.licensingDataList).toEqual(expectedLicensingDataList);
+ expect(props.selectedTab).toEqual(selectedButton.NOT_IN_USE);
+ });
+
+ it('should mapper return overview data for NOT-IN-USE list view (FG with children)', () => {
+ let EP1 = EntitlementPool.build();
+ let LKG1 = LicenseKeyGroup.build();
+ let FG1 = FeatureGroup.build({
+ entitlementPoolsIds: [EP1.id],
+ licenseKeyGroupsIds: [LKG1.id]
+ });
+ EP1.referencingFeatureGroups = [FG1.id];
+ LKG1.referencingFeatureGroups = [FG1.id];
+
+ const VLM1 = LicenseModelOverviewFactory.build({
+ licenseAgreement: { licenseAgreementList: [] },
+ featureGroup: {
+ featureGroupsList: [FG1]
+ },
+ entitlementPool: {
+ entitlementPoolsList: [EP1]
+ },
+ licenseKeyGroup: {
+ licenseKeyGroupsList: [LKG1]
+ },
+ licenseModelOverview: {
+ selectedTab: selectedButton.NOT_IN_USE
+ }
+ });
+
+ const state = {
+ licenseModel: VLM1
+ };
+
+ const expectedLicensingDataList = [
+ FeatureGroupDataListFactory.build({
+ ...FG1,
+ children: [
+ EntitlementPoolDataListFactory.build(EP1),
+ LicenseKeyGroupDataListFactory.build(LKG1)]
+ })
+ ];
+
+ var props = mapStateToProps(state);
+
+ expect(props.isReadOnlyMode).toEqual(true);
+ expect(props.isDisplayModal).toEqual(false);
+ expect(props.modalHeader).toEqual(undefined);
+ expect(props.licenseModelId).toEqual(VLM1.licenseModelEditor.data.id);
+ expect(props.licensingDataList).toEqual(expectedLicensingDataList);
+ expect(props.selectedTab).toEqual(selectedButton.NOT_IN_USE);
+ });
+});
diff --git a/openecomp-ui/test/licenseModel/overview/views.test.js b/openecomp-ui/test/licenseModel/overview/views.test.js
new file mode 100644
index 0000000000..4a38afccca
--- /dev/null
+++ b/openecomp-ui/test/licenseModel/overview/views.test.js
@@ -0,0 +1,159 @@
+/*!
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import {scryRenderedDOMComponentsWithTestId} from 'test-utils/Util.js';
+import SummaryView from 'sdc-app/onboarding/licenseModel/overview/SummaryView.jsx';
+import LicenseModelOverviewView from 'sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewView.jsx';
+import VLMListView from 'sdc-app/onboarding/licenseModel/overview/VLMListView.jsx';
+import {selectedButton} from 'sdc-app/onboarding/licenseModel/overview/LicenseModelOverviewConstants.js';
+
+import {FeatureGroupListItemFactory} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js';
+import {EntitlementPoolListItemFactory} from 'test-utils/factories/licenseModel/EntitlementPoolFactories.js';
+import {LicenseKeyGroupListItemFactory} from 'test-utils/factories/licenseModel/LicenseKeyGroupFactories.js';
+import {LicenseAgreementListItemFactory} from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js';
+
+describe('License Model Overview - View: ', function () {
+
+ const lkgChild = LicenseKeyGroupListItemFactory.build();
+
+ const epChild = EntitlementPoolListItemFactory.build();
+
+ const baseFGData = FeatureGroupListItemFactory.build({isCollapsed: false});
+ const baseLAData = LicenseAgreementListItemFactory.build({isCollapse: false});
+
+ it('should render SummaryView', () => {
+ var renderer = TestUtils.createRenderer();
+ renderer.render(
+ <SummaryView />
+ );
+ let renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toBeTruthy();
+ });
+
+ it('should render LicenseModelOverviewView', () => {
+ let fgData = {...baseFGData};
+ fgData.children = Array.of(epChild, lkgChild);
+ let laData = {...baseLAData};
+ laData.children = [fgData];
+
+ const params = {
+ licenseModelId: 'VLM1',
+ isDisplayModal: false,
+ modalHeader: undefined,
+ licensingDataList: [laData],
+ selectedTab: selectedButton.VLM_LIST_VIEW,
+ onTabSelect: () => {}
+ };
+ var renderer = TestUtils.createRenderer();
+ renderer.render(
+ <LicenseModelOverviewView {...params}/>
+ );
+ let renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toBeTruthy();
+ });
+
+
+ it('should render empty VLMListView', () => {
+ const listview = TestUtils.renderIntoDocument( <VLMListView /> );
+ expect(listview).toBeTruthy();
+ const elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list');
+ expect(elem).toBeTruthy();
+ expect(elem[0].children.length).toBe(0);
+ });
+
+ it('should render VLMListView with licenseAgreement', () => {
+ const listview = TestUtils.renderIntoDocument( <VLMListView licensingDataList={[baseLAData]}/> );
+ expect(listview).toBeTruthy();
+ let elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list');
+ expect(elem).toBeTruthy();
+ expect(elem[0].children.length).toBe(1);
+ elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-la-item');
+ expect(elem).toBeTruthy();
+ expect(elem.length).toBe(1);
+ });
+
+ it('should render VLMListView with Feature Group', () => {
+ let laData = {...baseLAData};
+ laData.children = [baseFGData];
+ const listview = TestUtils.renderIntoDocument( <VLMListView licensingDataList={[laData]}/> );
+ expect(listview).toBeTruthy();
+ const elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-fg');
+ expect(elem).toBeTruthy();
+ expect(elem.length).toBe(1);
+ });
+
+ it('should render VLMListView with Entitlement Pool', () => {
+ let fgData = {...baseFGData};
+ fgData.children = [epChild];
+ let laData = {...baseLAData};
+ laData.children = [fgData];
+
+ const listview = TestUtils.renderIntoDocument( <VLMListView licensingDataList={[laData]} showInUse={true} /> );
+ expect(listview).toBeTruthy();
+ const elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-ep');
+ expect(elem).toBeTruthy();
+ expect(elem.length).toBe(1);
+ });
+
+ it('should render VLMListView with LicenseKeyGroup', () => {
+ let fgData = {...baseFGData};
+ fgData.children = [lkgChild];
+ let laData = {...baseLAData};
+ laData.children = [fgData];
+
+ const listview = TestUtils.renderIntoDocument( <VLMListView licensingDataList={[laData]} showInUse={true} /> );
+ expect(listview).toBeTruthy();
+ const elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-lkg');
+ expect(elem).toBeTruthy();
+ expect(elem.length).toBe(1);
+ });
+
+ it('should render VLMListView with all items', () => {
+ let fgData = {...baseFGData};
+ fgData.children = Array.of(epChild, lkgChild);
+ let laData = {...baseLAData};
+ laData.children = [fgData];
+
+ const listview = TestUtils.renderIntoDocument( <VLMListView licensingDataList={[laData]} showInUse={true} /> );
+ expect(listview).toBeTruthy();
+ let elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-fg');
+ expect(elem).toBeTruthy();
+ expect(elem.length).toBe(1);
+ elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-lkg');
+ expect(elem).toBeTruthy();
+ expect(elem.length).toBe(1);
+ elem = scryRenderedDOMComponentsWithTestId(listview,'vlm-list-item-ep');
+ expect(elem).toBeTruthy();
+ expect(elem.length).toBe(1);
+ });
+
+ it('should update collapsing item', () => {
+ let fgData = {...baseFGData};
+ fgData.children = Array.of(epChild, lkgChild);
+ let laData = {...baseLAData};
+ laData.children = [fgData];
+
+ var renderer = TestUtils.renderIntoDocument(
+ <VLMListView licensingDataList={[laData]} showInUse={true}/>
+ );
+ expect(renderer).toBeTruthy();
+
+ renderer.updateCollapsable(new Event('click'), 'LA1');
+ expect(renderer.state['LA1']).toEqual(true);
+ });
+});
diff --git a/openecomp-ui/test/licenseModel/test.js b/openecomp-ui/test/licenseModel/test.js
index c21d18f146..eac1297f3e 100644
--- a/openecomp-ui/test/licenseModel/test.js
+++ b/openecomp-ui/test/licenseModel/test.js
@@ -1,57 +1,40 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-
-import {expect} from 'chai';
import deepFreeze from 'deep-freeze';
import mockRest from 'test-utils/MockRest.js';
-import {cloneAndSet} from 'test-utils/Util.js';
import {storeCreator} from 'sdc-app/AppStore.js';
import LicenseModelCreationActionHelper from 'sdc-app/onboarding/licenseModel/creation/LicenseModelCreationActionHelper.js';
+import {LicenseModelPostFactory, LicenseModelDispatchFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
+
describe('License Model Module Tests', function () {
it('Add License Model', () => {
const store = storeCreator();
deepFreeze(store.getState());
- const licenseModelPostRequest = deepFreeze({
- vendorName: 'vlm1',
- description: 'string',
- iconRef: 'icon'
- });
+ const licenseModelPostRequest = LicenseModelPostFactory.build();
- const licenseModelToAdd = deepFreeze({
- ...licenseModelPostRequest
- });
+ const licenseModelToAdd = LicenseModelDispatchFactory.build();
const licenseModelIdFromResponse = 'ADDED_ID';
- const licenseModelAfterAdd = deepFreeze({
- ...licenseModelToAdd,
- id: licenseModelIdFromResponse
- });
-
- const expectedStore = cloneAndSet(store.getState(), 'licenseModelList', [licenseModelAfterAdd]);
-
- mockRest.addHandler('create', ({options, data, baseUrl}) => {
- expect(baseUrl).to.equal('/onboarding-api/v1.0/vendor-license-models/');
- expect(data).to.deep.equal(licenseModelPostRequest);
- expect(options).to.equal(undefined);
+
+ mockRest.addHandler('post', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual('/onboarding-api/v1.0/vendor-license-models/');
+ expect(data).toEqual(licenseModelPostRequest);
+ expect(options).toEqual(undefined);
return {
value: licenseModelIdFromResponse
};
@@ -59,8 +42,8 @@ describe('License Model Module Tests', function () {
return LicenseModelCreationActionHelper.createLicenseModel(store.dispatch, {
licenseModel: licenseModelToAdd
- }).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ }).then((response) => {
+ expect(response.value).toEqual(licenseModelIdFromResponse);
});
});
});
diff --git a/openecomp-ui/test/nfvo-components/SubmitErrorResponse.test.js b/openecomp-ui/test/nfvo-components/SubmitErrorResponse.test.js
new file mode 100644
index 0000000000..7231fe4abc
--- /dev/null
+++ b/openecomp-ui/test/nfvo-components/SubmitErrorResponse.test.js
@@ -0,0 +1,33 @@
+/*!
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+
+import SubmitErrorResponse from 'nfvo-components/SubmitErrorResponse.jsx';
+import {SubmitErrorMessageFactory} from 'test-utils/factories/SubnitErrorMessageFactorie.js';
+
+describe('SubmitErrorResponse test: ', function () {
+ it('basic render test', () => {
+ let props = {
+ validationResponse: SubmitErrorMessageFactory.build()
+ };
+
+ let view = TestUtils.renderIntoDocument(<SubmitErrorResponse {...props} />);
+ expect(view).toBeTruthy();
+ });
+});
diff --git a/openecomp-ui/test/nfvo-components/__snapshots__/storyshots.test.js.snap b/openecomp-ui/test/nfvo-components/__snapshots__/storyshots.test.js.snap
new file mode 100644
index 0000000000..f7df9763da
--- /dev/null
+++ b/openecomp-ui/test/nfvo-components/__snapshots__/storyshots.test.js.snap
@@ -0,0 +1,686 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`Storyshots ListEditor regular 1`] = `
+<div
+ className="list-editor-view"
+>
+ <div
+ className="list-editor-view-header"
+ >
+ <div
+ className="list-editor-view-title"
+ >
+ List Editor
+ </div>
+ <div
+ className="list-editor-view-add-controller"
+ />
+ </div>
+ <div
+ className="list-editor-view-list-scroller"
+ >
+ <div
+ className="list-editor-view-list"
+ >
+ <div
+ className="list-editor-item-view"
+ data-test-id="list-editor-item"
+ >
+ <div
+ className="list-editor-item-view-content"
+ onClick={undefined}
+ >
+ <div
+ className="list-editor-item-view-field"
+ >
+ <div>
+ Lorum Ipsum
+ </div>
+ </div>
+ <div
+ className="list-editor-item-view-field"
+ >
+ <div>
+ Lorum Ipsum
+ </div>
+ </div>
+ </div>
+ </div>
+ <div
+ className="list-editor-item-view"
+ data-test-id="list-editor-item"
+ >
+ <div
+ className="list-editor-item-view-content"
+ onClick={undefined}
+ >
+ <div
+ className="list-editor-item-view-field"
+ >
+ <div>
+ Lorum Ipsum
+ </div>
+ </div>
+ <div
+ className="list-editor-item-view-field"
+ >
+ <div>
+ Lorum Ipsum
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+</div>
+`;
+
+exports[`Storyshots ListEditor two columns 1`] = `
+<div
+ className="list-editor-view"
+>
+ <div
+ className="list-editor-view-header"
+ >
+ <div
+ className="list-editor-view-title"
+ >
+ List Editor
+ </div>
+ <div
+ className="list-editor-view-add-controller"
+ />
+ </div>
+ <div
+ className="list-editor-view-list-scroller"
+ >
+ <div
+ className="list-editor-view-list two-columns"
+ >
+ <div
+ className="list-editor-item-view"
+ data-test-id="list-editor-item"
+ >
+ <div
+ className="list-editor-item-view-content"
+ onClick={undefined}
+ >
+ <div
+ className="list-editor-item-view-field"
+ >
+ <div>
+ Lorum Ipsum
+ </div>
+ </div>
+ <div
+ className="list-editor-item-view-field"
+ >
+ <div>
+ Lorum Ipsum
+ </div>
+ </div>
+ </div>
+ </div>
+ <div
+ className="list-editor-item-view"
+ data-test-id="list-editor-item"
+ >
+ <div
+ className="list-editor-item-view-content"
+ onClick={undefined}
+ >
+ <div
+ className="list-editor-item-view-field"
+ >
+ <div>
+ Lorum Ipsum
+ </div>
+ </div>
+ <div
+ className="list-editor-item-view-field"
+ >
+ <div>
+ Lorum Ipsum
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+</div>
+`;
+
+exports[`Storyshots ListEditor with add 1`] = `
+<div
+ className="list-editor-view"
+>
+ <div
+ className="list-editor-view-header"
+ >
+ <div
+ className="list-editor-view-title"
+ >
+ List Editor
+ </div>
+ <div
+ className="list-editor-view-add-controller"
+ >
+ <div
+ className="list-editor-view-add-title"
+ data-test-id="add-button"
+ onClick={[Function]}
+ >
+ <span>
+ + Add
+ </span>
+ </div>
+ </div>
+ </div>
+ <div
+ className="list-editor-view-list-scroller"
+ >
+ <div
+ className="list-editor-view-list two-columns"
+ >
+ <div
+ className="list-editor-item-view"
+ data-test-id="list-editor-item"
+ >
+ <div
+ className="list-editor-item-view-content"
+ onClick={undefined}
+ >
+ <div
+ className="list-editor-item-view-field"
+ >
+ <div>
+ Lorum Ipsum
+ </div>
+ </div>
+ <div
+ className="list-editor-item-view-field"
+ >
+ <div>
+ Lorum Ipsum
+ </div>
+ </div>
+ </div>
+ </div>
+ <div
+ className="list-editor-item-view"
+ data-test-id="list-editor-item"
+ >
+ <div
+ className="list-editor-item-view-content"
+ onClick={undefined}
+ >
+ <div
+ className="list-editor-item-view-field"
+ >
+ <div>
+ Lorum Ipsum
+ </div>
+ </div>
+ <div
+ className="list-editor-item-view-field"
+ >
+ <div>
+ Lorum Ipsum
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+</div>
+`;
+
+exports[`Storyshots ListEditor with delete 1`] = `
+<div
+ className="list-editor-view"
+>
+ <div
+ className="list-editor-view-header"
+ >
+ <div
+ className="list-editor-view-title"
+ >
+ List Editor
+ </div>
+ <div
+ className="list-editor-view-add-controller"
+ >
+ <div
+ className="list-editor-view-add-title"
+ data-test-id="add-button"
+ onClick={[Function]}
+ >
+ <span>
+ + Add
+ </span>
+ </div>
+ </div>
+ </div>
+ <div
+ className="list-editor-view-list-scroller"
+ >
+ <div
+ className="list-editor-view-list two-columns"
+ >
+ <div
+ className="list-editor-item-view"
+ data-test-id="list-editor-item"
+ >
+ <div
+ className="list-editor-item-view-content"
+ onClick={undefined}
+ >
+ <div
+ className="list-editor-item-view-field"
+ >
+ <div>
+ Lorum Ipsum
+ </div>
+ </div>
+ <div
+ className="list-editor-item-view-field"
+ >
+ <div>
+ Lorum Ipsum
+ </div>
+ </div>
+ </div>
+ <div
+ className="list-editor-item-view-controller"
+ >
+ <div
+ className="svg-icon-wrapper clickable bottom"
+ onClick={[Function]}
+ >
+ <svg
+ className="svg-icon trash-o "
+ >
+ <use
+ xlinkHref="test-file-stub"
+ />
+ </svg>
+
+ </div>
+ </div>
+ </div>
+ <div
+ className="list-editor-item-view"
+ data-test-id="list-editor-item"
+ >
+ <div
+ className="list-editor-item-view-content"
+ onClick={undefined}
+ >
+ <div
+ className="list-editor-item-view-field"
+ >
+ <div>
+ Lorum Ipsum
+ </div>
+ </div>
+ <div
+ className="list-editor-item-view-field"
+ >
+ <div>
+ Lorum Ipsum
+ </div>
+ </div>
+ </div>
+ <div
+ className="list-editor-item-view-controller"
+ >
+ <div
+ className="svg-icon-wrapper clickable bottom"
+ onClick={[Function]}
+ >
+ <svg
+ className="svg-icon trash-o "
+ >
+ <use
+ xlinkHref="test-file-stub"
+ />
+ </svg>
+
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+</div>
+`;
+
+exports[`Storyshots ListEditor with edit 1`] = `
+<div
+ className="list-editor-view"
+>
+ <div
+ className="list-editor-view-header"
+ >
+ <div
+ className="list-editor-view-title"
+ >
+ List Editor
+ </div>
+ <div
+ className="list-editor-view-add-controller"
+ >
+ <div
+ className="list-editor-view-add-title"
+ data-test-id="add-button"
+ onClick={[Function]}
+ >
+ <span>
+ + Add
+ </span>
+ </div>
+ </div>
+ </div>
+ <div
+ className="list-editor-view-list-scroller"
+ >
+ <div
+ className="list-editor-view-list two-columns"
+ >
+ <div
+ className="list-editor-item-view"
+ data-test-id="list-editor-item"
+ >
+ <div
+ className="list-editor-item-view-content"
+ onClick={undefined}
+ >
+ <div
+ className="list-editor-item-view-field"
+ >
+ <div>
+ Lorum Ipsum
+ </div>
+ </div>
+ <div
+ className="list-editor-item-view-field"
+ >
+ <div>
+ Lorum Ipsum
+ </div>
+ </div>
+ </div>
+ <div
+ className="list-editor-item-view-controller"
+ >
+ <div
+ className="svg-icon-wrapper clickable bottom"
+ onClick={[Function]}
+ >
+ <svg
+ className="svg-icon sliders "
+ >
+ <use
+ xlinkHref="test-file-stub"
+ />
+ </svg>
+
+ </div>
+ </div>
+ </div>
+ <div
+ className="list-editor-item-view"
+ data-test-id="list-editor-item"
+ >
+ <div
+ className="list-editor-item-view-content"
+ onClick={undefined}
+ >
+ <div
+ className="list-editor-item-view-field"
+ >
+ <div>
+ Lorum Ipsum
+ </div>
+ </div>
+ <div
+ className="list-editor-item-view-field"
+ >
+ <div>
+ Lorum Ipsum
+ </div>
+ </div>
+ </div>
+ <div
+ className="list-editor-item-view-controller"
+ >
+ <div
+ className="svg-icon-wrapper clickable bottom"
+ onClick={[Function]}
+ >
+ <svg
+ className="svg-icon sliders "
+ >
+ <use
+ xlinkHref="test-file-stub"
+ />
+ </svg>
+
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+</div>
+`;
+
+exports[`Storyshots ListEditor with edit and delete 1`] = `
+<div
+ className="list-editor-view"
+>
+ <div
+ className="list-editor-view-header"
+ >
+ <div
+ className="list-editor-view-title"
+ >
+ List Editor
+ </div>
+ <div
+ className="list-editor-view-add-controller"
+ >
+ <div
+ className="list-editor-view-add-title"
+ data-test-id="add-button"
+ onClick={[Function]}
+ >
+ <span>
+ + Add
+ </span>
+ </div>
+ </div>
+ </div>
+ <div
+ className="list-editor-view-list-scroller"
+ >
+ <div
+ className="list-editor-view-list two-columns"
+ >
+ <div
+ className="list-editor-item-view"
+ data-test-id="list-editor-item"
+ >
+ <div
+ className="list-editor-item-view-content"
+ onClick={undefined}
+ >
+ <div
+ className="list-editor-item-view-field"
+ >
+ <div>
+ Lorum Ipsum
+ </div>
+ </div>
+ <div
+ className="list-editor-item-view-field"
+ >
+ <div>
+ Lorum Ipsum
+ </div>
+ </div>
+ </div>
+ <div
+ className="list-editor-item-view-controller"
+ >
+ <div
+ className="svg-icon-wrapper clickable bottom"
+ onClick={[Function]}
+ >
+ <svg
+ className="svg-icon sliders "
+ >
+ <use
+ xlinkHref="test-file-stub"
+ />
+ </svg>
+
+ </div>
+ <div
+ className="svg-icon-wrapper clickable bottom"
+ onClick={[Function]}
+ >
+ <svg
+ className="svg-icon trash-o "
+ >
+ <use
+ xlinkHref="test-file-stub"
+ />
+ </svg>
+
+ </div>
+ </div>
+ </div>
+ <div
+ className="list-editor-item-view"
+ data-test-id="list-editor-item"
+ >
+ <div
+ className="list-editor-item-view-content"
+ onClick={undefined}
+ >
+ <div
+ className="list-editor-item-view-field"
+ >
+ <div>
+ Lorum Ipsum
+ </div>
+ </div>
+ <div
+ className="list-editor-item-view-field"
+ >
+ <div>
+ Lorum Ipsum
+ </div>
+ </div>
+ </div>
+ <div
+ className="list-editor-item-view-controller"
+ >
+ <div
+ className="svg-icon-wrapper clickable bottom"
+ onClick={[Function]}
+ >
+ <svg
+ className="svg-icon sliders "
+ >
+ <use
+ xlinkHref="test-file-stub"
+ />
+ </svg>
+
+ </div>
+ <div
+ className="svg-icon-wrapper clickable bottom"
+ onClick={[Function]}
+ >
+ <svg
+ className="svg-icon trash-o "
+ >
+ <use
+ xlinkHref="test-file-stub"
+ />
+ </svg>
+
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+</div>
+`;
+
+exports[`Storyshots SVGIcon icon 1`] = `
+<div
+ className="svg-icon-wrapper bottom"
+ onClick={undefined}
+ style={
+ Object {
+ "fill": "",
+ }
+ }
+>
+ <svg
+ className="svg-icon locked "
+ >
+ <use
+ xlinkHref="test-file-stub"
+ />
+ </svg>
+
+</div>
+`;
+
+exports[`Storyshots SVGIcon icon with label 1`] = `
+<div
+ className="svg-icon-wrapper bottom"
+ onClick={undefined}
+ style={
+ Object {
+ "fill": "",
+ }
+ }
+>
+ <svg
+ className="svg-icon locked "
+ >
+ <use
+ xlinkHref="test-file-stub"
+ />
+ </svg>
+ <span
+ className="svg-icon-label "
+ >
+ locked
+ </span>
+</div>
+`;
+
+exports[`Storyshots SVGIcon locked clickable 1`] = `
+<div
+ className="svg-icon-wrapper clickable bottom"
+ onClick={[Function]}
+ style={
+ Object {
+ "fill": "",
+ }
+ }
+>
+ <svg
+ className="svg-icon locked "
+ >
+ <use
+ xlinkHref="test-file-stub"
+ />
+ </svg>
+
+</div>
+`;
diff --git a/openecomp-ui/test/nfvo-components/activity-log/ActivityLog.test.js b/openecomp-ui/test/nfvo-components/activity-log/ActivityLog.test.js
new file mode 100644
index 0000000000..2f377a3539
--- /dev/null
+++ b/openecomp-ui/test/nfvo-components/activity-log/ActivityLog.test.js
@@ -0,0 +1,89 @@
+/*!
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+import React from 'react';
+import {mount} from 'enzyme';
+import {cloneAndSet} from 'test-utils/Util.js';
+import ActivityLogView, {ActivityListItem} from 'nfvo-components/activity-log/ActivityLogView.jsx';
+import ListEditorView from 'nfvo-components/listEditor/ListEditorView.jsx';
+import ActivityLogActionHelper from 'nfvo-components/activity-log/ActivityLogActionHelper.js';
+import {mapStateToProps} from 'nfvo-components/activity-log/ActivityLog.js';
+import {storeCreator} from 'sdc-app/AppStore.js';
+import mockRest from 'test-utils/MockRest.js';
+import {ActivityLogStoreFactory} from 'test-utils/factories/activity-log/ActivityLogFactories.js';
+import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
+
+describe('Activity Log Module Tests', function () {
+ const LICENSE_MODEL_ID = '555';
+ const version = VersionControllerUtilsFactory.build().version;
+
+ it('mapStateToProps mapper exists', () => {
+ expect(mapStateToProps).toBeTruthy();
+ });
+
+ it('Loads Activity Log and renders into jsx', () => {
+ const store = storeCreator();
+ const dispatch = store.dispatch;
+ let ActivityLogList = ActivityLogStoreFactory.buildList(1);
+ const expectedStore = cloneAndSet(store.getState(), 'licenseModel.activityLog', ActivityLogList);
+
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/activity-logs/${LICENSE_MODEL_ID}/versions/${version.id}`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: ActivityLogList};
+ });
+
+ return ActivityLogActionHelper.fetchActivityLog(dispatch, {itemId: LICENSE_MODEL_ID, versionId: version.id}).then(() => {
+ const state = store.getState();
+ expect(state).toEqual(expectedStore);
+ const props = mapStateToProps(state);
+ expect(props.activities).toEqual(ActivityLogList);
+ const wrapper = mount(<ActivityLogView {...props}/>);
+ expect(wrapper).toBeTruthy();
+ });
+ });
+
+ it('Tests Activity Log filter and sorting abilities', () => {
+ const firstDate = new Date();
+ const secondDate = new Date();
+ secondDate.setDate(firstDate.getDate() - 1);
+
+ const firstTimestamp = firstDate.getTime();
+ const secondTimestamp = secondDate.getTime();
+
+ let firstActivity = ActivityLogStoreFactory.build({user: 'first', timestamp: firstTimestamp});
+ let secondActivity = ActivityLogStoreFactory.build({user: 'second', timestamp: secondTimestamp, status: {success: false, message: 'error'}});
+ let props = mapStateToProps({licenseModel: {activityLog: [firstActivity, secondActivity]}});
+ const wrapper = mount(<ActivityLogView {...props}/>);
+ expect(wrapper.find(ActivityListItem).length).toEqual(3); // Includes Header component
+
+ const firstInstance = wrapper.find(ActivityListItem).at(1);
+ const firstInstanceProps = firstInstance.props();
+ expect(firstInstanceProps.activity.timestamp).toEqual(secondTimestamp); // Default sorting is descending
+
+ const header = wrapper.find(ActivityListItem).at(0);
+ header.props().onSort();
+ const newFirstInstance = wrapper.find(ActivityListItem).at(1);
+ const newFirstInstanceProps = newFirstInstance.props();
+ expect(newFirstInstanceProps.activity.timestamp).toEqual(firstTimestamp);
+
+ const listEditor = wrapper.find(ListEditorView);
+ listEditor.props().onFilter('second');
+ expect(wrapper.find(ActivityListItem).length).toEqual(2);
+ expect(wrapper.find(ActivityListItem).at(1).props().activity.user).toEqual('second');
+ });
+});
diff --git a/openecomp-ui/test/nfvo-components/editor/TabulatedEditor.test.js b/openecomp-ui/test/nfvo-components/editor/TabulatedEditor.test.js
new file mode 100644
index 0000000000..e61261e09a
--- /dev/null
+++ b/openecomp-ui/test/nfvo-components/editor/TabulatedEditor.test.js
@@ -0,0 +1,52 @@
+/*!
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import TabulatedEditor from 'nfvo-components/editor/TabulatedEditor.jsx';
+
+describe('Tabulated Editor test: ', function () {
+
+ it('basic view test', () => {
+ let renderer = TestUtils.createRenderer();
+ renderer.render(
+ <TabulatedEditor><button>test</button></TabulatedEditor>
+ );
+ let renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toBeTruthy();
+
+ });
+
+ it('handle func test', () => {
+ let props = {
+ navigationBarProps: {
+ groups: [],
+ onNavigationItemClick: ()=>{}
+ },
+ versionControllerProps: {
+ isCheckedOut: false,
+ version: {id: '0.1', label: '0.1'},
+ viewableVersions: [{id: '0.1', label: '0.1'}],
+ onSubmit: ()=>{},
+ onRevert: ()=>{}
+ }
+ };
+ const view = TestUtils.renderIntoDocument(<TabulatedEditor {...props}><button>test</button></TabulatedEditor>);
+ expect(view).toBeTruthy();
+ });
+
+});
diff --git a/openecomp-ui/test/nfvo-components/input/dualListBox/dualListbox.test.js b/openecomp-ui/test/nfvo-components/input/dualListBox/dualListbox.test.js
index eaa06eedf4..c578178d35 100644
--- a/openecomp-ui/test/nfvo-components/input/dualListBox/dualListbox.test.js
+++ b/openecomp-ui/test/nfvo-components/input/dualListBox/dualListbox.test.js
@@ -1,24 +1,19 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-import expect from 'expect';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import DualListboxView from 'nfvo-components/input/dualListbox/DualListboxView.jsx';
@@ -32,42 +27,62 @@ describe('dualListBox Module Tests', function () {
var renderer = TestUtils.createRenderer();
renderer.render(<DualListboxView onChange={()=>{}}/>);
var renderedOutput = renderer.getRenderOutput();
- expect(renderedOutput).toExist();
+ expect(renderedOutput).toBeTruthy();
});
it('should render with available list and 4 control buttons', () => {
var view = TestUtils.renderIntoDocument(<DualListboxView availableList={ITEMS} onChange={()=>{}}/>);
- expect(view).toExist();
+ expect(view).toBeTruthy();
var results = TestUtils.scryRenderedDOMComponentsWithClass(view, 'dual-list-option');
expect(results.length).toBe(4);
});
it('should add item to selected list', done => {
- const newItemValue = 'new item';
- let onChange = (value)=> {
- expect(value).toEqual(newItemValue);
+ const onChange = (values)=> {
+ expect(values).toEqual([ITEMS[2].id, ITEMS[0].id]);
done();
};
- var view = new DualListboxView({availableList:ITEMS, onChange, selectedValuesList:[]});
- expect(view).toExist();
- view.refs = {
- availableValues: {getValue(){return newItemValue;}}
- };
- view.addToSelectedList();
+ const document = TestUtils.renderIntoDocument(
+ <DualListboxView
+ availableList={ITEMS}
+ onChange={onChange}
+ selectedValuesList={[ITEMS[2].id]}/>);
+
+ const result = TestUtils.scryRenderedDOMComponentsWithTag(document, 'select');
+ const options = TestUtils.scryRenderedDOMComponentsWithTag(document, 'option');
+ const listBox = TestUtils.findRenderedComponentWithType(document, DualListboxView);
+ expect(result).toBeTruthy();
+ expect(options).toBeTruthy();
+ expect(listBox).toBeTruthy();
+
+ TestUtils.Simulate.change(result[0], {target: {selectedOptions: [options[0]]}});
+ expect(listBox.state.selectedValues).toEqual([ITEMS[0].id]);
+
+ listBox.addToSelectedList();
});
it('should remove item from selected list', done => {
- const selectedValuesList = ['a','b'];
- let onChange = (value)=> {
- expect(value).toEqual(selectedValuesList[1]);
+ const onChange = (values)=> {
+ expect(values).toEqual([ITEMS[0].id]);
done();
};
- var view = new DualListboxView({availableList:ITEMS, onChange, selectedValuesList});
- expect(view).toExist();
- view.refs = {
- selectedValues: {getValue(){return ['a'];}}
- };
- view.removeFromSelectedList();
+ const document = TestUtils.renderIntoDocument(
+ <DualListboxView
+ availableList={ITEMS}
+ onChange={onChange}
+ selectedValuesList={[ITEMS[0].id, ITEMS[1].id]}/>);
+
+ const result = TestUtils.scryRenderedDOMComponentsWithTag(document, 'select');
+ const options = TestUtils.scryRenderedDOMComponentsWithTag(document, 'option');
+ const listBox = TestUtils.findRenderedComponentWithType(document, DualListboxView);
+ expect(result).toBeTruthy();
+ expect(options).toBeTruthy();
+ expect(listBox).toBeTruthy();
+
+ TestUtils.Simulate.change(result[1], {target: {selectedOptions: [options[2]]}});
+ expect(listBox.state.selectedValues).toEqual([ITEMS[1].id]);
+
+ listBox.removeFromSelectedList();
});
it('should add all items to selected list', done => {
@@ -76,7 +91,7 @@ describe('dualListBox Module Tests', function () {
done();
};
var view = new DualListboxView({availableList:ITEMS, onChange, selectedValuesList:[]});
- expect(view).toExist();
+ expect(view).toBeTruthy();
view.addAllToSelectedList();
});
@@ -86,7 +101,7 @@ describe('dualListBox Module Tests', function () {
done();
};
var view = new DualListboxView({availableList:ITEMS, onChange, selectedValuesList:[]});
- expect(view).toExist();
+ expect(view).toBeTruthy();
view.removeAllFromSelectedList();
});
diff --git a/openecomp-ui/test/nfvo-components/input/validation/input.test.js b/openecomp-ui/test/nfvo-components/input/validation/input.test.js
new file mode 100644
index 0000000000..7743483603
--- /dev/null
+++ b/openecomp-ui/test/nfvo-components/input/validation/input.test.js
@@ -0,0 +1,141 @@
+/*!
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import {scryRenderedDOMComponentsWithTestId} from 'test-utils/Util.js';
+import Input from 'nfvo-components/input/validation/Input.jsx';
+import Overlay from 'react-bootstrap/lib/Overlay.js';
+
+describe('Input', function () {
+ it('should render with type text', () => {
+ let renderedOutput = TestUtils.renderIntoDocument(<Input type='text' data-test-id='mytest' />);
+ const elem = scryRenderedDOMComponentsWithTestId(renderedOutput,'mytest');
+ expect(elem).toBeTruthy();
+ expect(elem.length).toBe(1);
+ expect(elem[0].type).toBe('text');
+ });
+
+ it('should render with type textarea', () => {
+ let renderedOutput = TestUtils.renderIntoDocument(<Input type='textarea' data-test-id='mytest' />);
+ const elem = scryRenderedDOMComponentsWithTestId(renderedOutput,'mytest');
+ expect(elem).toBeTruthy();
+ expect(elem.length).toBe(1);
+ expect(elem[0].tagName.toLowerCase()).toBe('textarea');
+ });
+
+ it('should render with type radio', () => {
+ let renderedOutput = TestUtils.renderIntoDocument(<Input type='radio' data-test-id='mytest' />);
+ const elem = scryRenderedDOMComponentsWithTestId(renderedOutput,'mytest');
+ expect(elem).toBeTruthy();
+ expect(elem.length).toBe(1);
+ expect(elem[0].type).toBe('radio');
+ });
+
+ it('should render with type select', () => {
+ let renderedOutput = TestUtils.renderIntoDocument(<Input type='select' data-test-id='mytest' />);
+ const elem = scryRenderedDOMComponentsWithTestId(renderedOutput,'mytest');
+ expect(elem).toBeTruthy();
+ expect(elem.length).toBe(1);
+ expect(elem[0].tagName.toLowerCase()).toBe('select');
+ });
+
+ it('should render with type number', () => {
+ let renderedOutput = TestUtils.renderIntoDocument(<Input type='number' data-test-id='mytest' />);
+ const elem = scryRenderedDOMComponentsWithTestId(renderedOutput,'mytest');
+ expect(elem).toBeTruthy();
+ expect(elem.length).toBe(1);
+ expect(elem[0].tagName.toLowerCase()).toBe('input');
+ expect(elem[0].type).toBe('number');
+ });
+
+ it('should render with type checkbox', () => {
+ let renderedOutput = TestUtils.renderIntoDocument(<Input type='checkbox' data-test-id='mytest' />);
+ const elem = scryRenderedDOMComponentsWithTestId(renderedOutput,'mytest');
+ expect(elem).toBeTruthy();
+ expect(elem.length).toBe(1);
+ expect(elem[0].tagName.toLowerCase()).toBe('input');
+ expect(elem[0].type).toBe('checkbox');
+ });
+
+ it('should render error overlay when invalid', () => {
+ let renderedOutput = TestUtils.renderIntoDocument(<Input type='text' data-test-id='mytest' isValid={false} errorText='this is an error'/>);
+ const elem = TestUtils.findRenderedComponentWithType(renderedOutput,Overlay);
+ expect(elem).toBeTruthy();
+ expect(elem.props.show).toBe(true);
+ });
+
+ it('should not render error overlay when valid', () => {
+ let renderedOutput = TestUtils.renderIntoDocument(<Input type='text' data-test-id='mytest' isValid={true} errorText='this is an error'/>);
+ const elem = TestUtils.findRenderedComponentWithType(renderedOutput,Overlay);
+ expect(elem).toBeTruthy();
+ expect(elem.props.show).toBe(false);
+ });
+
+ /*it('should return the value of a select', () => {
+
+ });
+
+ it('should return the value of a checkbox', () => {
+
+ });
+
+ it('should return the value of a radio', () => {
+
+ });
+
+ it('should return the value of a text', () => {
+
+ });
+
+ it('should return the value of a textarea', () => {
+
+ });*/
+
+ /*it('should render and work as a group', () => {
+ let MockComp = React.createClass({
+ render: function() {
+ return (<div>
+ <Input type='radio' data-test-id='mytest' name='g1' value='0'/><Input type='radio' data-test-id='mytest1' name='g1' value='1' />
+ </div>);
+ }
+ });
+ let renderedOutput = TestUtils.renderIntoDocument(<MockComp />);
+ const radio1 = scryRenderedDOMComponentsWithTestId(renderedOutput,'mytest');
+ expect(radio1).toBeTruthy();
+ expect(radio1.length).toBe(1);
+ expect(radio1[0].type).toBe('radio');
+ expect(radio1[0].value).toBe('0');
+ const radio2 = scryRenderedDOMComponentsWithTestId(renderedOutput,'mytest1');
+ expect(radio2).toBeTruthy();
+ expect(radio2.length).toBe(1);
+ expect(radio2[0].type).toBe('radio');
+ expect(radio2[0].value).toBe('1');
+ TestUtils.Simulate.click(
+ radio2[0]
+ );
+ TestUtils.Simulate.click(
+ radio1[0]
+ );
+ console.log('radio1: ' + radio1[0].checked);
+ console.log('radio2: ' + radio2[0].checked);
+ expect(radio2[0].checked).toBe(false);
+ expect(radio1[0].checked).toBe(true);
+
+
+ });*/
+
+});
diff --git a/openecomp-ui/test/nfvo-components/listEditor/listEditor.test.js b/openecomp-ui/test/nfvo-components/listEditor/listEditor.test.js
index a3b098f611..c1f823c3fc 100644
--- a/openecomp-ui/test/nfvo-components/listEditor/listEditor.test.js
+++ b/openecomp-ui/test/nfvo-components/listEditor/listEditor.test.js
@@ -1,25 +1,21 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-import expect from 'expect';
import React from 'react';
+import {mount} from 'enzyme';
import TestUtils from 'react-addons-test-utils';
import ListEditorView from 'src/nfvo-components/listEditor/ListEditorView.jsx';
import ListEditorItemView from 'src/nfvo-components/listEditor/ListEditorItemView.jsx';
@@ -28,11 +24,11 @@ describe('listEditor Module Tests', function () {
it('list editor view should exist', () => {
- expect(ListEditorView).toExist();
+ expect(ListEditorView).toBeTruthy();
});
it('list editor item view should exist', () => {
- expect(ListEditorItemView).toExist();
+ expect(ListEditorItemView).toBeTruthy();
});
it('should render list and list item and call onEdit', done => {
@@ -43,22 +39,18 @@ describe('listEditor Module Tests', function () {
</ListEditorItemView>
</ListEditorView>
);
- expect(itemView).toExist();
- let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'fa-sliders');
+ expect(itemView).toBeTruthy();
+ let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'sliders');
TestUtils.Simulate.click(sliderIcon);
});
- it('should render list and list item and call onFilter', done => {
- let itemView = TestUtils.renderIntoDocument(
- <ListEditorView onFilter={()=>{done();}}>
- <ListEditorItemView>
- <div></div>
- </ListEditorItemView>
- </ListEditorView>
+ it('should render list and list item and call onFilter', () => {
+ let itemView = mount(
+ <ListEditorView onFilter={()=>{}} children={[(<ListEditorItemView key='id'/>)]} />
);
- expect(itemView).toExist();
- let filterInput = TestUtils.findRenderedDOMComponentWithTag(itemView, 'input');
- TestUtils.Simulate.change(filterInput);
+ expect(itemView).toBeTruthy();
+ let inputComponent = itemView.find('ExpandableInput');
+ expect(inputComponent.length).toBe(1);
});
it('should render READONLY list item and not call onEdit', done => {
@@ -67,8 +59,8 @@ describe('listEditor Module Tests', function () {
<div></div>
</ListEditorItemView>
);
- expect(itemView).toExist();
- let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'fa-sliders');
+ expect(itemView).toBeTruthy();
+ let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'sliders');
TestUtils.Simulate.click(sliderIcon);
});
@@ -78,8 +70,8 @@ describe('listEditor Module Tests', function () {
<div></div>
</ListEditorItemView>
);
- expect(itemView).toExist();
- let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'fa-trash-o');
+ expect(itemView).toBeTruthy();
+ let sliderIcon = TestUtils.findRenderedDOMComponentWithClass(itemView, 'trash-o');
TestUtils.Simulate.click(sliderIcon);
});
@@ -89,8 +81,8 @@ describe('listEditor Module Tests', function () {
<div></div>
</ListEditorItemView>
);
- expect(itemView).toExist();
- let sliderIcon = TestUtils.scryRenderedDOMComponentsWithClass(itemView, 'fa-trash-o');
- expect(sliderIcon).toEqual(0);
+ expect(itemView).toBeTruthy();
+ let trashIcon = TestUtils.scryRenderedDOMComponentsWithClass(itemView, 'fa-trash-o');
+ expect(trashIcon).toEqual([]);
});
});
diff --git a/openecomp-ui/test/nfvo-components/modal/globalModal.test.js b/openecomp-ui/test/nfvo-components/modal/globalModal.test.js
new file mode 100644
index 0000000000..efe43b6c37
--- /dev/null
+++ b/openecomp-ui/test/nfvo-components/modal/globalModal.test.js
@@ -0,0 +1,92 @@
+/*!
+ * 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 GlobalModal, {GlobalModalView, mapStateToProps} from 'src/nfvo-components/modal/GlobalModal.js';
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import store from 'sdc-app/AppStore.js';
+import {actionTypes, typeEnum} from 'src/nfvo-components/modal/GlobalModalConstants.js';
+
+const title = 'TITLE';
+const msg = 'message';
+
+describe('Global Modal tests: ', function () {
+ it (' mapStateToProps exists', function () {
+ expect(mapStateToProps).toBeTruthy();
+ });
+
+ it ('mapStateToProps should return show as true', () => {
+ let state = {
+ modal: {
+ type: ''
+ }
+ };
+ let props = mapStateToProps(state);
+ expect(props.show).toEqual(true);
+ });
+
+ it('modal should show with default values', () => {
+ store.dispatch({
+ type: actionTypes.GLOBAL_MODAL_SHOW,
+ data: {
+ title,
+ msg
+ }
+ });
+ const modal = store.getState().modal;
+ expect(modal).toBeTruthy();
+ expect(modal.title).toBe(title);
+ expect(modal.msg).toBe(msg);
+ });
+
+ it('global modal should show with type success with connected component', () => {
+ store.dispatch({type: actionTypes.GLOBAL_MODAL_SHOW, data: {title, msg}});
+
+ expect(store.getState().modal).toBeTruthy();
+
+ let renderer = TestUtils.createRenderer();
+ renderer.render(<GlobalModal store={store}/>);
+ let renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toBeTruthy();
+
+ });
+
+
+ it('global modal should show with type success with connected component and closed after', () => {
+ store.dispatch({type: actionTypes.GLOBAL_MODAL_SHOW, data: {title, msg}});
+
+ expect(store.getState().modal).toBeTruthy();
+
+ let renderer = TestUtils.createRenderer();
+ renderer.render(<GlobalModal store={store}/>);
+ let renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toBeTruthy();
+
+ store.dispatch({type: actionTypes.GLOBAL_MODAL_CLOSE});
+ expect(store.getState().modal).toBe(null);
+ });
+
+
+ it('checking component default render', ()=> {
+ expect(window.document).toBeTruthy();
+ let globalModalView = TestUtils.renderIntoDocument(
+ <GlobalModalView show={true} type={typeEnum.WARNING} title={title} msg={msg} onDeclined={()=>{}} />
+ );
+ expect(globalModalView).toBeTruthy();
+ });
+
+});
+
diff --git a/openecomp-ui/test/nfvo-components/notifications/notificationsModal.test.js b/openecomp-ui/test/nfvo-components/notifications/notificationsModal.test.js
deleted file mode 100644
index f84d38246d..0000000000
--- a/openecomp-ui/test/nfvo-components/notifications/notificationsModal.test.js
+++ /dev/null
@@ -1,144 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-import expect from 'expect';
-import React from 'react';
-import TestUtils from 'react-addons-test-utils';
-import store from 'sdc-app/AppStore.js';
-import ConnectedNotificationModal, {NotificationModal} from 'nfvo-components/notifications/NotificationModal.jsx';
-import NotificationConstants from 'nfvo-components/notifications/NotificationConstants.js';
-
-const title = 'test title';
-const msg = 'test msg';
-
-describe('Notification Modal Mapper and View Class: ', function () {
-
- it('notification should show with type error', done => {
- store.dispatch({type: NotificationConstants.NOTIFY_ERROR, data: {title, msg}});
- setTimeout(()=> {
- expect(store.getState().notification).toExist();
- expect(store.getState().notification.type).toBe('error');
- done();
- }, 0);
- });
-
- it('notification should show with type default', done => {
- store.dispatch({type: NotificationConstants.NOTIFY_INFO, data: {title, msg}});
- setTimeout(()=> {
- expect(store.getState().notification).toExist();
- expect(store.getState().notification.type).toBe('default');
- done();
- }, 0);
- });
-
- it('notification should show with type warning', done => {
- store.dispatch({type: NotificationConstants.NOTIFY_WARNING, data: {title, msg}});
- setTimeout(()=> {
- expect(store.getState().notification).toExist();
- expect(store.getState().notification.type).toBe('warning');
- done();
- }, 0);
- });
-
- it('notification should show with type success', done => {
- store.dispatch({type: NotificationConstants.NOTIFY_SUCCESS, data: {title, msg}});
- setTimeout(()=> {
- expect(store.getState().notification).toExist();
- expect(store.getState().notification.type).toBe('success');
- done();
- }, 0);
- });
-
- it('notification should show with type success with connected component', done => {
- store.dispatch({type: NotificationConstants.NOTIFY_SUCCESS, data: {title, msg}});
- setTimeout(()=> {
- expect(store.getState().notification).toExist();
- expect(store.getState().notification.type).toBe('success');
- let renderer = TestUtils.createRenderer();
- renderer.render(<ConnectedNotificationModal store={store}/>);
- let renderedOutput = renderer.getRenderOutput();
- expect(renderedOutput).toExist();
- done();
- }, 0);
- });
-
- it('notification should hide with connected component', done => {
- setTimeout(()=> {
- expect(store.getState().notification).toNotExist();
- let renderer = TestUtils.createRenderer();
- renderer.render(<ConnectedNotificationModal store={store}/>);
- let renderedOutput = renderer.getRenderOutput();
- expect(renderedOutput).toExist();
- done();
- }, 0);
- store.dispatch({type: NotificationConstants.NOTIFY_CLOSE});
- });
-
- it('notification should hide', done => {
- store.dispatch({type: NotificationConstants.NOTIFY_CLOSE});
- setTimeout(()=> {
- expect(store.getState().notification).toNotExist();
- done();
- }, 0);
- });
-
- it('NotificationModal should not render', ()=> {
- let renderer = TestUtils.createRenderer();
- renderer.render(<NotificationModal show={false} title={title} msg={msg} type='error'/>);
- let renderedOutput = renderer.getRenderOutput();
- expect(renderedOutput).toExist();
- });
-
- it('NotificationModal basic default render', ()=> {
- expect(window.document).toExist();
- let document = TestUtils.renderIntoDocument(
- <NotificationModal show={true} title={title} msg={msg} type='default' onCloseClick={()=>{}}/>
- );
- var result = TestUtils.findAllInRenderedTree(document, element => element.props.className === 'notification-modal primary');
- expect(result.length).toBeGreaterThan(0);
- });
-
- it('NotificationModal basic error render', ()=> {
- expect(window.document).toExist();
- let document = TestUtils.renderIntoDocument(
- <NotificationModal show={true} title={title} msg={msg} type='error' onCloseClick={()=>{}}/>
- );
- var result = TestUtils.findAllInRenderedTree(document, element => element.props.className === 'notification-modal danger');
- expect(result.length).toBeGreaterThan(0);
- });
-
- it('NotificationModal basic warning render', ()=> {
- expect(window.document).toExist();
- let document = TestUtils.renderIntoDocument(
- <NotificationModal show={true} title={title} msg={msg} type='warning' onCloseClick={()=>{}}/>
- );
- var result = TestUtils.findAllInRenderedTree(document, element => element.props.className === 'notification-modal warning');
- expect(result.length).toBeGreaterThan(0);
- });
-
- it('NotificationModal basic success render', ()=> {
- expect(window.document).toExist();
- let document = TestUtils.renderIntoDocument(
- <NotificationModal show={true} title={title} msg={msg} type='success' onCloseClick={()=>{}}/>
- );
- var result = TestUtils.findAllInRenderedTree(document, element => element.props.className === 'notification-modal success');
- expect(result.length).toBeGreaterThan(0);
- });
-});
diff --git a/openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js b/openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js
index 9ab18137cf..8f2b7e7e88 100644
--- a/openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js
+++ b/openecomp-ui/test/nfvo-components/panel/VersionController/versionController.test.js
@@ -1,43 +1,152 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-import expect from 'expect';
+
import React from 'react';
+
import TestUtils from 'react-addons-test-utils';
+import {mount} from 'enzyme';
import VersionController from 'nfvo-components/panel/versionController/VersionController.jsx';
-import {actionsEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
+import {actionsEnum, statusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
+import {scryRenderedDOMComponentsWithTestId} from 'test-utils/Util.js';
+import {VSPComponentsVersionControllerFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js';
describe('versionController UI Component', () => {
+ let onSave, onClose, onVersionSwitching = onSave = onClose = () => {return Promise.resolve();};
+ const versionData = VSPComponentsVersionControllerFactory.build();
+ const isFormDataValid = true;
+ const viewableVersions = versionData.viewableVersions;
+ const version = versionData.version;
+ const props = {onSave, onClose, isFormDataValid, viewableVersions, version, onVersionSwitching};
it('function does exist', () => {
var renderer = TestUtils.createRenderer();
- renderer.render(<VersionController isCheckedOut={false} status={'OUT'} />);
+ renderer.render(<VersionController isCheckedOut={false} status={statusEnum.CHECK_OUT_STATUS} {...props} />);
var renderedOutput = renderer.getRenderOutput();
- expect(renderedOutput).toExist();
+ expect(renderedOutput).toBeTruthy();
});
it('validating checkin function', () => {
-
- let versionController = TestUtils.renderIntoDocument(<VersionController isCheckedOut={false} status={'OUT'} onSave={()=>{return Promise.resolve();}}/>);
+ let versionController = TestUtils.renderIntoDocument(<VersionController isCheckedOut={true} status={statusEnum.CHECK_OUT_STATUS} {...props} />);
let cb = action => expect(action).toBe(actionsEnum.CHECK_IN);
versionController.checkin(cb);
+ });
+
+ it('validating checkout function', () => {
+ let versionController = TestUtils.renderIntoDocument(<VersionController isCheckedOut={false} status={statusEnum.CHECK_IN_STATUS} {...props} />);
+ let cb = action => expect(action).toBe(actionsEnum.CHECK_OUT);
+ versionController.checkout(cb);
+ });
+
+ it('validating submit function', () => {
+ let versionController = TestUtils.renderIntoDocument(<VersionController isCheckedOut={false} status={statusEnum.CHECK_IN_STATUS} {...props} />);
+ let cb = action => expect(action).toBe(actionsEnum.SUBMIT);
+ versionController.submit(cb);
+ });
+
+ it('validating revert function', () => {
+ let versionController = TestUtils.renderIntoDocument(<VersionController isCheckedOut={true} status={statusEnum.CHECK_OUT_STATUS} {...props} />);
+ let cb = action => expect(action).toBe(actionsEnum.UNDO_CHECK_OUT);
+ versionController.revertCheckout(cb);
+ });
+
+ it('does not show the save button when no onSave available', () => {
+ let noSaveProps = {...props, onSave: null };
+ let versionController = TestUtils.renderIntoDocument(<VersionController isCheckedOut={true} status={statusEnum.CHECK_OUT_STATUS} {...noSaveProps} />);
+ let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-save-btn');
+ expect(elem).toBeTruthy();
+ expect(elem.length).toBe(0);
+ });
+
+ it('does not show the submit button when no callVCAction available', () => {
+ let callVCActionProps = {...props, callVCAction: null};
+ let versionController = TestUtils.renderIntoDocument(<VersionController isCheckedOut={false} status={statusEnum.CHECK_IN_STATUS} {...callVCActionProps} />);
+ let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-submit-btn');
+ expect(elem).toBeTruthy();
+ expect(elem.length).toBe(0);
+ });
+
+ it('does not show the revert button when no callVCAction available', () => {
+ let callVCActionProps = {...props, callVCAction: null};
+ let versionController = TestUtils.renderIntoDocument(<VersionController isCheckedOut={true} status={statusEnum.CHECK_OUT_STATUS} {...callVCActionProps} />);
+ let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-revert-btn');
+ expect(elem).toBeTruthy();
+ expect(elem.length).toBe(0);
+ });
+
+ it('Shows the save button when onSave available', () => {
+ let versionController = TestUtils.renderIntoDocument(<VersionController isCheckedOut={true} status={statusEnum.CHECK_OUT_STATUS} {...props} />);
+ let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-save-btn');
+ expect(elem).toBeTruthy();
+ expect(elem.length).toBe(1);
+ });
+
+ it('Shows the submit button when callVCAction available', () => {
+ let callVCActionProps = { ...props, callVCAction: function(){} };
+ let versionController = TestUtils.renderIntoDocument(<VersionController isCheckedOut={false} status={statusEnum.CHECK_IN_STATUS} {...callVCActionProps} />);
+ let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-submit-btn');
+ expect(elem).toBeTruthy();
+ expect(elem.length).toBe(1);
+ });
+
+ it('Shows the revert button when callVCAction available', () => {
+ let callVCActionProps = { ...props, callVCAction: function(){} };
+ let versionController = TestUtils.renderIntoDocument(<VersionController isCheckedOut={true} status={statusEnum.CHECK_OUT_STATUS} {...callVCActionProps} />);
+ let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-revert-btn');
+ expect(elem).toBeTruthy();
+ expect(elem.length).toBe(1);
+ });
+
+ it('Shows the checkin button', () => {
+ let callVCActionProps = { ...props, callVCAction: function(){} };
+ let versionController = TestUtils.renderIntoDocument(<VersionController isCheckedOut={true} status={statusEnum.CHECK_OUT_STATUS} {...callVCActionProps} />);
+ let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-checkout-btn');
+ expect(elem).toBeTruthy();
+ expect(elem.length).toBe(1);
+ });
+
+ it('Shows the checkout button', () => {
+ let callVCActionProps = { ...props, callVCAction: function(){} };
+ let versionController = TestUtils.renderIntoDocument(<VersionController isCheckedOut={false} status={statusEnum.CHECK_IN_STATUS} {...callVCActionProps} />);
+ let elem = scryRenderedDOMComponentsWithTestId(versionController,'vc-checkout-btn');
+ expect(elem).toBeTruthy();
+ expect(elem.length).toBe(1);
+
+ });
+
+ it('Doesn\'t show the checkin button for prev version', () => {
+ let callVCActionProps = { ...props, version: '1.0', callVCAction: function(){} };
+ let versionController = mount(<VersionController isCheckedOut={true} status={statusEnum.CHECK_OUT_STATUS} {...callVCActionProps} />);
+ let elem = versionController.find('[data-test-id="vc-checkout-btn"]');
+ let svgIcon = versionController.find('.version-controller-lock-closed');
+
+ expect(elem).toBeTruthy();
+ expect(elem.length).toEqual(1);
+ expect(svgIcon.hasClass('disabled')).toBe(true);
+ });
+
+ it('Doesn\'t show the checkout button', () => {
+ let callVCActionProps = { ...props, version: '1.0', callVCAction: function(){} };
+ let versionController = mount(<VersionController isCheckedOut={false} status={statusEnum.CHECK_IN_STATUS} {...callVCActionProps} />);
+ let elem = versionController.find('[data-test-id="vc-checkout-btn"]');
+ let svgIcon = versionController.find('.version-controller-lock-closed');
+
+ expect(elem).toBeTruthy();
+ expect(elem.length).toBe(1);
+ expect(svgIcon.hasClass('disabled')).toBe(true);
});
diff --git a/openecomp-ui/test/nfvo-components/panel/VersionController/versionControllerUtils.test.js b/openecomp-ui/test/nfvo-components/panel/VersionController/versionControllerUtils.test.js
index 0e4a92118e..d654e16ddf 100644
--- a/openecomp-ui/test/nfvo-components/panel/VersionController/versionControllerUtils.test.js
+++ b/openecomp-ui/test/nfvo-components/panel/VersionController/versionControllerUtils.test.js
@@ -1,41 +1,38 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-import expect from 'expect';
-import deepFreeze from 'deep-freeze';
+
import Configuration from 'sdc-app/config/Configuration.js';
import VersionControllerUtils from 'nfvo-components/panel/versionController/VersionControllerUtils.js';
import {statusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
+import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
const status = 'testStatus';
+const {lockingUser: currentUser, viewableVersions: defaultVersions} = VersionControllerUtilsFactory.build();
describe('versionController UI Component', () => {
it('function does exist', () => {
- expect(VersionControllerUtils).toExist();
+ expect(VersionControllerUtils).toBeTruthy();
});
it('validating getCheckOutStatusKindByUserID - without "UserID"', () => {
var result = VersionControllerUtils.getCheckOutStatusKindByUserID(status);
expect(result.status).toBe(status);
- expect(result.isCheckedOut).toBe(true);
+ expect(result.isCheckedOut).toBe(false);
});
it('validating getCheckOutStatusKindByUserID - without "UserID" with locking user', () => {
@@ -45,12 +42,11 @@ describe('versionController UI Component', () => {
});
it('validating getCheckOutStatusKindByUserID - with "UserID" with configuration set', () => {
- const userId = 'att';
-
- Configuration.set('ATTUserID', userId);
- var result = VersionControllerUtils.getCheckOutStatusKindByUserID(status, userId);
- Configuration.set('ATTUserID', undefined);
+ const Uid = 'ecomp';
+ Configuration.set('UserID', Uid);
+ var result = VersionControllerUtils.getCheckOutStatusKindByUserID(status, Uid);
+ Configuration.set('UserID', undefined);
expect(result.status).toBe(status);
expect(result.isCheckedOut).toBe(true);
});
@@ -58,48 +54,31 @@ describe('versionController UI Component', () => {
it('validating isCheckedOutByCurrentUser - when resource is not checked out', () => {
- const currentUser = 'current';
- const resource = deepFreeze({
- version: '0.6',
- viewableVersions: ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6'],
- status: 'Final'
- });
-
- Configuration.set('ATTUserID', currentUser);
+ const resource = VersionControllerUtilsFactory.build({status: statusEnum.SUBMIT_STATUS});
+
+ Configuration.set('UserID', currentUser);
const result = VersionControllerUtils.isCheckedOutByCurrentUser(resource);
- Configuration.set('ATTUserID', undefined);
+ Configuration.set('UserID', undefined);
expect(result).toBe(false);
});
it('validating isCheckedOutByCurrentUser - when resource is checked out', () => {
- const currentUser = 'current';
- const resource = deepFreeze({
- version: '0.6',
- viewableVersions: ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6'],
- status: 'Locked',
- lockingUser: 'current'
- });
-
- Configuration.set('ATTUserID', currentUser);
+ const resource = VersionControllerUtilsFactory.build();
+
+ Configuration.set('UserID', currentUser);
const result = VersionControllerUtils.isCheckedOutByCurrentUser(resource);
- Configuration.set('ATTUserID', undefined);
+ Configuration.set('UserID', undefined);
expect(result).toBe(true);
});
it('validating isCheckedOutByCurrentUser - when resource is checked out by another user', () => {
- const currentUser = 'current';
- const resource = deepFreeze({
- version: '0.6',
- viewableVersions: ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6'],
- status: 'Locked',
- lockingUser: 'another'
- });
-
- Configuration.set('ATTUserID', currentUser);
+ const resource = VersionControllerUtilsFactory.build({lockingUser: 'another'});
+
+ Configuration.set('UserID', currentUser);
const result = VersionControllerUtils.isCheckedOutByCurrentUser(resource);
- Configuration.set('ATTUserID', undefined);
+ Configuration.set('UserID', undefined);
expect(result).toBe(false);
});
@@ -107,66 +86,43 @@ describe('versionController UI Component', () => {
it('validating isReadOnly - when resource is not checked out', () => {
- const currentUser = 'current';
- const resource = deepFreeze({
- version: '0.6',
- viewableVersions: ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6'],
- status: 'Final'
- });
-
- Configuration.set('ATTUserID', currentUser);
+ const resource = VersionControllerUtilsFactory.build({status: statusEnum.SUBMIT_STATUS});
+
+ Configuration.set('UserID', currentUser);
const result = VersionControllerUtils.isReadOnly(resource);
- Configuration.set('ATTUserID', undefined);
+ Configuration.set('UserID', undefined);
expect(result).toBe(true);
});
it('validating isReadOnly - when resource is checked out', () => {
- const currentUser = 'current';
- const resource = deepFreeze({
- version: '0.6',
- viewableVersions: ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6'],
- status: 'Locked',
- lockingUser: 'current'
- });
-
- Configuration.set('ATTUserID', currentUser);
+ const resource = VersionControllerUtilsFactory.build();
+
+ Configuration.set('UserID', currentUser);
const result = VersionControllerUtils.isReadOnly(resource);
- Configuration.set('ATTUserID', undefined);
+ Configuration.set('UserID', undefined);
expect(result).toBe(false);
});
it('validating isReadOnly - when version of resource is not latest', () => {
- const currentUser = 'current';
- const resource = deepFreeze({
- version: '0.2',
- viewableVersions: ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6'],
- status: 'Locked',
- lockingUser: 'current'
- });
-
- Configuration.set('ATTUserID', currentUser);
+
+ const resource = VersionControllerUtilsFactory.build({version: defaultVersions[defaultVersions.length - 2]});
+
+ Configuration.set('UserID', currentUser);
const result = VersionControllerUtils.isReadOnly(resource);
- Configuration.set('ATTUserID', undefined);
+ Configuration.set('UserID', undefined);
expect(result).toBe(true);
});
it('validating isReadOnly - when resource is checked out by another user', () => {
- const currentUser = 'current';
- const resource = deepFreeze({
- version: '0.6',
- viewableVersions: ['0.1', '0.2', '0.3', '0.4', '0.5', '0.6'],
- status: 'Locked',
- lockingUser: 'another'
- });
-
- Configuration.set('ATTUserID', currentUser);
+ const resource = VersionControllerUtilsFactory.build({lockingUser: 'another'});
+
+ Configuration.set('UserID', currentUser);
const result = VersionControllerUtils.isReadOnly(resource);
- Configuration.set('ATTUserID', undefined);
+ Configuration.set('UserID', undefined);
expect(result).toBe(true);
});
});
-
diff --git a/openecomp-ui/test/nfvo-components/storyshots.test.js b/openecomp-ui/test/nfvo-components/storyshots.test.js
new file mode 100644
index 0000000000..4d1bdbede0
--- /dev/null
+++ b/openecomp-ui/test/nfvo-components/storyshots.test.js
@@ -0,0 +1,2 @@
+import initStoryshots from 'storyshots';
+initStoryshots(); \ No newline at end of file
diff --git a/openecomp-ui/test/onboard/onboardingCatalog/test.js b/openecomp-ui/test/onboard/onboardingCatalog/test.js
new file mode 100644
index 0000000000..cc54e3199e
--- /dev/null
+++ b/openecomp-ui/test/onboard/onboardingCatalog/test.js
@@ -0,0 +1,63 @@
+/*!
+ * 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 {storeCreator} from 'sdc-app/AppStore.js';
+import {OnboardingCatalogStoreFactory} from 'test-utils/factories/onboard/OnboardingCatalogFactories.js';
+import {LicenseModelStoreFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
+import OnboardingCatalogActionHelper from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogActionHelper.js';
+import {tabsMapping} from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogConstants.js';
+
+
+describe('Onboarding Catalog Module Tests', () => {
+ it('should return default state', () => {
+ const store = storeCreator();
+ const expectedStore = OnboardingCatalogStoreFactory.build();
+ expect(store.getState().onboard.onboardingCatalog).toEqual(expectedStore);
+ });
+
+ it('should change active tab to All', () => {
+ const store = storeCreator();
+ const expectedStore = OnboardingCatalogStoreFactory.build({activeTab: tabsMapping.ALL});
+ OnboardingCatalogActionHelper.changeActiveTab(store.dispatch, tabsMapping.ALL);
+ expect(store.getState().onboard.onboardingCatalog).toEqual(expectedStore);
+ });
+
+
+ it('should change VSP Overlay', () => {
+ const vendor = LicenseModelStoreFactory.build();
+ const store = storeCreator();
+ const expectedStore = OnboardingCatalogStoreFactory.build({vendorCatalog: {vspOverlay: vendor.id}});
+ OnboardingCatalogActionHelper.changeVspOverlay(store.dispatch, vendor);
+ expect(store.getState().onboard.onboardingCatalog).toEqual(expectedStore);
+ });
+
+ it('should close VSP Overlay', () => {
+ const vendor = LicenseModelStoreFactory.build();
+ const store = storeCreator();
+ const expectedStore = OnboardingCatalogStoreFactory.build({vendorCatalog: {vspOverlay: null}});
+ OnboardingCatalogActionHelper.changeVspOverlay(store.dispatch, vendor);
+ OnboardingCatalogActionHelper.changeVspOverlay(store.dispatch, null);
+ expect(store.getState().onboard.onboardingCatalog).toEqual(expectedStore);
+ });
+
+ it('should select vendor', () => {
+ const vendor = LicenseModelStoreFactory.build();
+ const store = storeCreator();
+ const expectedStore = OnboardingCatalogStoreFactory.build({vendorCatalog: {selectedVendor: vendor}});
+ OnboardingCatalogActionHelper.onVendorSelect(store.dispatch, {vendor});
+ expect(store.getState().onboard.onboardingCatalog).toEqual(expectedStore);
+ });
+
+});
diff --git a/openecomp-ui/test/onboard/onboardingCatalog/views.test.js b/openecomp-ui/test/onboard/onboardingCatalog/views.test.js
new file mode 100644
index 0000000000..fb038eb680
--- /dev/null
+++ b/openecomp-ui/test/onboard/onboardingCatalog/views.test.js
@@ -0,0 +1,143 @@
+/*!
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import {defaultStoreFactory} from 'test-utils/factories/onboard/OnboardingCatalogFactories.js';
+import {FinalizedLicenseModelFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
+import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
+import {mapStateToProps} from 'sdc-app/onboarding/onboard/Onboard.js';
+import OnboardingCatalogView from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogView.jsx';
+import VendorItem from 'sdc-app/onboarding/onboard/onboardingCatalog/VendorItem.jsx';
+import VSPOverlay from 'sdc-app/onboarding/onboard/onboardingCatalog/VSPOverlay.jsx';
+import CatalogItemDetails from 'sdc-app/onboarding/onboard/CatalogItemDetails.jsx';
+import DetailsCatalogView from 'sdc-app/onboarding/onboard/DetailsCatalogView.jsx';
+
+describe('OnBoarding Catalog test - View: ', function () {
+
+
+ it('mapStateToProps mapper exists', () => {
+ expect(mapStateToProps).toBeTruthy();
+ });
+
+ it('mapStateToProps data test', () => {
+
+ const licenseModelList = FinalizedLicenseModelFactory.buildList(3);
+ const softwareProductList = VSPEditorFactory.buildList(4);
+ const data = defaultStoreFactory.build({licenseModelList, softwareProductList});
+
+ var results = mapStateToProps(data);
+ expect(results.softwareProductList).toBeTruthy();
+ expect(results.licenseModelList).toBeTruthy();
+ expect(results.activeTab).toBeTruthy();
+ expect(results.licenseModelList.length).toEqual(3);
+ });
+
+ it('licenseModelList creating algorithm test', () => {
+
+ const finalizedLicenseModelList = FinalizedLicenseModelFactory.buildList(3);
+ const licenseModelList = [...finalizedLicenseModelList];
+ const finalizedSoftwareProductList = VSPEditorFactory.buildList(4 ,{vendorId: finalizedLicenseModelList[0].id});
+ const softwareProductList = [...finalizedSoftwareProductList];
+ const data = defaultStoreFactory.build({licenseModelList, finalizedLicenseModelList, softwareProductList, finalizedSoftwareProductList});
+
+ var results = mapStateToProps(data);
+ expect(results.finalizedLicenseModelList[0].softwareProductList.length).toEqual(finalizedSoftwareProductList.length);
+ });
+
+
+ it('Catalog view test', () => {
+
+ const dummyFunc = () => {};
+ const licenseModelList = FinalizedLicenseModelFactory.buildList(3);
+ const softwareProductList = VSPEditorFactory.buildList(4 ,{vendorId: licenseModelList[0].id});
+ const data = defaultStoreFactory.build({licenseModelList, softwareProductList});
+
+ const func = {
+ onAddLicenseModelClick: dummyFunc,
+ onAddSoftwareProductClick: dummyFunc,
+ closeVspOverlay: dummyFunc,
+ onVspOverlayChange: dummyFunc,
+ onTabClick: dummyFunc,
+ onSearch: dummyFunc,
+ onSelectLicenseModel: dummyFunc,
+ onSelectSoftwareProduct: dummyFunc,
+ resetOnboardingCatalogStore: ''
+ };
+
+ let params = {...func, ...mapStateToProps(data)};
+ let CatalogView = TestUtils.renderIntoDocument(<OnboardingCatalogView
+ {...params}/>);
+ expect(CatalogView).toBeTruthy();
+ });
+
+ it('VendorItem view test', () => {
+ let vendor = FinalizedLicenseModelFactory.build();
+ const dummyFunc = () => {};
+ let params = {
+ softwareProductList: VSPEditorFactory.buildList(4 ,{vendorId: vendor.id}),
+ vendor,
+ onSelectVSP: dummyFunc,
+ shouldShowOverlay: false,
+ onVendorSelect: dummyFunc,
+ onAddVSP: dummyFunc,
+ onVSPIconClick: dummyFunc,
+ };
+
+ let VendorItemView = TestUtils.renderIntoDocument(<VendorItem{...params}/>);
+ expect(VendorItemView).toBeTruthy();
+ });
+
+
+ it('VSPOverlay view test', () => {
+
+ let params = {
+ VSPList: VSPEditorFactory.buildList(10 ,{vendorId: '1'}),
+ onSelectVSP: () => {}
+ };
+
+ let VSPOverlayView = TestUtils.renderIntoDocument(<div><VSPOverlay {...params}/></div>);
+ expect(VSPOverlayView).toBeTruthy();
+ });
+
+ it('CatalogItemDetails view test', () => {
+
+ let params = {
+ catalogItemData: FinalizedLicenseModelFactory.build(),
+ onSelect: () => {},
+ catalogItemTypeClass: ''
+ };
+
+ let CatalogItemDetailsView = TestUtils.renderIntoDocument(<div><CatalogItemDetails {...params}/></div>);
+ expect(CatalogItemDetailsView).toBeTruthy();
+ });
+
+ it('DetailsCatalogView view test', () => {
+
+ let params = {
+ VLMList: FinalizedLicenseModelFactory.buildList(3),
+ VSPList: VSPEditorFactory.buildList(4),
+ onSelectVLM: () => {},
+ onSelectVSP: () => {},
+ onAddVLM: () => {},
+ onAddVSP: () => {},
+ filter: ''
+ };
+
+ let AllCatalog = TestUtils.renderIntoDocument(<DetailsCatalogView {...params}/>);
+ expect(AllCatalog).toBeTruthy();
+ });
+});
diff --git a/openecomp-ui/test/onboard/test.js b/openecomp-ui/test/onboard/test.js
new file mode 100644
index 0000000000..18bb042aea
--- /dev/null
+++ b/openecomp-ui/test/onboard/test.js
@@ -0,0 +1,62 @@
+/*!
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+import {storeCreator} from 'sdc-app/AppStore.js';
+import {OnboardStoreFactory} from 'test-utils/factories/onboard/OnboardFactories.js';
+import OnboardActionHelper from 'sdc-app/onboarding/onboard/OnboardActionHelper.js';
+import OnboardingCatalogActionHelper from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogActionHelper.js';
+import {tabsMapping as onboardTabsMapping} from 'sdc-app/onboarding/onboard/OnboardConstants.js';
+import {tabsMapping as onboardCatalogTabsMapping} from 'sdc-app/onboarding/onboard/onboardingCatalog/OnboardingCatalogConstants.js';
+
+describe('Onboard Module Tests', () => {
+ it('should return default state', () => {
+ const store = storeCreator();
+ const expectedStore = OnboardStoreFactory.build();
+ expect(store.getState().onboard).toEqual(expectedStore);
+ });
+
+ it('should change active tab to Catalog', () => {
+ const store = storeCreator();
+ const expectedStore = OnboardStoreFactory.build({activeTab: onboardTabsMapping.CATALOG});
+ OnboardActionHelper.changeActiveTab(store.dispatch, onboardTabsMapping.CATALOG);
+ expect(store.getState().onboard).toEqual(expectedStore);
+ });
+
+ it('should change searchValue', () => {
+ const store = storeCreator();
+ const expectedStore = OnboardStoreFactory.build({searchValue: 'hello'});
+ OnboardActionHelper.changeSearchValue(store.dispatch, 'hello');
+ expect(store.getState().onboard).toEqual(expectedStore);
+ });
+
+ it('should clear searchValue', () => {
+ const store = storeCreator();
+ const expectedStore = OnboardStoreFactory.build();
+ OnboardActionHelper.changeSearchValue(store.dispatch, 'hello');
+ OnboardActionHelper.clearSearchValue(store.dispatch);
+ expect(store.getState().onboard).toEqual(expectedStore);
+ });
+
+ it('should reset store', () => {
+ const store = storeCreator();
+ const expectedStore = OnboardStoreFactory.build();
+ OnboardActionHelper.changeSearchValue(store.dispatch, 'hello');
+ OnboardActionHelper.changeActiveTab(store.dispatch, onboardTabsMapping.CATALOG);
+ OnboardingCatalogActionHelper.changeActiveTab(store.dispatch, onboardCatalogTabsMapping.ALL);
+ OnboardActionHelper.resetOnboardStore(store.dispatch, 'hello');
+ expect(store.getState().onboard).toEqual(expectedStore);
+ });
+
+});
diff --git a/openecomp-ui/test/setup.test.js b/openecomp-ui/test/setup.test.js
deleted file mode 100644
index 72f8b954b8..0000000000
--- a/openecomp-ui/test/setup.test.js
+++ /dev/null
@@ -1,25 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-import mockRest from 'test-utils/MockRest.js';
-
-beforeEach(function() {
- mockRest.resetQueue();
-});
diff --git a/openecomp-ui/test/softwareProduct/attachments/SoftwareProductAttachmentsView.test.js b/openecomp-ui/test/softwareProduct/attachments/SoftwareProductAttachmentsView.test.js
index 839176c970..5dfe98f273 100644
--- a/openecomp-ui/test/softwareProduct/attachments/SoftwareProductAttachmentsView.test.js
+++ b/openecomp-ui/test/softwareProduct/attachments/SoftwareProductAttachmentsView.test.js
@@ -1,198 +1,76 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-import expect from 'expect';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
-import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachments.js';
+import {VSPAttachmentTreeNodeWithChildrenFactory, VSPAttachmentDetailedError} from 'test-utils/factories/softwareProduct/SoftwareProductAttachmentsFactories.js';
+import {defaultStoreFactory} from 'test-utils/factories/onboard/OnboardingCatalogFactories.js';
+import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachments.js';
import SoftwareProductAttachmentsView from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsView.jsx';
-import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
+import {tabsMapping} from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsConstants.js';
+import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
-
-describe('SoftwareProductAttachments Modal Mapper and View Classes', () => {
-
- it ('mapStateToProps mapper exists', () => {
- expect(mapStateToProps).toExist();
+describe('SoftwareProduct Attachments - View: ', function () {
+ it('should mapper exist', () => {
+ expect(mapStateToProps).toBeTruthy();
});
+ it('should mapper return default data', () => {
- it ('mapStateToProps check data', () => {
+ let attachmentsTree = VSPAttachmentTreeNodeWithChildrenFactory.build();
+ let errorList = VSPAttachmentDetailedError.buildList(3);
+ let versionControllerData = VersionControllerUtilsFactory.build();
- const currentSoftwareProduct = {
- name: 'VSp',
- description: 'dfdf',
- vendorName: 'V1',
- vendorId: '97B3E2525E0640ACACF87CE6B3753E80',
- category: 'resourceNewCategory.application l4+',
- subCategory: 'resourceNewCategory.application l4+.database',
- id: 'D4774719D085414E9D5642D1ACD59D20',
- version: '0.10',
- viewableVersions: ['0.1', '0.2'],
- status: versionStatusEnum.CHECK_OUT_STATUS,
- lockingUser: 'cs0008'
- };
- const atTree = {
- 'children': [
- {
- 'name': 'HEAT',
- 'expanded': true,
- 'type': 'heat',
- 'children': [
- {
- 'name': 'heat_zxeyCtMHhf2.yaml',
- 'expanded': true,
- 'type': 'heat',
- 'errors': [
- {
- 'level': 'WARNING',
- 'message': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4'
- }
- ],
- 'children': [
- {
- 'name': 'heat_env_zxeyCtMHhf2.env',
- 'type': 'env'
- }
- ]
- }
- ]
- }
- ]
- };
- const errorList = [
- {
- 'errorLevel': 'WARNING',
- 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4',
- 'name': 'heat_zxeyCtMHhf2.yaml',
- 'hasParent': false,
- 'parentName': 'HEAT',
- 'type': 'heat'
+ let softwareProductAttachments = {
+ heatSetup: {},
+ heatValidation: {
+ attachmentsTree,
+ errorList
},
- {
- 'errorLevel': 'WARNING',
- 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_3',
- 'name': 'heat_zxeyCtMHhf2.yaml',
- 'hasParent': false,
- 'parentName': 'HEAT',
- 'type': 'heat'
- }
- ];
-
- var obj = {
- softwareProduct: {
- softwareProductEditor: {
- data:currentSoftwareProduct
- }, softwareProductAttachments:
- {
- attachmentsTree: atTree,
- errorList: errorList
- }
- }
+ heatSetupCache: {},
+ activeTab: tabsMapping.SETUP
};
-
- var results = mapStateToProps(obj);
- expect(results.attachmentsTree).toExist();
- expect(results.errorList).toExist();
- expect(results.hoveredNode).toBe(undefined);
- expect(results.selectedNode).toBe(undefined);
+ let data = defaultStoreFactory.build({softwareProduct: {softwareProductAttachments, softwareProductEditor: {data: {...versionControllerData}}}});
+ var result = mapStateToProps(data);
+ expect(result).toBeTruthy();
+ expect(result.isValidationAvailable).toBe(false);
});
+ it('view test', () => {
- it('function does exist', () => {
+ let attachmentsTree = VSPAttachmentTreeNodeWithChildrenFactory.build();
+ let errorList = VSPAttachmentDetailedError.buildList(3);
+ let versionControllerData = VersionControllerUtilsFactory.build();
- const currentSoftwareProduct = {
- name: 'VSp',
- description: 'dfdf',
- vendorName: 'V1',
- vendorId: '97B3E2525E0640ACACF87CE6B3753E80',
- category: 'resourceNewCategory.application l4+',
- subCategory: 'resourceNewCategory.application l4+.database',
- id: 'D4774719D085414E9D5642D1ACD59D20',
- version: '0.10',
- viewableVersions: ['0.1', '0.2'],
- status: versionStatusEnum.CHECK_OUT_STATUS,
- lockingUser: 'cs0008'
- };
- const versionControllerData = {
- version: currentSoftwareProduct.version,
- viewableVersions:currentSoftwareProduct.viewableVersions,
- status: currentSoftwareProduct.status,
- isCheckedOut: true
- };
- const atTree = {
- 'children': [
- {
- 'name': 'HEAT',
- 'expanded': true,
- 'type': 'heat',
- 'children': [
- {
- 'name': 'heat_zxeyCtMHhf2.yaml',
- 'expanded': true,
- 'type': 'heat',
- 'errors': [
- {
- 'level': 'WARNING',
- 'message': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4'
- }
- ],
- 'children': [
- {
- 'name': 'heat_env_zxeyCtMHhf2.env',
- 'type': 'env'
- }
- ]
- }
- ]
- }
- ]
- };
- const errorList = [
- {
- 'errorLevel': 'WARNING',
- 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4',
- 'name': 'heat_zxeyCtMHhf2.yaml',
- 'hasParent': false,
- 'parentName': 'HEAT',
- 'type': 'heat'
+ let softwareProductAttachments = {
+ heatSetup: {},
+ heatValidation: {
+ attachmentsTree,
+ errorList
},
- {
- 'errorLevel': 'WARNING',
- 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_3',
- 'name': 'heat_zxeyCtMHhf2.yaml',
- 'hasParent': false,
- 'parentName': 'HEAT',
- 'type': 'heat'
- }
- ];
-
+ shouldOpenValidationTab: false
+ };
+ let data = defaultStoreFactory.build({softwareProduct: {softwareProductAttachments, softwareProductEditor: {data: {...versionControllerData}}}});
+ var params = mapStateToProps(data);
var renderer = TestUtils.createRenderer();
- renderer.render(<SoftwareProductAttachmentsView
- versionControllerData={versionControllerData}
- currentSoftwareProduct={currentSoftwareProduct}
- attachmentsTree={atTree}
- errorList={errorList}/>);
+ renderer.render(<SoftwareProductAttachmentsView {...params}/>);
var renderedOutput = renderer.getRenderOutput();
- expect(renderedOutput).toExist();
+ expect(renderedOutput).toBeTruthy();
});
});
diff --git a/openecomp-ui/test/softwareProduct/attachments/setup/heatSetup.test.js b/openecomp-ui/test/softwareProduct/attachments/setup/heatSetup.test.js
new file mode 100644
index 0000000000..80e9401f1a
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/attachments/setup/heatSetup.test.js
@@ -0,0 +1,49 @@
+/*!
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+import React from 'react';
+
+import TestUtils from 'react-addons-test-utils';
+import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetup.js';
+import HeatSetupView from 'sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupView.jsx';
+import {storeCreator} from 'sdc-app/AppStore.js';
+
+describe('Heat Setup View test: ', function () {
+ it('should mapper exist', () => {
+ expect(mapStateToProps).toBeTruthy();
+ });
+
+ it('should mapper return basic data', () => {
+
+ const store = storeCreator();
+
+ var result = mapStateToProps(store.getState());
+ expect(result).toBeTruthy();
+ expect(result.modules.length).toEqual(0);
+ expect(result.unassigned.length).toEqual(0);
+ expect(result.artifacts.length).toEqual(0);
+ expect(result.nested.length).toEqual(0);
+ });
+
+ it('view test', () => {
+
+ const store = storeCreator();
+
+ var params = mapStateToProps(store.getState());
+
+ let heatSetupView = TestUtils.renderIntoDocument(<HeatSetupView {...params}/>);
+ expect(heatSetupView).toBeTruthy();
+ });
+});
diff --git a/openecomp-ui/test/softwareProduct/attachments/setup/heatSetupActionHelper.test.js b/openecomp-ui/test/softwareProduct/attachments/setup/heatSetupActionHelper.test.js
new file mode 100644
index 0000000000..99bbfeac11
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/attachments/setup/heatSetupActionHelper.test.js
@@ -0,0 +1,142 @@
+/*!
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+import HeatSetupActionHelper from 'sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupActionHelper.js';
+import {storeCreator} from 'sdc-app/AppStore.js';
+import deepFreeze from 'deep-freeze';
+import {heatSetupManifest} from 'test-utils/factories/softwareProduct/SoftwareProductAttachmentsFactories.js';
+import {actionTypes as HeatSetupActions, fileTypes as HeatSetupFileTypes} from 'sdc-app/onboarding/softwareProduct/attachments/setup/HeatSetupConstants.js';
+
+describe('Heat Setup Action Helper test', () => {
+
+ it('function does exist', () => {
+ expect(HeatSetupActionHelper).toBeTruthy();
+ });
+
+ it('manifest load test', () => {
+
+ const store = storeCreator();
+
+ const manifest = heatSetupManifest.build();
+ store.dispatch({
+ type: HeatSetupActions.MANIFEST_LOADED,
+ response: manifest
+ });
+
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.modules.length).toBe(manifest.modules.length);
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.nested.length).toBe(manifest.nested.length);
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.unassigned.length).toBe(manifest.unassigned.length);
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.artifacts.length).toBe(manifest.artifacts.length);
+
+ });
+
+ it('add module action test', () => {
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const manifest = heatSetupManifest.build();
+ store.dispatch({
+ type: HeatSetupActions.MANIFEST_LOADED,
+ response: manifest
+ });
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.modules.length).toBe(manifest.modules.length);
+ HeatSetupActionHelper.addModule(store.dispatch);
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.modules.length).toBe(manifest.modules.length + 1);
+
+ });
+
+ it('delete module action test', () => {
+
+ const store = storeCreator();
+
+ const manifest = heatSetupManifest.build();
+ store.dispatch({
+ type: HeatSetupActions.MANIFEST_LOADED,
+ response: manifest
+ });
+ HeatSetupActionHelper.deleteModule(store.dispatch, manifest.modules[0].name);
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.modules.length).toBe(manifest.modules.length - 1);
+
+ });
+
+ it('rename module action test', () => {
+
+ const store = storeCreator();
+
+ const manifest = heatSetupManifest.build();
+ store.dispatch({
+ type: HeatSetupActions.MANIFEST_LOADED,
+ response: manifest
+ });
+ const newName = 'newName';
+ HeatSetupActionHelper.renameModule(store.dispatch, {oldName: manifest.modules[0].name, newName});
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.modules[0].name).toBe(newName);
+
+ });
+
+ it('change module type action test', () => {
+
+ const store = storeCreator();
+
+ const manifest = heatSetupManifest.build();
+ store.dispatch({
+ type: HeatSetupActions.MANIFEST_LOADED,
+ response: manifest
+ });
+ const newValue = 'newvalue.env';
+ HeatSetupActionHelper.changeModuleFileType(store.dispatch,
+ {
+ module: manifest.modules[0],
+ value: {value: newValue},
+ type: HeatSetupFileTypes.ENV.label
+ });
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.modules[0].env).toBe(newValue);
+ });
+
+ it('change artifacts list action test', () => {
+
+ const store = storeCreator();
+
+ const manifest = heatSetupManifest.build();
+ store.dispatch({
+ type: HeatSetupActions.MANIFEST_LOADED,
+ response: manifest
+ });
+ const artifacts = store.getState().softwareProduct.softwareProductAttachments.heatSetup.artifacts;
+ const newArtifacts = [...artifacts, manifest.unassigned[0]].map(str => (typeof str === 'string' ? {value: str, label: str} : str));;
+ HeatSetupActionHelper.changeArtifactList(store.dispatch, newArtifacts);
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.artifacts[1]).toBe(manifest.unassigned[0]);
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.unassigned.length).toBe(manifest.unassigned.length - 1);
+ });
+
+ it('add All Unassigned Files To Artifacts action test', () => {
+
+ const store = storeCreator();
+
+ const manifest = heatSetupManifest.build();
+ store.dispatch({
+ type: HeatSetupActions.MANIFEST_LOADED,
+ response: manifest
+ });
+ const artifacts = store.getState().softwareProduct.softwareProductAttachments.heatSetup.artifacts;
+ const unassigned = store.getState().softwareProduct.softwareProductAttachments.heatSetup.unassigned;
+ const newArtifacts = [...artifacts, ...unassigned];
+ HeatSetupActionHelper.addAllUnassignedFilesToArtifacts(store.dispatch, true);
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.artifacts).toEqual(newArtifacts);
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatSetup.unassigned).toEqual([]);
+ });
+
+});
diff --git a/openecomp-ui/test/softwareProduct/attachments/SoftwareproductAttachmentsHelper.test.js b/openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationActionHelper.test.js
index 851560caa8..d8a5d1fad6 100644
--- a/openecomp-ui/test/softwareProduct/attachments/SoftwareproductAttachmentsHelper.test.js
+++ b/openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationActionHelper.test.js
@@ -1,38 +1,29 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-import expect from 'expect';
-import SoftwareProductAttachmentsActionHelper from 'sdc-app/onboarding/softwareProduct/attachments/SoftwareProductAttachmentsActionHelper.js';
+import HeatValidationActionHelper from 'sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationActionHelper.js';
import {storeCreator} from 'sdc-app/AppStore.js';
import deepFreeze from 'deep-freeze';
import {actionTypes} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js';
+import {nodeFilters} from 'sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationConstants.js';
-
-
-
-
-
-describe('SoftwareProductAttachments ActionHelper', () => {
+describe('HeatValidationActionHelper ActionHelper', () => {
it('function does exist', () => {
- expect(SoftwareProductAttachmentsActionHelper).toExist();
+ expect(HeatValidationActionHelper).toBeTruthy();
});
it('toggleExpanded function check', () => {
@@ -86,9 +77,9 @@ describe('SoftwareProductAttachments ActionHelper', () => {
response: currentSoftwareProduct
});
- expect(store.getState().softwareProduct.softwareProductAttachments.attachmentsTree.children[0].expanded).toBe(true);
- SoftwareProductAttachmentsActionHelper.toggleExpanded(store.dispatch, {path:[0]});
- expect(store.getState().softwareProduct.softwareProductAttachments.attachmentsTree.children[0].expanded).toBe(false);
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatValidation.attachmentsTree.children[0].expanded).toBe(true);
+ HeatValidationActionHelper.toggleExpanded(store.dispatch, {path:[0]});
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatValidation.attachmentsTree.children[0].expanded).toBe(false);
});
it('onSelectNode & onUnselectNode function check', () => {
@@ -96,7 +87,7 @@ describe('SoftwareProductAttachments ActionHelper', () => {
const validationData = {
importStructure: {
- HEAT: [
+ heat: [
{
fileName: 'hot-mog-0108-bs1271.yml',
env: {
@@ -133,7 +124,7 @@ describe('SoftwareProductAttachments ActionHelper', () => {
};
deepFreeze(currentSoftwareProduct);
-
+
const store = storeCreator();
deepFreeze(store.getState());
@@ -142,11 +133,11 @@ describe('SoftwareProductAttachments ActionHelper', () => {
response: currentSoftwareProduct
});
let expectedNodeName = 'name';
- expect(store.getState().softwareProduct.softwareProductAttachments.selectedNode).toBe(undefined);
- SoftwareProductAttachmentsActionHelper.onSelectNode(store.dispatch, {nodeName:expectedNodeName});
- expect(store.getState().softwareProduct.softwareProductAttachments.selectedNode).toBe(expectedNodeName);
- SoftwareProductAttachmentsActionHelper.onUnselectNode(store.dispatch);
- expect(store.getState().softwareProduct.softwareProductAttachments.selectedNode).toBe(undefined);
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatValidation.selectedNode).toBe(nodeFilters.ALL);
+ HeatValidationActionHelper.onSelectNode(store.dispatch, {nodeName:expectedNodeName});
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatValidation.selectedNode).toBe(expectedNodeName);
+ HeatValidationActionHelper.onDeselectNode(store.dispatch);
+ expect(store.getState().softwareProduct.softwareProductAttachments.heatValidation.selectedNode).toBe(nodeFilters.ALL);
});
diff --git a/openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationView.test.js b/openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationView.test.js
new file mode 100644
index 0000000000..a5ba297d2b
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/attachments/validation/HeatValidationView.test.js
@@ -0,0 +1,184 @@
+/*!
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidation.js';
+
+import HeatValidationView from 'sdc-app/onboarding/softwareProduct/attachments/validation/HeatValidationView.jsx';
+import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
+
+
+describe('SoftwareProductAttachments Modal Mapper and View Classes', () => {
+
+ it ('mapStateToProps mapper exists', () => {
+ expect(mapStateToProps).toBeTruthy();
+ });
+
+
+ it ('mapStateToProps check data', () => {
+
+ const currentSoftwareProduct = {
+ name: 'VSp',
+ description: 'dfdf',
+ vendorName: 'V1',
+ vendorId: '97B3E2525E0640ACACF87CE6B3753E80',
+ category: 'resourceNewCategory.application l4+',
+ subCategory: 'resourceNewCategory.application l4+.database',
+ id: 'D4774719D085414E9D5642D1ACD59D20',
+ version: '0.10',
+ viewableVersions: ['0.1', '0.2'],
+ status: versionStatusEnum.CHECK_OUT_STATUS,
+ lockingUser: 'cs0008'
+ };
+ const atTree = {
+ 'children': [
+ {
+ 'name': 'HEAT',
+ 'expanded': true,
+ 'type': 'heat',
+ 'children': [
+ {
+ 'name': 'heat_zxeyCtMHhf2.yaml',
+ 'expanded': true,
+ 'type': 'heat',
+ 'errors': [
+ {
+ 'level': 'WARNING',
+ 'message': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4'
+ }
+ ],
+ 'children': [
+ {
+ 'name': 'heat_env_zxeyCtMHhf2.env',
+ 'type': 'env'
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ };
+ const errorList = [
+ {
+ 'errorLevel': 'WARNING',
+ 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4',
+ 'name': 'heat_zxeyCtMHhf2.yaml',
+ 'hasParent': false,
+ 'parentName': 'HEAT',
+ 'type': 'heat'
+ },
+ {
+ 'errorLevel': 'WARNING',
+ 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_3',
+ 'name': 'heat_zxeyCtMHhf2.yaml',
+ 'hasParent': false,
+ 'parentName': 'HEAT',
+ 'type': 'heat'
+ }
+ ];
+
+ var obj = {
+ softwareProduct: {
+ softwareProductEditor: {
+ data:currentSoftwareProduct
+ }, softwareProductAttachments:
+ {
+ heatValidation: {
+ attachmentsTree: atTree,
+ errorList: errorList
+ }
+ }
+ }
+ };
+
+ var results = mapStateToProps(obj);
+ expect(results.attachmentsTree).toBeTruthy();
+ expect(results.errorList).toBeTruthy();
+ expect(results.currentErrors).toBeTruthy();
+ expect(results.currentWarnings).toBeTruthy();
+ expect(results.selectedNode).toBe(undefined);
+ });
+
+
+ it('function does exist', () => {
+
+ const atTree = {
+ 'children': [
+ {
+ 'name': 'HEAT',
+ 'expanded': true,
+ 'type': 'heat',
+ 'children': [
+ {
+ 'name': 'heat_zxeyCtMHhf2.yaml',
+ 'expanded': true,
+ 'type': 'heat',
+ 'errors': [
+ {
+ 'level': 'WARNING',
+ 'message': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4'
+ }
+ ],
+ 'children': [
+ {
+ 'name': 'heat_env_zxeyCtMHhf2.env',
+ 'type': 'env'
+ }
+ ]
+ }
+ ]
+ }
+ ]
+ };
+ const errorList = [
+ {
+ 'errorLevel': 'WARNING',
+ 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_4',
+ 'name': 'heat_zxeyCtMHhf2.yaml',
+ 'hasParent': false,
+ 'parentName': 'HEAT',
+ 'type': 'heat'
+ },
+ {
+ 'errorLevel': 'WARNING',
+ 'errorMessage': 'Resource is not defined as output and thus cannot be Shared. resource id - network_3',
+ 'name': 'heat_zxeyCtMHhf2.yaml',
+ 'hasParent': false,
+ 'parentName': 'HEAT',
+ 'type': 'heat'
+ }
+ ];
+ var currentErrors = [];
+ var currentWarnings = [];
+ var onSelect = () => { return null; } ;
+ var onDeSelect = () => { return null; } ;
+ var onToggle = () => { return null; } ;
+
+ var renderer = TestUtils.createRenderer();
+ renderer.render(<HeatValidationView
+ attachmentsTree={atTree}
+ errorList={errorList}
+ currentWarnings={currentWarnings}
+ currentErrors={currentErrors}
+ onSelectNode={onSelect}
+ onDeselectNode={onDeSelect}
+ toggleExpanded = {onToggle} />);
+ var renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toBeTruthy();
+ });
+
+});
diff --git a/openecomp-ui/test/softwareProduct/components/compute/test.js b/openecomp-ui/test/softwareProduct/components/compute/test.js
index 925de302b8..8d2d1fbb2f 100644
--- a/openecomp-ui/test/softwareProduct/components/compute/test.js
+++ b/openecomp-ui/test/softwareProduct/components/compute/test.js
@@ -1,24 +1,19 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-import expect from 'expect';
import deepFreeze from 'deep-freeze';
import mockRest from 'test-utils/MockRest.js';
import {cloneAndSet} from 'test-utils/Util.js';
@@ -26,14 +21,18 @@ import {storeCreator} from 'sdc-app/AppStore.js';
import Configuration from 'sdc-app/config/Configuration.js';
import SoftwareProductComponentsActionHelper from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js';
+import {default as VSPComponentsComputeFactory, VSPComponentsComputeDataMapFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsComputeFactory.js';
+import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
+
const softwareProductId = '123';
const vspComponentId = '111';
+const version = VersionControllerUtilsFactory.build().version;
describe('Software Product Components Compute Module Tests', function () {
let restPrefix = '';
- before(function() {
+ beforeAll(function() {
restPrefix = Configuration.get('restPrefix');
deepFreeze(restPrefix);
});
@@ -42,28 +41,32 @@ describe('Software Product Components Compute Module Tests', function () {
const store = storeCreator();
deepFreeze(store.getState());
+ const compute = VSPComponentsComputeFactory.build();
+ const dataMap = VSPComponentsComputeDataMapFactory.build();
+
const softwareProductComponentCompute = {
- data: JSON.stringify({'vmSizing':{'numOfCPUs':'3','fileSystemSizeGB':'888'},'numOfVMs':{'minimum':'2'}}),
- schema: JSON.stringify({'vmSizing':{'numOfCPUs':'3','fileSystemSizeGB':'888'},'numOfVMs':{'minimum':'2'}})
+ data: JSON.stringify(compute),
+ schema: JSON.stringify(compute)
};
deepFreeze(softwareProductComponentCompute);
const softwareProductComponentComputeData = {
- qdata: JSON.parse(softwareProductComponentCompute.data),
- qschema: JSON.parse(softwareProductComponentCompute.schema)
+ qdata: compute,
+ dataMap,
+ qgenericFieldInfo: {}
};
deepFreeze(softwareProductComponentComputeData);
const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor', softwareProductComponentComputeData);
mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
- expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/components/${vspComponentId}/questionnaire`);
+ expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/questionnaire`);
expect(data).toEqual(undefined);
expect(options).toEqual(undefined);
return softwareProductComponentCompute;
});
- return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, vspComponentId}).then(() => {
+ return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, version, vspComponentId}).then(() => {
expect(store.getState()).toEqual(expectedStore);
});
});
@@ -72,61 +75,33 @@ describe('Software Product Components Compute Module Tests', function () {
const store = storeCreator();
deepFreeze(store.getState());
+ const compute = VSPComponentsComputeFactory.build();
+
const softwareProductComponentQuestionnaire = {
data: null,
- schema: JSON.stringify({'vmSizing':{'numOfCPUs':'3','fileSystemSizeGB':'888'},'numOfVMs':{'minimum':'2'}})
+ schema: JSON.stringify(compute)
};
deepFreeze(softwareProductComponentQuestionnaire);
const softwareProductComponentQuestionnaireData = {
qdata: {},
- qschema: JSON.parse(softwareProductComponentQuestionnaire.schema)
+ dataMap: {},
+ qgenericFieldInfo: {}
};
deepFreeze(softwareProductComponentQuestionnaireData);
const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor', softwareProductComponentQuestionnaireData);
mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
- expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/components/${vspComponentId}/questionnaire`);
+ expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/questionnaire`);
expect(data).toEqual(undefined);
expect(options).toEqual(undefined);
return softwareProductComponentQuestionnaire;
});
- return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, vspComponentId}).then(() => {
+ return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, version, vspComponentId}).then(() => {
expect(store.getState()).toEqual(expectedStore);
});
});
- it('Update Software Products Components Compute', () => {
- const store = storeCreator({
- softwareProduct: {
- softwareProductComponents: {
- componentEditor: {
- qdata: {
- numOfCPUs: 3,
- fileSystemSizeGB: 999
- },
- qschema: {
- type: 'object',
- properties: {
- numOfCPUs: {type: 'number'},
- fileSystemSizeGB: {type: 'number'}
- }
- }
- }
- }
- }
- });
- deepFreeze(store);
-
- const data = {numOfCPUs: 5, fileSystemSizeGB: 300};
- deepFreeze(data);
-
- const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor.qdata', data);
-
- SoftwareProductComponentsActionHelper.componentQuestionnaireUpdated(store.dispatch, {data});
-
- expect(store.getState()).toEqual(expectedStore);
- });
});
diff --git a/openecomp-ui/test/softwareProduct/components/general/SoftwareProductComponentsGeneral.test.js b/openecomp-ui/test/softwareProduct/components/general/SoftwareProductComponentsGeneral.test.js
index ce2152b29b..4f6512ad15 100644
--- a/openecomp-ui/test/softwareProduct/components/general/SoftwareProductComponentsGeneral.test.js
+++ b/openecomp-ui/test/softwareProduct/components/general/SoftwareProductComponentsGeneral.test.js
@@ -1,113 +1,73 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-import expect from 'expect';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/components/general/SoftwareProductComponentsGeneral.js';
import SoftwareProductComponentsGeneralView from 'sdc-app/onboarding/softwareProduct/components/general/SoftwareProductComponentsGeneralView.jsx';
-import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
+//import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
+
+import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
+import {VSPComponentsVersionControllerFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js';
+import {SoftwareProductFactory} from 'test-utils/factories/softwareProduct/SoftwareProductFactory.js';
+import VSPQSchemaFactory from 'test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js';
describe('SoftwareProductComponentsGeneral Mapper and View Classes', () => {
it('mapStateToProps mapper exists', () => {
- expect(mapStateToProps).toExist();
+ expect(mapStateToProps).toBeTruthy();
});
it('mapStateToProps data test', () => {
- const currentSoftwareProduct = {
- name: 'VSp',
- description: 'dfdf',
- vendorName: 'V1',
- vendorId: '97B3E2525E0640ACACF87CE6B3753E80',
- category: 'resourceNewCategory.application l4+',
- subCategory: 'resourceNewCategory.application l4+.database',
- id: 'D4774719D085414E9D5642D1ACD59D20',
- version: '0.10',
- viewableVersions: ['0.1', '0.2'],
- status: versionStatusEnum.CHECK_OUT_STATUS,
- lockingUser: 'cs0008'
- };
+ const currentSoftwareProduct = VSPEditorFactory.build();
var obj = {
- softwareProduct: {
+ softwareProduct: SoftwareProductFactory.build({
softwareProductEditor: {
data: currentSoftwareProduct
},
softwareProductComponents: {
componentEditor: {
data: {},
- qdata: {},
- qschema: {}
+ qdata: {}
}
}
- }
+ })
};
var results = mapStateToProps(obj);
- expect(results.componentData).toExist();
- expect(results.qdata).toExist();
- expect(results.qschema).toExist();
+ expect(results.componentData).toBeTruthy();
+ expect(results.qdata).toBeTruthy();
});
it('VSP Components general view test', () => {
- const currentSoftwareProduct = {
- name: 'VSp',
- description: 'dfdf',
- vendorName: 'V1',
- vendorId: '97B3E2525E0640ACACF87CE6B3753E80',
- category: 'resourceNewCategory.application l4+',
- subCategory: 'resourceNewCategory.application l4+.database',
- id: 'D4774719D085414E9D5642D1ACD59D20',
- version: '0.10',
- viewableVersions: ['0.1', '0.2'],
- status: versionStatusEnum.CHECK_OUT_STATUS,
- lockingUser: 'cs0008'
- };
+ const currentSoftwareProduct = VSPEditorFactory.build();
const softwareProductComponents = {
componentEditor: {
data: {},
qdata: {},
- qschema: {
- $schema: 'http://json-schema.org/draft-04/schema#',
- type: 'object',
- properties: {
- general: {
- type: 'object',
- properties: {}
- }
- }
- }
+ qschema: VSPQSchemaFactory.build()
}
};
- const versionControllerData = {
- version: '1',
- viewableVersions: [],
- status: 'locked',
- isCheckedOut: true
- };
+ const versionControllerData = VSPComponentsVersionControllerFactory.build();
const componentData = {
name: '',
@@ -122,7 +82,7 @@ describe('SoftwareProductComponentsGeneral Mapper and View Classes', () => {
versionControllerData={versionControllerData}
currentSoftwareProduct={currentSoftwareProduct}/>);
var renderedOutput = renderer.getRenderOutput();
- expect(renderedOutput).toExist();
+ expect(renderedOutput).toBeTruthy();
});
diff --git a/openecomp-ui/test/softwareProduct/components/loadBalancing/softwareProductComponentLoadbalancing.test.js b/openecomp-ui/test/softwareProduct/components/loadBalancing/softwareProductComponentLoadbalancing.test.js
index 69a93b69e1..0ee9c76961 100644
--- a/openecomp-ui/test/softwareProduct/components/loadBalancing/softwareProductComponentLoadbalancing.test.js
+++ b/openecomp-ui/test/softwareProduct/components/loadBalancing/softwareProductComponentLoadbalancing.test.js
@@ -1,110 +1,69 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-import expect from 'expect';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/components/loadBalancing/SoftwareProductComponentLoadBalancing.js';
import SoftwareProductComponentLoadBalancingView from 'sdc-app/onboarding/softwareProduct/components/loadBalancing/SoftwareProductComponentLoadBalancingRefView.jsx';
-import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
+
+import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
+import {SoftwareProductFactory} from 'test-utils/factories/softwareProduct/SoftwareProductFactory.js';
+import {VSPComponentsVersionControllerFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js';
+import VSPQSchemaFactory from 'test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js';
describe('SoftwareProductComponentLoadBalancing Mapper and View Classes', () => {
it('mapStateToProps mapper exists', () => {
- expect(mapStateToProps).toExist();
+ expect(mapStateToProps).toBeTruthy();
});
it('mapStateToProps data test', () => {
- const currentSoftwareProduct = {
- name: 'VSp',
- description: 'dfdf',
- vendorName: 'V1',
- vendorId: '97B3E2525E0640ACACF87CE6B3753E80',
- category: 'resourceNewCategory.application l4+',
- subCategory: 'resourceNewCategory.application l4+.database',
- id: 'D4774719D085414E9D5642D1ACD59D20',
- version: '0.10',
- viewableVersions: ['0.1', '0.2'],
- status: versionStatusEnum.CHECK_OUT_STATUS,
- lockingUser: 'cs0008'
- };
+ const currentSoftwareProduct = VSPEditorFactory.build();
var obj = {
- softwareProduct: {
+ softwareProduct: SoftwareProductFactory.build({
softwareProductEditor: {
data: currentSoftwareProduct
},
softwareProductComponents: {
componentEditor: {
- qdata: {},
- qschema: {}
+ qdata: {}
}
}
- }
+ })
};
var results = mapStateToProps(obj);
- expect(results.qdata).toExist();
- expect(results.qschema).toExist();
+ expect(results.qdata).toBeTruthy();
});
it('VSP Components LoadBalancing view test', () => {
- const currentSoftwareProduct = {
- name: 'VSp',
- description: 'dfdf',
- vendorName: 'V1',
- vendorId: '97B3E2525E0640ACACF87CE6B3753E80',
- category: 'resourceNewCategory.application l4+',
- subCategory: 'resourceNewCategory.application l4+.database',
- id: 'D4774719D085414E9D5642D1ACD59D20',
- version: '0.10',
- viewableVersions: ['0.1', '0.2'],
- status: versionStatusEnum.CHECK_OUT_STATUS,
- lockingUser: 'cs0008'
- };
+ const currentSoftwareProduct = VSPEditorFactory.build();
const softwareProductComponents = {
componentEditor: {
qdata: {},
- qschema: {
- $schema: 'http://json-schema.org/draft-04/schema#',
- type: 'object',
- properties: {
- general: {
- type: 'object',
- properties: {}
- }
- }
- }
+ qschema: VSPQSchemaFactory.build()
}
};
- const versionControllerData = {
- version: '1',
- viewableVersions: [],
- status: 'locked',
- isCheckedOut: true
- };
+ const versionControllerData = VSPComponentsVersionControllerFactory.build();
var renderer = TestUtils.createRenderer();
renderer.render(
@@ -115,7 +74,7 @@ describe('SoftwareProductComponentLoadBalancing Mapper and View Classes', () =>
softwareProductId='123'
componentId='321'/>);
var renderedOutput = renderer.getRenderOutput();
- expect(renderedOutput).toExist();
+ expect(renderedOutput).toBeTruthy();
});
diff --git a/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js b/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js
index 2f1ea12c01..24658f1b30 100644
--- a/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js
+++ b/openecomp-ui/test/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.test.js
@@ -1,57 +1,53 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-import expect from 'expect';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoring.js';
import SoftwareProductComponentsMonitoringView from 'sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringView.jsx';
+import {VSPComponentsMonitoringViewFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsMonitoringFactories.js';
+import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
+
+const version = VersionControllerUtilsFactory.build();
+
describe('SoftwareProductComponentsMonitoring Module Tests', function () {
it('should mapper exist', () => {
- expect(mapStateToProps).toExist();
+ expect(mapStateToProps).toBeTruthy();
});
it('should return empty file names', () => {
- let softwareProduct = {softwareProductEditor: {data: {}}, softwareProductComponents: {monitoring: {}}};
+ let softwareProduct = {softwareProductEditor: {data: {...version}}, softwareProductComponents: {monitoring: {}}};
var results = mapStateToProps({softwareProduct});
expect(results.trapFilename).toEqual(undefined);
expect(results.pollFilename).toEqual(undefined);
});
it('should return trap file name', () => {
- const monitoring = {
- trapFilename: '123'
- };
- let softwareProduct = {softwareProductEditor: {data: {}}, softwareProductComponents: {monitoring}};
+ const monitoring = VSPComponentsMonitoringViewFactory.build({}, {snmpTrapFlag: true});
+ let softwareProduct = {softwareProductEditor: {data: {...version}}, softwareProductComponents: {monitoring}};
var results = mapStateToProps({softwareProduct});
expect(results.trapFilename).toEqual(monitoring.trapFilename);
expect(results.pollFilename).toEqual(undefined);
});
it('should return poll file names', () => {
- const monitoring = {
- pollFilename: '123'
- };
- let softwareProduct = {softwareProductEditor: {data: {}}, softwareProductComponents: {monitoring}};
+ const monitoring = VSPComponentsMonitoringViewFactory.build({}, {snmpPollFlag: true});
+ let softwareProduct = {softwareProductEditor: {data: {...version}}, softwareProductComponents: {monitoring}};
var results = mapStateToProps({softwareProduct});
expect(results.trapFilename).toEqual(undefined);
expect(results.pollFilename).toEqual(monitoring.pollFilename);
@@ -59,15 +55,12 @@ describe('SoftwareProductComponentsMonitoring Module Tests', function () {
let renderer = TestUtils.createRenderer();
renderer.render(<SoftwareProductComponentsMonitoringView {...results} />);
let renderedOutput = renderer.getRenderOutput();
- expect(renderedOutput).toExist();
+ expect(renderedOutput).toBeTruthy();
});
it('should return both file names', () => {
- const monitoring = {
- trapFilename: '1234',
- trapFilename: '123'
- };
- let softwareProduct = {softwareProductEditor: {data: {}}, softwareProductComponents: {monitoring}};
+ const monitoring = VSPComponentsMonitoringViewFactory.build({}, {snmpTrapFlag: true, snmpPollFlag: true});
+ let softwareProduct = {softwareProductEditor: {data: {...version}}, softwareProductComponents: {monitoring}};
var results = mapStateToProps({softwareProduct});
expect(results.trapFilename).toEqual(monitoring.trapFilename);
expect(results.pollFilename).toEqual(monitoring.pollFilename);
@@ -75,7 +68,7 @@ describe('SoftwareProductComponentsMonitoring Module Tests', function () {
let renderer = TestUtils.createRenderer();
renderer.render(<SoftwareProductComponentsMonitoringView {...results} />);
let renderedOutput = renderer.getRenderOutput();
- expect(renderedOutput).toExist();
+ expect(renderedOutput).toBeTruthy();
});
it('should change state to dragging', done => {
diff --git a/openecomp-ui/test/softwareProduct/components/monitoring/test.js b/openecomp-ui/test/softwareProduct/components/monitoring/test.js
index 172db653e9..dd0f850a89 100644
--- a/openecomp-ui/test/softwareProduct/components/monitoring/test.js
+++ b/openecomp-ui/test/softwareProduct/components/monitoring/test.js
@@ -1,31 +1,30 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-import expect from 'expect';
import mockRest from 'test-utils/MockRest.js';
import {storeCreator} from 'sdc-app/AppStore.js';
import SoftwareProductComponentsMonitoringConstants from 'sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringConstants.js';
import SoftwareProductComponentsMonitoringActionHelper from 'sdc-app/onboarding/softwareProduct/components/monitoring/SoftwareProductComponentsMonitoringActionHelper.js';
+import {VSPComponentsMonitoringRestFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsMonitoringFactories.js';
+import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
+
const softwareProductId = '123';
const componentId = '123';
+const version = VersionControllerUtilsFactory.build().version;
describe('Software Product Components Monitoring Module Tests', function () {
@@ -38,18 +37,16 @@ describe('Software Product Components Monitoring Module Tests', function () {
it('Fetch for existing files - no files', done => {
- let emptyResult = Object.freeze({
- snmpTrap: undefined,
- snmpPoll: undefined
- });
+ let emptyResult = VSPComponentsMonitoringRestFactory.build();
mockRest.addHandler('fetch', ({ baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp`);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp`);
return emptyResult;
});
SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, {
softwareProductId,
+ version,
componentId
});
setTimeout(()=> {
@@ -62,18 +59,16 @@ describe('Software Product Components Monitoring Module Tests', function () {
});
it('Fetch for existing files - only snmp trap file exists', done => {
- let response = Object.freeze({
- snmpTrap: 'asdfasdf',
- snmpPoll: undefined
- });
+ let response = VSPComponentsMonitoringRestFactory.build({}, {snmpTrapFlag: true});
mockRest.addHandler('fetch', ({ baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp`);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp`);
return response;
});
SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, {
softwareProductId,
+ version,
componentId
});
setTimeout(()=> {
@@ -85,18 +80,16 @@ describe('Software Product Components Monitoring Module Tests', function () {
});
it('Fetch for existing files - only snmp poll file exists', done => {
- let response = Object.freeze({
- snmpPoll: 'asdfasdf',
- snmpTrap: undefined
- });
+ let response = VSPComponentsMonitoringRestFactory.build({}, {snmpPollFlag: true});
mockRest.addHandler('fetch', ({baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp`);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp`);
return response;
});
SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, {
softwareProductId,
+ version,
componentId
});
setTimeout(()=> {
@@ -108,18 +101,16 @@ describe('Software Product Components Monitoring Module Tests', function () {
});
it('Fetch for existing files - both files exist', done => {
- let response = Object.freeze({
- snmpPoll: 'asdfasdf',
- snmpTrap: 'asdfgg'
- });
+ let response = VSPComponentsMonitoringRestFactory.build({}, {snmpTrapFlag: true, snmpPollFlag: true});
mockRest.addHandler('fetch', ({baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp`);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp`);
return response;
});
SoftwareProductComponentsMonitoringActionHelper.fetchExistingFiles(store.dispatch, {
softwareProductId,
+ version,
componentId
});
setTimeout(()=> {
@@ -132,8 +123,8 @@ describe('Software Product Components Monitoring Module Tests', function () {
it('Upload snmp trap file', done => {
- mockRest.addHandler('create', ({baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp-trap/upload`);
+ mockRest.addHandler('post', ({baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp-trap/upload`);
return {};
});
var debug = {hello: 'world'};
@@ -142,6 +133,7 @@ describe('Software Product Components Monitoring Module Tests', function () {
formData.append('upload', file);
SoftwareProductComponentsMonitoringActionHelper.uploadSnmpFile(store.dispatch, {
softwareProductId,
+ version,
componentId,
formData,
fileSize: file.size,
@@ -156,8 +148,8 @@ describe('Software Product Components Monitoring Module Tests', function () {
});
it('Upload snmp poll file', done => {
- mockRest.addHandler('create', ({baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp/upload`);
+ mockRest.addHandler('post', ({baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp/upload`);
return {};
});
var debug = {hello: 'world'};
@@ -166,6 +158,7 @@ describe('Software Product Components Monitoring Module Tests', function () {
formData.append('upload', file);
SoftwareProductComponentsMonitoringActionHelper.uploadSnmpFile(store.dispatch, {
softwareProductId,
+ version,
componentId,
formData,
fileSize: file.size,
@@ -181,11 +174,12 @@ describe('Software Product Components Monitoring Module Tests', function () {
it('Delete snmp trap file', done => {
mockRest.addHandler('destroy', ({baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp-trap`);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp-trap`);
return {};
});
SoftwareProductComponentsMonitoringActionHelper.deleteSnmpFile(store.dispatch, {
softwareProductId,
+ version,
componentId,
type: SoftwareProductComponentsMonitoringConstants.SNMP_TRAP
});
@@ -198,11 +192,12 @@ describe('Software Product Components Monitoring Module Tests', function () {
it('Delete snmp poll file', done => {
mockRest.addHandler('destroy', ({baseUrl}) => {
- expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/monitors/snmp`);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/monitors/snmp`);
return {};
});
SoftwareProductComponentsMonitoringActionHelper.deleteSnmpFile(store.dispatch, {
softwareProductId,
+ version,
componentId,
type: SoftwareProductComponentsMonitoringConstants.SNMP_POLL
});
diff --git a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js
index c9760f7799..094b95a091 100644
--- a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js
+++ b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNICEditor.test.js
@@ -1,55 +1,42 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-import expect from 'expect';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNICEditor.js';
import SoftwareProductComponentsNICEditorView from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNICEditorView.jsx';
-
+import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
+import {SoftwareProductFactory} from 'test-utils/factories/softwareProduct/SoftwareProductFactory.js';
+import {VSPComponentsNicFactory, VSPComponentsNetworkQDataFactory, VSPComponentsNicFactoryQGenericFieldInfo,
+ VSPComponentsNicFactoryGenericFieldInfo, VSPComponentsNetworkDataMapFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js';
describe('Software Product Component Network NIC Editor and View Classes', () => {
it('mapStateToProps mapper exists', () => {
- expect(mapStateToProps).toExist();
+ expect(mapStateToProps).toBeTruthy();
});
it('mapStateToProps data test', () => {
- const currentSoftwareProduct = {
- name: 'VSp',
- description: 'dfdf',
- vendorName: 'V1',
- vendorId: '97B3E2525E0640ACACF87CE6B3753E80',
- category: 'resourceNewCategory.application l4+',
- subCategory: 'resourceNewCategory.application l4+.database',
- id: 'D4774719D085414E9D5642D1ACD59D20',
- version: '0.10',
- viewableVersions: ['0.1', '0.2'],
- lockingUser: 'cs0008'
- };
+ const currentSoftwareProduct = VSPEditorFactory.build();
var obj = {
- softwareProduct: {
+ softwareProduct: SoftwareProductFactory.build({
softwareProductEditor: {
data: currentSoftwareProduct
},
@@ -58,40 +45,42 @@ describe('Software Product Component Network NIC Editor and View Classes', () =>
nicEditor: {
data: {},
qdata: {},
- qschema: {}
+ dataMap: {},
+ qgenericFieldInfo: {},
+ genericFieldInfo: {}
}
}
}
- }
+ })
};
var results = mapStateToProps(obj);
- expect(results.currentSoftwareProduct).toExist();
- expect(results.qdata).toExist();
- expect(results.qschema).toExist();
- expect(results.data).toExist();
+ expect(results.currentSoftwareProduct).toBeTruthy();
+ expect(results.qdata).toBeTruthy();
+ expect(results.dataMap).toBeTruthy();
+ expect(results.genericFieldInfo).toBeTruthy();
+ expect(results.qgenericFieldInfo).toBeTruthy();
+ expect(results.data).toBeTruthy();
});
it('Software Product Component Network NIC Editor View Test', () => {
- const data = {
- name: '',
- description: '',
- networkName: ''
+ const props = {
+ data: VSPComponentsNicFactory.build(),
+ qdata: VSPComponentsNetworkQDataFactory.build(),
+ dataMap: VSPComponentsNetworkDataMapFactory.build(),
+ genericFieldInfo: VSPComponentsNicFactoryGenericFieldInfo.build(),
+ qgenericFieldInfo: VSPComponentsNicFactoryQGenericFieldInfo.build(),
+ isFormValid: true,
+ formReady: false,
+ protocols: []
};
- const qdata = {};
- const qschema = {};
-
var renderer = TestUtils.createRenderer();
- renderer.render(
- <SoftwareProductComponentsNICEditorView
- data={data}
- qdata={qdata}
- qschema={qschema}/>);
+ renderer.render(<SoftwareProductComponentsNICEditorView {...props}/>);
var renderedOutput = renderer.getRenderOutput();
- expect(renderedOutput).toExist();
+ expect(renderedOutput).toBeTruthy();
});
});
diff --git a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetwork.test.js b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetwork.test.js
index 520fde7403..d35659c93b 100644
--- a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetwork.test.js
+++ b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetwork.test.js
@@ -1,110 +1,75 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-import expect from 'expect';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkList.js';
import SoftwareProductComponentsNetworkListView from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkListView.jsx';
-import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
+import {SoftwareProductFactory} from 'test-utils/factories/softwareProduct/SoftwareProductFactory.js';
+import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
+import {VSPComponentsNicWithIdFactory, VSPComponentsVersionControllerFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js';
describe('Software Product Component Network Mapper and View Classes', () => {
it('mapStateToProps mapper exists', () => {
- expect(mapStateToProps).toExist();
+ expect(mapStateToProps).toBeTruthy();
});
it('mapStateToProps data test', () => {
- const currentSoftwareProduct = {
- name: 'VSp',
- description: 'dfdf',
- vendorName: 'V1',
- vendorId: '97B3E2525E0640ACACF87CE6B3753E80',
- category: 'resourceNewCategory.application l4+',
- subCategory: 'resourceNewCategory.application l4+.database',
- id: 'D4774719D085414E9D5642D1ACD59D20',
- version: '0.10',
- viewableVersions: ['0.1', '0.2'],
- status: versionStatusEnum.CHECK_OUT_STATUS,
- lockingUser: 'cs0008'
- };
+ const currentSoftwareProduct = VSPEditorFactory.build();
var obj = {
- softwareProduct: {
+ softwareProduct: SoftwareProductFactory.build({
softwareProductEditor: {
data: currentSoftwareProduct
},
softwareProductComponents: {
componentEditor: {
qdata: {},
- qschema: {},
- data: {}
+ data: {},
+ dataMap: {},
+ qgenericFieldInfo: {},
+ isFormValid: true,
+ formReady: false
},
network: {
nicEditor: {},
nicList: []
}
}
- }
+ })
};
var results = mapStateToProps(obj);
- expect(results.qdata).toExist();
- expect(results.qschema).toExist();
- expect(results.componentData).toExist();
+ expect(results.qdata).toBeTruthy();
+ expect(results.dataMap).toBeTruthy();
+ expect(results.qgenericFieldInfo).toBeTruthy();
+ expect(results.componentData).toBeTruthy();
});
it('Software Product Component Network List View Test', () => {
- const currentSoftwareProduct = {
- name: 'VSp',
- description: 'dfdf',
- vendorName: 'V1',
- vendorId: '97B3E2525E0640ACACF87CE6B3753E80',
- category: 'resourceNewCategory.application l4+',
- subCategory: 'resourceNewCategory.application l4+.database',
- id: 'D4774719D085414E9D5642D1ACD59D20',
- version: '0.10',
- viewableVersions: ['0.1', '0.2'],
- status: versionStatusEnum.CHECK_IN_STATUS,
- lockingUser: 'cs0008'
- };
+ const currentSoftwareProduct = VSPEditorFactory.build();
- const versionControllerData = {
- version: '1',
- viewableVersions: [],
- status: 'locked',
- isCheckedOut: true
- };
+ const versionControllerData = VSPComponentsVersionControllerFactory.build();
- const nicList = [
- {
- name: 'name',
- networkId: 'network',
- id: '122',
- networkName: 'nname'
- }
- ];
+ const nicList = VSPComponentsNicWithIdFactory.buildList(1);
var renderer = TestUtils.createRenderer();
renderer.render(
@@ -115,7 +80,7 @@ describe('Software Product Component Network Mapper and View Classes', () => {
componentId='321'
nicList={nicList}/>);
var renderedOutput = renderer.getRenderOutput();
- expect(renderedOutput).toExist();
+ expect(renderedOutput).toBeTruthy();
diff --git a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js
index 8c23267c89..f5a10e23c9 100644
--- a/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js
+++ b/openecomp-ui/test/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.test.js
@@ -1,33 +1,33 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-
-import {expect} from 'chai';
import deepFreeze from 'deep-freeze';
import mockRest from 'test-utils/MockRest.js';
import {cloneAndSet} from 'test-utils/Util.js';
import {storeCreator} from 'sdc-app/AppStore.js';
import SoftwareProductComponentsNetworkActionHelper from 'sdc-app/onboarding/softwareProduct/components/network/SoftwareProductComponentsNetworkActionHelper.js';
+import {VSPComponentsNicFactory, VSPComponentsNetworkFactory, VSPComponentsNetworkQDataFactory, VSPComponentsNetworkDataMapFactory, VSPComponentsNicFactoryGenericFieldInfo} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js';
+import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
+import VSPQSchemaFactory from 'test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js';
+import {forms} from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsConstants.js';
+
const softwareProductId = '123';
const componentId = '321';
const nicId = '111';
+const version = VersionControllerUtilsFactory.build().version;
describe('Software Product Components Network Action Helper Tests', function () {
@@ -35,23 +35,7 @@ describe('Software Product Components Network Action Helper Tests', function ()
const store = storeCreator();
deepFreeze(store.getState());
- const NICList = [
- {
- name:'oam01_port_0',
- description:'bbbbbbb',
- networkId:'A0E578751B284D518ED764D5378EA97C',
- id:'96D3648338F94DAA9889E9FBB8E59895',
- networkName:'csb_net'
- },
- {
- name:'oam01_port_1',
- description:'bbbbbbb',
- networkId:'378EA97CA0E578751B284D518ED764D5',
- id:'8E5989596D3648338F94DAA9889E9FBB',
- networkName:'csb_net_2'
- }
-
- ];
+ const NICList = VSPComponentsNicFactory.buildList(2);
deepFreeze(NICList);
@@ -60,14 +44,14 @@ describe('Software Product Components Network Action Helper Tests', function ()
const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network.nicList', NICList);
mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/nics`);
- expect(data).to.deep.equal(undefined);
- expect(options).to.equal(undefined);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
return {results: NICList};
});
- return SoftwareProductComponentsNetworkActionHelper.fetchNICsList(store.dispatch, {softwareProductId, componentId}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ return SoftwareProductComponentsNetworkActionHelper.fetchNICsList(store.dispatch, {softwareProductId, version, componentId}).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
});
});
@@ -76,12 +60,8 @@ describe('Software Product Components Network Action Helper Tests', function ()
const store = storeCreator();
deepFreeze(store.getState());
- const data = {
- name: 'oam01_port_0',
- description: 'bbbbbbb',
- networkId: 'A0E578751B284D518ED764D5378EA97C',
- networkName: 'csb_net'
- };
+ const data = VSPComponentsNicFactory.build();
+ const genericFieldInfo = VSPComponentsNicFactoryGenericFieldInfo.build();
const nic = {id: '444'};
deepFreeze(data);
@@ -91,20 +71,19 @@ describe('Software Product Components Network Action Helper Tests', function ()
deepFreeze(expectedData);
- const network = {
+ const network = VSPComponentsNetworkFactory.build({
nicEditor: {
- data: expectedData
- },
- nicList: []
- };
+ data: expectedData,
+ formName: forms.NIC_EDIT_FORM,
+ genericFieldInfo
+ }
+ });
const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', network);
SoftwareProductComponentsNetworkActionHelper.openNICEditor(store.dispatch, {nic, data});
- return setTimeout(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
- }, 100);
+ expect(store.getState()).toEqual(expectedStore);
});
it('close NICE editor', () => {
@@ -112,41 +91,31 @@ describe('Software Product Components Network Action Helper Tests', function ()
const store = storeCreator();
deepFreeze(store.getState());
- const network = {
- nicEditor: {},
- nicList: []
- };
+ const network = VSPComponentsNetworkFactory.build();
deepFreeze(network);
const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', network);
SoftwareProductComponentsNetworkActionHelper.closeNICEditor(store.dispatch);
- return setTimeout(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
- }, 100);
+ expect(store.getState()).toEqual(expectedStore);
});
it('Load NIC data', () => {
- const expectedData = {
- description: 'bbbbbbb',
- name: 'oam01_port_0',
- networkId: 'A0E578751B284D518ED764D5378EA97C',
- networkName: 'csb_net'
- };
+ const expectedData = VSPComponentsNicFactory.build();
deepFreeze(expectedData);
mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/nics/${nicId}`);
- expect(data).to.deep.equal(undefined);
- expect(options).to.equal(undefined);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics/${nicId}`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
return (expectedData);
});
- return SoftwareProductComponentsNetworkActionHelper.loadNICData({softwareProductId, componentId, nicId}).then((data) => {
- expect(data).to.deep.equal(expectedData);
+ return SoftwareProductComponentsNetworkActionHelper.loadNICData({softwareProductId, version, componentId, nicId}).then((data) => {
+ expect(data).toEqual(expectedData);
});
});
@@ -156,119 +125,47 @@ describe('Software Product Components Network Action Helper Tests', function ()
const store = storeCreator();
deepFreeze(store.getState());
- const qdata = {
- protocols: {
- protocolWithHighestTrafficProfile: 'UDP',
- protocols: ['UDP']
- },
- ipConfiguration: {
- ipv4Required: true
- }
- };
-
- const qschema = {
- $schema: 'http://json-schema.org/draft-04/schema#',
- type: 'object',
- properties: {
- 'protocols': {
- type: 'object',
- properties: {}
- }
- }
- };
+ const qdata = VSPComponentsNetworkQDataFactory.build();
+ const dataMap = VSPComponentsNetworkDataMapFactory.build();
+ const qgenericFieldInfo = {};
+ const qschema = VSPQSchemaFactory.build();
deepFreeze(qdata);
+ deepFreeze(dataMap);
deepFreeze(qschema);
- const network = {
+ const network = VSPComponentsNetworkFactory.build({
nicEditor: {
qdata,
- qschema
- },
- nicList: []
- };
+ dataMap,
+ qgenericFieldInfo
+ }
+ });
deepFreeze(network);
const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', network);
mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/nics/${nicId}/questionnaire`);
- expect(data).to.deep.equal(undefined);
- expect(options).to.equal(undefined);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics/${nicId}/questionnaire`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
return ({data: JSON.stringify(qdata), schema: JSON.stringify(qschema)});
});
- return SoftwareProductComponentsNetworkActionHelper.loadNICQuestionnaire(store.dispatch, {softwareProductId, componentId, nicId}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ return SoftwareProductComponentsNetworkActionHelper.loadNICQuestionnaire(store.dispatch, {softwareProductId, version, componentId, nicId}).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
});
- it('update NIC Data', () => {
- const store = storeCreator();
- deepFreeze(store.getState());
-
- const data = {test: '123'};
- deepFreeze(data);
-
- const network = {
- nicEditor: {
- data
- },
- nicList: []
- };
-
- deepFreeze(network);
-
- const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', network);
-
- SoftwareProductComponentsNetworkActionHelper.updateNICData(store.dispatch, {deltaData:data});
-
- return setTimeout(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
- }, 100);
-
- });
-
- it('update NIC Questionnaire', () => {
- const store = storeCreator();
- deepFreeze(store.getState());
-
- const qdata = {
- test: '123'
- };
- const network = {
- nicEditor: {
- qdata,
- qschema: undefined
- },
- nicList: []
- };
- deepFreeze(network);
-
- const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', network);
-
- SoftwareProductComponentsNetworkActionHelper.updateNICQuestionnaire(store.dispatch, {data:qdata});
-
- return setTimeout(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
- }, 100);
-
- });
-
it('save NIC Data And Questionnaire', () => {
const store = storeCreator();
deepFreeze(store.getState());
- const qdata = {
- qtest: '111'
- };
- const data = {
- name: '2222',
- description: 'blabla',
- networkId: '123445'
- };
+ const qdata = VSPComponentsNetworkQDataFactory.build();
+ const data = VSPComponentsNicFactory.build();
const expectedData = {...data, id: nicId};
@@ -282,22 +179,22 @@ describe('Software Product Components Network Action Helper Tests', function ()
const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.network', network);
deepFreeze(expectedStore);
- mockRest.addHandler('save', ({options, data, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/nics/${nicId}/questionnaire`);
- expect(data).to.deep.equal(qdata);
- expect(options).to.equal(undefined);
+ mockRest.addHandler('put', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics/${nicId}/questionnaire`);
+ expect(data).toEqual(qdata);
+ expect(options).toEqual(undefined);
return {returnCode: 'OK'};
});
- mockRest.addHandler('save', ({options, data, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/nics/${nicId}`);
- expect(data).to.deep.equal(data);
- expect(options).to.equal(undefined);
+ mockRest.addHandler('put', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${componentId}/nics/${nicId}`);
+ expect(data).toEqual(data);
+ expect(options).toEqual(undefined);
return {returnCode: 'OK'};
});
- return SoftwareProductComponentsNetworkActionHelper.saveNICDataAndQuestionnaire(store.dispatch, {softwareProductId, componentId, qdata, data: expectedData}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ return SoftwareProductComponentsNetworkActionHelper.saveNICDataAndQuestionnaire(store.dispatch, {softwareProductId, version, componentId, qdata, data: expectedData}).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
});
});
diff --git a/openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesEditor.test.js b/openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesEditor.test.js
new file mode 100644
index 0000000000..f3653fbcac
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesEditor.test.js
@@ -0,0 +1,57 @@
+/*!
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesEditor.js';
+import SoftwareProductComponentProcessesEditorView from 'sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesEditorView.jsx';
+
+describe('Software Product Components Processes Editor Module Tests', function () {
+
+ it('should mapper exist', () => {
+ expect(mapStateToProps).toBeTruthy();
+ });
+
+ it('should return empty data', () => {
+
+ var state = {
+ softwareProduct: {
+ softwareProductComponents: {
+ componentProcesses: {
+ processesList: [],
+ processesEditor: {data: {}}
+ }
+ }
+ }
+ };
+
+ var results = mapStateToProps(state);
+ expect(results.data).toEqual({});
+ expect(results.previousData).toEqual(undefined);
+ });
+
+ it('jsx view test', () => {
+ var view = TestUtils.renderIntoDocument(
+ <SoftwareProductComponentProcessesEditorView
+ isReadOnlyMode={true}
+ data={{name: '1', description: '1', artifactName: '1'}}
+ previousData={{}}
+ onDataChanged={() => {}}
+ onSubmit={() => {}}
+ onClose={() => {}}/>);
+ expect(view).toBeTruthy();
+ });
+});
diff --git a/openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesView.test.js b/openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesView.test.js
new file mode 100644
index 0000000000..ac866727a6
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/components/processes/SoftwareProductComponentsProcessesView.test.js
@@ -0,0 +1,77 @@
+/*!
+* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+*
+* Licensed under the Apache License, Version 2.0 (the "License");
+* you may not use this file except in compliance with the License.
+* You may obtain a copy of the License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+* or implied. See the License for the specific language governing
+* permissions and limitations under the License.
+*/
+
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+
+import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesList.js';
+import SoftwareProductComponentsProcessesView from 'sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentsProcessesListView.jsx';
+
+import {VSPProcessStoreFactory} from 'test-utils/factories/softwareProduct/SoftwareProductProcessFactories.js';
+import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
+import {VSPComponentsFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js';
+
+describe('SoftwareProductComponetsProcesses Mapper and View Classes', () => {
+ it('mapStateToProps mapper exists', () => {
+ expect(mapStateToProps).toBeTruthy();
+ });
+
+ it('mapStateToProps data test', () => {
+ const currentSoftwareProduct = VSPEditorFactory.build();
+
+ const processesList = VSPProcessStoreFactory.buildList(2);
+
+ var state = {
+ softwareProduct: {
+ softwareProductEditor: {
+ data: currentSoftwareProduct
+ },
+ softwareProductComponents: {
+ componentProcesses: {
+ processesList,
+ processesEditor: {
+ data: {}
+ }
+ }
+ }
+ }
+ };
+ var results = mapStateToProps(state);
+ expect(results.processesList.length).toBe(2);
+ });
+
+ it('view simple test', () => {
+ const currentSoftwareProduct = VSPEditorFactory.build();
+ const currentSoftwareProductComponent = VSPComponentsFactory.build();
+ const processesList = VSPProcessStoreFactory.buildList(2);
+
+ var renderer = TestUtils.createRenderer();
+ renderer.render(
+ <SoftwareProductComponentsProcessesView
+ processesList={processesList}
+ currentSoftwareProduct={currentSoftwareProduct}
+ softwareProductId={currentSoftwareProduct.id}
+ componentId={currentSoftwareProductComponent.id}
+ onAddProcess={() => {}}
+ onEditProcessClick={() => {}}
+ onDeleteProcessClick={() => {}}
+ isDisplayEditor={false}
+ isReadOnlyMode={false}/>
+ );
+ var renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toBeTruthy();
+ });
+});
diff --git a/openecomp-ui/test/softwareProduct/components/processes/test.js b/openecomp-ui/test/softwareProduct/components/processes/test.js
index 67427d3c05..02009e6542 100644
--- a/openecomp-ui/test/softwareProduct/components/processes/test.js
+++ b/openecomp-ui/test/softwareProduct/components/processes/test.js
@@ -1,51 +1,43 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-
-import {expect} from 'chai';
import deepFreeze from 'deep-freeze';
import mockRest from 'test-utils/MockRest.js';
+import {buildFromExistingObject} from 'test-utils/Util.js';
import {cloneAndSet} from 'test-utils/Util.js';
import {storeCreator} from 'sdc-app/AppStore.js';
import SoftwareProductComponentProcessesActionHelper from 'sdc-app/onboarding/softwareProduct/components/processes/SoftwareProductComponentProcessesActionHelper.js';
+import {
+ VSPProcessStoreWithArtifactNameFactory,
+ VSPProcessPostFactory,
+ VSPProcessStoreFactory,
+ VSPProcessPostFactoryWithType,
+ VSPProcessStoreFactoryWithType} from 'test-utils/factories/softwareProduct/SoftwareProductProcessFactories.js';
+
const softwareProductId = '123';
const componentId = '222';
+const versionId = '1';
+const version = {id: versionId, label: versionId};
+
describe('Software Product Component Processes Module Tests', function () {
it('Get Software Products Processes List', () => {
const store = storeCreator();
deepFreeze(store.getState());
- const softwareProductProcessesList = [
- {
- name: 'Pr1',
- description: 'hjhj',
- id: 'EBADF561B7FA4A788075E1840D0B5971',
- artifactName: 'artifact'
- },
- {
- name: 'Pr1',
- description: 'hjhj',
- id: '2F47447D22DB4C53B020CA1E66201EF2',
- artifactName: 'artifact'
- }
- ];
+ const softwareProductProcessesList = VSPProcessStoreWithArtifactNameFactory.buildList(2);
deepFreeze(softwareProductProcessesList);
@@ -54,25 +46,20 @@ describe('Software Product Component Processes Module Tests', function () {
const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentProcesses.processesList', softwareProductProcessesList);
mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/processes`);
- expect(data).to.deep.equal(undefined);
- expect(options).to.equal(undefined);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components/${componentId}/processes`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
return {results: softwareProductProcessesList};
});
+
- return SoftwareProductComponentProcessesActionHelper.fetchProcessesList(store.dispatch, {softwareProductId, componentId}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ return SoftwareProductComponentProcessesActionHelper.fetchProcessesList(store.dispatch, {softwareProductId, componentId, version}).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
});
});
it('Delete Software Products Processes', () => {
- const softwareProductProcessesList = [
- {
- name: 'Pr1',
- description: 'hjhj',
- id: 'EBADF561B7FA4A788075E1840D0B5971',
- artifactName: 'artifact'
- }
- ];
+ let process = VSPProcessStoreWithArtifactNameFactory.build();
+ const softwareProductProcessesList = [process];
deepFreeze(softwareProductProcessesList);
const store = storeCreator({
@@ -83,15 +70,15 @@ describe('Software Product Component Processes Module Tests', function () {
}
});
- const processId = 'EBADF561B7FA4A788075E1840D0B5971';
+ const processId = process.id;
deepFreeze(store.getState());
const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentProcesses.processesList', []);
mockRest.addHandler('destroy', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/processes/${processId}`);
- expect(data).to.equal(undefined);
- expect(options).to.equal(undefined);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components/${componentId}/processes/${processId}`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
return {
results: {
returnCode: 'OK'
@@ -101,9 +88,10 @@ describe('Software Product Component Processes Module Tests', function () {
return SoftwareProductComponentProcessesActionHelper.deleteProcess(store.dispatch, {
process: softwareProductProcessesList[0],
- softwareProductId, componentId
+ softwareProductId, componentId,
+ version
}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
});
@@ -112,27 +100,18 @@ describe('Software Product Component Processes Module Tests', function () {
const store = storeCreator();
deepFreeze(store.getState());
- const softwareProductPostRequest = {
- name: 'Pr1',
- description: 'string'
- };
- const softwareProductProcessToAdd = {
- name: 'Pr1',
- description: 'string'
- };
const softwareProductProcessFromResponse = 'ADDED_ID';
- const softwareProductProcessAfterAdd = {
- ...softwareProductProcessToAdd,
- id: softwareProductProcessFromResponse
- };
+
+ const softwareProductProcessAfterAdd = VSPProcessStoreFactory.build({id: softwareProductProcessFromResponse});
+ const softwareProductPostRequest = buildFromExistingObject(VSPProcessPostFactory, softwareProductProcessAfterAdd);
const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentProcesses.processesList', [softwareProductProcessAfterAdd]);
- mockRest.addHandler('create', ({data, options, baseUrl}) => {
+ mockRest.addHandler('post', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/processes`);
- expect(data).to.deep.equal(softwareProductPostRequest);
- expect(options).to.equal(undefined);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components/${componentId}/processes`);
+ expect(data).toEqual(softwareProductPostRequest);
+ expect(options).toEqual(undefined);
return {
returnCode: 'OK',
value: softwareProductProcessFromResponse
@@ -143,23 +122,55 @@ describe('Software Product Component Processes Module Tests', function () {
{
softwareProductId,
previousProcess: null,
- process: softwareProductProcessToAdd,
- componentId
+ process: softwareProductPostRequest,
+ componentId,
+ version
}
).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
});
- it('Update Software Products Processes', () => {
- const softwareProductProcessesList = [
+ it('Add Software Products Processes with type', () => {
+
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const softwareProductPostRequest = VSPProcessPostFactoryWithType.build();
+
+ const softwareProductProcessAfterAdd = VSPProcessStoreFactoryWithType.build(softwareProductPostRequest);
+ const softwareProductProcessFromResponse = softwareProductProcessAfterAdd.id;
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentProcesses.processesList', [softwareProductProcessAfterAdd]);
+
+ mockRest.addHandler('post', ({data, options, baseUrl}) => {
+
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components/${componentId}/processes`);
+ expect(data).toEqual(softwareProductPostRequest);
+ expect(options).toEqual(undefined);
+ return {
+ returnCode: 'OK',
+ value: softwareProductProcessFromResponse
+ };
+ });
+
+ return SoftwareProductComponentProcessesActionHelper.saveProcess(store.dispatch,
{
- name: 'Pr1',
- description: 'string',
- id: 'EBADF561B7FA4A788075E1840D0B5971',
- artifactName: 'artifact'
+ softwareProductId,
+ previousProcess: null,
+ process: softwareProductPostRequest,
+ componentId,
+ version
}
- ];
+ ).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+ it('Update Software Products Processes', () => {
+ let process = VSPProcessStoreWithArtifactNameFactory.build();
+
+ const softwareProductProcessesList = [process];
deepFreeze(softwareProductProcessesList);
const store = storeCreator({
@@ -173,28 +184,30 @@ describe('Software Product Component Processes Module Tests', function () {
});
deepFreeze(store.getState());
- const toBeUpdatedProcessId = softwareProductProcessesList[0].id;
- const previousProcessData = softwareProductProcessesList[0];
- const processUpdateData = {
- ...softwareProductProcessesList[0],
+ const toBeUpdatedProcessId = process.id;
+ const previousProcessData = process;
+ const processUpdateData = VSPProcessStoreWithArtifactNameFactory.build({
+ ...process,
name: 'Pr1_UPDATED',
- description: 'string_UPDATED'
- };
+ description: 'string_UPDATED',
+ type: 'Other'
+ });
deepFreeze(processUpdateData);
- const processPutRequest = {
+ const processPutRequest = VSPProcessPostFactory.build({
name: 'Pr1_UPDATED',
- description: 'string_UPDATED'
- };
+ description: 'string_UPDATED',
+ type: 'Other'
+ });
deepFreeze(processPutRequest);
const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentProcesses.processesList', [processUpdateData]);
- mockRest.addHandler('save', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${componentId}/processes/${toBeUpdatedProcessId}`);
- expect(data).to.deep.equal(processPutRequest);
- expect(options).to.equal(undefined);
+ mockRest.addHandler('put', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/components/${componentId}/processes/${toBeUpdatedProcessId}`);
+ expect(data).toEqual(processPutRequest);
+ expect(options).toEqual(undefined);
return {returnCode: 'OK'};
});
@@ -203,12 +216,12 @@ describe('Software Product Component Processes Module Tests', function () {
softwareProductId: softwareProductId,
componentId,
previousProcess: previousProcessData,
- process: processUpdateData
+ process: processUpdateData,
+ version
}
).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
});
});
-
diff --git a/openecomp-ui/test/softwareProduct/components/storage/test.js b/openecomp-ui/test/softwareProduct/components/storage/test.js
index 87cad368be..138c4da7d6 100644
--- a/openecomp-ui/test/softwareProduct/components/storage/test.js
+++ b/openecomp-ui/test/softwareProduct/components/storage/test.js
@@ -1,24 +1,19 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-import expect from 'expect';
import deepFreeze from 'deep-freeze';
import mockRest from 'test-utils/MockRest.js';
import {cloneAndSet} from 'test-utils/Util.js';
@@ -26,14 +21,18 @@ import {storeCreator} from 'sdc-app/AppStore.js';
import Configuration from 'sdc-app/config/Configuration.js';
import SoftwareProductComponentsActionHelper from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js';
+import {default as VSPComponentsStorageFactory, VSPComponentsStorageDataMapFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsStorageFactory.js';
+import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
+
const softwareProductId = '123';
const vspComponentId = '111';
+const version = VersionControllerUtilsFactory.build().version;
describe('Software Product Components Storage Module Tests', function () {
let restPrefix = '';
- before(function() {
+ beforeAll(function() {
restPrefix = Configuration.get('restPrefix');
deepFreeze(restPrefix);
});
@@ -42,28 +41,32 @@ describe('Software Product Components Storage Module Tests', function () {
const store = storeCreator();
deepFreeze(store.getState());
+ const storage = VSPComponentsStorageFactory.build();
+ const dataMap = VSPComponentsStorageDataMapFactory.build();
+
const softwareProductComponentStorage = {
- data: JSON.stringify({'backup':{'backupType':'OnSite','backupSolution':'76333'},'snapshotBackup':{'snapshotFrequency':'2'}}),
- schema: JSON.stringify({'backup':{'backupType':'OnSite','backupSolution':'76333'},'snapshotBackup':{'snapshotFrequency':'2'}})
+ data: JSON.stringify(storage),
+ schema: JSON.stringify(storage)
};
deepFreeze(softwareProductComponentStorage);
const softwareProductComponentStorageData = {
- qdata: JSON.parse(softwareProductComponentStorage.data),
- qschema: JSON.parse(softwareProductComponentStorage.schema)
+ qdata: storage,
+ dataMap: dataMap,
+ qgenericFieldInfo: {}
};
deepFreeze(softwareProductComponentStorageData);
const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor', softwareProductComponentStorageData);
mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
- expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/components/${vspComponentId}/questionnaire`);
+ expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/questionnaire`);
expect(data).toEqual(undefined);
expect(options).toEqual(undefined);
return softwareProductComponentStorage;
});
- return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, vspComponentId}).then(() => {
+ return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, version, vspComponentId}).then(() => {
expect(store.getState()).toEqual(expectedStore);
});
});
@@ -72,61 +75,33 @@ describe('Software Product Components Storage Module Tests', function () {
const store = storeCreator();
deepFreeze(store.getState());
+ const storage = VSPComponentsStorageFactory.build();
+
const softwareProductComponentQuestionnaire = {
data: null,
- schema: JSON.stringify({'backup':{'backupType':'OnSite','backupSolution':'76333'},'snapshotBackup':{'snapshotFrequency':'2'}})
+ schema: JSON.stringify(storage)
};
deepFreeze(softwareProductComponentQuestionnaire);
const softwareProductComponentQuestionnaireData = {
qdata: {},
- qschema: JSON.parse(softwareProductComponentQuestionnaire.schema)
+ dataMap: {},
+ qgenericFieldInfo: {}
};
deepFreeze(softwareProductComponentQuestionnaireData);
const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor', softwareProductComponentQuestionnaireData);
mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
- expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/components/${vspComponentId}/questionnaire`);
+ expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/questionnaire`);
expect(data).toEqual(undefined);
expect(options).toEqual(undefined);
return softwareProductComponentQuestionnaire;
});
- return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, vspComponentId}).then(() => {
+ return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, version, vspComponentId}).then(() => {
expect(store.getState()).toEqual(expectedStore);
});
});
- it('Update Software Products Components Storage', () => {
- const store = storeCreator({
- softwareProduct: {
- softwareProductComponents: {
- componentEditor: {
- qdata: {
- backupType: 'OnSite',
- backupStorageSize: 30
- },
- qschema: {
- type: 'object',
- properties: {
- backupType: {type: 'string'},
- backupStorageSize: {type: 'number'}
- }
- }
- }
- }
- }
- });
- deepFreeze(store);
-
- const data = {backupType: 'OffSite', backupStorageSize: 30};
- deepFreeze(data);
-
- const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor.qdata', data);
-
- SoftwareProductComponentsActionHelper.componentQuestionnaireUpdated(store.dispatch, {data});
-
- expect(store.getState()).toEqual(expectedStore);
- });
});
diff --git a/openecomp-ui/test/softwareProduct/components/test.js b/openecomp-ui/test/softwareProduct/components/test.js
index 839e1b7cf7..b3994b1461 100644
--- a/openecomp-ui/test/softwareProduct/components/test.js
+++ b/openecomp-ui/test/softwareProduct/components/test.js
@@ -1,32 +1,30 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-
-import {expect} from 'chai';
import deepFreeze from 'deep-freeze';
import mockRest from 'test-utils/MockRest.js';
import {cloneAndSet} from 'test-utils/Util.js';
import {storeCreator} from 'sdc-app/AppStore.js';
import SoftwareProductComponentsActionHelper from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js';
+import {VSPComponentsFactory, VSPComponentsGeneralFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js';
+import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
+
const softwareProductId = '123';
const vspComponentId = '321';
+const version = VersionControllerUtilsFactory.build().version;
describe('Software Product Components Module Tests', function () {
it('Get Software Products Components List', () => {
@@ -34,18 +32,8 @@ describe('Software Product Components Module Tests', function () {
deepFreeze(store.getState());
const softwareProductComponentsList = [
- {
- name: 'com.d2.resource.vfc.nodes.heat.sm_server',
- displayName: 'sm_server',
- description: 'hjhj',
- id: 'EBADF561B7FA4A788075E1840D0B5971'
- },
- {
- name: 'com.d2.resource.vfc.nodes.heat.pd_server',
- displayName: 'pd_server',
- description: 'hjhj',
- id: '2F47447D22DB4C53B020CA1E66201EF2'
- }
+ VSPComponentsFactory.build({}, {componentName: 'sd', componentType: 'server'}),
+ VSPComponentsFactory.build({}, {componentName: 'pd', componentType: 'server'})
];
deepFreeze(softwareProductComponentsList);
@@ -55,14 +43,14 @@ describe('Software Product Components Module Tests', function () {
const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentsList', softwareProductComponentsList);
mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components`);
- expect(data).to.deep.equal(undefined);
- expect(options).to.equal(undefined);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
return {results: softwareProductComponentsList};
});
- return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(store.dispatch, {softwareProductId}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(store.dispatch, {softwareProductId, version}).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
});
});
@@ -70,27 +58,21 @@ describe('Software Product Components Module Tests', function () {
const store = storeCreator();
const qdataUpdated = {
- general: {
- hypervisor: {
- containerFeatureDescription: 'aaaUpdated',
- drivers: 'bbbUpdated',
- hypervisor: 'cccUpdated'
- }
- }
+ general: VSPComponentsGeneralFactory.build()
};
const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductComponents.componentEditor.qdata', qdataUpdated);
deepFreeze(expectedStore);
- mockRest.addHandler('save', ({options, data, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/components/${vspComponentId}/questionnaire`);
- expect(data).to.deep.equal(qdataUpdated);
- expect(options).to.equal(undefined);
+ mockRest.addHandler('put', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components/${vspComponentId}/questionnaire`);
+ expect(data).toEqual(qdataUpdated);
+ expect(options).toEqual(undefined);
return {returnCode: 'OK'};
});
- return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, vspComponentId, qdata: qdataUpdated}).then(() => {
+ return SoftwareProductComponentsActionHelper.updateSoftwareProductComponentQuestionnaire(store.dispatch, {softwareProductId, version, vspComponentId, qdata: qdataUpdated}).then(() => {
//TODO think should we add here something or not
});
@@ -98,4 +80,3 @@ describe('Software Product Components Module Tests', function () {
});
});
-
diff --git a/openecomp-ui/test/softwareProduct/creation/SoftwareProductCreation.test.js b/openecomp-ui/test/softwareProduct/creation/SoftwareProductCreation.test.js
new file mode 100644
index 0000000000..c7c55bdbaf
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/creation/SoftwareProductCreation.test.js
@@ -0,0 +1,105 @@
+/*!
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import {mapStateToProps, mapActionsToProps} from 'sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreation.js';
+import SoftwareProductCreationView from 'sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationView.jsx';
+import {SoftwareProductCreationFactory, SoftwareProductCreationFactoryWithSelectedVendor} from 'test-utils/factories/softwareProduct/SoftwareProductCreationFactories.js';
+import {CategoryWithSubFactory} from 'test-utils/factories/softwareProduct/VSPCategoriesFactory.js';
+import {FinalizedLicenseModelFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
+import {storeCreator} from 'sdc-app/AppStore.js';
+
+describe('Software Product Creation Module Tests', function() {
+ it ('mapStateToProps mapper exists', () => {
+ expect(mapStateToProps).toBeTruthy();
+ });
+
+ it ('should return empty data', () => {
+ let state = {
+ softwareProductList: [],
+ softwareProduct: {
+ softwareProductCreation: {
+ data: {}
+ }
+ }
+ };
+ let props = mapStateToProps(state);
+ expect(props.data).toEqual({});
+ });
+
+ it ('should return vsp names list', () => {
+ let state = {
+ softwareProductList: [{
+ name: 'vsp1',
+ id: 'vsp1_id'
+ }, {
+ name: 'vsp2',
+ id: 'vsp2_id'
+ }],
+ softwareProduct: {
+ softwareProductCreation: {
+ data: {}
+ }
+ }
+ };
+ let props = mapStateToProps(state);
+ expect(props.data).toEqual({});
+ expect(props.VSPNames).toEqual({vsp1: 'vsp1_id', vsp2: 'vsp2_id'});
+ });
+
+ it('simple jsx test', () => {
+ const store = storeCreator();
+ let dispatch = store.dispatch;
+
+ let state = {
+ softwareProductList: [],
+ softwareProduct: {
+ softwareProductCreation: SoftwareProductCreationFactory.build(),
+ softwareProductCategories: CategoryWithSubFactory.buildList({}, {quantity: 2})
+ },
+ finalizedLicenseModelList: FinalizedLicenseModelFactory.buildList(3)
+ };
+ let props = Object.assign({}, mapStateToProps(state), mapActionsToProps(dispatch));
+ var renderer = TestUtils.createRenderer();
+ renderer.render(
+ <SoftwareProductCreationView {...props}/>
+ );
+ var renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toBeTruthy();
+ });
+
+ it('simple jsx test - with selected vendor', () => {
+ const store = storeCreator();
+ let dispatch = store.dispatch;
+ let finalizedLicenseModelList = FinalizedLicenseModelFactory.buildList(3);
+ let state = {
+ softwareProductList: [],
+ softwareProduct: {
+ softwareProductCreation: SoftwareProductCreationFactoryWithSelectedVendor.build({selectedVendorId: finalizedLicenseModelList[0].id}),
+ softwareProductCategories: CategoryWithSubFactory.buildList({}, {quantity: 2})
+ },
+ finalizedLicenseModelList
+ };
+ let props = Object.assign({}, mapStateToProps(state), mapActionsToProps(dispatch));
+ let renderer = TestUtils.createRenderer();
+ renderer.render(
+ <SoftwareProductCreationView {...props}/>
+ );
+ let renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toBeTruthy();
+ });
+});
diff --git a/openecomp-ui/test/softwareProduct/dependencies/SoftwareProductDependencies.test.js b/openecomp-ui/test/softwareProduct/dependencies/SoftwareProductDependencies.test.js
new file mode 100644
index 0000000000..5325a58959
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/dependencies/SoftwareProductDependencies.test.js
@@ -0,0 +1,210 @@
+/*!
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+import React from 'react';
+import {mount} from 'enzyme';
+import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependencies.js';
+import {
+ SoftwareProductDependenciesResponseFactory,
+ SoftwareProductDependenciesStoreFactory} from 'test-utils/factories/softwareProduct/SoftwareProductDependenciesFactories.js';
+import {VSPComponentsFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js';
+import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
+import {storeCreator} from 'sdc-app/AppStore.js';
+import {cloneAndSet} from 'test-utils/Util.js';
+import mockRest from 'test-utils/MockRest.js';
+
+import SoftwareProductComponentsActionHelper from 'sdc-app/onboarding/softwareProduct/components/SoftwareProductComponentsActionHelper.js';
+import SoftwareProductDependenciesActionHelper from 'sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesActionHelper.js';
+import SoftwareProductDependenciesView from 'sdc-app/onboarding/softwareProduct/dependencies/SoftwareProductDependenciesView.jsx';
+import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
+
+describe('Software Product Dependencies Module Tests', function () {
+ const softwareProductId = '555';
+ const version = VersionControllerUtilsFactory.build().version;
+
+ it('mapStateToProps mapper exists', () => {
+ expect(mapStateToProps).toBeTruthy();
+ });
+
+ it('Get Software Product Dependencies List', () => {
+ const store = storeCreator();
+ const dispatch = store.dispatch;
+
+ let DependenciesListResponse = SoftwareProductDependenciesResponseFactory.buildList(2);
+ let DependenciesListStore = DependenciesListResponse.map(dependency => SoftwareProductDependenciesStoreFactory.build(dependency));
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductDependencies', DependenciesListStore);
+
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/component-dependency-model`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: DependenciesListResponse};
+ });
+
+ return SoftwareProductDependenciesActionHelper.fetchDependencies(dispatch, {softwareProductId, version}).then(() => {
+ const state = store.getState();
+ const depndenciesWithGeneratedId = state.softwareProduct.softwareProductDependencies;
+ const currentDependencies = expectedStore.softwareProduct.softwareProductDependencies;
+ let expectedStoreDependencies = currentDependencies.map((dependency, index) => ({...dependency, id: depndenciesWithGeneratedId[index].id}));
+
+ const newExpectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductDependencies', expectedStoreDependencies);
+
+ expect(state).toEqual(newExpectedStore);
+ });
+ });
+
+ it('Update Software Product Dependencies List', () => {
+ const store = storeCreator();
+ const dispatch = store.dispatch;
+
+ let DependenciesListResponse = SoftwareProductDependenciesResponseFactory.buildList(3);
+ let DependenciesListStore = DependenciesListResponse.map(dependency => SoftwareProductDependenciesStoreFactory.build(dependency));
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductDependencies', DependenciesListStore);
+
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/component-dependency-model`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: DependenciesListResponse};
+ });
+
+ return SoftwareProductDependenciesActionHelper.fetchDependencies(dispatch, {softwareProductId, version}).then(() => {
+
+ const state = store.getState();
+ const depndenciesWithGeneratedId = state.softwareProduct.softwareProductDependencies;
+ const currentDependencies = expectedStore.softwareProduct.softwareProductDependencies;
+ let expectedStoreDependencies = currentDependencies.map((dependency, index) => ({...dependency, id: depndenciesWithGeneratedId[index].id}));
+
+ let newDependency = SoftwareProductDependenciesStoreFactory.build();
+ expectedStoreDependencies.push(newDependency);
+
+ const newExpectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductDependencies', expectedStoreDependencies);
+
+ SoftwareProductDependenciesActionHelper.updateDependencyList(dispatch, {dependenciesList: expectedStoreDependencies});
+ const newState = store.getState();
+ expect(newState).toEqual(newExpectedStore);
+ });
+ });
+
+ it('Add And Save Software Product Dependencies List', () => {
+ const store = storeCreator();
+ const dispatch = store.dispatch;
+
+ let mockServerDependencies = [];
+
+ SoftwareProductDependenciesActionHelper.addDependency(dispatch);
+ let state = store.getState();
+ let dependencies = state.softwareProduct.softwareProductDependencies;
+ expect(dependencies.length).toEqual(1);
+ expect(dependencies[0].sourceId).toEqual(null);
+ expect(dependencies[0].targetId).toEqual(null);
+
+ let newDependencies = SoftwareProductDependenciesStoreFactory.buildList(1);
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductDependencies', newDependencies);
+ SoftwareProductDependenciesActionHelper.updateDependencyList(dispatch, {dependenciesList: newDependencies});
+
+ mockRest.addHandler('post', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/component-dependency-model`);
+ expect(data).toEqual({componentDependencyModels: newDependencies.map(item => ({sourceId: item.sourceId, targetId: item.targetId, relationType: item.relationType}) )});
+ expect(options).toEqual(undefined);
+ mockServerDependencies = [...data.componentDependencyModels];
+ return {returnCode: 'OK'};
+ });
+
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/component-dependency-model`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: mockServerDependencies};
+ });
+
+ return SoftwareProductDependenciesActionHelper.saveDependencies(dispatch, {softwareProductId, version, dependenciesList: newDependencies}).then(() => {
+ return SoftwareProductDependenciesActionHelper.fetchDependencies(dispatch, {softwareProductId, version});
+ }).then(() => {
+ const state = store.getState();
+ const depndenciesWithGeneratedId = state.softwareProduct.softwareProductDependencies;
+ const currentDependencies = expectedStore.softwareProduct.softwareProductDependencies;
+ let expectedStoreDependencies = currentDependencies.map((dependency, index) => ({...dependency, id: depndenciesWithGeneratedId[index].id}));
+
+ const newExpectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductDependencies', expectedStoreDependencies);
+
+ expect(state).toEqual(newExpectedStore);
+ });
+ });
+
+ it('Get Software Product Dependencies List with loop, and render to JSX', () => {
+ const store = storeCreator();
+ const dispatch = store.dispatch;
+
+ let components = VSPComponentsFactory.buildList(2);
+ let vspEditor = VSPEditorFactory.build({id: softwareProductId, version});
+
+ let DependenciesListResponse = SoftwareProductDependenciesResponseFactory.buildList(2);
+ let firstDependecy = DependenciesListResponse[0];
+ let secondDependency = DependenciesListResponse[1];
+ firstDependecy.sourceId = components[0].id;
+ secondDependency.sourceId = components[1].id;
+ firstDependecy.targetId = secondDependency.sourceId;
+ secondDependency.targetId = firstDependecy.sourceId;
+
+ let DependenciesListStore = DependenciesListResponse.map(dependency => SoftwareProductDependenciesStoreFactory.build({...dependency, hasCycle: true}));
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductDependencies', DependenciesListStore);
+
+ mockRest.addHandler('fetch', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/component-dependency-model`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: DependenciesListResponse};
+ });
+
+ mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/components`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: components};
+ });
+
+ return SoftwareProductDependenciesActionHelper.fetchDependencies(dispatch, {softwareProductId, version}).then(() => {
+ return SoftwareProductComponentsActionHelper.fetchSoftwareProductComponents(dispatch, {softwareProductId, version});
+ }).then(() => {
+ const state = store.getState();
+ state.softwareProduct.softwareProductEditor = {data: vspEditor};
+ const depndenciesWithGeneratedId = state.softwareProduct.softwareProductDependencies;
+ const currentDependencies = expectedStore.softwareProduct.softwareProductDependencies;
+ let expectedStoreDependencies = currentDependencies.map((dependency, index) => ({...dependency, id: depndenciesWithGeneratedId[index].id}));
+
+ const newExpectedStore = {
+ ...expectedStore,
+ softwareProduct: {
+ ...expectedStore.softwareProduct,
+ softwareProductDependencies: expectedStoreDependencies,
+ softwareProductEditor: {data: vspEditor},
+ softwareProductComponents: {
+ ...expectedStore.softwareProduct.softwareProductComponents,
+ componentsList: components
+ }
+ }
+ };
+
+ expect(state).toEqual(newExpectedStore);
+
+ const props = mapStateToProps(state);
+ expect(props.softwareProductDependencies).toEqual(expectedStoreDependencies);
+ const wrapper = mount(<SoftwareProductDependenciesView {...props}/>);
+ expect(wrapper).toBeTruthy();
+ });
+ });
+}); \ No newline at end of file
diff --git a/openecomp-ui/test/softwareProduct/details/detailsView.test.js b/openecomp-ui/test/softwareProduct/details/detailsView.test.js
index b6a8ca5d4e..37c5df5079 100644
--- a/openecomp-ui/test/softwareProduct/details/detailsView.test.js
+++ b/openecomp-ui/test/softwareProduct/details/detailsView.test.js
@@ -1,87 +1,93 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-
-import expect from 'expect';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/details/SoftwareProductDetails.js';
import SoftwareProductDetailsView from 'sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsView.jsx';
-import {vspQschema as vspQuestionnaireSchema} from './vspQschema.js';
+import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
+import {CategoryWithSubFactory} from 'test-utils/factories/softwareProduct/VSPCategoriesFactory.js';
+import {LicenseAgreementStoreFactory} from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js';
+import {FeatureGroupStoreFactory} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js';
+import {SchemaGenericFieldInfoFactory} from 'test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js';
+import {default as VspQdataFactory, VspDataMapFactory} from 'test-utils/factories/softwareProduct/VspQdataFactory.js';
+import {FinalizedLicenseModelFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
describe('Software Product Details: ', function () {
- let currentSoftwareProduct = {}, categories = [], finalizedLicenseModelList, licenseAgreementList, featureGroupsList, vspQschema;
+ let currentSoftwareProduct = {}, currentSoftwareProductWithLicensingData = {}, softwareProductCategories = [],
+ finalizedLicenseModelList, licenseAgreementList, featureGroupsList, qdata = {}, dataMap = {}, genericFieldInfo = {}, qGenericFieldInfo = {};
let dummyFunc = () => {};
- before(function() {
- currentSoftwareProduct = {
- id: 'D4774719D085414E9D5642D1ACD59D20',
- name: 'VSP',
- description: 'dfdf',
- category: 'category1',
- subCategory: 'category1.subCategory',
- vendorId: 'VLM_ID1',
- vendorName: 'VLM1',
- licensingVersion: '1.0',
- licensingData: {}
+ beforeAll(function() {
+ finalizedLicenseModelList = FinalizedLicenseModelFactory.buildList(2);
+ currentSoftwareProduct = VSPEditorFactory.build({
+ id: 'RTRTG454545',
+ vendorId: finalizedLicenseModelList[0].id,
+ vendorName: finalizedLicenseModelList[0].vendorName
+ });
+ softwareProductCategories = CategoryWithSubFactory.buildList(2, {}, {quantity: 1});
+ licenseAgreementList = LicenseAgreementStoreFactory.buildList(2);
+ featureGroupsList = FeatureGroupStoreFactory.buildList(2, {referencingLicenseAgreements: [licenseAgreementList[0].id]});
+ qdata = VspQdataFactory.build();
+ dataMap = VspDataMapFactory.build();
+ currentSoftwareProductWithLicensingData = {
+ ...currentSoftwareProduct,
+ licensingData: {
+ licenseAgreement: licenseAgreementList[0].id,
+ featureGroups: [featureGroupsList[0].id]
+ }
+ };
+ genericFieldInfo = {
+ 'name': {
+ isValid: true,
+ errorText: '',
+ validations: [{type: 'validateName', data: true}, {type: 'maxLength', data: 120}, {
+ type: 'required',
+ data: true
+ }]
+ },
+ 'description': {
+ isValid: true,
+ errorText: '',
+ validations: [{type: 'required', data: true}]
+ }
};
- categories = [{
- uniqueId: 'category1',
- subcategories: [{
- uniqueId: 'subCategory'
- }]
- }, {
- uniqueId: 'category2',
- subcategories: [{
- uniqueId: 'subCategory2'
- }]
- }];
- finalizedLicenseModelList = [{
- id: 'VLM_ID1',
- name: 'VLM1'
- }];
- licenseAgreementList = [{id: 'LA_ID1'}, {id: 'LA_ID2'}];
- featureGroupsList = [
- {id: 'FG_ID1', name: 'FG1', referencingLicenseAgreements: ['LA_ID1']},
- {id: 'FG_ID2', name: 'FG2', referencingLicenseAgreements: ['LA_ID1']}
- ];
- vspQschema = vspQuestionnaireSchema;
+ qGenericFieldInfo = SchemaGenericFieldInfoFactory.build();
});
it('should mapper exist', () => {
- expect(mapStateToProps).toExist();
+ expect(mapStateToProps).toBeTruthy();
});
it('should mapper return vsp basic data', () => {
+
var obj = {
softwareProduct: {
softwareProductEditor: {
- data: currentSoftwareProduct
+ data: currentSoftwareProduct,
+ genericFieldInfo
},
- softwareProductCategories: categories,
+ softwareProductCategories,
softwareProductQuestionnaire: {
- qdata: {},
- qschema: vspQschema
+ qdata,
+ genericFieldInfo: qGenericFieldInfo,
+ dataMap
}
},
- finalizedLicenseModelList: finalizedLicenseModelList,
+ finalizedLicenseModelList,
licenseModel: {
licenseAgreement: {
licenseAgreementList: []
@@ -96,35 +102,32 @@ describe('Software Product Details: ', function () {
expect(result.currentSoftwareProduct).toEqual(currentSoftwareProduct);
expect(result.finalizedLicenseModelList).toEqual(finalizedLicenseModelList);
expect(result.finalizedLicenseModelList.length).toBeGreaterThan(0);
- expect(finalizedLicenseModelList).toInclude({
+ expect(finalizedLicenseModelList[0]).toMatchObject({
id: result.currentSoftwareProduct.vendorId,
- name: result.currentSoftwareProduct.vendorName
+ vendorName: result.currentSoftwareProduct.vendorName
});
- expect(result.softwareProductCategories).toEqual(categories);
+ expect(result.softwareProductCategories).toEqual(softwareProductCategories);
expect(result.licenseAgreementList).toEqual([]);
expect(result.featureGroupsList).toEqual([]);
- expect(result.qdata).toEqual({});
- expect(result.qschema).toEqual(vspQschema);
+ expect(result.qdata).toEqual(qdata);
+ expect(result.dataMap).toEqual(dataMap);
+ expect(result.isFormValid).toEqual(true);
expect(result.isReadOnlyMode).toEqual(true);
});
it('should mapper return vsp data with selected licenseAgreement and featureGroup', () => {
- let vspWithLicensingData = {
- ...currentSoftwareProduct,
- licensingData: {
- licenseAgreement: 'LA_ID1',
- featureGroups: [{enum: 'FG_ID1', title: 'FG1'}]
- }
- };
+
var obj = {
softwareProduct: {
softwareProductEditor: {
- data: vspWithLicensingData
+ data: currentSoftwareProductWithLicensingData,
+ genericFieldInfo
},
- softwareProductCategories: categories,
+ softwareProductCategories,
softwareProductQuestionnaire: {
- qdata: {},
- qschema: vspQschema
+ qdata,
+ genericFieldInfo: qGenericFieldInfo,
+ dataMap
}
},
finalizedLicenseModelList: finalizedLicenseModelList,
@@ -139,51 +142,36 @@ describe('Software Product Details: ', function () {
};
var result = mapStateToProps(obj);
- expect(result.currentSoftwareProduct).toEqual(vspWithLicensingData);
+ expect(result.currentSoftwareProduct).toEqual(currentSoftwareProductWithLicensingData);
expect(result.finalizedLicenseModelList).toEqual(finalizedLicenseModelList);
expect(result.finalizedLicenseModelList.length).toBeGreaterThan(0);
- expect(result.finalizedLicenseModelList).toInclude({
+ expect(result.finalizedLicenseModelList[0]).toMatchObject({
id: result.currentSoftwareProduct.vendorId,
- name: result.currentSoftwareProduct.vendorName
+ vendorName: result.currentSoftwareProduct.vendorName
});
- expect(result.softwareProductCategories).toEqual(categories);
+ expect(result.softwareProductCategories).toEqual(softwareProductCategories);
expect(result.licenseAgreementList).toEqual(licenseAgreementList);
- expect(result.licenseAgreementList).toInclude({id: result.currentSoftwareProduct.licensingData.licenseAgreement});
+ expect(result.licenseAgreementList[0]).toMatchObject({...licenseAgreementList[0], id: result.currentSoftwareProduct.licensingData.licenseAgreement});
result.currentSoftwareProduct.licensingData.featureGroups.forEach(fg => {
- expect(featureGroupsList).toInclude({
- id: fg.enum,
- name: fg.title,
- referencingLicenseAgreements: [result.currentSoftwareProduct.licensingData.licenseAgreement]
- });
- expect(result.featureGroupsList).toInclude(fg);
+ expect(featureGroupsList[0]).toMatchObject({...featureGroupsList[0], id: fg});
});
- expect(result.qdata).toEqual({});
- expect(result.qschema).toEqual(vspQschema);
+ expect(result.qdata).toEqual(qdata);
expect(result.isReadOnlyMode).toEqual(true);
});
it('VSP Details view test', () => {
+
let params = {
- currentSoftwareProduct: currentSoftwareProduct,
- softwareProductCategories: categories,
- qdata: {},
- qschema: vspQschema,
- finalizedLicenseModelList: [{
- id: 'VLM_ID1',
- vendorName: 'VLM1',
- version: '2.0',
- viewableVersions: ['1.0', '2.0']
- }, {
- id: 'VLM_ID2',
- vendorName: 'VLM2',
- version: '3.0',
- viewableVersions: ['1.0', '2.0', '3.0']
- }],
- licenseAgreementList: [{id: 'LA_ID1'}, {id: 'LA_ID2'}],
- featureGroupsList: [
- {id: 'FG_ID1', name: 'FG1', referencingLicenseAgreements: ['LA_ID1']},
- {id: 'FG_ID2', name: 'FG2', referencingLicenseAgreements: ['LA_ID1']}
- ]
+ currentSoftwareProduct,
+ softwareProductCategories,
+ qdata,
+ dataMap,
+ isFormValid: true,
+ finalizedLicenseModelList,
+ licenseAgreementList,
+ featureGroupsList,
+ genericFieldInfo,
+ qGenericFieldInfo,
};
var renderer = TestUtils.createRenderer();
renderer.render(
@@ -196,42 +184,26 @@ describe('Software Product Details: ', function () {
onVendorParamChanged = {dummyFunc}/>
);
let renderedOutput = renderer.getRenderOutput();
- expect(renderedOutput).toExist();
+ expect(renderedOutput).toBeTruthy();
});
it('in view: should change vendorId and update vsp licensing-version', done => {
- let vspWithLicensingData = {
- ...currentSoftwareProduct,
- licensingData: {
- licenseAgreement: 'LA_ID1',
- featureGroups: [{enum: 'FG_ID1', title: 'FG1'}]
- }
- };
+
let params = {
- currentSoftwareProduct: vspWithLicensingData,
- softwareProductCategories: categories,
- qdata: {},
- qschema: vspQschema,
- finalizedLicenseModelList: [{
- id: 'VLM_ID1',
- vendorName: 'VLM1',
- version: '2.0',
- viewableVersions: ['1.0', '2.0']
- }, {
- id: 'VLM_ID2',
- vendorName: 'VLM2',
- version: '3.0',
- viewableVersions: ['1.0', '2.0', '3.0']
- }],
- licenseAgreementList: [{id: 'LA_ID1'}, {id: 'LA_ID2'}],
- featureGroupsList: [
- {id: 'FG_ID1', name: 'FG1', referencingLicenseAgreements: ['LA_ID1']},
- {id: 'FG_ID2', name: 'FG2', referencingLicenseAgreements: ['LA_ID1']}
- ]
+ currentSoftwareProduct: currentSoftwareProductWithLicensingData,
+ softwareProductCategories,
+ qdata,
+ dataMap,
+ isFormValid: true,
+ genericFieldInfo,
+ qGenericFieldInfo,
+ finalizedLicenseModelList,
+ licenseAgreementList,
+ featureGroupsList
};
const onVendorChangedListener = (deltaData) => {
- expect(deltaData.vendorId).toEqual('VLM_ID2');
- expect(deltaData.vendorName).toEqual('VLM2');
+ expect(deltaData.vendorId).toEqual(finalizedLicenseModelList[1].id);
+ expect(deltaData.vendorName).toEqual(finalizedLicenseModelList[1].vendorName);
expect(deltaData.licensingVersion).toEqual('');
expect(deltaData.licensingData).toEqual({});
done();
@@ -241,7 +213,10 @@ describe('Software Product Details: ', function () {
currentSoftwareProduct = {params.currentSoftwareProduct}
softwareProductCategories = {params.softwareProductCategories}
qdata = {params.qdata}
- qschema = {params.qschema}
+ qGenericFieldInfo = {params.qGenericFieldInfo}
+ genericFieldInfo = {params.genericFieldInfo}
+ isFormValid={params.isFormValid}
+ dataMap={params.dataMap}
finalizedLicenseModelList = {params.finalizedLicenseModelList}
licenseAgreementList = {params.licenseAgreementList}
featureGroupsList = {params.featureGroupsList}
@@ -250,37 +225,27 @@ describe('Software Product Details: ', function () {
onValidityChanged = {dummyFunc}
onQDataChanged = {dummyFunc}
onVendorParamChanged = {(deltaData) => onVendorChangedListener(deltaData)}/>);
- expect(vspDetailsView).toExist();
- vspDetailsView.onVendorParamChanged({vendorId: 'VLM_ID2'});
+ expect(vspDetailsView).toBeTruthy();
+ vspDetailsView.onVendorParamChanged({vendorId: finalizedLicenseModelList[1].id});
});
it('in view: should change licensing-version and update licensing data', done => {
let params = {
currentSoftwareProduct: currentSoftwareProduct,
- softwareProductCategories: categories,
- qdata: {},
- qschema: vspQschema,
- finalizedLicenseModelList: [{
- id: 'VLM_ID1',
- vendorName: 'VLM1',
- version: '2.0',
- viewableVersions: ['1.0', '2.0']
- }, {
- id: 'VLM_ID2',
- vendorName: 'VLM2',
- version: '3.0',
- viewableVersions: ['1.0', '2.0', '3.0']
- }],
- licenseAgreementList: [{id: 'LA_ID1'}, {id: 'LA_ID2'}],
- featureGroupsList: [
- {id: 'FG_ID1', name: 'FG1', referencingLicenseAgreements: ['LA_ID1']},
- {id: 'FG_ID2', name: 'FG2', referencingLicenseAgreements: ['LA_ID1']}
- ]
+ softwareProductCategories,
+ qdata,
+ dataMap,
+ isFormValid: true,
+ genericFieldInfo,
+ qGenericFieldInfo,
+ finalizedLicenseModelList,
+ licenseAgreementList,
+ featureGroupsList
};
const onVendorChangedListener = (deltaData) => {
- expect(deltaData.vendorId).toEqual('VLM_ID2');
- expect(deltaData.vendorName).toEqual('VLM2');
- expect(deltaData.licensingVersion).toEqual('2.0');
+ expect(deltaData.vendorId).toEqual(finalizedLicenseModelList[1].id);
+ expect(deltaData.vendorName).toEqual(finalizedLicenseModelList[1].vendorName);
+ expect(deltaData.licensingVersion).toEqual(finalizedLicenseModelList[1].viewableVersion[0]);
expect(deltaData.licensingData).toEqual({});
done();
};
@@ -292,36 +257,26 @@ describe('Software Product Details: ', function () {
onValidityChanged = {dummyFunc}
onQDataChanged = {dummyFunc}
onVendorParamChanged = {(deltaData) => onVendorChangedListener(deltaData)}/>);
- expect(vspDetailsView).toExist();
- vspDetailsView.onVendorParamChanged({vendorId: 'VLM_ID2', licensingVersion: '2.0'});
+ expect(vspDetailsView).toBeTruthy();
+ vspDetailsView.onVendorParamChanged({vendorId: finalizedLicenseModelList[1].id, licensingVersion: finalizedLicenseModelList[1].viewableVersion[0]});
});
it('in view: should change subcategory', done => {
let params = {
currentSoftwareProduct: currentSoftwareProduct,
- softwareProductCategories: categories,
- qdata: {},
- qschema: vspQschema,
- finalizedLicenseModelList: [{
- id: 'VLM_ID1',
- vendorName: 'VLM1',
- version: '2.0',
- viewableVersions: ['1.0', '2.0']
- }, {
- id: 'VLM_ID2',
- vendorName: 'VLM2',
- version: '3.0',
- viewableVersions: ['1.0', '2.0', '3.0']
- }],
- licenseAgreementList: [{id: 'LA_ID1'}, {id: 'LA_ID2'}],
- featureGroupsList: [
- {id: 'FG_ID1', name: 'FG1', referencingLicenseAgreements: ['LA_ID1']},
- {id: 'FG_ID2', name: 'FG2', referencingLicenseAgreements: ['LA_ID1']}
- ]
+ softwareProductCategories,
+ qdata,
+ dataMap,
+ isFormValid: true,
+ genericFieldInfo,
+ qGenericFieldInfo,
+ finalizedLicenseModelList,
+ licenseAgreementList,
+ featureGroupsList
};
const onDataChangedListener = ({category, subCategory}) => {
- expect(category).toEqual('category2');
- expect(subCategory).toEqual('subCategory2');
+ expect(category).toEqual(softwareProductCategories[1].uniqueId);
+ expect(subCategory).toEqual(softwareProductCategories[1].subcategories[0].uniqueId);
done();
};
@@ -332,45 +287,29 @@ describe('Software Product Details: ', function () {
onValidityChanged = {dummyFunc}
onQDataChanged = {dummyFunc}
onVendorParamChanged = {dummyFunc}/>);
- expect(vspDetailsView).toExist();
- vspDetailsView.onSelectSubCategory('subCategory2');
+ expect(vspDetailsView).toBeTruthy();
+ vspDetailsView.onSelectSubCategory(softwareProductCategories[1].subcategories[0].uniqueId);
});
it('in view: should change feature groups', done => {
- let vspWithLicensingData = {
- ...currentSoftwareProduct,
- licensingData: {
- licenseAgreement: 'LA_ID1',
- featureGroups: [{enum: 'FG_ID1', title: 'FG1'}]
- }
- };
+
let params = {
- currentSoftwareProduct: vspWithLicensingData,
- softwareProductCategories: categories,
- qdata: {},
- qschema: vspQschema,
- finalizedLicenseModelList: [{
- id: 'VLM_ID1',
- vendorName: 'VLM1',
- version: '2.0',
- viewableVersions: ['1.0', '2.0']
- }, {
- id: 'VLM_ID2',
- vendorName: 'VLM2',
- version: '3.0',
- viewableVersions: ['1.0', '2.0', '3.0']
- }],
- licenseAgreementList: [{id: 'LA_ID1'}, {id: 'LA_ID2'}],
- featureGroupsList: [
- {id: 'FG_ID1', name: 'FG1', referencingLicenseAgreements: ['LA_ID1']},
- {id: 'FG_ID2', name: 'FG2', referencingLicenseAgreements: ['LA_ID1']}
- ]
+ currentSoftwareProduct: currentSoftwareProductWithLicensingData,
+ softwareProductCategories,
+ qdata,
+ dataMap,
+ isFormValid: true,
+ genericFieldInfo,
+ qGenericFieldInfo,
+ finalizedLicenseModelList,
+ licenseAgreementList,
+ featureGroupsList
};
const onDataChangedListener = ({licensingData}) => {
- expect(licensingData.licenseAgreement).toEqual('LA_ID1');
+ expect(licensingData.licenseAgreement).toEqual(licenseAgreementList[0].id);
expect(licensingData.featureGroups).toEqual([
- {enum: 'FG_ID1', title: 'FG1'},
- {enum: 'FG_ID2', title: 'FG2'}
+ {enum: featureGroupsList[0].id, title: featureGroupsList[0].name},
+ {enum: featureGroupsList[1].id, title: featureGroupsList[1].name}
]);
done();
};
@@ -382,45 +321,29 @@ describe('Software Product Details: ', function () {
onValidityChanged = {dummyFunc}
onQDataChanged = {dummyFunc}
onVendorParamChanged = {dummyFunc}/>);
- expect(vspDetailsView).toExist();
+ expect(vspDetailsView).toBeTruthy();
vspDetailsView.onFeatureGroupsChanged({featureGroups: [
- {enum: 'FG_ID1', title: 'FG1'},
- {enum: 'FG_ID2', title: 'FG2'}
+ {enum: featureGroupsList[0].id, title: featureGroupsList[0].name},
+ {enum: featureGroupsList[1].id, title: featureGroupsList[1].name}
]});
});
it('in view: should change license agreement', done => {
- let vspWithLicensingData = {
- ...currentSoftwareProduct,
- licensingData: {
- licenseAgreement: 'LA_ID1',
- featureGroups: [{enum: 'FG_ID1', title: 'FG1'}]
- }
- };
+
let params = {
- currentSoftwareProduct: vspWithLicensingData,
- softwareProductCategories: categories,
- qdata: {},
- qschema: vspQschema,
- finalizedLicenseModelList: [{
- id: 'VLM_ID1',
- vendorName: 'VLM1',
- version: '2.0',
- viewableVersions: ['1.0', '2.0']
- }, {
- id: 'VLM_ID2',
- vendorName: 'VLM2',
- version: '3.0',
- viewableVersions: ['1.0', '2.0', '3.0']
- }],
- licenseAgreementList: [{id: 'LA_ID1'}, {id: 'LA_ID2'}],
- featureGroupsList: [
- {id: 'FG_ID1', name: 'FG1', referencingLicenseAgreements: ['LA_ID1']},
- {id: 'FG_ID2', name: 'FG2', referencingLicenseAgreements: ['LA_ID1']}
- ]
+ currentSoftwareProduct: currentSoftwareProductWithLicensingData,
+ softwareProductCategories,
+ qdata,
+ dataMap,
+ isFormValid: true,
+ genericFieldInfo,
+ qGenericFieldInfo,
+ finalizedLicenseModelList,
+ licenseAgreementList,
+ featureGroupsList
};
const onDataChangedListener = ({licensingData}) => {
- expect(licensingData.licenseAgreement).toEqual('LA_ID2');
+ expect(licensingData.licenseAgreement).toEqual(licenseAgreementList[1].id);
expect(licensingData.featureGroups).toEqual([]);
done();
};
@@ -432,7 +355,7 @@ describe('Software Product Details: ', function () {
onValidityChanged = {dummyFunc}
onQDataChanged = {dummyFunc}
onVendorParamChanged = {dummyFunc}/>);
- expect(vspDetailsView).toExist();
- vspDetailsView.onLicensingDataChanged({licenseAgreement: 'LA_ID2', featureGroups: []});
+ expect(vspDetailsView).toBeTruthy();
+ vspDetailsView.onLicensingDataChanged({licenseAgreement: licenseAgreementList[1].id, featureGroups: []});
});
});
diff --git a/openecomp-ui/test/softwareProduct/details/test.js b/openecomp-ui/test/softwareProduct/details/test.js
index 9803b1611d..df84d184ce 100644
--- a/openecomp-ui/test/softwareProduct/details/test.js
+++ b/openecomp-ui/test/softwareProduct/details/test.js
@@ -1,84 +1,65 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-
-import {expect} from 'chai';
import deepFreeze from 'deep-freeze';
import mockRest from 'test-utils/MockRest.js';
-import {cloneAndSet} from 'test-utils/Util.js';
+import {cloneAndSet, buildFromExistingObject} from 'test-utils/Util.js';
import {storeCreator} from 'sdc-app/AppStore.js';
import SoftwareProductCreationActionHelper from 'sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationActionHelper.js';
import SoftwareProductActionHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js';
import SoftwareProductCategoriesHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductCategoriesHelper.js';
+import {forms} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js';
+import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js';
+
+import {VSPEditorFactory, VSPEditorPostFactory, VSPEditorFactoryWithLicensingData, VSPEditorPostFactoryWithLicensingData} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
+import {CategoryFactory} from 'test-utils/factories/softwareProduct/VSPCategoriesFactory.js';
+import {heatSetupManifest} from 'test-utils/factories/softwareProduct/SoftwareProductAttachmentsFactories.js';
+
+import { FeatureGroupStoreFactory as FeatureGroup} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js';
+import {LicenseAgreementStoreFactory as LicenseAgreement} from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js';
+import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
+
describe('Software Product Module Tests', function () {
it('Get Software Products List', () => {
const store = storeCreator();
deepFreeze(store.getState());
-
- const softwareProductList = [
- {
- name: 'VSP1',
- description: 'hjhj',
- version: '0.1',
- id: 'EBADF561B7FA4A788075E1840D0B5971',
- subCategory: 'resourceNewCategory.network connectivity.virtual links',
- category: 'resourceNewCategory.network connectivity',
- vendorId: '5259EDE4CC814DC9897BA6F69E2C971B',
- vendorName: 'Vendor',
- checkinStatus: 'CHECK_OUT',
- licensingData: {
- 'featureGroups': []
- }
- },
- {
- name: 'VSP2',
- description: 'dfdfdfd',
- version: '0.1',
- id: '2F47447D22DB4C53B020CA1E66201EF2',
- subCategory: 'resourceNewCategory.network connectivity.virtual links',
- category: 'resourceNewCategory.network connectivity',
- vendorId: '5259EDE4CC814DC9897BA6F69E2C971B',
- vendorName: 'Vendor',
- checkinStatus: 'CHECK_OUT',
- licensingData: {
- featureGroups: []
- }
- }
- ];
-
+ const softwareProductList = VSPEditorFactory.buildList(2);
deepFreeze(softwareProductList);
-
deepFreeze(store.getState());
-
const expectedStore = cloneAndSet(store.getState(), 'softwareProductList', softwareProductList);
mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
- expect(baseUrl).to.equal('/onboarding-api/v1.0/vendor-software-products/');
- expect(data).to.deep.equal(undefined);
- expect(options).to.equal(undefined);
+ expect(baseUrl).toEqual('/onboarding-api/v1.0/vendor-software-products/');
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
return {results: softwareProductList};
});
+ mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual('/onboarding-api/v1.0/vendor-software-products/?versionFilter=Final');
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: []};
+ });
+
return SoftwareProductActionHelper.fetchSoftwareProductList(store.dispatch).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ return SoftwareProductActionHelper.fetchFinalizedSoftwareProductList(store.dispatch);
+ }).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
});
});
@@ -86,62 +67,195 @@ describe('Software Product Module Tests', function () {
const store = storeCreator();
deepFreeze(store.getState());
- const softwareProductPostRequest = deepFreeze({
- name: 'vsp1',
- description: 'string',
- vendorId: '1',
- vendorName: 'Vendor',
- icon: 'icon',
- subCategory: 'resourceNewCategory.network connectivity.virtual links',
- category: 'resourceNewCategory.network connectivity',
- licensingData: {}
- });
+ const softwareProductPostRequest = VSPEditorPostFactory.build();
+ deepFreeze(softwareProductPostRequest);
+ const idFromResponse = '1';
+ const expectedVSP = VSPEditorPostFactory.build({id: idFromResponse, vendorId: softwareProductPostRequest.vendorId});
+ deepFreeze(expectedVSP);
- const softwareProductToAdd = deepFreeze({
- ...softwareProductPostRequest
+ mockRest.addHandler('post', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual('/onboarding-api/v1.0/vendor-software-products/');
+ expect(data).toEqual(softwareProductPostRequest);
+ expect(options).toEqual(undefined);
+ return {
+ vspId: idFromResponse
+ };
});
- const softwareProductIdFromResponse = 'ADDED_ID';
- const softwareProductAfterAdd = deepFreeze({
- ...softwareProductToAdd,
- id: softwareProductIdFromResponse
+ return SoftwareProductCreationActionHelper.createSoftwareProduct(store.dispatch, {
+ softwareProduct: softwareProductPostRequest
+ }).then((response) => {
+ expect(response.vspId).toEqual(idFromResponse);
});
+ });
+
+ it('Fetch Software Product with manifest', () => {
+ const store = storeCreator();
+ deepFreeze(store.getState());
- const expectedStore = cloneAndSet(store.getState(), 'softwareProductList', [softwareProductAfterAdd]);
+ const softwareProductPostRequest = VSPEditorPostFactory.build();
+ deepFreeze(softwareProductPostRequest);
+
+ const expectedGenericInfo = {
+ 'name': {
+ isValid: true,
+ errorText: '',
+ validations: [{type: 'validateName', data: true}, {type: 'maxLength', data: 25}, {
+ type: 'required',
+ data: true
+ }]
+ },
+ 'description': {
+ isValid: true,
+ errorText: '',
+ validations: [{type: 'required', data: true}]
+ }
+ };
+ const expectedFormName = forms.VENDOR_SOFTWARE_PRODUCT_DETAILS;
+
+ const idFromResponse = '1';
+ const version = { id: '0.1', label: '0.1'};
+ const expectedVSP = VSPEditorPostFactory.build({id: idFromResponse, vendorId: softwareProductPostRequest.vendorId});
+ deepFreeze(expectedVSP);
+ let expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductEditor.data', expectedVSP);
+ expectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductEditor.genericFieldInfo', expectedGenericInfo);
+ expectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductEditor.formName', expectedFormName);
+ expectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductQuestionnaire', {qdata: {}, dataMap: {}, qgenericFieldInfo: {}});
+
+ expectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductAttachments.heatValidation', {
+ 'attachmentsTree': {},
+ 'errorList': [],
+ 'selectedNode': 'All'
+ });
+ let manifest = heatSetupManifest.build();
+ expectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductAttachments.heatSetup', manifest);
- mockRest.addHandler('create', ({options, data, baseUrl}) => {
- expect(baseUrl).to.equal('/onboarding-api/v1.0/vendor-software-products/');
- expect(data).to.deep.equal(softwareProductPostRequest);
- expect(options).to.equal(undefined);
+ mockRest.addHandler('post', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual('/onboarding-api/v1.0/vendor-software-products/');
+ expect(data).toEqual(softwareProductPostRequest);
+ expect(options).toEqual(undefined);
return {
- vspId: softwareProductIdFromResponse
+ vspId: idFromResponse,
+ version
};
});
+ mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${idFromResponse}/versions/${version.id}`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return expectedVSP;
+ });
+
+ mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${idFromResponse}/versions/${version.id}/questionnaire`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {data: JSON.stringify({}), schema: JSON.stringify({})};
+ });
+
+ mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${idFromResponse}/versions/${version.id}/orchestration-template-candidate/manifest`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return manifest;
+ });
+
return SoftwareProductCreationActionHelper.createSoftwareProduct(store.dispatch, {
- softwareProduct: softwareProductToAdd
+ softwareProduct: softwareProductPostRequest
+ }).then(() => {
+ return SoftwareProductActionHelper.fetchSoftwareProduct(store.dispatch, {softwareProductId: idFromResponse, version});
}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ return SoftwareProductActionHelper.loadSoftwareProductHeatCandidate(store.dispatch, {softwareProductId: idFromResponse, version});
+ }).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ let newName = 'newName';
+ expectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductEditor.formReady', null);
+ ValidationHelper.dataChanged(store.dispatch, {deltaData: {'name': newName}, formName: forms.VENDOR_SOFTWARE_PRODUCT_DETAILS});
+ expectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductEditor.data.name', newName);
+ expect(store.getState()).toEqual(expectedStore);
});
});
+
+ it('Load and edit Software Product licensing data', () => {
+ const store = storeCreator();
+
+ const softwareProductPostRequest = VSPEditorPostFactory.build();
+ deepFreeze(softwareProductPostRequest);
+
+ const licenseModelId = softwareProductPostRequest.vendorId;
+ const LMVersion = VersionControllerUtilsFactory.build().version;
+ const secondLicenseModelId = 'secondLicenseModelId';
+
+ let FG1 = FeatureGroup.build();
+ let LA1 = LicenseAgreement.build({
+ featureGroupsIds: [FG1.id]
+ });
+
+ let FG2 = FeatureGroup.build();
+ let LA2 = LicenseAgreement.build({
+ featureGroupsIds: [FG2.id]
+ });
+
+ mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual('/sdc1/feProxy/rest/v1/categories/resources/');
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return [];
+ });
+
+ mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual('/onboarding-api/v1.0/vendor-license-models/?versionFilter=Final');
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: []};
+ });
+
+ mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${licenseModelId}/versions/${LMVersion.id}/license-agreements`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: [LA1]};
+ });
+
+ mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${licenseModelId}/versions/${LMVersion.id}/feature-groups`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: [FG1]};
+ });
+
+ mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${secondLicenseModelId}/versions/${LMVersion.id}/license-agreements`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: [LA2]};
+ });
+
+ mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${secondLicenseModelId}/versions/${LMVersion.id}/feature-groups`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
+ return {results: [FG2]};
+ });
+
+ return SoftwareProductActionHelper.loadSoftwareProductDetailsData(store.dispatch, {licenseModelId, licensingVersion: LMVersion}).then(() => {
+ let state = store.getState();
+ expect(state.licenseModel.licenseAgreement.licenseAgreementList).toEqual([LA1]);
+ expect(state.licenseModel.featureGroup.featureGroupsList).toEqual([FG1]);
+ return SoftwareProductActionHelper.softwareProductEditorVendorChanged(store.dispatch,
+ {deltaData: {vendorId: secondLicenseModelId, licensingVersion: LMVersion},
+ formName: forms.VENDOR_SOFTWARE_PRODUCT_DETAILS});
+ }).then(() => {
+ let state = store.getState();
+ expect(state.licenseModel.licenseAgreement.licenseAgreementList).toEqual([LA2]);
+ expect(state.licenseModel.featureGroup.featureGroupsList).toEqual([FG2]);
+ });
+ });
+
it('Save Software product', () => {
- const softwareProduct = {
- name: 'VSP5',
- id: '4730033D16C64E3CA556AB0AC4478218',
- description: 'A software model for Fortigate.',
- subCategory: 'resourceNewCategory.network connectivity.virtual links',
- category: 'resourceNewCategory.network connectivity',
- vendorId: '1',
- vendorName: 'Vendor',
- licensingVersion: '1.0',
- icon: 'icon',
- licensingData: {
- licenceAgreement: '123',
- featureGroups: [
- '123', '234'
- ]
- }
- };
+
+ const softwareProduct = VSPEditorFactoryWithLicensingData.build();
deepFreeze(softwareProduct);
const store = storeCreator({
@@ -152,15 +266,20 @@ describe('Software Product Module Tests', function () {
});
deepFreeze(store.getState());
- const toBeUpdatedSoftwareProductId = softwareProduct.id;
- const softwareProductUpdateData = {
- ...softwareProduct,
+ const dataForUpdate = {
name: 'VSP5_UPDATED',
description: 'A software model for Fortigate._UPDATED'
};
+
+ const toBeUpdatedSoftwareProductId = softwareProduct.id;
+ let softwareProductUpdateData = VSPEditorPostFactoryWithLicensingData.build(dataForUpdate);
+ delete softwareProductUpdateData.version;
+
+ const softwareProductPutRequest = buildFromExistingObject(VSPEditorFactoryWithLicensingData, softwareProductUpdateData, {id: toBeUpdatedSoftwareProductId, version: softwareProduct.version});
+
deepFreeze(softwareProductUpdateData);
- const expectedStore = cloneAndSet(store.getState(), 'softwareProductList', [softwareProductUpdateData]);
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProductList', [softwareProductPutRequest]);
const questionnaireData = {
general: {
affinityData: {
@@ -171,60 +290,30 @@ describe('Software Product Module Tests', function () {
};
deepFreeze(questionnaireData);
- mockRest.addHandler('save', ({data, options, baseUrl}) => {
- const expectedData = {
- name: 'VSP5_UPDATED',
- description: 'A software model for Fortigate._UPDATED',
- subCategory: 'resourceNewCategory.network connectivity.virtual links',
- category: 'resourceNewCategory.network connectivity',
- vendorId: '1',
- vendorName: 'Vendor',
- licensingVersion: '1.0',
- icon: 'icon',
- licensingData: {
- licenceAgreement: '123',
- featureGroups: [
- '123', '234'
- ]
- }
- };
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}`);
- expect(data).to.deep.equal(expectedData);
- expect(options).to.equal(undefined);
+ mockRest.addHandler('put', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/versions/${softwareProduct.version.id}`);
+ expect(data).toEqual(softwareProductUpdateData);
+ expect(options).toEqual(undefined);
return {returnCode: 'OK'};
});
- mockRest.addHandler('save', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/questionnaire`);
- expect(data).to.deep.equal(questionnaireData);
- expect(options).to.equal(undefined);
+ mockRest.addHandler('put', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/versions/${softwareProduct.version.id}/questionnaire`);
+ expect(data).toEqual(questionnaireData);
+ expect(options).toEqual(undefined);
return {returnCode: 'OK'};
});
return SoftwareProductActionHelper.updateSoftwareProduct(store.dispatch, {
- softwareProduct: softwareProductUpdateData,
+ softwareProduct: softwareProductPutRequest,
qdata: questionnaireData
}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
});
+
it('Save Software product data only', () => {
- const softwareProduct = {
- name: 'VSP5',
- id: '4730033D16C64E3CA556AB0AC4478218',
- description: 'A software model for Fortigate.',
- subCategory: 'resourceNewCategory.network connectivity.virtual links',
- category: 'resourceNewCategory.network connectivity',
- vendorId: '1',
- vendorName: 'Vendor',
- licensingVersion: '1.0',
- icon: 'icon',
- licensingData: {
- licenceAgreement: '123',
- featureGroups: [
- '123', '234'
- ]
- }
- };
+
+ const softwareProduct = VSPEditorFactoryWithLicensingData.build();
deepFreeze(softwareProduct);
const store = storeCreator({
@@ -236,61 +325,35 @@ describe('Software Product Module Tests', function () {
deepFreeze(store.getState());
const expectedStore = store.getState();
- const toBeUpdatedSoftwareProductId = softwareProduct.id;
- const softwareProductUpdateData = {
- ...softwareProduct,
+ const dataForUpdate = {
name: 'VSP5_UPDATED',
description: 'A software model for Fortigate._UPDATED'
};
+
+ const toBeUpdatedSoftwareProductId = softwareProduct.id;
+ let softwareProductUpdateData = VSPEditorPostFactoryWithLicensingData.build(dataForUpdate);
+ delete softwareProductUpdateData.version;
+
+ const softwareProductPutRequest = buildFromExistingObject(VSPEditorFactoryWithLicensingData, softwareProductUpdateData, {id: toBeUpdatedSoftwareProductId, version: softwareProduct.version});
+
deepFreeze(softwareProductUpdateData);
- mockRest.addHandler('save', ({data, options, baseUrl}) => {
- const expectedData = {
- name: 'VSP5_UPDATED',
- description: 'A software model for Fortigate._UPDATED',
- subCategory: 'resourceNewCategory.network connectivity.virtual links',
- category: 'resourceNewCategory.network connectivity',
- vendorId: '1',
- vendorName: 'Vendor',
- licensingVersion: '1.0',
- icon: 'icon',
- licensingData: {
- licenceAgreement: '123',
- featureGroups: [
- '123', '234'
- ]
- }
- };
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}`);
- expect(data).to.deep.equal(expectedData);
- expect(options).to.equal(undefined);
+ mockRest.addHandler('put', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/versions/${softwareProduct.version.id}`);
+ expect(data).toEqual(softwareProductUpdateData);
+ expect(options).toEqual(undefined);
return {returnCode: 'OK'};
});
return SoftwareProductActionHelper.updateSoftwareProductData(store.dispatch, {
- softwareProduct: softwareProductUpdateData
+ softwareProduct: softwareProductPutRequest
}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
});
it('Save Software product questionnaire only', () => {
- const softwareProduct = {
- name: 'VSP5',
- id: '4730033D16C64E3CA556AB0AC4478218',
- description: 'A software model for Fortigate.',
- subCategory: 'resourceNewCategory.network connectivity.virtual links',
- category: 'resourceNewCategory.network connectivity',
- vendorId: '1',
- vendorName: 'Vendor',
- icon: 'icon',
- licensingData: {
- licenceAgreement: '123',
- featureGroups: [
- '123', '234'
- ]
- }
- };
+ const softwareProduct = VSPEditorFactoryWithLicensingData.build();
deepFreeze(softwareProduct);
const store = storeCreator({
@@ -313,71 +376,30 @@ describe('Software Product Module Tests', function () {
};
deepFreeze(questionnaireData);
- mockRest.addHandler('save', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/questionnaire`);
- expect(data).to.deep.equal(questionnaireData);
- expect(options).to.equal(undefined);
+ mockRest.addHandler('put', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/versions/${softwareProduct.version.id}/questionnaire`);
+ expect(data).toEqual(questionnaireData);
+ expect(options).toEqual(undefined);
return {returnCode: 'OK'};
});
return SoftwareProductActionHelper.updateSoftwareProductQuestionnaire(store.dispatch, {
softwareProductId: softwareProduct.id,
+ version: softwareProduct.version,
qdata: questionnaireData
}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
});
it('Handle category without subcategories', () => {
- const categories = deepFreeze([
- {
- name: 'Resource Category 1',
- normalizedName: 'resource category 1',
- uniqueId: 'resourceNewCategory.resource category 1',
- subcategories: [
- {
- name: 'Sub Category for RC 1',
- normalizedName: 'sub category for rc 1',
- uniqueId: 'resourceNewCategory.resource category 1.sub category for rc 1'
- },
- {
- name: 'SC4RC2',
- normalizedName: 'sc4rc2',
- uniqueId: 'resourceNewCategory.resource category 1.sc4rc2'
- },
- {
- name: 'SC4RC1',
- normalizedName: 'sc4rc1',
- uniqueId: 'resourceNewCategory.resource category 1.sc4rc1'
- }
- ]
- },
- {
- name: 'Eeeeee',
- normalizedName: 'eeeeee',
- uniqueId: 'resourceNewCategory.eeeeee'
- },
- {
- name: 'Some Recource',
- normalizedName: 'some recource',
- uniqueId: 'resourceNewCategory.some recource',
- subcategories: [
- {
- name: 'Second Sub Category for S',
- normalizedName: 'second sub category for s',
- uniqueId: 'resourceNewCategory.some recource.second sub category for s'
- },
- {
- name: 'Sub Category for Some Rec',
- normalizedName: 'sub category for some rec',
- uniqueId: 'resourceNewCategory.some recource.sub category for some rec'
- }
- ]
- }
- ]);
- const category = SoftwareProductCategoriesHelper.getCurrentCategoryOfSubCategory('resourceNewCategory.some recource.sub category for some rec', categories);
- expect(category).to.equal('resourceNewCategory.some recource');
+
+ const categories = CategoryFactory.buildList(3);
+ categories[0].subcategories = CategoryFactory.buildList(3);
+ categories[2].subcategories = CategoryFactory.buildList(3);
+
+ const category = SoftwareProductCategoriesHelper.getCurrentCategoryOfSubCategory(categories[2].subcategories[2].uniqueId, categories);
+ expect(category).toEqual(categories[2].uniqueId);
});
});
-
diff --git a/openecomp-ui/test/softwareProduct/details/vspQschema.js b/openecomp-ui/test/softwareProduct/details/vspQschema.js
index 5612b19991..fb8ac6fd91 100644
--- a/openecomp-ui/test/softwareProduct/details/vspQschema.js
+++ b/openecomp-ui/test/softwareProduct/details/vspQschema.js
@@ -1,21 +1,17 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
export const vspQschema = {
diff --git a/openecomp-ui/test/softwareProduct/landingPage/landingPage.test.js b/openecomp-ui/test/softwareProduct/landingPage/landingPage.test.js
new file mode 100644
index 0000000000..f06ad61e4f
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/landingPage/landingPage.test.js
@@ -0,0 +1,177 @@
+/*!
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+
+
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+
+import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
+import {CategoryWithSubFactory} from 'test-utils/factories/softwareProduct/VSPCategoriesFactory.js';
+import {LicenseAgreementStoreFactory} from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js';
+import {FeatureGroupStoreFactory} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js';
+import {default as SoftwareProductQSchemaFactory} from 'test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js';
+import {default as VspQdataFactory} from 'test-utils/factories/softwareProduct/VspQdataFactory.js';
+import {VSPComponentsFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsFactories.js';
+import {FinalizedLicenseModelFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js';
+
+
+import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPage.js';
+import SoftwareProductLandingPageView from 'sdc-app/onboarding/softwareProduct/landingPage/SoftwareProductLandingPageView.jsx';
+
+
+describe('Software Product Landing Page: ', function () {
+
+ let currentSoftwareProduct = {}, softwareProductCategories = [],
+ finalizedLicenseModelList, licenseAgreementList, featureGroupsList, qschema, qdata = {};
+ const dummyFunc = () => {};
+ beforeAll(function() {
+ finalizedLicenseModelList = FinalizedLicenseModelFactory.buildList(2);
+ currentSoftwareProduct = VSPEditorFactory.build({id:'RTRTG454545', vendorId: finalizedLicenseModelList[0].id, vendorName: finalizedLicenseModelList[0].name});
+ softwareProductCategories = CategoryWithSubFactory.buildList(2,{},{quantity: 1});
+ licenseAgreementList = LicenseAgreementStoreFactory.buildList(2);
+ featureGroupsList = FeatureGroupStoreFactory.buildList(2,{referencingLicenseAgreements:[licenseAgreementList[0].id]});
+ qdata = VspQdataFactory.build();
+ qschema = SoftwareProductQSchemaFactory.build(qdata);
+
+ });
+
+
+
+ it('should mapper exist', () => {
+ expect(mapStateToProps).toBeTruthy();
+ });
+
+ it('should mapper return vsp basic data', () => {
+ const obj = {
+ softwareProduct: {
+ softwareProductEditor: {
+ data: currentSoftwareProduct
+ },
+ softwareProductCategories,
+ softwareProductQuestionnaire: {
+ qdata,
+ qschema
+ },
+ softwareProductComponents: {
+ componentsList:[]
+ }
+ },
+ finalizedLicenseModelList,
+ licenseModel: {
+ licenseAgreement: {
+ licenseAgreementList
+ },
+ featureGroup: {
+ featureGroupsList
+ }
+ }
+ };
+
+ const result = mapStateToProps(obj);
+ expect(result.currentSoftwareProduct).toBeTruthy();
+ expect(result.isReadOnlyMode).toEqual(true);
+
+ });
+
+ it('vsp landing basic view', () => {
+
+ const params = {
+ currentSoftwareProduct,
+ isReadOnlyMode: false,
+ componentsList: VSPComponentsFactory.buildList(2)
+ };
+
+ let vspLandingView = TestUtils.renderIntoDocument(<SoftwareProductLandingPageView
+ {...params}/>);
+ expect(vspLandingView).toBeTruthy();
+ });
+
+ it('vsp landing handleOnDragEnter test ', () => {
+
+ const params = {
+ currentSoftwareProduct,
+ isReadOnlyMode: false,
+ componentsList: VSPComponentsFactory.buildList(2)
+ };
+
+ let vspLandingView = TestUtils.renderIntoDocument(<SoftwareProductLandingPageView
+ {...params}/>);
+ expect(vspLandingView).toBeTruthy();
+ vspLandingView.handleOnDragEnter(false);
+ expect(vspLandingView.state.dragging).toEqual(true);
+ });
+
+
+ it('vsp landing handleImportSubmit test ', () => {
+
+ const params = {
+ currentSoftwareProduct,
+ isReadOnlyMode: false,
+ componentsList: VSPComponentsFactory.buildList(2),
+ onUploadConfirmation: dummyFunc,
+ onUpload: dummyFunc,
+ onInvalidFileSizeUpload: dummyFunc
+ };
+
+ let vspLandingView = TestUtils.renderIntoDocument(<SoftwareProductLandingPageView
+ {...params}/>);
+ expect(vspLandingView).toBeTruthy();
+ const files = [
+ {
+ name: 'aaa',
+ size: 123
+ }
+ ];
+
+ vspLandingView.handleImportSubmit(files, false);
+ expect(vspLandingView.state.dragging).toEqual(false);
+ expect(vspLandingView.state.fileName).toEqual(files[0].name);
+ const files1 = [
+ {
+ name: 'bbb',
+ size: 0
+ }
+ ];
+ vspLandingView.handleImportSubmit(files1, false);
+ });
+
+ it('vsp landing handleImportSubmit with damaged file test ', () => {
+
+ const params = {
+ currentSoftwareProduct,
+ isReadOnlyMode: false,
+ componentsList: VSPComponentsFactory.buildList(2),
+ onUploadConfirmation: dummyFunc,
+ onUpload: dummyFunc,
+ onInvalidFileSizeUpload: dummyFunc
+ };
+
+ let vspLandingView = TestUtils.renderIntoDocument(<SoftwareProductLandingPageView
+ {...params}/>);
+ expect(vspLandingView).toBeTruthy();
+ const files = [
+ {
+ name: 'aaa',
+ size: 0
+ }
+ ];
+
+ vspLandingView.handleImportSubmit(files, false);
+ expect(vspLandingView.state.dragging).toEqual(false);
+ expect(vspLandingView.state.fileName).toEqual('');
+ });
+});
diff --git a/openecomp-ui/test/softwareProduct/networks/SoftwareProductNetworksView.test.js b/openecomp-ui/test/softwareProduct/networks/SoftwareProductNetworksView.test.js
index a7f7b2b0c2..6ef6bcf02a 100644
--- a/openecomp-ui/test/softwareProduct/networks/SoftwareProductNetworksView.test.js
+++ b/openecomp-ui/test/softwareProduct/networks/SoftwareProductNetworksView.test.js
@@ -1,63 +1,39 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-import expect from 'expect';
import React from 'react';
import TestUtils from 'react-addons-test-utils';
import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworks.js';
import SoftwareProductNetworksView from 'sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksView.jsx';
-import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
+//import {statusEnum as versionStatusEnum} from 'nfvo-components/panel/versionController/VersionControllerConstants.js';
+
+import VSPNetworkFactory from 'test-utils/factories/softwareProduct/SoftwareProductNetworkFactory.js';
+import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
+import {VSPComponentsVersionControllerFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js';
describe('SoftwareProductNetworks Mapper and View Classes', () => {
it ('mapStateToProps mapper exists', () => {
- expect(mapStateToProps).toExist();
+ expect(mapStateToProps).toBeTruthy();
});
it ('mapStateToProps data test', () => {
- const currentSoftwareProduct = {
- name: 'VSp',
- description: 'dfdf',
- vendorName: 'V1',
- vendorId: '97B3E2525E0640ACACF87CE6B3753E80',
- category: 'resourceNewCategory.application l4+',
- subCategory: 'resourceNewCategory.application l4+.database',
- id: 'D4774719D085414E9D5642D1ACD59D20',
- version: '0.10',
- viewableVersions: ['0.1', '0.2'],
- status: versionStatusEnum.CHECK_OUT_STATUS,
- lockingUser: 'cs0008'
- };
+ const currentSoftwareProduct = VSPEditorFactory.build();
- const networksList = [
- {
- name:'dummy_net_1',
- dhcp:true,
- 'id':'7F60CD390458421DA588AF4AD217B93F'
- },
- {
- name:'dummy_net_2',
- dhcp:true,
- 'id':'AD217B93F7F60CD390458421DA588AF4'
- }
- ];
+ const networksList = VSPNetworkFactory.buildList(2);
var obj = {
softwareProduct: {
@@ -71,49 +47,21 @@ describe('SoftwareProductNetworks Mapper and View Classes', () => {
}
};
var results = mapStateToProps(obj);
- expect(results.networksList,).toExist();
+ expect(results.networksList).toBeTruthy();
});
it ('view simple test', () => {
- const currentSoftwareProduct = {
- name: 'VSp',
- description: 'dfdf',
- vendorName: 'V1',
- vendorId: '97B3E2525E0640ACACF87CE6B3753E80',
- category: 'resourceNewCategory.application l4+',
- subCategory: 'resourceNewCategory.application l4+.database',
- id: 'D4774719D085414E9D5642D1ACD59D20',
- version: '0.10',
- viewableVersions: ['0.1', '0.2'],
- status: versionStatusEnum.CHECK_OUT_STATUS,
- lockingUser: 'cs0008'
- };
+ const currentSoftwareProduct = VSPEditorFactory.build();
- const networksList = [
- {
- name:'dummy_net_1',
- dhcp:true,
- 'id':'7F60CD390458421DA588AF4AD217B93F'
- },
- {
- name:'dummy_net_2',
- dhcp:true,
- 'id':'AD217B93F7F60CD390458421DA588AF4'
- }
- ];
+ const networksList = VSPNetworkFactory.buildList(2);
- const versionControllerData = {
- version: '1',
- viewableVersions: [],
- status: 'locked',
- isCheckedOut: true
- };
+ const versionControllerData = VSPComponentsVersionControllerFactory.build();
var renderer = TestUtils.createRenderer();
renderer.render(<SoftwareProductNetworksView networksList={networksList} versionControllerData={versionControllerData} currentSoftwareProduct={currentSoftwareProduct}/>);
var renderedOutput = renderer.getRenderOutput();
- expect(renderedOutput).toExist();
+ expect(renderedOutput).toBeTruthy();
});
diff --git a/openecomp-ui/test/softwareProduct/networks/softwareProductNetworksActionHelper.test.js b/openecomp-ui/test/softwareProduct/networks/softwareProductNetworksActionHelper.test.js
index 2920803c64..1475ae610e 100644
--- a/openecomp-ui/test/softwareProduct/networks/softwareProductNetworksActionHelper.test.js
+++ b/openecomp-ui/test/softwareProduct/networks/softwareProductNetworksActionHelper.test.js
@@ -1,62 +1,49 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-
-import {expect} from 'chai';
import deepFreeze from 'deep-freeze';
import mockRest from 'test-utils/MockRest.js';
import {cloneAndSet} from 'test-utils/Util.js';
import {storeCreator} from 'sdc-app/AppStore.js';
import SoftwareProductNetworksActionHelper from 'sdc-app/onboarding/softwareProduct/networks/SoftwareProductNetworksActionHelper.js';
+import VersionControllerUtilsFactory from 'test-utils/factories/softwareProduct/VersionControllerUtilsFactory.js';
+
+import VSPNetworkFactory from 'test-utils/factories/softwareProduct/SoftwareProductNetworkFactory.js';
const softwareProductId = '123';
describe('Software Product Networks ActionHelper Tests', function () {
it('Get Software Products Networks List', () => {
const store = storeCreator();
+ const vcData = VersionControllerUtilsFactory.build();
deepFreeze(store.getState());
- const networksList = [
- {
- name:'dummy_net_1',
- dhcp:true,
- 'id':'7F60CD390458421DA588AF4AD217B93F'
- },
- {
- name:'dummy_net_2',
- dhcp:true,
- 'id':'AD217B93F7F60CD390458421DA588AF4'
- }
- ];
+ const networksList = VSPNetworkFactory.buildList(2);
deepFreeze(networksList);
const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductNetworks.networksList', networksList);
mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
- expect(baseUrl).to.equal(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/networks`);
- expect(data).to.deep.equal(undefined);
- expect(options).to.equal(undefined);
+ expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${softwareProductId}/versions/${vcData.version.id}/networks`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
return {results: networksList};
});
- return SoftwareProductNetworksActionHelper.fetchNetworksList(store.dispatch, {softwareProductId}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ return SoftwareProductNetworksActionHelper.fetchNetworksList(store.dispatch, {softwareProductId, version: vcData.version}).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
});
});
diff --git a/openecomp-ui/test/softwareProduct/processes/SoftwareProductEditor.test.js b/openecomp-ui/test/softwareProduct/processes/SoftwareProductEditor.test.js
new file mode 100644
index 0000000000..b4df9bebd9
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/processes/SoftwareProductEditor.test.js
@@ -0,0 +1,62 @@
+/*!
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesEditor.js';
+import SoftwareProductProcessesEditorView from 'sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesEditorView.jsx';
+import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
+
+describe('Software Product Processes Editor Module Tests', function () {
+
+ it('should mapper exist', () => {
+ expect(mapStateToProps).toBeTruthy();
+ });
+
+ it('should return empty data', () => {
+
+ const currentSoftwareProduct = VSPEditorFactory.build();
+
+ var state = {
+ softwareProduct: {
+ softwareProductEditor: {
+ data: currentSoftwareProduct
+ },
+ softwareProductProcesses:
+ {
+ processesList: [],
+ processesEditor: {data: {}}
+ }
+ }
+ };
+
+ var results = mapStateToProps(state);
+ expect(results.data).toEqual({});
+ expect(results.previousData).toEqual(undefined);
+ });
+
+ it('jsx view test', () => {
+ var view = TestUtils.renderIntoDocument(<SoftwareProductProcessesEditorView
+ isReadOnlyMode={true}
+ data={{}}
+ previousData={{}}
+ onDataChanged={() => {}}
+ onSubmit={() => {}}
+ onClose={() => {}}/>);
+ expect(view).toBeTruthy();
+ });
+
+});
diff --git a/openecomp-ui/test/softwareProduct/processes/SoftwareProductProcessesView.test.js b/openecomp-ui/test/softwareProduct/processes/SoftwareProductProcessesView.test.js
new file mode 100644
index 0000000000..2d7da91cbb
--- /dev/null
+++ b/openecomp-ui/test/softwareProduct/processes/SoftwareProductProcessesView.test.js
@@ -0,0 +1,75 @@
+/*!
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
+ */
+
+import React from 'react';
+import TestUtils from 'react-addons-test-utils';
+import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcesses.js';
+import SoftwareProductProcessesView from 'sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesView.jsx';
+
+import {VSPProcessStoreFactory} from 'test-utils/factories/softwareProduct/SoftwareProductProcessFactories.js';
+import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
+import {VSPComponentsVersionControllerFactory} from 'test-utils/factories/softwareProduct/SoftwareProductComponentsNetworkFactories.js';
+
+describe('SoftwareProductProcesses Mapper and View Classes', () => {
+ it ('mapStateToProps mapper exists', () => {
+ expect(mapStateToProps).toBeTruthy();
+ });
+
+ it ('mapStateToProps data test', () => {
+ const currentSoftwareProduct = VSPEditorFactory.build();
+
+ const processesList = VSPProcessStoreFactory.buildList(2);
+
+ var obj = {
+ softwareProduct: {
+ softwareProductEditor: {
+ data: currentSoftwareProduct
+ },
+ softwareProductProcesses:
+ {
+ processesList,
+ processesEditor: {data: {}}
+ }
+ }
+ };
+ var results = mapStateToProps(obj);
+ expect(results.processesList).toBeTruthy();
+ });
+
+ it ('view simple test', () => {
+ const currentSoftwareProduct = VSPEditorFactory.build();
+ const processesList = VSPProcessStoreFactory.buildList(2);
+
+ const versionControllerData = VSPComponentsVersionControllerFactory.build();
+
+
+ var renderer = TestUtils.createRenderer();
+ renderer.render(
+ <SoftwareProductProcessesView
+ processesList={processesList}
+ versionControllerData={versionControllerData}
+ currentSoftwareProduct={currentSoftwareProduct}
+ onAddProcess={() => {}}
+ onEditProcess={() => {}}
+ onDeleteProcess={() => {}}
+ isDisplayEditor={false}
+ isReadOnlyMode={false} />
+ );
+ var renderedOutput = renderer.getRenderOutput();
+ expect(renderedOutput).toBeTruthy();
+
+ });
+});
diff --git a/openecomp-ui/test/softwareProduct/processes/test.js b/openecomp-ui/test/softwareProduct/processes/test.js
index 73f22a7898..43110d2e55 100644
--- a/openecomp-ui/test/softwareProduct/processes/test.js
+++ b/openecomp-ui/test/softwareProduct/processes/test.js
@@ -1,38 +1,44 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-
-import {expect} from 'chai';
import deepFreeze from 'deep-freeze';
import mockRest from 'test-utils/MockRest.js';
import {cloneAndSet} from 'test-utils/Util.js';
import {storeCreator} from 'sdc-app/AppStore.js';
import Configuration from 'sdc-app/config/Configuration.js';
import SoftwareProductProcessesActionHelper from 'sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesActionHelper.js';
+import {
+ VSPProcessPostFactory,
+ VSPProcessStoreFactory,
+ VSPProcessPostFactoryWithType,
+ VSPProcessStoreFactoryWithType,
+ VSPProcessStoreWithFormDataFactory,
+ VSPProcessPostWithFormDataFactory,
+ VSPProcessStoreWithArtifactNameFactory } from 'test-utils/factories/softwareProduct/SoftwareProductProcessFactories.js';
+import {buildFromExistingObject} from 'test-utils/Util.js';
+import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
+import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js';
const softwareProductId = '123';
+const version = VSPEditorFactory.build().version;
describe('Software Product Processes Module Tests', function () {
let restPrefix = '';
- before(function() {
+ beforeAll(function() {
restPrefix = Configuration.get('restPrefix');
deepFreeze(restPrefix);
});
@@ -45,27 +51,18 @@ describe('Software Product Processes Module Tests', function () {
const store = storeCreator();
deepFreeze(store.getState());
- const softwareProductPostRequest = {
- name: 'Pr1',
- description: 'string'
- };
- const softwareProductProcessToAdd = {
- name: 'Pr1',
- description: 'string'
- };
const softwareProductProcessFromResponse = 'ADDED_ID';
- const softwareProductProcessAfterAdd = {
- ...softwareProductProcessToAdd,
- id: softwareProductProcessFromResponse
- };
+
+ const softwareProductProcessAfterAdd = VSPProcessStoreFactory.build({id: softwareProductProcessFromResponse});
+ const softwareProductPostRequest = buildFromExistingObject(VSPProcessPostFactory, softwareProductProcessAfterAdd);
const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', [softwareProductProcessAfterAdd]);
- mockRest.addHandler('create', ({data, options, baseUrl}) => {
+ mockRest.addHandler('post', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes`);
- expect(data).to.deep.equal(softwareProductPostRequest);
- expect(options).to.equal(undefined);
+ expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes`);
+ expect(data).toEqual(softwareProductPostRequest);
+ expect(options).toEqual(undefined);
return {
returnCode: 'OK',
value: softwareProductProcessFromResponse
@@ -74,64 +71,88 @@ describe('Software Product Processes Module Tests', function () {
return SoftwareProductProcessesActionHelper.saveProcess(store.dispatch,
{
- softwareProductId: softwareProductId,
+ softwareProductId,
+ version,
previousProcess: null,
- process: softwareProductProcessToAdd
+ process: softwareProductPostRequest
}
).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
});
- it('Add Software Products Processes with uploaded file', () => {
+ it('Add Software Products Processes with type', () => {
const store = storeCreator();
deepFreeze(store.getState());
- const softwareProductPostRequest = {
- name: 'Pr1',
- description: 'string'
- };
- const softwareProductProcessToAdd = {
- name: 'Pr1',
- description: 'string',
- formData: {
- name: 'new artifact name'
- }
- };
const softwareProductProcessFromResponse = 'ADDED_ID';
- const softwareProductProcessAfterAdd = {
- ...softwareProductProcessToAdd,
- id: softwareProductProcessFromResponse
- };
+
+ const softwareProductProcessAfterAdd = VSPProcessStoreFactoryWithType.build({id: softwareProductProcessFromResponse});
+ const softwareProductPostRequest = buildFromExistingObject(VSPProcessPostFactoryWithType, softwareProductProcessAfterAdd);
const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', [softwareProductProcessAfterAdd]);
- mockRest.addHandler('create', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes`);
- expect(data).to.deep.equal(softwareProductPostRequest);
- expect(options).to.equal(undefined);
+ mockRest.addHandler('post', ({data, options, baseUrl}) => {
+
+ expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes`);
+ expect(data).toEqual(softwareProductPostRequest);
+ expect(options).toEqual(undefined);
return {
returnCode: 'OK',
value: softwareProductProcessFromResponse
};
});
- mockRest.addHandler('create', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes/${softwareProductProcessAfterAdd.id}/upload`);
- expect(data).to.deep.equal(softwareProductProcessToAdd.formData);
- expect(options).to.equal(undefined);
+ return SoftwareProductProcessesActionHelper.saveProcess(store.dispatch,
+ {
+ softwareProductId,
+ version,
+ previousProcess: null,
+ process: softwareProductPostRequest
+ }
+ ).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
+ });
+ });
+
+ it('Add Software Products Processes with uploaded file', () => {
+
+ const store = storeCreator();
+ deepFreeze(store.getState());
+
+ const softwareProductPostRequest = VSPProcessPostFactoryWithType.build();
+ const softwareProductProcessToAdd = VSPProcessPostWithFormDataFactory.build(softwareProductPostRequest);
+ const softwareProductProcessAfterAdd = VSPProcessStoreWithFormDataFactory.build();
+
+ const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', [softwareProductProcessAfterAdd]);
+
+ mockRest.addHandler('post', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes`);
+ expect(data).toEqual(softwareProductPostRequest);
+ expect(options).toEqual(undefined);
+ return {
+ returnCode: 'OK',
+ value: softwareProductProcessAfterAdd.id
+ };
+ });
+
+ mockRest.addHandler('post', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes/${softwareProductProcessAfterAdd.id}/upload`);
+ expect(data).toEqual(softwareProductProcessToAdd.formData);
+ expect(options).toEqual(undefined);
return {returnCode: 'OK'};
});
return SoftwareProductProcessesActionHelper.saveProcess(store.dispatch,
{
- softwareProductId: softwareProductId,
+ softwareProductId,
+ version,
previousProcess: null,
process: softwareProductProcessToAdd
}
).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
});
@@ -139,14 +160,7 @@ describe('Software Product Processes Module Tests', function () {
//** UPDATE
//**
it('Update Software Products Processes', () => {
- const softwareProductProcessesList = [
- {
- name: 'Pr1',
- description: 'string',
- id: 'EBADF561B7FA4A788075E1840D0B5971',
- artifactName: 'artifact'
- }
- ];
+ const softwareProductProcessesList = VSPProcessStoreWithArtifactNameFactory.buildList(1);
deepFreeze(softwareProductProcessesList);
const store = storeCreator({
@@ -160,47 +174,47 @@ describe('Software Product Processes Module Tests', function () {
const toBeUpdatedProcessId = softwareProductProcessesList[0].id;
const previousProcessData = softwareProductProcessesList[0];
- const processUpdateData = {
- ...softwareProductProcessesList[0],
- name: 'Pr1_UPDATED',
- description: 'string_UPDATED'
- };
+ const processUpdateData = VSPProcessStoreWithArtifactNameFactory.build(
+ {...previousProcessData,
+ name: 'Pr1_UPDATED',
+ description: 'string_UPDATED',
+ type: 'Other'
+ }
+ );
+
deepFreeze(processUpdateData);
- const processPutRequest = {
+ const processPutRequest = VSPProcessPostFactory.build({
name: 'Pr1_UPDATED',
- description: 'string_UPDATED'
- };
+ description: 'string_UPDATED',
+ type: 'Other'
+ });
deepFreeze(processPutRequest);
const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', [processUpdateData]);
- mockRest.addHandler('save', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes/${toBeUpdatedProcessId}`);
- expect(data).to.deep.equal(processPutRequest);
- expect(options).to.equal(undefined);
+ mockRest.addHandler('put', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes/${toBeUpdatedProcessId}`);
+ expect(data).toEqual(processPutRequest);
+ expect(options).toEqual(undefined);
return {returnCode: 'OK'};
});
return SoftwareProductProcessesActionHelper.saveProcess(store.dispatch,
{
- softwareProductId: softwareProductId,
+ softwareProductId,
+ version,
previousProcess: previousProcessData,
process: processUpdateData
}
).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
});
it('Update Software Products Processes and uploaded file', () => {
- const previousProcessData = {
- id: 'EBADF561B7FA4A788075E1840D0B5971',
- name: 'p1',
- description: 'string',
- artifactName: 'artifact'
- };
+ const previousProcessData = VSPProcessStoreWithArtifactNameFactory.build();
deepFreeze(previousProcessData);
const store = storeCreator({
@@ -212,45 +226,47 @@ describe('Software Product Processes Module Tests', function () {
});
deepFreeze(store.getState());
- const newProcessToUpdate = {
+ const newProcessToUpdate = VSPProcessStoreWithFormDataFactory.build({
...previousProcessData,
name: 'new name',
formData: {
name: 'new artifact name'
}
- };
+ });
deepFreeze(newProcessToUpdate);
- const newProcessToPutRequest = {
+ const newProcessToPutRequest = VSPProcessPostFactory.build({
name: newProcessToUpdate.name,
- description: previousProcessData.description
- };
+ description: previousProcessData.description,
+ type: previousProcessData.type
+ });
deepFreeze(newProcessToPutRequest);
const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', [newProcessToUpdate]);
- mockRest.addHandler('save', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes/${previousProcessData.id}`);
- expect(data).to.deep.equal(newProcessToPutRequest);
- expect(options).to.equal(undefined);
+ mockRest.addHandler('put', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes/${newProcessToUpdate.id}`);
+ expect(data).toEqual(newProcessToPutRequest);
+ expect(options).toEqual(undefined);
return {returnCode: 'OK'};
});
- mockRest.addHandler('create', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes/${previousProcessData.id}/upload`);
- expect(data).to.deep.equal(newProcessToUpdate.formData);
- expect(options).to.equal(undefined);
+ mockRest.addHandler('post', ({data, options, baseUrl}) => {
+ expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes/${newProcessToUpdate.id}/upload`);
+ expect(data).toEqual(newProcessToUpdate.formData);
+ expect(options).toEqual(undefined);
return {returnCode: 'OK'};
});
return SoftwareProductProcessesActionHelper.saveProcess(store.dispatch,
{
- softwareProductId: softwareProductId,
+ softwareProductId,
+ version,
previousProcess: previousProcessData,
process: newProcessToUpdate
}
).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
});
@@ -261,20 +277,7 @@ describe('Software Product Processes Module Tests', function () {
const store = storeCreator();
deepFreeze(store.getState());
- const softwareProductProcessesList = [
- {
- name: 'Pr1',
- description: 'hjhj',
- id: 'EBADF561B7FA4A788075E1840D0B5971',
- artifactName: 'artifact'
- },
- {
- name: 'Pr1',
- description: 'hjhj',
- id: '2F47447D22DB4C53B020CA1E66201EF2',
- artifactName: 'artifact'
- }
- ];
+ const softwareProductProcessesList = VSPProcessStoreFactory.buildList(2);
deepFreeze(softwareProductProcessesList);
@@ -283,14 +286,14 @@ describe('Software Product Processes Module Tests', function () {
const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', softwareProductProcessesList);
mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
- expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes`);
- expect(data).to.deep.equal(undefined);
- expect(options).to.equal(undefined);
+ expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
return {results: softwareProductProcessesList};
});
- return SoftwareProductProcessesActionHelper.fetchProcessesList(store.dispatch, {softwareProductId}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ return SoftwareProductProcessesActionHelper.fetchProcessesList(store.dispatch, {softwareProductId, version}).then(() => {
+ expect(store.getState()).toEqual(expectedStore);
});
});
@@ -298,33 +301,32 @@ describe('Software Product Processes Module Tests', function () {
//** DELETE
//**
it('Delete Software Products Processes', () => {
- const softwareProductProcessesList = [
- {
- name: 'Pr1',
- description: 'hjhj',
- id: 'EBADF561B7FA4A788075E1840D0B5971',
- artifactName: 'artifact'
- }
- ];
+ const softwareProductProcessesList = VSPProcessStoreWithArtifactNameFactory.buildList(1);
+ const currentSoftwareProduct = VSPEditorFactory.build();
deepFreeze(softwareProductProcessesList);
const store = storeCreator({
softwareProduct: {
softwareProductProcesses: {
processesList: softwareProductProcessesList
+ },
+ softwareProductEditor: {
+ data: currentSoftwareProduct
}
}
});
- const processId = 'EBADF561B7FA4A788075E1840D0B5971';
+ const processId = softwareProductProcessesList[0].id;
+ const version = store.getState().softwareProduct.softwareProductEditor.data.version;
+ const versionId = version.id;
deepFreeze(store.getState());
const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', []);
mockRest.addHandler('destroy', ({data, options, baseUrl}) => {
- expect(baseUrl).to.equal(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/processes/${processId}`);
- expect(data).to.equal(undefined);
- expect(options).to.equal(undefined);
+ expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/processes/${processId}`);
+ expect(data).toEqual(undefined);
+ expect(options).toEqual(undefined);
return {
results: {
returnCode: 'OK'
@@ -334,9 +336,10 @@ describe('Software Product Processes Module Tests', function () {
return SoftwareProductProcessesActionHelper.deleteProcess(store.dispatch, {
process: softwareProductProcessesList[0],
- softwareProductId
+ softwareProductId,
+ version
}).then(() => {
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
});
});
@@ -344,10 +347,7 @@ describe('Software Product Processes Module Tests', function () {
const store = storeCreator();
deepFreeze(store.getState());
- let process = {
- id: 'p_id',
- name: 'p_name'
- };
+ let process = VSPProcessStoreFactory.build();
deepFreeze(process);
const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processToDelete', process);
@@ -355,7 +355,7 @@ describe('Software Product Processes Module Tests', function () {
SoftwareProductProcessesActionHelper.openDeleteProcessesConfirm(store.dispatch, {process});
setTimeout(function(){
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
done();
}, 100);
});
@@ -369,7 +369,7 @@ describe('Software Product Processes Module Tests', function () {
SoftwareProductProcessesActionHelper.hideDeleteConfirm(store.dispatch);
setTimeout(function(){
- expect(store.getState()).to.deep.equal(expectedStore);
+ expect(store.getState()).toEqual(expectedStore);
done();
}, 100);
});
@@ -377,7 +377,7 @@ describe('Software Product Processes Module Tests', function () {
//**
//** CREATE/EDIT
//**
- it('Validating open Software Products Processes for create', done => {
+ it('Validating open Software Products Processes for create', () => {
const store = storeCreator();
deepFreeze(store.getState());
@@ -387,28 +387,20 @@ describe('Software Product Processes Module Tests', function () {
const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesEditor.data', process);
SoftwareProductProcessesActionHelper.openEditor(store.dispatch);
-
- setTimeout(function(){
- expect(store.getState()).to.deep.equal(expectedStore);
- done();
- }, 100);
+ expect(store.getState().softwareProduct.softwareProductProcesses.processesEditor.data).toEqual(expectedStore.softwareProduct.softwareProductProcesses.processesEditor.data);
});
- it('Validating close Software Products Processes from editing mode', done => {
+ it('Validating close Software Products Processes from editing mode', () => {
const store = storeCreator();
deepFreeze(store.getState());
const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesEditor', {});
SoftwareProductProcessesActionHelper.closeEditor(store.dispatch);
-
- setTimeout(function(){
- expect(store.getState()).to.deep.equal(expectedStore);
- done();
- }, 100);
+ expect(store.getState()).toEqual(expectedStore);
});
- it('Validating open Software Products Processes for editing', done => {
+ it('Validating open Software Products Processes for editing', () => {
const store = storeCreator();
deepFreeze(store.getState());
@@ -418,42 +410,8 @@ describe('Software Product Processes Module Tests', function () {
const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesEditor.data', process);
SoftwareProductProcessesActionHelper.openEditor(store.dispatch, process);
+ expect(store.getState().softwareProduct.softwareProductProcesses.processesEditor.data).toEqual(expectedStore.softwareProduct.softwareProductProcesses.processesEditor.data);
- setTimeout(function(){
- expect(store.getState()).to.deep.equal(expectedStore);
- done();
- }, 100);
});
- it('Validating Software Products Processes dataChanged event', done => {
- let process = {name: 'aa', description: 'xx'};
- deepFreeze(process);
-
- const store = storeCreator({
- softwareProduct: {
- softwareProductProcesses: {
- processesEditor: {
- data: process
- }
- }
- }
- });
- deepFreeze(store.getState());
-
- let deltaData = {name: 'bb'};
- deepFreeze(deltaData);
-
- let expectedProcess = {name: 'bb', description: 'xx'};
- deepFreeze(expectedProcess);
-
- const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesEditor.data', expectedProcess);
-
- SoftwareProductProcessesActionHelper.processEditorDataChanged(store.dispatch, {deltaData});
-
- setTimeout(function(){
- expect(store.getState()).to.deep.equal(expectedStore);
- done();
- }, 100);
- });
});
-
diff --git a/openecomp-ui/test/utils/errorResponseHandler.test.js b/openecomp-ui/test/utils/errorResponseHandler.test.js
index fd9dec6a8d..40836f728a 100644
--- a/openecomp-ui/test/utils/errorResponseHandler.test.js
+++ b/openecomp-ui/test/utils/errorResponseHandler.test.js
@@ -1,28 +1,24 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-
import deepFreeze from 'deep-freeze';
-import expect from 'expect';
+
import {cloneAndSet} from '../../test-utils/Util.js';
import store from 'sdc-app/AppStore.js';
import errorResponseHandler from 'nfvo-utils/ErrorResponseHandler.js';
+import {typeEnum as modalType} from 'nfvo-components/modal/GlobalModalConstants.js';
describe('Error Response Handler Util', () => {
@@ -44,15 +40,20 @@ describe('Error Response Handler Util', () => {
};
deepFreeze(xhr);
- const errorNotification = {
- type: 'error', title: 'Error: SVC4122', msg: 'Error: Invalid data.', timeout: undefined,
- validationResponse: undefined
+ const errorNotification = {
+ title: 'Error: SVC4122',
+ msg: 'Error: Invalid data.',
+ modalClassName: 'notification-modal',
+ type: modalType.ERROR
};
- const expectedStore = cloneAndSet(store.getState(), 'notification', errorNotification);
+
+
+
+ const expectedStore = cloneAndSet(store.getState(), 'modal', errorNotification);
errorResponseHandler(xhr, textStatus, errorThrown);
- setTimeout(function () {
+ setTimeout(function () {
expect(store.getState()).toEqual(expectedStore);
done();
}, 100);
@@ -72,12 +73,15 @@ describe('Error Response Handler Util', () => {
}
};
deepFreeze(xhr);
-
- const errorNotification = {
- type: 'error', title: 'Error: SVC4122', msg: 'Error: Invalid artifact type newType.', timeout: undefined,
- validationResponse: undefined
+
+ const errorNotification = {
+ title: 'Error: SVC4122',
+ msg: 'Error: Invalid artifact type newType.',
+ modalClassName: 'notification-modal',
+ type: modalType.ERROR
};
- const expectedStore = cloneAndSet(store.getState(), 'notification', errorNotification);
+
+ const expectedStore = cloneAndSet(store.getState(), 'modal', errorNotification);
errorResponseHandler(xhr, textStatus, errorThrown);
@@ -97,11 +101,14 @@ describe('Error Response Handler Util', () => {
};
deepFreeze(xhr);
- const errorNotification = {
- type: 'error', title: 'AA', msg: 'Error: Invalid data.', timeout: undefined,
- validationResponse: undefined
+ const errorNotification = {
+ title: 'AA',
+ msg: 'Error: Invalid data.',
+ modalClassName: 'notification-modal',
+ type: modalType.ERROR
};
- const expectedStore = cloneAndSet(store.getState(), 'notification', errorNotification);
+
+ const expectedStore = cloneAndSet(store.getState(), 'modal', errorNotification);
errorResponseHandler(xhr, textStatus, errorThrown);
@@ -118,12 +125,15 @@ describe('Error Response Handler Util', () => {
responseText: 'Internal server error.'
};
deepFreeze(xhr);
-
- const errorNotification = {
- type: 'error', title: '500', msg: 'Internal server error.', timeout: undefined,
- validationResponse: undefined
+
+ const errorNotification = {
+ title: '500',
+ msg: 'Internal server error.',
+ modalClassName: 'notification-modal',
+ type: modalType.ERROR
};
- const expectedStore = cloneAndSet(store.getState(), 'notification', errorNotification);
+
+ const expectedStore = cloneAndSet(store.getState(), 'modal', errorNotification);
errorResponseHandler(xhr, textStatus, errorThrown);
diff --git a/openecomp-ui/test/utils/restApiUtil.test.js b/openecomp-ui/test/utils/restApiUtil.test.js
deleted file mode 100644
index 2a5e69b02e..0000000000
--- a/openecomp-ui/test/utils/restApiUtil.test.js
+++ /dev/null
@@ -1,149 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
- */
-
-import expect from 'expect';
-import $ from 'jquery';
-import RestAPIUtil, {makeQueryParams} from 'src/nfvo-utils/RestAPIUtil';
-
-const URL = 'http://bla.ble.blu/';
-
-describe('RestAPIUtil Util class', () => {
-
- beforeEach(()=> {
- $.ajax = (options) => options;
- });
-
- it('RestAPIUtil does exist', () => {
- expect(RestAPIUtil).toExist();
- });
-
- it('RestAPIUtil makeQueryParams does exist', () => {
- expect(makeQueryParams).toExist();
- });
-
- it('RestAPIUtil makeQueryParams params', () => {
- const pageStart = 1, pageSize = 25;
- const response = makeQueryParams({pagination: {pageStart, pageSize}});
- expect(response.pageStart).toBe(pageStart);
- expect(response.pageSize).toBe(pageSize);
- });
-
- it('normal basic fetch', () => {
- const response = RestAPIUtil.fetch(URL);
- expect(response).toExist();
- });
-
- it('no url', function () {
- expect(function () {
- RestAPIUtil.fetch();
- }).toThrow(/url/);
- });
-
- it('fetch with pagination', () => {
- const pageStart = 1, pageSize = 25;
- const response = RestAPIUtil.fetch(URL, {pagination: {pageStart, pageSize}});
- expect(response.pagination).toExist();
- expect(response.url).toInclude(`?pageStart=${pageStart}&pageSize=${pageSize}`);
- });
-
- it('fetch with sorting', () => {
- const sortField = 'name', sortDir = 'ASCENDING';
- const response = RestAPIUtil.fetch(URL, {sorting: {sortField, sortDir}});
- expect(response.sorting).toExist();
- expect(response.url).toInclude(`?sortField=${sortField}&sortDir=${sortDir}`);
- });
-
- it('fetch with filtering', () => {
- const baseFilter = [
- {
- criterionValue: 'service',
- fieldName: 'Brand',
- operator: 'EQUALS',
- type: 'STRING'
- },
- {
- criterionValue: 'resource',
- fieldName: 'Brand',
- operator: 'EQUALS',
- type: 'STRING'
- }
- ];
- const response = RestAPIUtil.fetch(URL, {filtering: {filterCriteria: baseFilter, logicalRelation: 'OR'}});
- expect(response.filtering).toExist();
- expect(response.url).toInclude('?filter=');
- });
-
- it('fetch with qParams', () => {
- const response = RestAPIUtil.fetch(URL, {qParams: {pageStart: 1, pageSize: 10}});
- expect(response.qParams).toExist();
- });
-
- it('fetch with url on options', () => {
- const response = RestAPIUtil.fetch(URL, {url:'12345', qParams: {pageStart: 1, pageSize: 10}});
- expect(response.qParams).toExist();
- });
-
- it('fetch with url path param', () => {
- let someData = 'data';
- const response = RestAPIUtil.fetch(`${URL}{someData}/`, {params: {someData}});
- expect(response.url).toInclude(`/${someData}/`);
- });
-
- it('fetch with url undefined path param', () => {
- const response = RestAPIUtil.fetch(`${URL}{someData}/`, {params: {someData: undefined}});
- expect(response.url).toInclude('/undefined/');
- });
-
- it('normal basic create', () => {
- const response = RestAPIUtil.create(URL);
- expect(response).toExist();
- });
-
- it('create with FormData', () => {
- let formData = new FormData();
- formData.append('username', 'Chris');
- const response = RestAPIUtil.create(URL, formData);
- expect(response).toExist();
- });
-
- it('create with FormData with md5', () => {
- let formData = new FormData();
- formData.append('username', 'Chris');
- const response = RestAPIUtil.create(URL, formData, {md5: true});
- expect(response).toExist();
- });
-
- it('create with file', () => {
- let progressCallback = () => {};
- const response = RestAPIUtil.create(URL, {}, {progressCallback, fileSize: 123});
- expect(response).toExist();
- });
-
- it('normal basic save', () => {
- const response = RestAPIUtil.save(URL);
- expect(response).toExist();
- });
-
- it('normal basic delete', () => {
- const response = RestAPIUtil.destroy(URL);
- expect(response).toExist();
- });
-
-});
diff --git a/openecomp-ui/test/utils/uuid.test.js b/openecomp-ui/test/utils/uuid.test.js
index cd55baadea..21ac2712de 100644
--- a/openecomp-ui/test/utils/uuid.test.js
+++ b/openecomp-ui/test/utils/uuid.test.js
@@ -1,50 +1,45 @@
-/*-
- * ============LICENSE_START=======================================================
- * SDC
- * ================================================================================
+/*!
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * ================================================================================
+ *
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- * ============LICENSE_END=========================================================
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
+ * or implied. See the License for the specific language governing
+ * permissions and limitations under the License.
*/
-
import uuid from 'src/nfvo-utils/UUID.js';
-import expect from 'expect';
+
describe('UUID', () => {
it('function does exist', () => {
- expect(uuid).toExist();
+ expect(uuid).toBeTruthy();
});
it('generate UUID synchronously', () => {
let result = uuid(undefined, true);
- expect(result).toExist();
+ expect(result).toBeTruthy();
});
it('generate UUID synchronously with number', () => {
let result = uuid(5, true);
- expect(result).toExist();
+ expect(result).toBeTruthy();
});
it('generate UUID synchronously with number', () => {
let result = uuid(1, true);
- expect(result).toExist();
+ expect(result).toBeTruthy();
});
it('generate UUID asynchronously', done => {
uuid().then(result => {
- expect(result).toExist();
+ expect(result).toBeTruthy();
done();
});
});
diff --git a/openecomp-ui/test/utils/validator.test.js b/openecomp-ui/test/utils/validator.test.js
new file mode 100644
index 0000000000..4062fa2d07
--- /dev/null
+++ b/openecomp-ui/test/utils/validator.test.js
@@ -0,0 +1,69 @@
+/*!
+ * 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 Validator from 'src/nfvo-utils/Validator.js';
+
+
+describe('Validator ', () => {
+
+ it('class does exist', () => {
+ expect(Validator).toBeTruthy();
+ });
+
+ it('returns global validation functions', () => {
+ expect(Validator.globalValidationFunctions).toBeTruthy();
+ });
+
+ it('returns global validation messages', () => {
+ expect(Validator.globalValidationMessagingFunctions).toBeTruthy();
+ });
+
+ it('validates data per specific types list', () => {
+ const types = ['required', 'maxLength', 'minLength', 'pattern', 'numeric', 'maximum', 'minimum',
+ 'alphanumeric', 'alphanumericWithSpaces', 'validateName', 'validateVendorName', 'freeEnglishText', 'email', 'ip', 'url', 'maximumExclusive', 'minimumExclusive'];
+
+ for (let i = 0; i < types.length; i++) {
+ expect(Validator.globalValidationFunctions[types[i]]).toBeTruthy();
+ }
+ });
+
+ it('gives validation messages per specific types list', () => {
+ const types = ['required', 'maxLength', 'minLength', 'pattern', 'numeric', 'maximum', 'minimum',
+ 'alphanumeric', 'alphanumericWithSpaces', 'validateName', 'validateVendorName', 'freeEnglishText', 'email', 'ip', 'url', 'maximumExclusive', 'minimumExclusive'];
+
+ for (let i = 0; i < types.length; i++) {
+ expect(Validator.globalValidationFunctions[types[i]]).toBeTruthy();
+ }
+ });
+
+ it('returns a validation response of {isValid, errorText} when validating only by validator.js', () => {
+ const result = Validator.validateItem('a', null, 'required');
+ const keys = Object.keys(result);
+ expect(keys.length).toBe(2);
+ expect(keys).toContain('isValid');
+ expect(keys).toContain('errorText');
+ });
+
+ it('returns a validation response of {isValid, errorText} when validating with custom functions', () => {
+ const errorText = 'ran custom validation';
+ const result = Validator.validate('myfield','a', [{type: 'required', data: null}], {}, { 'myfield' : () => { return { isValid: false, errorText};} });
+ const keys = Object.keys(result);
+ expect(keys.length).toBe(2);
+ expect(keys).toContain('isValid');
+ expect(keys).toContain('errorText');
+ expect(result.errorText).toBe(errorText);
+ });
+
+});