From a159f5a1be12403373e25d9bdbf7a405562da1d0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stephan=20M=C3=BCller?= Date: Tue, 6 Nov 2018 13:49:45 +0100 Subject: [PATCH] mgr/dashboard: Verify the RGW mail reset behavior MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The current behavior when submitting an empty mail field in the RGW user form that was previously filled was to replace it with "false". This was a regression introduced through the use of "CdFormGroup" which had a "_filterValue" method which converted empty strings into false, but it was removed now. Fixes: http://tracker.ceph.com/issues/26861 Signed-off-by: Stephan Müller --- .../rgw-user-form.component.spec.ts | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.spec.ts index f6025a23e06..af77ad771c2 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/rgw/rgw-user-form/rgw-user-form.component.spec.ts @@ -15,6 +15,8 @@ import { RgwUserFormComponent } from './rgw-user-form.component'; describe('RgwUserFormComponent', () => { let component: RgwUserFormComponent; let fixture: ComponentFixture; + let rgwUserService: RgwUserService; + let formHelper: FormHelper; configureTestBed({ declarations: [RgwUserFormComponent], @@ -26,6 +28,8 @@ describe('RgwUserFormComponent', () => { fixture = TestBed.createComponent(RgwUserFormComponent); component = fixture.componentInstance; fixture.detectChanges(); + rgwUserService = TestBed.get(RgwUserService); + formHelper = new FormHelper(component.userForm); }); it('should create', () => { @@ -33,10 +37,7 @@ describe('RgwUserFormComponent', () => { }); describe('s3 key management', () => { - let rgwUserService: RgwUserService; - beforeEach(() => { - rgwUserService = TestBed.get(RgwUserService); spyOn(rgwUserService, 'addS3Key').and.stub(); }); @@ -113,13 +114,8 @@ describe('RgwUserFormComponent', () => { }); describe('username validation', () => { - let rgwUserService: RgwUserService; - let formHelper: FormHelper; - beforeEach(() => { - rgwUserService = TestBed.get(RgwUserService); spyOn(rgwUserService, 'enumerate').and.returnValue(observableOf(['abc', 'xyz'])); - formHelper = new FormHelper(component.userForm); }); it('should validate that username is required', () => { @@ -144,4 +140,19 @@ describe('RgwUserFormComponent', () => { }) ); }); + + describe('onSubmit', () => { + it('should be able to clear the mail field on update', () => { + spyOn(rgwUserService, 'update'); + component.editing = true; + formHelper.setValue('email', '', true); + component.onSubmit(); + expect(rgwUserService.update).toHaveBeenCalledWith(null, { + display_name: null, + email: '', + max_buckets: 1000, + suspended: false + }); + }); + }); }); -- 2.39.5