aboutsummaryrefslogtreecommitdiffstats
path: root/openecomp-ui/test/softwareProduct/components/processes/test.js
diff options
context:
space:
mode:
authorAviZi <avi.ziv@amdocs.com>2017-06-09 02:39:56 +0300
committerAviZi <avi.ziv@amdocs.com>2017-06-09 02:39:56 +0300
commit280f8015d06af1f41a3ef12e8300801c7a5e0d54 (patch)
tree9c1d3978c04cd28068f02073038c936bb49ca9e0 /openecomp-ui/test/softwareProduct/components/processes/test.js
parentfd3821dad11780d33c5373d74c957c442489945e (diff)
[SDC-29] Amdocs OnBoard 1707 initial commit.
Change-Id: Ie4d12a3f574008b792899b368a0902a8b46b5370 Signed-off-by: AviZi <avi.ziv@amdocs.com>
Diffstat (limited to 'openecomp-ui/test/softwareProduct/components/processes/test.js')
-rw-r--r--openecomp-ui/test/softwareProduct/components/processes/test.js191
1 files changed, 102 insertions, 89 deletions
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);
});
});
});
-