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