]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/pybind/mgr/dashboard/frontend/src/app/ceph/dashboard/health/health.component.spec.ts
Import ceph 15.2.8
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / ceph / dashboard / health / health.component.spec.ts
index 50a96ee6b51b58da2779cdbbf0a7020cc9eda28f..d2fea1406cdcd6aecd96e8adfc61eaf8899e4471 100644 (file)
@@ -94,7 +94,7 @@ describe('HealthComponent', () => {
     expect(infoGroups.length).toBe(3);
 
     const infoCards = fixture.debugElement.nativeElement.querySelectorAll('cd-info-card');
-    expect(infoCards.length).toBe(18);
+    expect(infoCards.length).toBe(17);
   });
 
   describe('features disabled', () => {
@@ -119,7 +119,7 @@ describe('HealthComponent', () => {
       expect(infoGroups.length).toBe(3);
 
       const infoCards = fixture.debugElement.nativeElement.querySelectorAll('cd-info-card');
-      expect(infoCards.length).toBe(15);
+      expect(infoCards.length).toBe(14);
     });
   });
 
@@ -141,7 +141,7 @@ describe('HealthComponent', () => {
     expect(infoGroups.length).toBe(2);
 
     const infoCards = fixture.debugElement.nativeElement.querySelectorAll('cd-info-card');
-    expect(infoCards.length).toBe(10);
+    expect(infoCards.length).toBe(9);
   });
 
   it('should render all except "Performance" group and cards', () => {
@@ -172,7 +172,7 @@ describe('HealthComponent', () => {
     expect(infoGroups.length).toBe(2);
 
     const infoCards = fixture.debugElement.nativeElement.querySelectorAll('cd-info-card');
-    expect(infoCards.length).toBe(13);
+    expect(infoCards.length).toBe(12);
   });
 
   it('should render all groups and 1 card per group', () => {
@@ -256,17 +256,25 @@ describe('HealthComponent', () => {
   });
 
   describe('preparePgStatus', () => {
-    const calcPercentage = (data: number) => Math.round((data / 10) * 100) || 0;
-
-    const expectedChart = (data: number[]) => ({
+    const expectedChart = (data: number[], label: string = null) => ({
       labels: [
-        `Clean (${calcPercentage(data[0])}%)`,
-        `Working (${calcPercentage(data[1])}%)`,
-        `Warning (${calcPercentage(data[2])}%)`,
-        `Unknown (${calcPercentage(data[3])}%)`
+        `Clean: ${component['dimless'].transform(data[0])}`,
+        `Working: ${component['dimless'].transform(data[1])}`,
+        `Warning: ${component['dimless'].transform(data[2])}`,
+        `Unknown: ${component['dimless'].transform(data[3])}`
       ],
       options: {},
-      dataset: [{ data: data }]
+      dataset: [
+        {
+          data: data.map((i) =>
+            component['calcPercentage'](
+              i,
+              data.reduce((j, k) => j + k)
+            )
+          ),
+          label: label
+        }
+      ]
     });
 
     it('gets no data', () => {
@@ -274,7 +282,7 @@ describe('HealthComponent', () => {
       component.preparePgStatus(chart, {
         pg_info: {}
       });
-      expect(chart).toEqual(expectedChart([undefined, undefined, undefined, undefined]));
+      expect(chart).toEqual(expectedChart([0, 0, 0, 0], '0\nPGs'));
     });
 
     it('gets data from all categories', () => {
@@ -289,7 +297,7 @@ describe('HealthComponent', () => {
           }
         }
       });
-      expect(chart).toEqual(expectedChart([1, 2, 3, 4]));
+      expect(chart).toEqual(expectedChart([1, 2, 3, 4], '10\nPGs'));
     });
   });