]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: fix rbd list tests
authorPere Diaz Bou <pdiazbou@redhat.com>
Wed, 29 Jun 2022 11:37:17 +0000 (13:37 +0200)
committerPere Diaz Bou <pdiazbou@redhat.com>
Tue, 12 Jul 2022 17:09:02 +0000 (19:09 +0200)
X-Total-Count header was missing from rbdservice.list spy mock

Signed-off-by: Pere Diaz Bou <pdiazbou@redhat.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.spec.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/block/rbd-list/rbd-list.component.ts

index 85e9ad35dbd56bffa620e54e10dde61ed2728897..fa7a772f02239654f975a54bbb6330c6dc8a5bce 100644 (file)
@@ -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();
     });
 
index e3040f693137bdb973b2425a11b3f73563488224..bbbfbe8b7e48c1f4a9da92b16ab35b0361677575 100644 (file)
@@ -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) {