From: Stephan Müller Date: Tue, 6 Nov 2018 12:49:45 +0000 (+0100) Subject: mgr/dashboard: Verify the RGW mail reset behavior X-Git-Tag: v14.1.0~968^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=a159f5a1be12403373e25d9bdbf7a405562da1d0;p=ceph-ci.git mgr/dashboard: Verify the RGW mail reset behavior 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 --- 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 + }); + }); + }); });