From abb5985d156fcf7d7cd0a838ca760651223a7a2c Mon Sep 17 00:00:00 2001 From: Alexey Sandler Date: Tue, 26 Nov 2019 21:44:18 +0200 Subject: [PATCH] add sdnc checkbox to vfm upgrade modal Issue-ID: VID-603 Signed-off-by: Alexey Sandler Change-Id: Ic297486bc343419415bf3736ebb56944e72bf8b8 Signed-off-by: Alexey Sandler --- .../upgrade_vfmodule_e2e__fe_input_cypress.json | 1 + .../upgrade_vfmodule_e2e__payload_to_mso.json | 1 + .../iFrames/viewEditUpgradeVfModule.e2e.ts | 1 + .../vfModule.upgrade.popuop.service.ts | 24 +++++++------- .../vfModule.upgrade.popup.service.spec.ts | 37 +++++++++++----------- 5 files changed, 34 insertions(+), 30 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 743e5a0c1..e7a640599 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 @@ -35,6 +35,7 @@ "action": "None_Upgrade", "retainAssignments" : false, "retainVolumeGroups" : false, + "sdncPreLoad" : true, "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 55f22ca3b..45b89f730 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 @@ -35,6 +35,7 @@ "requestParameters": { "retainAssignments": false, "rebuildVolumeGroups":true, + "usePreload" : true, "userParams": [], "testApi": "VNF_API" }, diff --git a/vid-webpack-master/cypress/integration/iFrames/viewEditUpgradeVfModule.e2e.ts b/vid-webpack-master/cypress/integration/iFrames/viewEditUpgradeVfModule.e2e.ts index 97eadabcb..9f2499f3c 100644 --- a/vid-webpack-master/cypress/integration/iFrames/viewEditUpgradeVfModule.e2e.ts +++ b/vid-webpack-master/cypress/integration/iFrames/viewEditUpgradeVfModule.e2e.ts @@ -220,6 +220,7 @@ describe('View Edit Page: Upgrade VFModule', function () { cy.getElementByDataTestsId('retainAssignments').click(); cy.getElementByDataTestsId('retainVolumeGroups').click(); + cy.getElementByDataTestsId('sdncPreLoad').click(); cy.screenshot(); cy.getElementByDataTestsId('form-set').click(); } 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 5de2da112..576e63df5 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 @@ -20,6 +20,7 @@ import {mergeObjectByPathAction} from "../../../../storeUtil/utils/general/gener export enum UpgradeFormControlNames { RETAIN_VOLUME_GROUPS = 'retainVolumeGroups', RETAIN_ASSIGNMENTS = 'retainAssignments', + SDN_C_PRE_LOAD = 'sdncPreLoad', } @Injectable() @@ -29,20 +30,22 @@ export class VfModuleUpgradePopupService extends VfModulePopupServiceBase { protected _iframeService: IframeService, protected _defaultDataGeneratorService: DefaultDataGeneratorService, protected _aaiService: AaiService, - protected _basicPopupService : BasicPopupService, + protected _basicPopupService: BasicPopupService, protected _store: NgRedux, - private _sharedTreeService : SharedTreeService){ - super(_basicControlGenerator, _vfModuleControlGenerator, _iframeService, _defaultDataGeneratorService, _aaiService, _basicPopupService,_store); + private _sharedTreeService: SharedTreeService) { + super(_basicControlGenerator, _vfModuleControlGenerator, _iframeService, _defaultDataGeneratorService, _aaiService, _basicPopupService, _store); } + node: ITreeNode; getDynamicInputs = () => null; - getControls(serviceId: string, vnfStoreKey: string, vfModuleStoreKey: string, isUpdateMode: boolean) { - let result: FormControlModel[] = []; - result.push(this.getRetainVolumeGroupsControl()); - result.push(this.getRetainAssignmentsControl()); - return result; + getControls = (): FormControlModel[] => { + return [ + this.getRetainAssignmentsControl(), + this.getRetainVolumeGroupsControl(), + this._basicControlGenerator.getSDNCControl(null) + ] }; getTitle = (): string => 'Upgrade Module'; @@ -54,8 +57,8 @@ export class VfModuleUpgradePopupService extends VfModulePopupServiceBase { const modelName = node.data.modelName; const dynamicModelName = node.data.dynamicModelName; - this._store.dispatch(upgradeVFModule(modelName, vnfStoreKey, serviceInstanceId ,dynamicModelName)); - this._store.dispatch(mergeObjectByPathAction(['serviceInstance',serviceInstanceId, 'vnfs', vnfStoreKey, 'vfModules', modelName, dynamicModelName], form.value)); + this._store.dispatch(upgradeVFModule(modelName, vnfStoreKey, serviceInstanceId, dynamicModelName)); + this._store.dispatch(mergeObjectByPathAction(['serviceInstance', serviceInstanceId, 'vnfs', vnfStoreKey, 'vfModules', modelName, dynamicModelName], form.value)); this._sharedTreeService.upgradeBottomUp(node, serviceInstanceId); this.postSubmitIframeMessage(that); @@ -83,5 +86,4 @@ export class VfModuleUpgradePopupService extends VfModulePopupServiceBase { 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 5feadeb8a..8d11caf5d 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 @@ -20,24 +20,18 @@ import {GeneralActions} from "../../../../storeUtil/utils/general/general.action import {VfModuleActions} from "../../../../storeUtil/utils/vfModule/vfModule.actions"; import {ServiceActions} from "../../../../storeUtil/utils/service/service.actions"; -class MockModalService { -} - -class MockAppStore { -} +class MockModalService {} -let uuidData = {}; +class MockAppStore {} class MockReduxStore { getState() { return {}; } - dispatch() {} } -class MockFeatureFlagsService { -} +class MockFeatureFlagsService {} describe('VFModule popup service', () => { let injector; @@ -77,17 +71,16 @@ describe('VFModule popup service', () => { fb = injector.get(FormBuilder); iframeService = injector.get(IframeService); store = injector.get(NgRedux); - })().then(done).catch(done.fail)); test('getTitle should return the correct title', () => { expect(service.getTitle()).toBe("Upgrade Module") }); - test('get controls should return retainAssignments control with false i', ()=> { + test('get controls should return retainAssignments control with true i', ()=> { - const controls = service.getControls('a', 'b', 'c', true); - expect(controls.length).toEqual(2); + const controls = service.getControls(); + expect(controls.length).toEqual(3); const retainAssignmentsControl = controls.find((control)=>{ return control.controlName === UpgradeFormControlNames.RETAIN_ASSIGNMENTS; @@ -96,7 +89,6 @@ describe('VFModule popup service', () => { expect(retainAssignmentsControl).toBeDefined(); expect(retainAssignmentsControl.value).toBeTruthy(); - const retainVolumeGroup = controls.find((control)=>{ return control.controlName === UpgradeFormControlNames.RETAIN_VOLUME_GROUPS; }); @@ -106,9 +98,6 @@ describe('VFModule popup service', () => { }); test('on submit should call merge action of form value to vfModule', () => { - - //given - const serviceId = "serviceId5"; const vnfStoreKey = 'vnfStoreKey3'; const modelName = 'modelA'; @@ -136,10 +125,10 @@ describe('VFModule popup service', () => { let mockFrom: FormGroup = mock(FormGroup); let form = instance(mockFrom); - form.value = { + form.setValue({ a: "value", b: "another" - }; + }); spyOn(store, 'dispatch'); @@ -154,4 +143,14 @@ describe('VFModule popup service', () => { expect(store.dispatch).toBeCalledWith({type: ServiceActions.UPGRADE_SERVICE_ACTION, serviceUuid: "serviceId5"}); }); + + + test( 'get controls should return usePreload with false value', () => { + const controls = service.getControls(); + const usePreloadControl = controls.find((control)=>{ + return control.controlName === 'sdncPreLoad'; + }); + expect(usePreloadControl).toBeDefined(); + expect(usePreloadControl.value).toBeFalsy(); + }); }); -- 2.16.6