]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Add hosts page unit tests 36350/head
authorVolker Theile <vtheile@suse.com>
Fri, 10 Jul 2020 09:34:08 +0000 (11:34 +0200)
committerTatjana Dehler <tdehler@suse.com>
Wed, 29 Jul 2020 13:02:50 +0000 (15:02 +0200)
Fixes: https://tracker.ceph.com/issues/46448
Signed-off-by: Volker Theile <vtheile@suse.com>
(cherry picked from commit f2270d901853d6dc0620bb1b23d64df51c5683f0)

Conflicts:
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.spec.ts
Trivial - small conflict in import section.

src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.spec.ts

index 5b16f2b41805f2ba6da88017184dc7f08da66011..05f3d962f0e4047ac3b71af59f9d42d50f0c3c62 100644 (file)
@@ -3,6 +3,7 @@ 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 { BsDropdownModule } from 'ngx-bootstrap/dropdown';
 import { TabsModule } from 'ngx-bootstrap/tabs';
 import { ToastrModule } from 'ngx-toastr';
@@ -11,6 +12,8 @@ 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';
@@ -93,30 +96,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 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();
     });
   });