svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 1 | /* |
| 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 |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +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, |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [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 deepFreeze from 'deep-freeze'; |
| 17 | import mockRest from 'test-utils/MockRest.js'; |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 18 | import { cloneAndSet, buildListFromFactory } from 'test-utils/Util.js'; |
| 19 | import { storeCreator } from 'sdc-app/AppStore.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 20 | import FeatureGroupsActionHelper from 'sdc-app/onboarding/licenseModel/featureGroups/FeatureGroupsActionHelper.js'; |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 21 | import { |
| 22 | FeatureGroupStoreFactory, |
| 23 | FeatureGroupPostFactory, |
| 24 | FeatureGroupDispatchFactory, |
| 25 | FeatureGroupPutFactory |
| 26 | } from 'test-utils/factories/licenseModel/FeatureGroupFactories.js'; |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 27 | import VersionFactory from 'test-utils/factories/common/VersionFactory.js'; |
| 28 | import CurrentScreenFactory from 'test-utils/factories/common/CurrentScreenFactory.js'; |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 29 | import { SyncStates } from 'sdc-app/common/merge/MergeEditorConstants.js'; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 30 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 31 | describe('Feature Groups Module Tests', function() { |
| 32 | const LICENSE_MODEL_ID = '555'; |
| 33 | const version = VersionFactory.build(); |
| 34 | const itemPermissionAndProps = CurrentScreenFactory.build({}, { version }); |
| 35 | const returnedVersionFields = { |
| 36 | baseId: version.baseId, |
| 37 | description: version.description, |
| 38 | id: version.id, |
| 39 | name: version.name, |
| 40 | status: version.status |
| 41 | }; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 42 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 43 | it('Load Feature Groups List', () => { |
| 44 | const featureGroupsList = buildListFromFactory( |
| 45 | FeatureGroupStoreFactory |
| 46 | ); |
| 47 | deepFreeze(featureGroupsList); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 48 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 49 | const store = storeCreator(); |
| 50 | deepFreeze(store.getState()); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 51 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 52 | const expectedStore = cloneAndSet( |
| 53 | store.getState(), |
| 54 | 'licenseModel.featureGroup.featureGroupsList', |
| 55 | featureGroupsList |
| 56 | ); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 57 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 58 | mockRest.addHandler('fetch', ({ data, options, baseUrl }) => { |
| 59 | expect(baseUrl).toEqual( |
| 60 | `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${ |
| 61 | version.id |
| 62 | }/feature-groups` |
| 63 | ); |
| 64 | expect(data).toEqual(undefined); |
| 65 | expect(options).toEqual(undefined); |
| 66 | return { results: featureGroupsList }; |
| 67 | }); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 68 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 69 | return FeatureGroupsActionHelper.fetchFeatureGroupsList( |
| 70 | store.dispatch, |
| 71 | { licenseModelId: LICENSE_MODEL_ID, version } |
| 72 | ).then(() => { |
| 73 | expect(store.getState()).toEqual(expectedStore); |
| 74 | }); |
| 75 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 76 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 77 | it('Delete Feature Group', () => { |
| 78 | const featureGroupsList = buildListFromFactory( |
| 79 | FeatureGroupStoreFactory, |
| 80 | 1 |
| 81 | ); |
| 82 | deepFreeze(featureGroupsList); |
| 83 | const store = storeCreator({ |
| 84 | currentScreen: { ...itemPermissionAndProps }, |
| 85 | licenseModel: { |
| 86 | featureGroup: { |
| 87 | featureGroupsList |
| 88 | } |
| 89 | } |
| 90 | }); |
| 91 | deepFreeze(store.getState()); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 92 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 93 | const expectedCurrentScreenProps = { |
| 94 | ...itemPermissionAndProps, |
| 95 | itemPermission: { |
| 96 | ...itemPermissionAndProps.itemPermission, |
| 97 | isDirty: true |
| 98 | } |
| 99 | }; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 100 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 101 | let expectedStore = cloneAndSet( |
| 102 | store.getState(), |
| 103 | 'licenseModel.featureGroup.featureGroupsList', |
| 104 | [] |
| 105 | ); |
| 106 | expectedStore = cloneAndSet( |
| 107 | expectedStore, |
| 108 | 'currentScreen.itemPermission', |
| 109 | expectedCurrentScreenProps.itemPermission |
| 110 | ); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 111 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 112 | const idToDelete = featureGroupsList[0].id; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 113 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 114 | mockRest.addHandler('destroy', ({ data, options, baseUrl }) => { |
| 115 | expect(baseUrl).toEqual( |
| 116 | `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${ |
| 117 | version.id |
| 118 | }/feature-groups/${idToDelete}` |
| 119 | ); |
| 120 | expect(data).toEqual(undefined); |
| 121 | expect(options).toEqual(undefined); |
| 122 | return { |
| 123 | results: { |
| 124 | returnCode: 'OK' |
| 125 | } |
| 126 | }; |
| 127 | }); |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 128 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 129 | mockRest.addHandler('fetch', ({ data, options, baseUrl }) => { |
| 130 | expect(baseUrl).toEqual( |
| 131 | `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${ |
| 132 | version.id |
| 133 | }` |
| 134 | ); |
| 135 | expect(data).toEqual(undefined); |
| 136 | expect(options).toEqual(undefined); |
| 137 | return { |
| 138 | ...returnedVersionFields, |
| 139 | state: { |
| 140 | synchronizationState: SyncStates.UP_TO_DATE, |
| 141 | dirty: true |
| 142 | } |
| 143 | }; |
| 144 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 145 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 146 | mockRest.addHandler('fetch', ({ data, options, baseUrl }) => { |
| 147 | expect(baseUrl).toEqual( |
| 148 | `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}` |
| 149 | ); |
| 150 | expect(data).toEqual(undefined); |
| 151 | expect(options).toEqual(undefined); |
| 152 | return { |
| 153 | ...returnedVersionFields |
| 154 | }; |
| 155 | }); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 156 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 157 | return FeatureGroupsActionHelper.deleteFeatureGroup(store.dispatch, { |
| 158 | licenseModelId: LICENSE_MODEL_ID, |
| 159 | version, |
| 160 | featureGroupId: idToDelete |
| 161 | }).then(() => { |
| 162 | expect(store.getState()).toEqual(expectedStore); |
| 163 | }); |
| 164 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 165 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 166 | it('Add Feature Group', () => { |
| 167 | const store = storeCreator({ |
| 168 | currentScreen: { ...itemPermissionAndProps }, |
| 169 | licenseModel: { |
| 170 | featureGroup: { |
| 171 | featureGroupsList: [] |
| 172 | } |
| 173 | } |
| 174 | }); |
| 175 | deepFreeze(store.getState()); |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 176 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 177 | const FeatureGroupPostRequest = FeatureGroupPostFactory.build({ |
| 178 | addedLicenseKeyGroupsIds: [1], |
| 179 | addedEntitlementPoolsIds: [1] |
| 180 | }); |
| 181 | const featureGroupToAdd = FeatureGroupDispatchFactory.build({ |
| 182 | licenseKeyGroupsIds: [1], |
| 183 | entitlementPoolsIds: [1] |
| 184 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 185 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 186 | const featureGroupIdFromResponse = 'ADDED_ID'; |
| 187 | const featureGroupAfterAdd = FeatureGroupStoreFactory.build({ |
| 188 | ...featureGroupToAdd, |
| 189 | id: featureGroupIdFromResponse |
| 190 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 191 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 192 | const expectedCurrentScreenProps = { |
| 193 | ...itemPermissionAndProps, |
| 194 | itemPermission: { |
| 195 | ...itemPermissionAndProps.itemPermission, |
| 196 | isDirty: true |
| 197 | } |
| 198 | }; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 199 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 200 | let expectedStore = cloneAndSet( |
| 201 | store.getState(), |
| 202 | 'licenseModel.featureGroup.featureGroupsList', |
| 203 | [featureGroupAfterAdd] |
| 204 | ); |
| 205 | expectedStore = cloneAndSet( |
| 206 | expectedStore, |
| 207 | 'currentScreen.itemPermission', |
| 208 | expectedCurrentScreenProps.itemPermission |
| 209 | ); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 210 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 211 | mockRest.addHandler('post', ({ data, options, baseUrl }) => { |
| 212 | expect(baseUrl).toEqual( |
| 213 | `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${ |
| 214 | version.id |
| 215 | }/feature-groups` |
| 216 | ); |
| 217 | expect(data).toEqual(FeatureGroupPostRequest); |
| 218 | expect(options).toEqual(undefined); |
| 219 | return { |
| 220 | returnCode: 'OK', |
| 221 | value: featureGroupIdFromResponse |
| 222 | }; |
| 223 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 224 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 225 | mockRest.addHandler('fetch', ({ data, options, baseUrl }) => { |
| 226 | expect(baseUrl).toEqual( |
| 227 | `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${ |
| 228 | version.id |
| 229 | }/entitlement-pools` |
| 230 | ); |
| 231 | expect(data).toEqual(undefined); |
| 232 | expect(options).toEqual(undefined); |
| 233 | return { results: [] }; |
| 234 | }); |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 235 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 236 | mockRest.addHandler('fetch', ({ data, options, baseUrl }) => { |
| 237 | expect(baseUrl).toEqual( |
| 238 | `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${ |
| 239 | version.id |
| 240 | }/license-key-groups` |
| 241 | ); |
| 242 | expect(data).toEqual(undefined); |
| 243 | expect(options).toEqual(undefined); |
| 244 | return { results: [] }; |
| 245 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 246 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 247 | mockRest.addHandler('fetch', ({ data, options, baseUrl }) => { |
| 248 | expect(baseUrl).toEqual( |
| 249 | `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${ |
| 250 | version.id |
| 251 | }` |
| 252 | ); |
| 253 | expect(data).toEqual(undefined); |
| 254 | expect(options).toEqual(undefined); |
| 255 | return { |
| 256 | ...returnedVersionFields, |
| 257 | state: { |
| 258 | synchronizationState: SyncStates.UP_TO_DATE, |
| 259 | dirty: true |
| 260 | } |
| 261 | }; |
| 262 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 263 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 264 | mockRest.addHandler('fetch', ({ data, options, baseUrl }) => { |
| 265 | expect(baseUrl).toEqual( |
| 266 | `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}` |
| 267 | ); |
| 268 | expect(data).toEqual(undefined); |
| 269 | expect(options).toEqual(undefined); |
| 270 | return { |
| 271 | ...returnedVersionFields |
| 272 | }; |
| 273 | }); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 274 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 275 | return FeatureGroupsActionHelper.saveFeatureGroup(store.dispatch, { |
| 276 | licenseModelId: LICENSE_MODEL_ID, |
| 277 | version, |
| 278 | featureGroup: featureGroupToAdd |
| 279 | }).then(() => { |
| 280 | expect(store.getState()).toEqual(expectedStore); |
| 281 | }); |
| 282 | }); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 283 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 284 | it('Update Feature Group', () => { |
| 285 | const featureGroupsList = buildListFromFactory( |
| 286 | FeatureGroupStoreFactory, |
| 287 | 1, |
| 288 | { |
| 289 | licenseKeyGroupsIds: [1], |
| 290 | entitlementPoolsIds: [1] |
| 291 | } |
| 292 | ); |
| 293 | deepFreeze(featureGroupsList); |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 294 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 295 | const store = storeCreator({ |
| 296 | currentScreen: { ...itemPermissionAndProps }, |
| 297 | licenseModel: { |
| 298 | featureGroup: { |
| 299 | featureGroupsList |
| 300 | } |
| 301 | } |
| 302 | }); |
| 303 | deepFreeze(store.getState()); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 304 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 305 | const toBeUpdatedFeatureGroupId = featureGroupsList[0].id; |
| 306 | const previousFeatureGroupData = featureGroupsList[0]; |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 307 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 308 | const featureGroupUpdateData = FeatureGroupStoreFactory.build({ |
| 309 | ...previousFeatureGroupData, |
| 310 | licenseKeyGroupsIds: [7], |
| 311 | entitlementPoolsIds: [7] |
| 312 | }); |
| 313 | deepFreeze(featureGroupUpdateData); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 314 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 315 | const FeatureGroupPutFactoryRequest = FeatureGroupPutFactory.build({ |
| 316 | name: featureGroupUpdateData.name, |
| 317 | description: featureGroupUpdateData.description, |
| 318 | partNumber: featureGroupUpdateData.partNumber, |
| 319 | addedLicenseKeyGroupsIds: [7], |
| 320 | addedEntitlementPoolsIds: [7], |
| 321 | removedLicenseKeyGroupsIds: [1], |
| 322 | removedEntitlementPoolsIds: [1] |
| 323 | }); |
| 324 | deepFreeze(FeatureGroupPutFactoryRequest); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 325 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 326 | const expectedCurrentScreenProps = { |
| 327 | ...itemPermissionAndProps, |
| 328 | itemPermission: { |
| 329 | ...itemPermissionAndProps.itemPermission, |
| 330 | isDirty: true |
| 331 | } |
| 332 | }; |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 333 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 334 | let expectedStore = cloneAndSet( |
| 335 | store.getState(), |
| 336 | 'licenseModel.featureGroup.featureGroupsList', |
| 337 | [featureGroupUpdateData] |
| 338 | ); |
| 339 | expectedStore = cloneAndSet( |
| 340 | expectedStore, |
| 341 | 'currentScreen.itemPermission', |
| 342 | expectedCurrentScreenProps.itemPermission |
| 343 | ); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 344 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 345 | mockRest.addHandler('put', ({ data, options, baseUrl }) => { |
| 346 | expect(baseUrl).toEqual( |
| 347 | `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${ |
| 348 | version.id |
| 349 | }/feature-groups/${toBeUpdatedFeatureGroupId}` |
| 350 | ); |
| 351 | expect(data).toEqual(FeatureGroupPutFactoryRequest); |
| 352 | expect(options).toEqual(undefined); |
| 353 | return { returnCode: 'OK' }; |
| 354 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 355 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 356 | mockRest.addHandler('fetch', ({ data, options, baseUrl }) => { |
| 357 | expect(baseUrl).toEqual( |
| 358 | `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${ |
| 359 | version.id |
| 360 | }/entitlement-pools` |
| 361 | ); |
| 362 | expect(data).toEqual(undefined); |
| 363 | expect(options).toEqual(undefined); |
| 364 | return { results: [] }; |
| 365 | }); |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 366 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 367 | mockRest.addHandler('fetch', ({ data, options, baseUrl }) => { |
| 368 | expect(baseUrl).toEqual( |
| 369 | `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${ |
| 370 | version.id |
| 371 | }/license-key-groups` |
| 372 | ); |
| 373 | expect(data).toEqual(undefined); |
| 374 | expect(options).toEqual(undefined); |
| 375 | return { results: [] }; |
| 376 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 377 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 378 | mockRest.addHandler('fetch', ({ data, options, baseUrl }) => { |
| 379 | expect(baseUrl).toEqual( |
| 380 | `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}/versions/${ |
| 381 | version.id |
| 382 | }` |
| 383 | ); |
| 384 | expect(data).toEqual(undefined); |
| 385 | expect(options).toEqual(undefined); |
| 386 | return { |
| 387 | ...returnedVersionFields, |
| 388 | state: { |
| 389 | synchronizationState: SyncStates.UP_TO_DATE, |
| 390 | dirty: true |
| 391 | } |
| 392 | }; |
| 393 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 394 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 395 | mockRest.addHandler('fetch', ({ data, options, baseUrl }) => { |
| 396 | expect(baseUrl).toEqual( |
| 397 | `/onboarding-api/v1.0/items/${LICENSE_MODEL_ID}` |
| 398 | ); |
| 399 | expect(data).toEqual(undefined); |
| 400 | expect(options).toEqual(undefined); |
| 401 | return { |
| 402 | ...returnedVersionFields |
| 403 | }; |
| 404 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 405 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 406 | return FeatureGroupsActionHelper.saveFeatureGroup(store.dispatch, { |
| 407 | licenseModelId: LICENSE_MODEL_ID, |
| 408 | version, |
| 409 | previousFeatureGroup: previousFeatureGroupData, |
| 410 | featureGroup: featureGroupUpdateData |
| 411 | }).then(() => { |
| 412 | expect(store.getState()).toEqual(expectedStore); |
| 413 | }); |
| 414 | }); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 415 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 416 | it('Open Editor', () => { |
| 417 | const store = storeCreator(); |
| 418 | deepFreeze(store.getState()); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 419 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 420 | const editorData = FeatureGroupStoreFactory.build(); |
| 421 | deepFreeze(editorData); |
| 422 | const LICENSE_MODEL_ID = '123'; |
talig | 8e9c065 | 2017-12-20 14:30:43 +0200 | [diff] [blame] | 423 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 424 | mockRest.addHandler('fetch', ({ data, options, baseUrl }) => { |
| 425 | expect(baseUrl).toEqual( |
| 426 | `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${ |
| 427 | version.id |
| 428 | }/entitlement-pools` |
| 429 | ); |
| 430 | expect(data).toEqual(undefined); |
| 431 | expect(options).toEqual(undefined); |
| 432 | return { results: [] }; |
| 433 | }); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 434 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 435 | mockRest.addHandler('fetch', ({ data, options, baseUrl }) => { |
| 436 | expect(baseUrl).toEqual( |
| 437 | `/onboarding-api/v1.0/vendor-license-models/${LICENSE_MODEL_ID}/versions/${ |
| 438 | version.id |
| 439 | }/license-key-groups` |
| 440 | ); |
| 441 | expect(data).toEqual(undefined); |
| 442 | expect(options).toEqual(undefined); |
| 443 | return { results: [] }; |
| 444 | }); |
AviZi | 280f801 | 2017-06-09 02:39:56 +0300 | [diff] [blame] | 445 | |
svishnev | 57c5c4a | 2018-04-22 14:14:31 +0300 | [diff] [blame] | 446 | return FeatureGroupsActionHelper.openFeatureGroupsEditor( |
| 447 | store.dispatch, |
| 448 | { featureGroup: editorData, licenseModelId: '123', version } |
| 449 | ).then(() => { |
| 450 | expect( |
| 451 | store.getState().licenseModel.featureGroup.featureGroupEditor |
| 452 | .data |
| 453 | ).toEqual(editorData); |
| 454 | }); |
| 455 | }); |
Michael Lando | efa037d | 2017-02-19 12:57:33 +0200 | [diff] [blame] | 456 | }); |