AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 1 | /*! |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 2 | * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 3 | * |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express |
| 13 | * or implied. See the License for the specific language governing |
| 14 | * permissions and limitations under the License. |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 15 | */ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 16 | import deepFreeze from 'deep-freeze'; |
| 17 | import mockRest from 'test-utils/MockRest.js'; |
| 18 | import {cloneAndSet} from 'test-utils/Util.js'; |
| 19 | import {storeCreator} from 'sdc-app/AppStore.js'; |
| 20 | import Configuration from 'sdc-app/config/Configuration.js'; |
| 21 | import SoftwareProductProcessesActionHelper from 'sdc-app/onboarding/softwareProduct/processes/SoftwareProductProcessesActionHelper.js'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 22 | import { |
| 23 | VSPProcessPostFactory, |
| 24 | VSPProcessStoreFactory, |
| 25 | VSPProcessPostFactoryWithType, |
| 26 | VSPProcessStoreFactoryWithType, |
| 27 | VSPProcessStoreWithFormDataFactory, |
| 28 | VSPProcessPostWithFormDataFactory, |
| 29 | VSPProcessStoreWithArtifactNameFactory } from 'test-utils/factories/softwareProduct/SoftwareProductProcessFactories.js'; |
| 30 | import {buildFromExistingObject} from 'test-utils/Util.js'; |
| 31 | import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 32 | import VersionFactory from 'test-utils/factories/common/VersionFactory.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 33 | |
| 34 | const softwareProductId = '123'; |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 35 | const version = VersionFactory.build(); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 36 | |
| 37 | describe('Software Product Processes Module Tests', function () { |
| 38 | |
| 39 | let restPrefix = ''; |
| 40 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 41 | beforeAll(function() { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 42 | restPrefix = Configuration.get('restPrefix'); |
| 43 | deepFreeze(restPrefix); |
| 44 | }); |
| 45 | |
| 46 | //** |
| 47 | //** ADD |
| 48 | //** |
| 49 | it('Add Software Products Processes', () => { |
| 50 | |
| 51 | const store = storeCreator(); |
| 52 | deepFreeze(store.getState()); |
| 53 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 54 | const softwareProductProcessFromResponse = 'ADDED_ID'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 55 | |
| 56 | const softwareProductProcessAfterAdd = VSPProcessStoreFactory.build({id: softwareProductProcessFromResponse}); |
| 57 | const softwareProductPostRequest = buildFromExistingObject(VSPProcessPostFactory, softwareProductProcessAfterAdd); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 58 | |
| 59 | const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', [softwareProductProcessAfterAdd]); |
| 60 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 61 | mockRest.addHandler('post', ({data, options, baseUrl}) => { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 62 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 63 | expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes`); |
| 64 | expect(data).toEqual(softwareProductPostRequest); |
| 65 | expect(options).toEqual(undefined); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 66 | return { |
| 67 | returnCode: 'OK', |
| 68 | value: softwareProductProcessFromResponse |
| 69 | }; |
| 70 | }); |
| 71 | |
| 72 | return SoftwareProductProcessesActionHelper.saveProcess(store.dispatch, |
| 73 | { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 74 | softwareProductId, |
| 75 | version, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 76 | previousProcess: null, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 77 | process: softwareProductPostRequest |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 78 | } |
| 79 | ).then(() => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 80 | expect(store.getState()).toEqual(expectedStore); |
| 81 | }); |
| 82 | }); |
| 83 | |
| 84 | it('Add Software Products Processes with type', () => { |
| 85 | |
| 86 | const store = storeCreator(); |
| 87 | deepFreeze(store.getState()); |
| 88 | |
| 89 | const softwareProductProcessFromResponse = 'ADDED_ID'; |
| 90 | |
| 91 | const softwareProductProcessAfterAdd = VSPProcessStoreFactoryWithType.build({id: softwareProductProcessFromResponse}); |
| 92 | const softwareProductPostRequest = buildFromExistingObject(VSPProcessPostFactoryWithType, softwareProductProcessAfterAdd); |
| 93 | |
| 94 | const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', [softwareProductProcessAfterAdd]); |
| 95 | |
| 96 | mockRest.addHandler('post', ({data, options, baseUrl}) => { |
| 97 | |
| 98 | expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes`); |
| 99 | expect(data).toEqual(softwareProductPostRequest); |
| 100 | expect(options).toEqual(undefined); |
| 101 | return { |
| 102 | returnCode: 'OK', |
| 103 | value: softwareProductProcessFromResponse |
| 104 | }; |
| 105 | }); |
| 106 | |
| 107 | return SoftwareProductProcessesActionHelper.saveProcess(store.dispatch, |
| 108 | { |
| 109 | softwareProductId, |
| 110 | version, |
| 111 | previousProcess: null, |
| 112 | process: softwareProductPostRequest |
| 113 | } |
| 114 | ).then(() => { |
| 115 | expect(store.getState()).toEqual(expectedStore); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 116 | }); |
| 117 | }); |
| 118 | |
| 119 | it('Add Software Products Processes with uploaded file', () => { |
| 120 | |
| 121 | const store = storeCreator(); |
| 122 | deepFreeze(store.getState()); |
| 123 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 124 | const softwareProductPostRequest = VSPProcessPostFactoryWithType.build(); |
| 125 | const softwareProductProcessToAdd = VSPProcessPostWithFormDataFactory.build(softwareProductPostRequest); |
| 126 | const softwareProductProcessAfterAdd = VSPProcessStoreWithFormDataFactory.build(); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 127 | |
| 128 | const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', [softwareProductProcessAfterAdd]); |
| 129 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 130 | mockRest.addHandler('post', ({data, options, baseUrl}) => { |
| 131 | expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes`); |
| 132 | expect(data).toEqual(softwareProductPostRequest); |
| 133 | expect(options).toEqual(undefined); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 134 | return { |
| 135 | returnCode: 'OK', |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 136 | value: softwareProductProcessAfterAdd.id |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 137 | }; |
| 138 | }); |
| 139 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 140 | mockRest.addHandler('post', ({data, options, baseUrl}) => { |
| 141 | expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes/${softwareProductProcessAfterAdd.id}/upload`); |
| 142 | expect(data).toEqual(softwareProductProcessToAdd.formData); |
| 143 | expect(options).toEqual(undefined); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 144 | return {returnCode: 'OK'}; |
| 145 | }); |
| 146 | |
| 147 | return SoftwareProductProcessesActionHelper.saveProcess(store.dispatch, |
| 148 | { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 149 | softwareProductId, |
| 150 | version, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 151 | previousProcess: null, |
| 152 | process: softwareProductProcessToAdd |
| 153 | } |
| 154 | ).then(() => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 155 | expect(store.getState()).toEqual(expectedStore); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 156 | }); |
| 157 | }); |
| 158 | |
| 159 | //** |
| 160 | //** UPDATE |
| 161 | //** |
| 162 | it('Update Software Products Processes', () => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 163 | const softwareProductProcessesList = VSPProcessStoreWithArtifactNameFactory.buildList(1); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 164 | deepFreeze(softwareProductProcessesList); |
| 165 | |
| 166 | const store = storeCreator({ |
| 167 | softwareProduct: { |
| 168 | softwareProductProcesses: { |
| 169 | processesList: softwareProductProcessesList |
| 170 | } |
| 171 | } |
| 172 | }); |
| 173 | deepFreeze(store.getState()); |
| 174 | |
| 175 | const toBeUpdatedProcessId = softwareProductProcessesList[0].id; |
| 176 | const previousProcessData = softwareProductProcessesList[0]; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 177 | const processUpdateData = VSPProcessStoreWithArtifactNameFactory.build( |
| 178 | {...previousProcessData, |
| 179 | name: 'Pr1_UPDATED', |
| 180 | description: 'string_UPDATED', |
| 181 | type: 'Other' |
| 182 | } |
| 183 | ); |
| 184 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 185 | deepFreeze(processUpdateData); |
| 186 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 187 | const processPutRequest = VSPProcessPostFactory.build({ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 188 | name: 'Pr1_UPDATED', |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 189 | description: 'string_UPDATED', |
| 190 | type: 'Other' |
| 191 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 192 | deepFreeze(processPutRequest); |
| 193 | |
| 194 | const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', [processUpdateData]); |
| 195 | |
| 196 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 197 | mockRest.addHandler('put', ({data, options, baseUrl}) => { |
| 198 | expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes/${toBeUpdatedProcessId}`); |
| 199 | expect(data).toEqual(processPutRequest); |
| 200 | expect(options).toEqual(undefined); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 201 | return {returnCode: 'OK'}; |
| 202 | }); |
| 203 | |
| 204 | return SoftwareProductProcessesActionHelper.saveProcess(store.dispatch, |
| 205 | { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 206 | softwareProductId, |
| 207 | version, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 208 | previousProcess: previousProcessData, |
| 209 | process: processUpdateData |
| 210 | } |
| 211 | ).then(() => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 212 | expect(store.getState()).toEqual(expectedStore); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 213 | }); |
| 214 | }); |
| 215 | |
| 216 | it('Update Software Products Processes and uploaded file', () => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 217 | const previousProcessData = VSPProcessStoreWithArtifactNameFactory.build(); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 218 | deepFreeze(previousProcessData); |
| 219 | |
| 220 | const store = storeCreator({ |
| 221 | softwareProduct: { |
| 222 | softwareProductProcesses: { |
| 223 | processesList: [previousProcessData] |
| 224 | } |
| 225 | } |
| 226 | }); |
| 227 | deepFreeze(store.getState()); |
| 228 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 229 | const newProcessToUpdate = VSPProcessStoreWithFormDataFactory.build({ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 230 | ...previousProcessData, |
| 231 | name: 'new name', |
| 232 | formData: { |
| 233 | name: 'new artifact name' |
| 234 | } |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 235 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 236 | deepFreeze(newProcessToUpdate); |
| 237 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 238 | const newProcessToPutRequest = VSPProcessPostFactory.build({ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 239 | name: newProcessToUpdate.name, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 240 | description: previousProcessData.description, |
| 241 | type: previousProcessData.type |
| 242 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 243 | deepFreeze(newProcessToPutRequest); |
| 244 | |
| 245 | const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', [newProcessToUpdate]); |
| 246 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 247 | mockRest.addHandler('put', ({data, options, baseUrl}) => { |
| 248 | expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes/${newProcessToUpdate.id}`); |
| 249 | expect(data).toEqual(newProcessToPutRequest); |
| 250 | expect(options).toEqual(undefined); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 251 | return {returnCode: 'OK'}; |
| 252 | }); |
| 253 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 254 | mockRest.addHandler('post', ({data, options, baseUrl}) => { |
| 255 | expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes/${newProcessToUpdate.id}/upload`); |
| 256 | expect(data).toEqual(newProcessToUpdate.formData); |
| 257 | expect(options).toEqual(undefined); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 258 | return {returnCode: 'OK'}; |
| 259 | }); |
| 260 | |
| 261 | return SoftwareProductProcessesActionHelper.saveProcess(store.dispatch, |
| 262 | { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 263 | softwareProductId, |
| 264 | version, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 265 | previousProcess: previousProcessData, |
| 266 | process: newProcessToUpdate |
| 267 | } |
| 268 | ).then(() => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 269 | expect(store.getState()).toEqual(expectedStore); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 270 | }); |
| 271 | }); |
| 272 | |
| 273 | //** |
| 274 | //** GET |
| 275 | //** |
| 276 | it('Get Software Products Processes List', () => { |
| 277 | const store = storeCreator(); |
| 278 | deepFreeze(store.getState()); |
| 279 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 280 | const softwareProductProcessesList = VSPProcessStoreFactory.buildList(2); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 281 | |
| 282 | deepFreeze(softwareProductProcessesList); |
| 283 | |
| 284 | deepFreeze(store.getState()); |
| 285 | |
| 286 | const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', softwareProductProcessesList); |
| 287 | |
| 288 | mockRest.addHandler('fetch', ({options, data, baseUrl}) => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 289 | expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${version.id}/processes`); |
| 290 | expect(data).toEqual(undefined); |
| 291 | expect(options).toEqual(undefined); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 292 | return {results: softwareProductProcessesList}; |
| 293 | }); |
| 294 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 295 | return SoftwareProductProcessesActionHelper.fetchProcessesList(store.dispatch, {softwareProductId, version}).then(() => { |
| 296 | expect(store.getState()).toEqual(expectedStore); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 297 | }); |
| 298 | }); |
| 299 | |
| 300 | //** |
| 301 | //** DELETE |
| 302 | //** |
| 303 | it('Delete Software Products Processes', () => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 304 | const softwareProductProcessesList = VSPProcessStoreWithArtifactNameFactory.buildList(1); |
| 305 | const currentSoftwareProduct = VSPEditorFactory.build(); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 306 | |
| 307 | deepFreeze(softwareProductProcessesList); |
| 308 | const store = storeCreator({ |
| 309 | softwareProduct: { |
| 310 | softwareProductProcesses: { |
| 311 | processesList: softwareProductProcessesList |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 312 | }, |
| 313 | softwareProductEditor: { |
| 314 | data: currentSoftwareProduct |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 315 | } |
| 316 | } |
| 317 | }); |
| 318 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 319 | const processId = softwareProductProcessesList[0].id; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 320 | const versionId = version.id; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 321 | deepFreeze(store.getState()); |
| 322 | |
| 323 | const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', []); |
| 324 | |
| 325 | mockRest.addHandler('destroy', ({data, options, baseUrl}) => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 326 | expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/processes/${processId}`); |
| 327 | expect(data).toEqual(undefined); |
| 328 | expect(options).toEqual(undefined); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 329 | return { |
| 330 | results: { |
| 331 | returnCode: 'OK' |
| 332 | } |
| 333 | }; |
| 334 | }); |
| 335 | |
| 336 | return SoftwareProductProcessesActionHelper.deleteProcess(store.dispatch, { |
| 337 | process: softwareProductProcessesList[0], |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 338 | softwareProductId, |
| 339 | version |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 340 | }).then(() => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 341 | expect(store.getState()).toEqual(expectedStore); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 342 | }); |
| 343 | }); |
| 344 | |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 345 | it('Validating Software Products Processes Delete confirmation', () => { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 346 | const store = storeCreator(); |
| 347 | deepFreeze(store.getState()); |
| 348 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 349 | let process = VSPProcessStoreFactory.build(); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 350 | deepFreeze(process); |
| 351 | |
| 352 | const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processToDelete', process); |
| 353 | |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 354 | return SoftwareProductProcessesActionHelper.openDeleteProcessesConfirm(store.dispatch, {process}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 355 | |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 356 | expect(store.getState()).toEqual(expectedStore); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 357 | }); |
| 358 | |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 359 | it('Validating Software Products Processes Cancel Delete', () => { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 360 | const store = storeCreator(); |
| 361 | deepFreeze(store.getState()); |
| 362 | |
| 363 | const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processToDelete', false); |
| 364 | |
| 365 | SoftwareProductProcessesActionHelper.hideDeleteConfirm(store.dispatch); |
| 366 | |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 367 | expect(store.getState()).toEqual(expectedStore); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 368 | }); |
| 369 | |
| 370 | //** |
| 371 | //** CREATE/EDIT |
| 372 | //** |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 373 | it('Validating open Software Products Processes for create', () => { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 374 | const store = storeCreator(); |
| 375 | deepFreeze(store.getState()); |
| 376 | |
| 377 | let process = {}; |
| 378 | deepFreeze(process); |
| 379 | |
| 380 | const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesEditor.data', process); |
| 381 | |
| 382 | SoftwareProductProcessesActionHelper.openEditor(store.dispatch); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 383 | expect(store.getState().softwareProduct.softwareProductProcesses.processesEditor.data).toEqual(expectedStore.softwareProduct.softwareProductProcesses.processesEditor.data); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 384 | }); |
| 385 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 386 | it('Validating close Software Products Processes from editing mode', () => { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 387 | const store = storeCreator(); |
| 388 | deepFreeze(store.getState()); |
| 389 | |
| 390 | const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesEditor', {}); |
| 391 | |
| 392 | SoftwareProductProcessesActionHelper.closeEditor(store.dispatch); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 393 | expect(store.getState()).toEqual(expectedStore); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 394 | }); |
| 395 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 396 | it('Validating open Software Products Processes for editing', () => { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 397 | const store = storeCreator(); |
| 398 | deepFreeze(store.getState()); |
| 399 | |
| 400 | let process = {name: 'aa', description: 'xx'}; |
| 401 | deepFreeze(process); |
| 402 | |
| 403 | const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesEditor.data', process); |
| 404 | |
| 405 | SoftwareProductProcessesActionHelper.openEditor(store.dispatch, process); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 406 | expect(store.getState().softwareProduct.softwareProductProcesses.processesEditor.data).toEqual(expectedStore.softwareProduct.softwareProductProcesses.processesEditor.data); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 407 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 408 | }); |
| 409 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 410 | }); |