From e4ec69b8a8a179bc095f7e62efc9bbfa94017a5b Mon Sep 17 00:00:00 2001 From: Alexey Sandler Date: Mon, 16 Mar 2020 21:47:40 +0200 Subject: set default values in VFM Upgrade popup Issue-ID: VID-794 Signed-off-by: Alexey Sandler Change-Id: Ic8c896e0eea0535e0e52a394c403c2e167240b47 Signed-off-by: Alexey Sandler --- .../upgrade_vfmodule_e2e__fe_input_cypress.json | 4 ++-- .../vfmodule/upgrade_vfmodule_e2e__payload_to_mso.json | 4 ++-- ..._related_to_current_model_e2e__fe_input_cypress.json | 6 +++--- .../sharedControlles/shared.controllers.service.spec.ts | 17 +++++++++++++---- .../sharedControlles/shared.controllers.service.ts | 5 +++-- .../vfModuleGenerator/vfModule.control.generator.ts | 2 +- .../vfModuleUpgrade/vfModule.upgrade.popuop.service.ts | 7 ++++--- .../vfModule.upgrade.popup.service.spec.ts | 14 +++++++------- 8 files changed, 35 insertions(+), 24 deletions(-) diff --git a/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__fe_input_cypress.json b/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__fe_input_cypress.json index 16d369ba7..dc9d82c9a 100644 --- a/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__fe_input_cypress.json +++ b/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__fe_input_cypress.json @@ -33,8 +33,8 @@ "xbitestmodulereplace0..XbiTestModuleReplace..base_ocg..module-0": { "b0732bed-3ddf-43cc-b193-7f18db84e476": { "action": "None_Upgrade", - "retainAssignments" : false, - "sdncPreLoad" : true, + "retainAssignments" : true, + "sdncPreLoad" : false, "instanceName": "PST-VfMod-Replace-5-Vfmod", "instanceId": "b0732bed-3ddf-43cc-b193-7f18db84e476", "orchStatus": "Active", diff --git a/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__payload_to_mso.json b/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__payload_to_mso.json index 5c258f66b..d72dc7a23 100644 --- a/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__payload_to_mso.json +++ b/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_e2e__payload_to_mso.json @@ -33,8 +33,8 @@ } ], "requestParameters": { - "retainAssignments": false, - "usePreload" : true, + "retainAssignments": true, + "usePreload" : false, "userParams": [], "testApi": "GR_API" }, diff --git a/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_not_related_to_current_model_e2e__fe_input_cypress.json b/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_not_related_to_current_model_e2e__fe_input_cypress.json index 46eb3421d..842d6946d 100644 --- a/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_not_related_to_current_model_e2e__fe_input_cypress.json +++ b/vid-app-common/src/test/resources/payload_jsons/vfmodule/upgrade_vfmodule_not_related_to_current_model_e2e__fe_input_cypress.json @@ -174,9 +174,9 @@ "platformName": null, "productFamilyId": null, "provStatus": null, - "retainAssignments": false, - "retainVolumeGroups": false, - "sdncPreLoad": true, + "retainAssignments": true, + "retainVolumeGroups": true, + "sdncPreLoad": false, "supplementaryFile": null, "supplementaryFile_hidden": null, "supplementaryFile_hidden_content": null, diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.spec.ts index f456a747a..b141a1e79 100644 --- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.spec.ts @@ -9,6 +9,7 @@ import {FeatureFlagsService} from "../../../../services/featureFlag/feature-flag import {DropdownFormControl} from "../../../../models/formControlModels/dropdownFormControl.model"; import {FormControlModel, ValidatorOptions} from "../../../../models/formControlModels/formControl.model"; import {ControlGeneratorUtil} from "../control.generator.util.service"; +import each from "jest-each"; describe('Shared Controllers Service', () => { @@ -99,11 +100,19 @@ describe('Shared Controllers Service', () => { expect(lcpRegionControl.isDisabled).toBeFalsy(); }); - test('sdn-preload checkbox is visible', () => { - const instance = {}; - const sdncPreload: FormControlModel = service.getSDNCControl(instance); + each( + [ + [' checked', true, true], + [' not checked', false, false ] + ] + ). + test('sdn-preload checkbox is %s', ( + description: string, checkedByDefault: boolean, expected: boolean + ) => { + const instance = null; + const sdncPreload: FormControlModel = service.getSDNCControl(instance, checkedByDefault); expect (sdncPreload.displayName).toEqual('SDN-C pre-load'); - expect (sdncPreload.value).toBeFalsy(); + expect (sdncPreload.value).toBe(expected); }); test('getlegacyRegion with AAIAIC25 - isVisible true', () => { diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.ts index 32259b198..d82ba36a9 100644 --- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.ts +++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/sharedControlles/shared.controllers.service.ts @@ -236,12 +236,13 @@ export class SharedControllersService { tenantsControl['hasEmptyOptions'] = tenants && tenants.length === 0; }; - getSDNCControl = (instance: any, extraContents? : object[]): FormControlModel => { + + getSDNCControl = (instance: any, checkedByDefault: boolean, extraContents? : object[]): FormControlModel => { return new CheckboxFormControl({ controlName: SDN_C_PRE_LOAD, displayName: 'SDN-C pre-load', dataTestId: 'sdncPreLoad', - value: instance ? instance.sdncPreLoad : false, + value: instance ? instance.sdncPreLoad : checkedByDefault, validations: [new ValidatorModel(ValidatorOptions.required, 'is required')], extraContents }) diff --git a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.ts b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.ts index b614ecf30..b7cf80be3 100644 --- a/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.ts +++ b/vid-webpack-master/src/app/shared/components/genericForm/formControlsServices/vfModuleGenerator/vfModule.control.generator.ts @@ -132,7 +132,7 @@ export class VfModuleControlGenerator { result.push(this._sharedControllersService.getTenantControl(serviceId, vfModuleInstance)); } result.push(this._sharedControllersService.getRollbackOnFailureControl(vfModuleInstance)); - result.push(this._sharedControllersService.getSDNCControl(vfModuleInstance, this.getSdncExtraContents())); + result.push(this._sharedControllersService.getSDNCControl(vfModuleInstance, false, this.getSdncExtraContents())); if (this.store.getState().global.flags['FLAG_SUPPLEMENTARY_FILE']) { result = this._basicControlGenerator.concatSupplementaryFile(result, vfModuleInstance); } diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service.ts index 5fcdc3093..afc099c1e 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popuop.service.ts @@ -45,8 +45,9 @@ export class VfModuleUpgradePopupService extends VfModulePopupServiceBase { getControls(serviceId: string, vnfStoreKey: string, vfModuleStoreKey: string, isUpdateMode: boolean): FormControlModel[] { let result: FormControlModel[] =[ this.getRetainAssignmentsControl(), - this._sharedControllersService.getSDNCControl(null) + this._sharedControllersService.getSDNCControl(null, true) ]; + const vfModuleInstance :VfModuleInstance = this._vfModuleControlGenerator.getVfModuleInstance(serviceId, vnfStoreKey, this.uuidData, isUpdateMode); let volumeGroupAllowed = this._store.getState().service.serviceHierarchy[serviceId].vfModules[this.uuidData['modelName']].volumeGroupAllowed; @@ -83,7 +84,7 @@ export class VfModuleUpgradePopupService extends VfModulePopupServiceBase { controlName: UpgradeFormControlNames.RETAIN_VOLUME_GROUPS, displayName: 'Retain Volume Groups', dataTestId: UpgradeFormControlNames.RETAIN_VOLUME_GROUPS, - value: true, + value: false, validations: [] }) }; @@ -94,7 +95,7 @@ export class VfModuleUpgradePopupService extends VfModulePopupServiceBase { controlName: UpgradeFormControlNames.RETAIN_ASSIGNMENTS, displayName: 'Retain Assignments', dataTestId: UpgradeFormControlNames.RETAIN_ASSIGNMENTS, - value: true, + value: false, validations: [] }) }; diff --git a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popup.service.spec.ts b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popup.service.spec.ts index 2123d6a9f..86ec66652 100644 --- a/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popup.service.spec.ts +++ b/vid-webpack-master/src/app/shared/components/genericFormPopup/genericFormServices/vfModuleUpgrade/vfModule.upgrade.popup.service.spec.ts @@ -133,12 +133,12 @@ describe('VFModule popup service', () => { } } - test('get controls should return retainAssignments control with true value', ()=> { - getControlByNameAndCheckValue(UpgradeFormControlNames.RETAIN_ASSIGNMENTS, true, true); + test('get controls should return retainAssignments control with false', ()=> { + getControlByNameAndCheckValue(UpgradeFormControlNames.RETAIN_ASSIGNMENTS, false, true); }); - test('get controls should return retainVolumeGroup control with true value', ()=> { - getControlByNameAndCheckValue(UpgradeFormControlNames.RETAIN_VOLUME_GROUPS, true, true); + test('get controls should return retainVolumeGroup control with false', ()=> { + getControlByNameAndCheckValue(UpgradeFormControlNames.RETAIN_VOLUME_GROUPS, false, true); }); [true, false].forEach(notExistsOnModel => { @@ -149,7 +149,7 @@ describe('VFModule popup service', () => { jest.spyOn(_sharedTreeService, 'isVfModuleCustomizationIdNotExistsOnModel').mockReturnValue(notExistsOnModel); - getControlByNameAndCheckValue(UpgradeFormControlNames.RETAIN_VOLUME_GROUPS, true, notExistsOnModel); + getControlByNameAndCheckValue(UpgradeFormControlNames.RETAIN_VOLUME_GROUPS, false, notExistsOnModel); }); }); @@ -232,7 +232,7 @@ describe('VFModule popup service', () => { }); - test( 'get controls should return usePreload with false value', () => { - getControlByNameAndCheckValue(SDN_C_PRE_LOAD, false, true); + test( 'get controls should return usePreload with true value', () => { + getControlByNameAndCheckValue(SDN_C_PRE_LOAD, true, true); }); }); -- cgit 1.2.3-korg