]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.spec.ts
update ceph source to reef 18.2.1
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / cluster / hosts / hosts.component.spec.ts
index 2e76d1f43ed63645d9e1497d9883b76690ac9bd1..43be6e8c758227d52aa6e7fb6dddca8c38920e17 100644 (file)
@@ -1,3 +1,4 @@
+import { HttpHeaders } from '@angular/common/http';
 import { HttpClientTestingModule } from '@angular/common/http/testing';
 import { ComponentFixture, TestBed } from '@angular/core/testing';
 import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
@@ -45,6 +46,7 @@ describe('HostsComponent', () => {
   let hostListSpy: jasmine.Spy;
   let orchService: OrchestratorService;
   let showForceMaintenanceModal: MockShowForceMaintenanceModal;
+  let headers: HttpHeaders;
 
   const fakeAuthStorageService = {
     getPermissions: () => {
@@ -75,6 +77,7 @@ describe('HostsComponent', () => {
     component = fixture.componentInstance;
     hostListSpy = spyOn(TestBed.inject(HostService), 'list');
     orchService = TestBed.inject(OrchestratorService);
+    headers = new HttpHeaders().set('x-total-count', '10');
   });
 
   it('should create', () => {
@@ -100,11 +103,13 @@ describe('HostsComponent', () => {
           }
         ],
         hostname: hostname,
-        labels: ['foo', 'bar']
+        labels: ['foo', 'bar'],
+        headers: headers
       }
     ];
 
     OrchestratorHelper.mockStatus(false);
+    fixture.detectChanges();
     hostListSpy.and.callFake(() => of(payload));
     fixture.detectChanges();
 
@@ -136,11 +141,13 @@ describe('HostsComponent', () => {
           }
         ],
         hostname: hostname,
-        labels: ['foo', 'bar']
+        labels: ['foo', 'bar'],
+        headers: headers
       }
     ];
 
     OrchestratorHelper.mockStatus(false);
+    fixture.detectChanges();
     hostListSpy.and.callFake(() => of(payload));
     fixture.detectChanges();
 
@@ -173,10 +180,12 @@ describe('HostsComponent', () => {
         hdd_capacity_bytes: 1024,
         flash_count: 4,
         flash_capacity_bytes: 1024,
-        nic_count: 1
+        nic_count: 1,
+        headers: headers
       }
     ];
     OrchestratorHelper.mockStatus(true, features);
+    fixture.detectChanges();
     hostListSpy.and.callFake(() => of(payload));
     fixture.detectChanges();
 
@@ -200,10 +209,12 @@ describe('HostsComponent', () => {
             type: 'osd',
             id: '0'
           }
-        ]
+        ],
+        headers: headers
       }
     ];
     OrchestratorHelper.mockStatus(false);
+    fixture.detectChanges();
     hostListSpy.and.callFake(() => of(payload));
     fixture.detectChanges();
 
@@ -225,10 +236,12 @@ describe('HostsComponent', () => {
             type: 'osd',
             id: '0'
           }
-        ]
+        ],
+        headers: headers
       }
     ];
     OrchestratorHelper.mockStatus(true);
+    fixture.detectChanges();
     hostListSpy.and.callFake(() => of(payload));
     fixture.detectChanges();
 
@@ -260,10 +273,12 @@ describe('HostsComponent', () => {
         hdd_capacity_bytes: undefined,
         flash_count: 4,
         flash_capacity_bytes: undefined,
-        nic_count: 1
+        nic_count: 1,
+        headers: headers
       }
     ];
     OrchestratorHelper.mockStatus(true, features);
+    fixture.detectChanges();
     hostListSpy.and.callFake(() => of(hostPayload));
     fixture.detectChanges();
 
@@ -307,7 +322,10 @@ describe('HostsComponent', () => {
     const fakeHosts = require('./fixtures/host_list_response.json');
 
     beforeEach(() => {
-      hostListSpy.and.callFake(() => of(fakeHosts));
+      let headers = new HttpHeaders().set('x-total-count', '10');
+      headers = headers.set('x-total-count', '10');
+      fakeHosts[0].headers = headers;
+      fakeHosts[1].headers = headers;
     });
 
     const testTableActions = async (
@@ -319,6 +337,9 @@ describe('HostsComponent', () => {
       fixture.detectChanges();
       await fixture.whenStable();
 
+      component.getHosts(new CdTableFetchDataContext(() => undefined));
+      hostListSpy.and.callFake(() => of(fakeHosts));
+      fixture.detectChanges();
       for (const test of tests) {
         if (test.selectRow) {
           component.selection = new CdTableSelection();