aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-ui/test/softwareProduct/components/processes
diff options
context:
space:
mode:
Diffstat (limited to 'openecomp-ui/test/softwareProduct/components/processes')
-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
3 files changed, 236 insertions, 89 deletions
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);
});
});
});
-