From: Pere Diaz Bou Date: Wed, 29 Jun 2022 11:37:17 +0000 (+0200) Subject: mgr/dashboard: fix rbd list tests X-Git-Tag: v18.0.0~511^2~10 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=08b6f22807c14967fb49495ca9f18124d495b19b;p=ceph.git mgr/dashboard: fix rbd list tests X-Total-Count header was missing from rbdservice.list spy mock Signed-off-by: Pere Diaz Bou --- diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.spec.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.spec.ts index 85e9ad35dbd56..fa7a772f02239 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.spec.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.spec.ts @@ -27,6 +27,7 @@ describe('RbdListComponent', () => { let component: RbdListComponent; let summaryService: SummaryService; let rbdService: RbdService; + let headers: HttpHeaders; const refresh = (data: any) => { summaryService['summaryDataSource'].next(data); @@ -57,6 +58,7 @@ describe('RbdListComponent', () => { component = fixture.componentInstance; summaryService = TestBed.inject(SummaryService); rbdService = TestBed.inject(RbdService); + headers = new HttpHeaders().set('X-Total-Count', '10'); // this is needed because summaryService isn't being reset after each test. summaryService['summaryDataSource'] = new BehaviorSubject(null); @@ -117,7 +119,9 @@ describe('RbdListComponent', () => { }); it('should display N/A for Provisioned & Total Provisioned columns if disk usage is null', () => { - rbdServiceListSpy.and.callFake(() => of([{ pool_name: 'rbd', value: images }])); + rbdServiceListSpy.and.callFake(() => + of([{ pool_name: 'rbd', value: images, headers: headers }]) + ); fixture.detectChanges(); const spanWithoutFastDiff = fixture.debugElement.nativeElement.querySelectorAll( '.datatable-body-cell-label span' @@ -129,7 +133,9 @@ describe('RbdListComponent', () => { component.images = images; refresh({ executing_tasks: [], finished_tasks: [] }); - rbdServiceListSpy.and.callFake(() => of([{ pool_name: 'rbd', value: images }])); + rbdServiceListSpy.and.callFake(() => + of([{ pool_name: 'rbd', value: images, headers: headers }]) + ); fixture.detectChanges(); const spanWithFastDiff = fixture.debugElement.nativeElement.querySelectorAll( @@ -253,8 +259,9 @@ describe('RbdListComponent', () => { addImage('c'); component.images = images; refresh({ executing_tasks: [], finished_tasks: [] }); - spyOn(rbdService, 'list').and.callFake(() => of([{ pool_name: 'rbd', value: images }])); - new HttpHeaders().set('X-Total-Count', '10'); + spyOn(rbdService, 'list').and.callFake(() => + of([{ pool_name: 'rbd', value: images, headers: headers }]) + ); fixture.detectChanges(); }); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts index e3040f693137b..bbbfbe8b7e48c 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts +++ b/src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts @@ -6,7 +6,7 @@ import { Observable, Subscriber } from 'rxjs'; import { RbdService } from '~/app/shared/api/rbd.service'; import { ListWithDetails } from '~/app/shared/classes/list-with-details.class'; -import { TableStatusViewCache } from '~/app/shared/classes/table-status-view-cache'; +import { TableStatus } from '~/app/shared/classes/table-status'; import { ConfirmationModalComponent } from '~/app/shared/components/confirmation-modal/confirmation-modal.component'; import { CriticalConfirmationModalComponent } from '~/app/shared/components/critical-confirmation-modal/critical-confirmation-modal.component'; import { ActionLabelsI18n } from '~/app/shared/constants/app.constants'; @@ -71,12 +71,11 @@ export class RbdListComponent extends ListWithDetails implements OnInit { images: any; columns: CdTableColumn[]; retries: number; - tableStatus = new TableStatusViewCache(); + tableStatus = new TableStatus('light'); selection = new CdTableSelection(); icons = Icons; count = 0; private tableContext: CdTableFetchDataContext = null; - modalRef: NgbModalRef; builders = { @@ -360,7 +359,7 @@ export class RbdListComponent extends ListWithDetails implements OnInit { onFetchError() { this.table.reset(); // Disable loading indicator. - this.tableStatus = new TableStatusViewCache(ViewCacheStatus.ValueException); + this.tableStatus = new TableStatus('danger'); } getRbdImages(context: CdTableFetchDataContext) {