blob: 27cbaa40efb56d732e9aeb6c2296a9c25fd32d9c [file] [log] [blame]
AviZi280f8012017-06-09 02:39:56 +03001/*!
Michael Landoefa037d2017-02-19 12:57:33 +02002 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
AviZi280f8012017-06-09 02:39:56 +03003 *
Michael Landoefa037d2017-02-19 12:57:33 +02004 * 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
AviZi280f8012017-06-09 02:39:56 +03007 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
Michael Landoefa037d2017-02-19 12:57:33 +020010 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
AviZi280f8012017-06-09 02:39:56 +030012 * 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 Landoefa037d2017-02-19 12:57:33 +020015 */
Michael Landoefa037d2017-02-19 12:57:33 +020016import deepFreeze from 'deep-freeze';
17import mockRest from 'test-utils/MockRest.js';
AviZi280f8012017-06-09 02:39:56 +030018import {cloneAndSet, buildFromExistingObject} from 'test-utils/Util.js';
Michael Landoefa037d2017-02-19 12:57:33 +020019import {storeCreator} from 'sdc-app/AppStore.js';
20
21import SoftwareProductCreationActionHelper from 'sdc-app/onboarding/softwareProduct/creation/SoftwareProductCreationActionHelper.js';
22import SoftwareProductActionHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductActionHelper.js';
23import SoftwareProductCategoriesHelper from 'sdc-app/onboarding/softwareProduct/SoftwareProductCategoriesHelper.js';
AviZi280f8012017-06-09 02:39:56 +030024import {forms} from 'sdc-app/onboarding/softwareProduct/SoftwareProductConstants.js';
25import ValidationHelper from 'sdc-app/common/helpers/ValidationHelper.js';
26
27import {VSPEditorFactory, VSPEditorPostFactory, VSPEditorFactoryWithLicensingData, VSPEditorPostFactoryWithLicensingData} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js';
28import {CategoryFactory} from 'test-utils/factories/softwareProduct/VSPCategoriesFactory.js';
29import {heatSetupManifest} from 'test-utils/factories/softwareProduct/SoftwareProductAttachmentsFactories.js';
30
31import { FeatureGroupStoreFactory as FeatureGroup} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js';
32import {LicenseAgreementStoreFactory as LicenseAgreement} from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js';
AviZi280f8012017-06-09 02:39:56 +030033
talig8e9c0652017-12-20 14:30:43 +020034import VersionFactory from 'test-utils/factories/common/VersionFactory.js';
35import {InitializedCurrentScreenFactory} from 'test-utils/factories/common/CurrentScreenFactory.js';
Michael Landoefa037d2017-02-19 12:57:33 +020036
talig8e9c0652017-12-20 14:30:43 +020037describe('Software Product Details Module Tests', function () {
Michael Landoefa037d2017-02-19 12:57:33 +020038 it('Get Software Products List', () => {
39 const store = storeCreator();
40 deepFreeze(store.getState());
AviZi280f8012017-06-09 02:39:56 +030041 const softwareProductList = VSPEditorFactory.buildList(2);
Michael Landoefa037d2017-02-19 12:57:33 +020042 deepFreeze(softwareProductList);
Michael Landoefa037d2017-02-19 12:57:33 +020043 deepFreeze(store.getState());
Michael Landoefa037d2017-02-19 12:57:33 +020044 const expectedStore = cloneAndSet(store.getState(), 'softwareProductList', softwareProductList);
45
46 mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
talig8e9c0652017-12-20 14:30:43 +020047 expect(baseUrl).toEqual('/onboarding-api/v1.0/vendor-software-products/?versionFilter=Draft');
AviZi280f8012017-06-09 02:39:56 +030048 expect(data).toEqual(undefined);
49 expect(options).toEqual(undefined);
Michael Landoefa037d2017-02-19 12:57:33 +020050 return {results: softwareProductList};
51 });
52
AviZi280f8012017-06-09 02:39:56 +030053 mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
talig8e9c0652017-12-20 14:30:43 +020054 expect(baseUrl).toEqual('/onboarding-api/v1.0/vendor-software-products/?versionFilter=Certified');
AviZi280f8012017-06-09 02:39:56 +030055 expect(data).toEqual(undefined);
56 expect(options).toEqual(undefined);
57 return {results: []};
58 });
59
Michael Landoefa037d2017-02-19 12:57:33 +020060 return SoftwareProductActionHelper.fetchSoftwareProductList(store.dispatch).then(() => {
AviZi280f8012017-06-09 02:39:56 +030061 return SoftwareProductActionHelper.fetchFinalizedSoftwareProductList(store.dispatch);
62 }).then(() => {
63 expect(store.getState()).toEqual(expectedStore);
Michael Landoefa037d2017-02-19 12:57:33 +020064 });
65 });
66
67 it('Add Software Product', () => {
68 const store = storeCreator();
69 deepFreeze(store.getState());
70
AviZi280f8012017-06-09 02:39:56 +030071 const softwareProductPostRequest = VSPEditorPostFactory.build();
72 deepFreeze(softwareProductPostRequest);
73 const idFromResponse = '1';
74 const expectedVSP = VSPEditorPostFactory.build({id: idFromResponse, vendorId: softwareProductPostRequest.vendorId});
75 deepFreeze(expectedVSP);
Michael Landoefa037d2017-02-19 12:57:33 +020076
AviZi280f8012017-06-09 02:39:56 +030077 mockRest.addHandler('post', ({options, data, baseUrl}) => {
78 expect(baseUrl).toEqual('/onboarding-api/v1.0/vendor-software-products/');
79 expect(data).toEqual(softwareProductPostRequest);
80 expect(options).toEqual(undefined);
Michael Landoefa037d2017-02-19 12:57:33 +020081 return {
AviZi280f8012017-06-09 02:39:56 +030082 vspId: idFromResponse
Michael Landoefa037d2017-02-19 12:57:33 +020083 };
84 });
85
86 return SoftwareProductCreationActionHelper.createSoftwareProduct(store.dispatch, {
AviZi280f8012017-06-09 02:39:56 +030087 softwareProduct: softwareProductPostRequest
88 }).then((response) => {
89 expect(response.vspId).toEqual(idFromResponse);
Michael Landoefa037d2017-02-19 12:57:33 +020090 });
91 });
AviZi280f8012017-06-09 02:39:56 +030092
93 it('Fetch Software Product with manifest', () => {
94 const store = storeCreator();
95 deepFreeze(store.getState());
96
97 const softwareProductPostRequest = VSPEditorPostFactory.build();
98 deepFreeze(softwareProductPostRequest);
99
100 const expectedGenericInfo = {
101 'name': {
102 isValid: true,
103 errorText: '',
104 validations: [{type: 'validateName', data: true}, {type: 'maxLength', data: 25}, {
105 type: 'required',
106 data: true
107 }]
108 },
109 'description': {
110 isValid: true,
111 errorText: '',
112 validations: [{type: 'required', data: true}]
Michael Landoefa037d2017-02-19 12:57:33 +0200113 }
114 };
AviZi280f8012017-06-09 02:39:56 +0300115 const expectedFormName = forms.VENDOR_SOFTWARE_PRODUCT_DETAILS;
116
117 const idFromResponse = '1';
118 const version = { id: '0.1', label: '0.1'};
119 const expectedVSP = VSPEditorPostFactory.build({id: idFromResponse, vendorId: softwareProductPostRequest.vendorId});
120 deepFreeze(expectedVSP);
121 let expectedStore = cloneAndSet(store.getState(), 'softwareProduct.softwareProductEditor.data', expectedVSP);
122 expectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductEditor.genericFieldInfo', expectedGenericInfo);
123 expectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductEditor.formName', expectedFormName);
124 expectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductQuestionnaire', {qdata: {}, dataMap: {}, qgenericFieldInfo: {}});
125
126 expectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductAttachments.heatValidation', {
127 'attachmentsTree': {},
128 'errorList': [],
129 'selectedNode': 'All'
130 });
131 let manifest = heatSetupManifest.build();
132 expectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductAttachments.heatSetup', manifest);
133
talig8e9c0652017-12-20 14:30:43 +0200134 const expectedCurrentScreen = InitializedCurrentScreenFactory.build();
135 expectedStore = cloneAndSet(expectedStore, 'currentScreen.itemPermission', expectedCurrentScreen.itemPermission);
136 expectedStore = cloneAndSet(expectedStore, 'currentScreen.props', expectedCurrentScreen.props);
137
AviZi280f8012017-06-09 02:39:56 +0300138 mockRest.addHandler('post', ({options, data, baseUrl}) => {
139 expect(baseUrl).toEqual('/onboarding-api/v1.0/vendor-software-products/');
140 expect(data).toEqual(softwareProductPostRequest);
141 expect(options).toEqual(undefined);
142 return {
143 vspId: idFromResponse,
144 version
145 };
146 });
147
148 mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
149 expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${idFromResponse}/versions/${version.id}`);
150 expect(data).toEqual(undefined);
151 expect(options).toEqual(undefined);
152 return expectedVSP;
153 });
154
155 mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
156 expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${idFromResponse}/versions/${version.id}/questionnaire`);
157 expect(data).toEqual(undefined);
158 expect(options).toEqual(undefined);
159 return {data: JSON.stringify({}), schema: JSON.stringify({})};
160 });
161
162 mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
163 expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${idFromResponse}/versions/${version.id}/orchestration-template-candidate/manifest`);
164 expect(data).toEqual(undefined);
165 expect(options).toEqual(undefined);
166 return manifest;
167 });
168
169 return SoftwareProductCreationActionHelper.createSoftwareProduct(store.dispatch, {
170 softwareProduct: softwareProductPostRequest
171 }).then(() => {
172 return SoftwareProductActionHelper.fetchSoftwareProduct(store.dispatch, {softwareProductId: idFromResponse, version});
173 }).then(() => {
174 return SoftwareProductActionHelper.loadSoftwareProductHeatCandidate(store.dispatch, {softwareProductId: idFromResponse, version});
175 }).then(() => {
176 expect(store.getState()).toEqual(expectedStore);
177 let newName = 'newName';
178 expectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductEditor.formReady', null);
179 ValidationHelper.dataChanged(store.dispatch, {deltaData: {'name': newName}, formName: forms.VENDOR_SOFTWARE_PRODUCT_DETAILS});
180 expectedStore = cloneAndSet(expectedStore, 'softwareProduct.softwareProductEditor.data.name', newName);
181 expect(store.getState()).toEqual(expectedStore);
182 });
183 });
184
185 it('Load and edit Software Product licensing data', () => {
186 const store = storeCreator();
187
188 const softwareProductPostRequest = VSPEditorPostFactory.build();
189 deepFreeze(softwareProductPostRequest);
190
191 const licenseModelId = softwareProductPostRequest.vendorId;
talig8e9c0652017-12-20 14:30:43 +0200192 const LMVersion = VersionFactory.build();
AviZi280f8012017-06-09 02:39:56 +0300193 const secondLicenseModelId = 'secondLicenseModelId';
194
195 let FG1 = FeatureGroup.build();
196 let LA1 = LicenseAgreement.build({
197 featureGroupsIds: [FG1.id]
198 });
199
200 let FG2 = FeatureGroup.build();
201 let LA2 = LicenseAgreement.build({
202 featureGroupsIds: [FG2.id]
203 });
204
205 mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
206 expect(baseUrl).toEqual('/sdc1/feProxy/rest/v1/categories/resources/');
207 expect(data).toEqual(undefined);
208 expect(options).toEqual(undefined);
209 return [];
210 });
211
212 mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
talig8e9c0652017-12-20 14:30:43 +0200213 expect(baseUrl).toEqual('/onboarding-api/v1.0/vendor-license-models/?versionFilter=Certified');
AviZi280f8012017-06-09 02:39:56 +0300214 expect(data).toEqual(undefined);
215 expect(options).toEqual(undefined);
216 return {results: []};
217 });
218
219 mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
talig8e9c0652017-12-20 14:30:43 +0200220 expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${licenseModelId}/versions/${LMVersion.id}`);
221 expect(data).toEqual(undefined);
222 expect(options).toEqual(undefined);
223 return {results: {}};
224 });
225
226 mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
AviZi280f8012017-06-09 02:39:56 +0300227 expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${licenseModelId}/versions/${LMVersion.id}/license-agreements`);
228 expect(data).toEqual(undefined);
229 expect(options).toEqual(undefined);
230 return {results: [LA1]};
231 });
232
233 mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
234 expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${licenseModelId}/versions/${LMVersion.id}/feature-groups`);
235 expect(data).toEqual(undefined);
236 expect(options).toEqual(undefined);
237 return {results: [FG1]};
238 });
239
240 mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
talig8e9c0652017-12-20 14:30:43 +0200241 expect(baseUrl).toEqual(`/onboarding-api/v1.0/items/${secondLicenseModelId}/versions/${LMVersion.id}`);
242 expect(data).toEqual(undefined);
243 expect(options).toEqual(undefined);
244 return {results: {}};
245 });
246
247 mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
AviZi280f8012017-06-09 02:39:56 +0300248 expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${secondLicenseModelId}/versions/${LMVersion.id}/license-agreements`);
249 expect(data).toEqual(undefined);
250 expect(options).toEqual(undefined);
251 return {results: [LA2]};
252 });
253
254 mockRest.addHandler('fetch', ({options, data, baseUrl}) => {
255 expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-license-models/${secondLicenseModelId}/versions/${LMVersion.id}/feature-groups`);
256 expect(data).toEqual(undefined);
257 expect(options).toEqual(undefined);
258 return {results: [FG2]};
259 });
260
talig8e9c0652017-12-20 14:30:43 +0200261 return SoftwareProductActionHelper.loadSoftwareProductDetailsData(store.dispatch, {licenseModelId, licensingVersion: LMVersion.id}).then(() => {
AviZi280f8012017-06-09 02:39:56 +0300262 let state = store.getState();
263 expect(state.licenseModel.licenseAgreement.licenseAgreementList).toEqual([LA1]);
264 expect(state.licenseModel.featureGroup.featureGroupsList).toEqual([FG1]);
265 return SoftwareProductActionHelper.softwareProductEditorVendorChanged(store.dispatch,
talig8e9c0652017-12-20 14:30:43 +0200266 {deltaData: {vendorId: secondLicenseModelId, licensingVersion: LMVersion.id},
267 formName: forms.VENDOR_SOFTWARE_PRODUCT_DETAILS}
268 ).then(() => {
269 let state = store.getState();
270 expect(state.licenseModel.licenseAgreement.licenseAgreementList).toEqual([LA2]);
271 expect(state.licenseModel.featureGroup.featureGroupsList).toEqual([FG2]);
272 });
AviZi280f8012017-06-09 02:39:56 +0300273 });
274 });
275
276 it('Save Software product', () => {
277
278 const softwareProduct = VSPEditorFactoryWithLicensingData.build();
Michael Landoefa037d2017-02-19 12:57:33 +0200279 deepFreeze(softwareProduct);
280
talig8e9c0652017-12-20 14:30:43 +0200281 const version = VersionFactory.build();
282
Michael Landoefa037d2017-02-19 12:57:33 +0200283 const store = storeCreator({
284 softwareProduct: {
285 softwareProductEditor: {data: softwareProduct},
286 softwareProductQuestionnaire: {qdata: 'test', qschema: {type: 'string'}}
287 }
288 });
289 deepFreeze(store.getState());
290
AviZi280f8012017-06-09 02:39:56 +0300291 const dataForUpdate = {
Michael Landoefa037d2017-02-19 12:57:33 +0200292 name: 'VSP5_UPDATED',
293 description: 'A software model for Fortigate._UPDATED'
294 };
AviZi280f8012017-06-09 02:39:56 +0300295
296 const toBeUpdatedSoftwareProductId = softwareProduct.id;
297 let softwareProductUpdateData = VSPEditorPostFactoryWithLicensingData.build(dataForUpdate);
298 delete softwareProductUpdateData.version;
299
300 const softwareProductPutRequest = buildFromExistingObject(VSPEditorFactoryWithLicensingData, softwareProductUpdateData, {id: toBeUpdatedSoftwareProductId, version: softwareProduct.version});
301
Michael Landoefa037d2017-02-19 12:57:33 +0200302 deepFreeze(softwareProductUpdateData);
303
AviZi280f8012017-06-09 02:39:56 +0300304 const expectedStore = cloneAndSet(store.getState(), 'softwareProductList', [softwareProductPutRequest]);
Michael Landoefa037d2017-02-19 12:57:33 +0200305 const questionnaireData = {
306 general: {
307 affinityData: {
308 affinityGrouping: true,
309 antiAffinityGrouping: false
310 }
311 }
312 };
313 deepFreeze(questionnaireData);
314
AviZi280f8012017-06-09 02:39:56 +0300315 mockRest.addHandler('put', ({data, options, baseUrl}) => {
talig8e9c0652017-12-20 14:30:43 +0200316 expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/versions/${version.id}`);
AviZi280f8012017-06-09 02:39:56 +0300317 expect(data).toEqual(softwareProductUpdateData);
318 expect(options).toEqual(undefined);
Michael Landoefa037d2017-02-19 12:57:33 +0200319 return {returnCode: 'OK'};
320 });
AviZi280f8012017-06-09 02:39:56 +0300321 mockRest.addHandler('put', ({data, options, baseUrl}) => {
talig8e9c0652017-12-20 14:30:43 +0200322 expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/versions/${version.id}/questionnaire`);
AviZi280f8012017-06-09 02:39:56 +0300323 expect(data).toEqual(questionnaireData);
324 expect(options).toEqual(undefined);
Michael Landoefa037d2017-02-19 12:57:33 +0200325 return {returnCode: 'OK'};
326 });
327
328 return SoftwareProductActionHelper.updateSoftwareProduct(store.dispatch, {
AviZi280f8012017-06-09 02:39:56 +0300329 softwareProduct: softwareProductPutRequest,
talig8e9c0652017-12-20 14:30:43 +0200330 qdata: questionnaireData,
331 version
Michael Landoefa037d2017-02-19 12:57:33 +0200332 }).then(() => {
AviZi280f8012017-06-09 02:39:56 +0300333 expect(store.getState()).toEqual(expectedStore);
Michael Landoefa037d2017-02-19 12:57:33 +0200334 });
335 });
AviZi280f8012017-06-09 02:39:56 +0300336
Michael Landoefa037d2017-02-19 12:57:33 +0200337 it('Save Software product data only', () => {
AviZi280f8012017-06-09 02:39:56 +0300338
339 const softwareProduct = VSPEditorFactoryWithLicensingData.build();
Michael Landoefa037d2017-02-19 12:57:33 +0200340 deepFreeze(softwareProduct);
341
talig8e9c0652017-12-20 14:30:43 +0200342 const version = VersionFactory.build();
343
Michael Landoefa037d2017-02-19 12:57:33 +0200344 const store = storeCreator({
345 softwareProduct: {
346 softwareProductEditor: {data: softwareProduct},
347 softwareProductQuestionnaire: {qdata: 'test', qschema: {type: 'string'}}
348 }
349 });
350 deepFreeze(store.getState());
351 const expectedStore = store.getState();
352
AviZi280f8012017-06-09 02:39:56 +0300353 const dataForUpdate = {
Michael Landoefa037d2017-02-19 12:57:33 +0200354 name: 'VSP5_UPDATED',
355 description: 'A software model for Fortigate._UPDATED'
356 };
AviZi280f8012017-06-09 02:39:56 +0300357
358 const toBeUpdatedSoftwareProductId = softwareProduct.id;
359 let softwareProductUpdateData = VSPEditorPostFactoryWithLicensingData.build(dataForUpdate);
360 delete softwareProductUpdateData.version;
361
talig8e9c0652017-12-20 14:30:43 +0200362 const softwareProductPutRequest = buildFromExistingObject(VSPEditorFactoryWithLicensingData, softwareProductUpdateData, {id: toBeUpdatedSoftwareProductId});
AviZi280f8012017-06-09 02:39:56 +0300363
Michael Landoefa037d2017-02-19 12:57:33 +0200364 deepFreeze(softwareProductUpdateData);
365
AviZi280f8012017-06-09 02:39:56 +0300366 mockRest.addHandler('put', ({data, options, baseUrl}) => {
talig8e9c0652017-12-20 14:30:43 +0200367 expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/versions/${version.id}`);
AviZi280f8012017-06-09 02:39:56 +0300368 expect(data).toEqual(softwareProductUpdateData);
369 expect(options).toEqual(undefined);
Michael Landoefa037d2017-02-19 12:57:33 +0200370 return {returnCode: 'OK'};
371 });
372
373 return SoftwareProductActionHelper.updateSoftwareProductData(store.dispatch, {
talig8e9c0652017-12-20 14:30:43 +0200374 softwareProduct: softwareProductPutRequest,
375 version
Michael Landoefa037d2017-02-19 12:57:33 +0200376 }).then(() => {
AviZi280f8012017-06-09 02:39:56 +0300377 expect(store.getState()).toEqual(expectedStore);
Michael Landoefa037d2017-02-19 12:57:33 +0200378 });
379 });
380
381 it('Save Software product questionnaire only', () => {
AviZi280f8012017-06-09 02:39:56 +0300382 const softwareProduct = VSPEditorFactoryWithLicensingData.build();
Michael Landoefa037d2017-02-19 12:57:33 +0200383 deepFreeze(softwareProduct);
384
talig8e9c0652017-12-20 14:30:43 +0200385 const version = VersionFactory.build();
386
Michael Landoefa037d2017-02-19 12:57:33 +0200387 const store = storeCreator({
388 softwareProduct: {
389 softwareProductEditor: {data: softwareProduct},
390 softwareProductQuestionnaire: {qdata: 'test', qschema: {type: 'string'}}
391 }
392 });
393 deepFreeze(store.getState());
394 const expectedStore = store.getState();
395
396 const toBeUpdatedSoftwareProductId = softwareProduct.id;
397 const questionnaireData = {
398 general: {
399 affinityData: {
400 affinityGrouping: true,
401 antiAffinityGrouping: false
402 }
403 }
404 };
405 deepFreeze(questionnaireData);
406
AviZi280f8012017-06-09 02:39:56 +0300407 mockRest.addHandler('put', ({data, options, baseUrl}) => {
talig8e9c0652017-12-20 14:30:43 +0200408 expect(baseUrl).toEqual(`/onboarding-api/v1.0/vendor-software-products/${toBeUpdatedSoftwareProductId}/versions/${version.id}/questionnaire`);
AviZi280f8012017-06-09 02:39:56 +0300409 expect(data).toEqual(questionnaireData);
410 expect(options).toEqual(undefined);
Michael Landoefa037d2017-02-19 12:57:33 +0200411 return {returnCode: 'OK'};
412 });
413
414 return SoftwareProductActionHelper.updateSoftwareProductQuestionnaire(store.dispatch, {
415 softwareProductId: softwareProduct.id,
talig8e9c0652017-12-20 14:30:43 +0200416 version,
Michael Landoefa037d2017-02-19 12:57:33 +0200417 qdata: questionnaireData
418 }).then(() => {
AviZi280f8012017-06-09 02:39:56 +0300419 expect(store.getState()).toEqual(expectedStore);
Michael Landoefa037d2017-02-19 12:57:33 +0200420 });
421 });
422
423 it('Handle category without subcategories', () => {
AviZi280f8012017-06-09 02:39:56 +0300424
425 const categories = CategoryFactory.buildList(3);
426 categories[0].subcategories = CategoryFactory.buildList(3);
427 categories[2].subcategories = CategoryFactory.buildList(3);
428
429 const category = SoftwareProductCategoriesHelper.getCurrentCategoryOfSubCategory(categories[2].subcategories[2].uniqueId, categories);
430 expect(category).toEqual(categories[2].uniqueId);
Michael Landoefa037d2017-02-19 12:57:33 +0200431 });
432
433});