]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: Add hosts page unit tests
authorVolker Theile <vtheile@suse.com>
Fri, 10 Jul 2020 09:34:08 +0000 (11:34 +0200)
committerVolker Theile <vtheile@suse.com>
Wed, 15 Jul 2020 15:28:06 +0000 (17:28 +0200)
Fixes: https://tracker.ceph.com/issues/46448
Signed-off-by: Volker Theile <vtheile@suse.com>
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.spec.ts

index b4ba5643fb8089ebe0a6ddebf1eca88c6e412f2b..c8f395db5fc41fed3076fe546b4df9018e0b60e4 100644 (file)
@@ -3,12 +3,15 @@ import { async, ComponentFixture, TestBed } from '@angular/core/testing';
 import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
 import { RouterTestingModule } from '@angular/router/testing';
 
+import * as _ from 'lodash';
 import { ToastrModule } from 'ngx-toastr';
 import { of } from 'rxjs';
 
 import { configureTestBed, i18nProviders } from '../../../../testing/unit-test-helper';
 import { CoreModule } from '../../../core/core.module';
 import { HostService } from '../../../shared/api/host.service';
+import { ActionLabels } from '../../../shared/constants/app.constants';
+import { CdTableAction } from '../../../shared/models/cd-table-action';
 import { Permissions } from '../../../shared/models/permissions';
 import { AuthStorageService } from '../../../shared/services/auth-storage.service';
 import { SharedModule } from '../../../shared/shared.module';
@@ -89,30 +92,39 @@ describe('HostsComponent', () => {
     });
   }));
 
-  describe('getEditDisableDesc', () => {
-    it('should return message (not managed by Orchestrator)', () => {
+  describe('test edit button', () => {
+    let tableAction: CdTableAction;
+
+    beforeEach(() => {
+      tableAction = _.find(component.tableActions, { name: ActionLabels.EDIT });
+    });
+
+    it('should disable button and return message (not managed by Orchestrator)', () => {
       component.selection.add({
         sources: {
           ceph: true,
           orchestrator: false
         }
       });
+      expect(tableAction.disable(component.selection)).toBeTruthy();
       expect(component.getEditDisableDesc(component.selection)).toBe(
         'Host editing is disabled because the selected host is not managed by Orchestrator.'
       );
     });
 
-    it('should return undefined (no selection)', () => {
+    it('should disable button and return undefined (no selection)', () => {
+      expect(tableAction.disable(component.selection)).toBeTruthy();
       expect(component.getEditDisableDesc(component.selection)).toBeUndefined();
     });
 
-    it('should return undefined (managed by Orchestrator)', () => {
+    it('should enable button and return undefined (managed by Orchestrator)', () => {
       component.selection.add({
         sources: {
           ceph: false,
           orchestrator: true
         }
       });
+      expect(tableAction.disable(component.selection)).toBeFalsy();
       expect(component.getEditDisableDesc(component.selection)).toBeUndefined();
     });
   });