svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 1 | /* |
Einav Weiss Keidar | d2f5794 | 2018-02-14 14:00:07 +0200 | [diff] [blame] | 2 | * Copyright © 2016-2018 European Support Limited |
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 |
Einav Weiss Keidar | d2f5794 | 2018-02-14 14:00:07 +0200 | [diff] [blame] | 7 | * |
svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
Einav Weiss Keidar | d2f5794 | 2018-02-14 14:00:07 +0200 | [diff] [blame] | 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, |
svishnev | 1eb66b7 | 2018-01-11 14:39:45 +0200 | [diff] [blame] | 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * 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 React from 'react'; |
Einav Weiss Keidar | d2f5794 | 2018-02-14 14:00:07 +0200 | [diff] [blame] | 17 | import TestUtils from 'react-dom/test-utils'; |
| 18 | import ShallowRenderer from 'react-test-renderer/shallow'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 19 | import {mapStateToProps} from 'sdc-app/onboarding/softwareProduct/details/SoftwareProductDetails.js'; |
| 20 | import SoftwareProductDetailsView from 'sdc-app/onboarding/softwareProduct/details/SoftwareProductDetailsView.jsx'; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 21 | import {VSPEditorFactory} from 'test-utils/factories/softwareProduct/SoftwareProductEditorFactories.js'; |
| 22 | import {CategoryWithSubFactory} from 'test-utils/factories/softwareProduct/VSPCategoriesFactory.js'; |
| 23 | import {LicenseAgreementStoreFactory} from 'test-utils/factories/licenseModel/LicenseAgreementFactories.js'; |
| 24 | import {FeatureGroupStoreFactory} from 'test-utils/factories/licenseModel/FeatureGroupFactories.js'; |
| 25 | import {SchemaGenericFieldInfoFactory} from 'test-utils/factories/softwareProduct/SoftwareProductQSchemaFactory.js'; |
| 26 | import {default as VspQdataFactory, VspDataMapFactory} from 'test-utils/factories/softwareProduct/VspQdataFactory.js'; |
| 27 | import {FinalizedLicenseModelFactory} from 'test-utils/factories/licenseModel/LicenseModelFactories.js'; |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 28 | import VersionFactory from 'test-utils/factories/common/VersionFactory.js'; |
| 29 | import CurrentScreenFactory from 'test-utils/factories/common/CurrentScreenFactory.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 30 | |
| 31 | describe('Software Product Details: ', function () { |
| 32 | |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 33 | let currentSoftwareProduct = {}, currentSoftwareProductWithLicensingData = {}, softwareProductCategories = [], licensingVersionsList = [], currentScreen = {}, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 34 | finalizedLicenseModelList, licenseAgreementList, featureGroupsList, qdata = {}, dataMap = {}, genericFieldInfo = {}, qGenericFieldInfo = {}; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 35 | let dummyFunc = () => {}; |
| 36 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 37 | beforeAll(function() { |
| 38 | finalizedLicenseModelList = FinalizedLicenseModelFactory.buildList(2); |
| 39 | currentSoftwareProduct = VSPEditorFactory.build({ |
| 40 | id: 'RTRTG454545', |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 41 | licensingVersion: undefined, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 42 | vendorId: finalizedLicenseModelList[0].id, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 43 | vendorName: finalizedLicenseModelList[0].name |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 44 | }); |
| 45 | softwareProductCategories = CategoryWithSubFactory.buildList(2, {}, {quantity: 1}); |
| 46 | licenseAgreementList = LicenseAgreementStoreFactory.buildList(2); |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 47 | licensingVersionsList = [ |
| 48 | { |
| 49 | "id":"0127b419e9574a11aab8e031a78fc534", |
| 50 | "name":"1.0","description":"Initial version", |
| 51 | "baseId":"","status":"Certified","creationTime":1506409288390,"modificationTime":1506409288390,"additionalInfo":{"OptionalCreationMethods":["minor"]}},{"id":"ea159ffedd9a4f9a8a56d53ba66b7314","name":"2.0","description":"ggggg","baseId":"0127b419e9574a11aab8e031a78fc534","status":"Draft","creationTime":1508839019802,"modificationTime":1508839019802,"additionalInfo":{"OptionalCreationMethods":[]}} |
| 52 | ]; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 53 | featureGroupsList = FeatureGroupStoreFactory.buildList(2, {referencingLicenseAgreements: [licenseAgreementList[0].id]}); |
| 54 | qdata = VspQdataFactory.build(); |
| 55 | dataMap = VspDataMapFactory.build(); |
| 56 | currentSoftwareProductWithLicensingData = { |
| 57 | ...currentSoftwareProduct, |
| 58 | licensingData: { |
| 59 | licenseAgreement: licenseAgreementList[0].id, |
| 60 | featureGroups: [featureGroupsList[0].id] |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 61 | }, |
| 62 | licensingVersion : licensingVersionsList[0].id |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 63 | }; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 64 | genericFieldInfo = { |
| 65 | 'name': { |
| 66 | isValid: true, |
| 67 | errorText: '', |
| 68 | validations: [{type: 'validateName', data: true}, {type: 'maxLength', data: 120}, { |
| 69 | type: 'required', |
| 70 | data: true |
| 71 | }] |
| 72 | }, |
| 73 | 'description': { |
| 74 | isValid: true, |
| 75 | errorText: '', |
| 76 | validations: [{type: 'required', data: true}] |
| 77 | } |
| 78 | }; |
| 79 | qGenericFieldInfo = SchemaGenericFieldInfoFactory.build(); |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 80 | currentScreen = CurrentScreenFactory.build(); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 81 | }); |
| 82 | |
| 83 | it('should mapper exist', () => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 84 | expect(mapStateToProps).toBeTruthy(); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 85 | }); |
| 86 | |
| 87 | it('should mapper return vsp basic data', () => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 88 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 89 | var obj = { |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 90 | currentScreen, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 91 | softwareProduct: { |
| 92 | softwareProductEditor: { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 93 | data: currentSoftwareProduct, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 94 | genericFieldInfo, |
| 95 | licensingVersionsList |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 96 | }, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 97 | softwareProductCategories, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 98 | softwareProductQuestionnaire: { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 99 | qdata, |
| 100 | genericFieldInfo: qGenericFieldInfo, |
| 101 | dataMap |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 102 | } |
| 103 | }, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 104 | finalizedLicenseModelList, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 105 | licenseModel: { |
| 106 | licenseAgreement: { |
| 107 | licenseAgreementList: [] |
| 108 | }, |
| 109 | featureGroup: { |
| 110 | featureGroupsList: [] |
| 111 | } |
| 112 | } |
| 113 | }; |
| 114 | |
| 115 | var result = mapStateToProps(obj); |
| 116 | expect(result.currentSoftwareProduct).toEqual(currentSoftwareProduct); |
| 117 | expect(result.finalizedLicenseModelList).toEqual(finalizedLicenseModelList); |
| 118 | expect(result.finalizedLicenseModelList.length).toBeGreaterThan(0); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 119 | expect(finalizedLicenseModelList[0]).toMatchObject({ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 120 | id: result.currentSoftwareProduct.vendorId, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 121 | name: result.currentSoftwareProduct.vendorName |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 122 | }); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 123 | expect(result.softwareProductCategories).toEqual(softwareProductCategories); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 124 | expect(result.licenseAgreementList).toEqual([]); |
| 125 | expect(result.featureGroupsList).toEqual([]); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 126 | expect(result.qdata).toEqual(qdata); |
| 127 | expect(result.dataMap).toEqual(dataMap); |
| 128 | expect(result.isFormValid).toEqual(true); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 129 | }); |
| 130 | |
| 131 | it('should mapper return vsp data with selected licenseAgreement and featureGroup', () => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 132 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 133 | var obj = { |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 134 | currentScreen, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 135 | softwareProduct: { |
| 136 | softwareProductEditor: { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 137 | data: currentSoftwareProductWithLicensingData, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 138 | genericFieldInfo, |
| 139 | licensingVersionsList |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 140 | }, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 141 | softwareProductCategories, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 142 | softwareProductQuestionnaire: { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 143 | qdata, |
| 144 | genericFieldInfo: qGenericFieldInfo, |
| 145 | dataMap |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 146 | } |
| 147 | }, |
| 148 | finalizedLicenseModelList: finalizedLicenseModelList, |
| 149 | licenseModel: { |
| 150 | licenseAgreement: { |
| 151 | licenseAgreementList: licenseAgreementList |
| 152 | }, |
| 153 | featureGroup: { |
| 154 | featureGroupsList: featureGroupsList |
| 155 | } |
| 156 | } |
| 157 | }; |
| 158 | |
| 159 | var result = mapStateToProps(obj); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 160 | expect(result.currentSoftwareProduct).toEqual(currentSoftwareProductWithLicensingData); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 161 | expect(result.finalizedLicenseModelList).toEqual(finalizedLicenseModelList); |
| 162 | expect(result.finalizedLicenseModelList.length).toBeGreaterThan(0); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 163 | expect(result.finalizedLicenseModelList[0]).toMatchObject({ |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 164 | id: result.currentSoftwareProduct.vendorId, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 165 | name: result.currentSoftwareProduct.vendorName |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 166 | }); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 167 | expect(result.softwareProductCategories).toEqual(softwareProductCategories); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 168 | expect(result.licenseAgreementList).toEqual(licenseAgreementList); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 169 | expect(result.licenseAgreementList[0]).toMatchObject({...licenseAgreementList[0], id: result.currentSoftwareProduct.licensingData.licenseAgreement}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 170 | result.currentSoftwareProduct.licensingData.featureGroups.forEach(fg => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 171 | expect(featureGroupsList[0]).toMatchObject({...featureGroupsList[0], id: fg}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 172 | }); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 173 | expect(result.qdata).toEqual(qdata); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 174 | }); |
| 175 | |
| 176 | it('VSP Details view test', () => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 177 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 178 | let params = { |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 179 | ...currentScreen.props, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 180 | currentSoftwareProduct, |
| 181 | softwareProductCategories, |
| 182 | qdata, |
| 183 | dataMap, |
| 184 | isFormValid: true, |
| 185 | finalizedLicenseModelList, |
| 186 | licenseAgreementList, |
| 187 | featureGroupsList, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 188 | licensingVersionsList, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 189 | genericFieldInfo, |
| 190 | qGenericFieldInfo, |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 191 | }; |
Einav Weiss Keidar | d2f5794 | 2018-02-14 14:00:07 +0200 | [diff] [blame] | 192 | const renderer = new ShallowRenderer(); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 193 | renderer.render( |
| 194 | <SoftwareProductDetailsView |
| 195 | {...params} |
| 196 | onSubmit = {dummyFunc} |
| 197 | onDataChanged = {dummyFunc} |
| 198 | onValidityChanged = {dummyFunc} |
| 199 | onQDataChanged = {dummyFunc} |
| 200 | onVendorParamChanged = {dummyFunc}/> |
| 201 | ); |
| 202 | let renderedOutput = renderer.getRenderOutput(); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 203 | expect(renderedOutput).toBeTruthy(); |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 204 | expect(renderedOutput.props.children.props.isReadOnlyMode).toBe(false); |
| 205 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 206 | }); |
| 207 | |
| 208 | it('in view: should change vendorId and update vsp licensing-version', done => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 209 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 210 | let params = { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 211 | currentSoftwareProduct: currentSoftwareProductWithLicensingData, |
| 212 | softwareProductCategories, |
| 213 | qdata, |
| 214 | dataMap, |
| 215 | isFormValid: true, |
| 216 | genericFieldInfo, |
| 217 | qGenericFieldInfo, |
| 218 | finalizedLicenseModelList, |
| 219 | licenseAgreementList, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 220 | licensingVersionsList, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 221 | featureGroupsList |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 222 | }; |
| 223 | const onVendorChangedListener = (deltaData) => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 224 | expect(deltaData.vendorId).toEqual(finalizedLicenseModelList[1].id); |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 225 | expect(deltaData.vendorName).toEqual(finalizedLicenseModelList[1].name); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 226 | expect(deltaData.licensingVersion).toEqual(''); |
| 227 | expect(deltaData.licensingData).toEqual({}); |
| 228 | done(); |
| 229 | }; |
| 230 | |
| 231 | var vspDetailsView = TestUtils.renderIntoDocument(<SoftwareProductDetailsView |
| 232 | currentSoftwareProduct = {params.currentSoftwareProduct} |
| 233 | softwareProductCategories = {params.softwareProductCategories} |
| 234 | qdata = {params.qdata} |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 235 | qGenericFieldInfo = {params.qGenericFieldInfo} |
| 236 | genericFieldInfo = {params.genericFieldInfo} |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 237 | licensingVersionsList={params.licensingVersionsList} |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 238 | isFormValid={params.isFormValid} |
| 239 | dataMap={params.dataMap} |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 240 | finalizedLicenseModelList = {params.finalizedLicenseModelList} |
| 241 | licenseAgreementList = {params.licenseAgreementList} |
| 242 | featureGroupsList = {params.featureGroupsList} |
| 243 | onSubmit = {dummyFunc} |
| 244 | onDataChanged = {dummyFunc} |
| 245 | onValidityChanged = {dummyFunc} |
| 246 | onQDataChanged = {dummyFunc} |
| 247 | onVendorParamChanged = {(deltaData) => onVendorChangedListener(deltaData)}/>); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 248 | expect(vspDetailsView).toBeTruthy(); |
| 249 | vspDetailsView.onVendorParamChanged({vendorId: finalizedLicenseModelList[1].id}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 250 | }); |
| 251 | |
| 252 | it('in view: should change licensing-version and update licensing data', done => { |
| 253 | let params = { |
| 254 | currentSoftwareProduct: currentSoftwareProduct, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 255 | softwareProductCategories, |
| 256 | qdata, |
| 257 | dataMap, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 258 | licensingVersionsList, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 259 | isFormValid: true, |
| 260 | genericFieldInfo, |
| 261 | qGenericFieldInfo, |
| 262 | finalizedLicenseModelList, |
| 263 | licenseAgreementList, |
| 264 | featureGroupsList |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 265 | }; |
| 266 | const onVendorChangedListener = (deltaData) => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 267 | expect(deltaData.vendorId).toEqual(finalizedLicenseModelList[1].id); |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 268 | expect(deltaData.vendorName).toEqual(finalizedLicenseModelList[1].name); |
| 269 | expect(deltaData.licensingVersion).toEqual(licensingVersionsList[1]); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 270 | expect(deltaData.licensingData).toEqual({}); |
| 271 | done(); |
| 272 | }; |
| 273 | |
| 274 | let vspDetailsView = TestUtils.renderIntoDocument(<SoftwareProductDetailsView |
| 275 | {...params} |
| 276 | onSubmit = {dummyFunc} |
| 277 | onDataChanged = {dummyFunc} |
| 278 | onValidityChanged = {dummyFunc} |
| 279 | onQDataChanged = {dummyFunc} |
| 280 | onVendorParamChanged = {(deltaData) => onVendorChangedListener(deltaData)}/>); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 281 | expect(vspDetailsView).toBeTruthy(); |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 282 | vspDetailsView.onVendorParamChanged({vendorId: finalizedLicenseModelList[1].id, licensingVersion: licensingVersionsList[1]}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 283 | }); |
| 284 | |
| 285 | it('in view: should change subcategory', done => { |
| 286 | let params = { |
| 287 | currentSoftwareProduct: currentSoftwareProduct, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 288 | softwareProductCategories, |
| 289 | qdata, |
| 290 | dataMap, |
| 291 | isFormValid: true, |
| 292 | genericFieldInfo, |
| 293 | qGenericFieldInfo, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 294 | licensingVersionsList, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 295 | finalizedLicenseModelList, |
| 296 | licenseAgreementList, |
| 297 | featureGroupsList |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 298 | }; |
| 299 | const onDataChangedListener = ({category, subCategory}) => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 300 | expect(category).toEqual(softwareProductCategories[1].uniqueId); |
| 301 | expect(subCategory).toEqual(softwareProductCategories[1].subcategories[0].uniqueId); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 302 | done(); |
| 303 | }; |
| 304 | |
| 305 | let vspDetailsView = TestUtils.renderIntoDocument(<SoftwareProductDetailsView |
| 306 | {...params} |
| 307 | onSubmit = {dummyFunc} |
| 308 | onDataChanged = {({category, subCategory}) => onDataChangedListener({category, subCategory})} |
| 309 | onValidityChanged = {dummyFunc} |
| 310 | onQDataChanged = {dummyFunc} |
| 311 | onVendorParamChanged = {dummyFunc}/>); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 312 | expect(vspDetailsView).toBeTruthy(); |
| 313 | vspDetailsView.onSelectSubCategory(softwareProductCategories[1].subcategories[0].uniqueId); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 314 | }); |
| 315 | |
| 316 | it('in view: should change feature groups', done => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 317 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 318 | let params = { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 319 | currentSoftwareProduct: currentSoftwareProductWithLicensingData, |
| 320 | softwareProductCategories, |
| 321 | qdata, |
| 322 | dataMap, |
| 323 | isFormValid: true, |
| 324 | genericFieldInfo, |
| 325 | qGenericFieldInfo, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 326 | licensingVersionsList, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 327 | finalizedLicenseModelList, |
| 328 | licenseAgreementList, |
| 329 | featureGroupsList |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 330 | }; |
| 331 | const onDataChangedListener = ({licensingData}) => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 332 | expect(licensingData.licenseAgreement).toEqual(licenseAgreementList[0].id); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 333 | expect(licensingData.featureGroups).toEqual([ |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 334 | {enum: featureGroupsList[0].id, title: featureGroupsList[0].name}, |
| 335 | {enum: featureGroupsList[1].id, title: featureGroupsList[1].name} |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 336 | ]); |
| 337 | done(); |
| 338 | }; |
| 339 | |
| 340 | let vspDetailsView = TestUtils.renderIntoDocument(<SoftwareProductDetailsView |
| 341 | {...params} |
| 342 | onSubmit = {dummyFunc} |
| 343 | onDataChanged = {({licensingData}) => onDataChangedListener({licensingData})} |
| 344 | onValidityChanged = {dummyFunc} |
| 345 | onQDataChanged = {dummyFunc} |
| 346 | onVendorParamChanged = {dummyFunc}/>); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 347 | expect(vspDetailsView).toBeTruthy(); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 348 | vspDetailsView.onFeatureGroupsChanged({featureGroups: [ |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 349 | {enum: featureGroupsList[0].id, title: featureGroupsList[0].name}, |
| 350 | {enum: featureGroupsList[1].id, title: featureGroupsList[1].name} |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 351 | ]}); |
| 352 | }); |
| 353 | |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 354 | |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 355 | it('in view: should change license agreement', done => { |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 356 | let params = { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 357 | currentSoftwareProduct: currentSoftwareProductWithLicensingData, |
| 358 | softwareProductCategories, |
| 359 | qdata, |
| 360 | dataMap, |
| 361 | isFormValid: true, |
| 362 | genericFieldInfo, |
| 363 | qGenericFieldInfo, |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 364 | licensingVersionsList, |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 365 | finalizedLicenseModelList, |
| 366 | licenseAgreementList, |
| 367 | featureGroupsList |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 368 | }; |
| 369 | const onDataChangedListener = ({licensingData}) => { |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 370 | expect(licensingData.licenseAgreement).toEqual(licenseAgreementList[1].id); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 371 | expect(licensingData.featureGroups).toEqual([]); |
| 372 | done(); |
| 373 | }; |
| 374 | |
| 375 | let vspDetailsView = TestUtils.renderIntoDocument(<SoftwareProductDetailsView |
| 376 | {...params} |
| 377 | onSubmit = {dummyFunc} |
| 378 | onDataChanged = {({licensingData}) => onDataChangedListener({licensingData})} |
| 379 | onValidityChanged = {dummyFunc} |
| 380 | onQDataChanged = {dummyFunc} |
| 381 | onVendorParamChanged = {dummyFunc}/>); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 382 | expect(vspDetailsView).toBeTruthy(); |
| 383 | vspDetailsView.onLicensingDataChanged({licenseAgreement: licenseAgreementList[1].id, featureGroups: []}); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 384 | }); |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 385 | |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 386 | }); |