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'; |
| 32 | import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 33 | |
| 34 | const softwareProductId = '123'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 35 | const version = VSPEditorFactory.build().version; |
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; |
| 320 | const version = store.getState().softwareProduct.softwareProductEditor.data.version; |
| 321 | const versionId = version.id; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 322 | deepFreeze(store.getState()); |
| 323 | |
| 324 | const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesList', []); |
| 325 | |
| 326 | mockRest.addHandler('destroy', ({data, options, baseUrl}) => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 327 | expect(baseUrl).toEqual(`${restPrefix}/v1.0/vendor-software-products/${softwareProductId}/versions/${versionId}/processes/${processId}`); |
| 328 | expect(data).toEqual(undefined); |
| 329 | expect(options).toEqual(undefined); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 330 | return { |
| 331 | results: { |
| 332 | returnCode: 'OK' |
| 333 | } |
| 334 | }; |
| 335 | }); |
| 336 | |
| 337 | return SoftwareProductProcessesActionHelper.deleteProcess(store.dispatch, { |
| 338 | process: softwareProductProcessesList[0], |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 339 | softwareProductId, |
| 340 | version |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 341 | }).then(() => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 342 | expect(store.getState()).toEqual(expectedStore); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 343 | }); |
| 344 | }); |
| 345 | |
| 346 | it('Validating Software Products Processes Delete confirmation', done => { |
| 347 | const store = storeCreator(); |
| 348 | deepFreeze(store.getState()); |
| 349 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 350 | let process = VSPProcessStoreFactory.build(); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 351 | deepFreeze(process); |
| 352 | |
| 353 | const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processToDelete', process); |
| 354 | |
| 355 | SoftwareProductProcessesActionHelper.openDeleteProcessesConfirm(store.dispatch, {process}); |
| 356 | |
| 357 | setTimeout(function(){ |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 358 | expect(store.getState()).toEqual(expectedStore); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 359 | done(); |
| 360 | }, 100); |
| 361 | }); |
| 362 | |
| 363 | it('Validating Software Products Processes Cancel Delete', done => { |
| 364 | const store = storeCreator(); |
| 365 | deepFreeze(store.getState()); |
| 366 | |
| 367 | const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processToDelete', false); |
| 368 | |
| 369 | SoftwareProductProcessesActionHelper.hideDeleteConfirm(store.dispatch); |
| 370 | |
| 371 | setTimeout(function(){ |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 372 | expect(store.getState()).toEqual(expectedStore); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 373 | done(); |
| 374 | }, 100); |
| 375 | }); |
| 376 | |
| 377 | //** |
| 378 | //** CREATE/EDIT |
| 379 | //** |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 380 | it('Validating open Software Products Processes for create', () => { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 381 | const store = storeCreator(); |
| 382 | deepFreeze(store.getState()); |
| 383 | |
| 384 | let process = {}; |
| 385 | deepFreeze(process); |
| 386 | |
| 387 | const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesEditor.data', process); |
| 388 | |
| 389 | SoftwareProductProcessesActionHelper.openEditor(store.dispatch); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 390 | 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] | 391 | }); |
| 392 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 393 | it('Validating close Software Products Processes from editing mode', () => { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 394 | const store = storeCreator(); |
| 395 | deepFreeze(store.getState()); |
| 396 | |
| 397 | const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesEditor', {}); |
| 398 | |
| 399 | SoftwareProductProcessesActionHelper.closeEditor(store.dispatch); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 400 | expect(store.getState()).toEqual(expectedStore); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 401 | }); |
| 402 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 403 | it('Validating open Software Products Processes for editing', () => { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 404 | const store = storeCreator(); |
| 405 | deepFreeze(store.getState()); |
| 406 | |
| 407 | let process = {name: 'aa', description: 'xx'}; |
| 408 | deepFreeze(process); |
| 409 | |
| 410 | const expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductProcesses.processesEditor.data', process); |
| 411 | |
| 412 | SoftwareProductProcessesActionHelper.openEditor(store.dispatch, process); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 413 | 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] | 414 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 415 | }); |
| 416 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 417 | }); |