]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: migrate E2E hosts to async/await
authorPatrick Seidensal <pseidensal@suse.com>
Mon, 19 Aug 2019 11:07:05 +0000 (13:07 +0200)
committerPatrick Seidensal <pseidensal@suse.com>
Wed, 28 Aug 2019 07:38:48 +0000 (09:38 +0200)
Fixes: https://tracker.ceph.com/issues/40693
Signed-off-by: Patrick Seidensal <pseidensal@suse.com>
src/pybind/mgr/dashboard/frontend/e2e/cluster/hosts.e2e-spec.ts
src/pybind/mgr/dashboard/frontend/e2e/cluster/hosts.po.ts
src/pybind/mgr/dashboard/frontend/e2e/helper.po.ts
src/pybind/mgr/dashboard/frontend/src/app/ceph/cluster/hosts/hosts.component.html

index f3137366eff4ab26cba0ecb59351f0f34a73e0a4..db385ed6a3e13c26e1a36346b57c0b444d948111 100644 (file)
@@ -7,39 +7,39 @@ describe('Hosts page', () => {
     hosts = new Helper().hosts;
   });
 
-  afterEach(() => {
-    Helper.checkConsole();
+  afterEach(async () => {
+    await Helper.checkConsole();
   });
 
   describe('breadcrumb and tab tests', () => {
-    beforeAll(() => {
-      hosts.navigateTo();
+    beforeAll(async () => {
+      await hosts.navigateTo();
     });
 
-    it('should open and show breadcrumb', () => {
-      expect(hosts.getBreadcrumbText()).toEqual('Hosts');
+    it('should open and show breadcrumb', async () => {
+      expect(await hosts.getBreadcrumbText()).toEqual('Hosts');
     });
 
-    it('should show two tabs', () => {
-      expect(hosts.getTabsCount()).toEqual(2);
+    it('should show two tabs', async () => {
+      expect(await hosts.getTabsCount()).toEqual(2);
     });
 
-    it('should show hosts list tab at first', () => {
-      expect(hosts.getTabText(0)).toEqual('Hosts List');
+    it('should show hosts list tab at first', async () => {
+      expect(await hosts.getTabText(0)).toEqual('Hosts List');
     });
 
-    it('should show overall performance as a second tab', () => {
-      expect(hosts.getTabText(1)).toEqual('Overall Performance');
+    it('should show overall performance as a second tab', async () => {
+      expect(await hosts.getTabText(1)).toEqual('Overall Performance');
     });
   });
 
   describe('services link test', () => {
-    it('should check at least one host is present', () => {
-      hosts.check_for_host();
+    it('should check at least one host is present', async () => {
+      await hosts.check_for_host();
     });
 
-    it('should check services link(s) work for first host', () => {
-      hosts.check_services_links();
+    it('should check services link(s) work for first host', async () => {
+      await hosts.check_services_links();
     });
   });
 });
index c628be7ef162234658ea1de87714a75d81452949..0d0b8f1090d4f5651cdc39553d1e2025975ba04e 100644 (file)
@@ -4,49 +4,40 @@ import { PageHelper } from '../page-helper.po';
 export class HostsPageHelper extends PageHelper {
   pages = { index: '/#/hosts' };
 
-  check_for_host() {
-    this.navigateTo();
+  async check_for_host() {
+    await this.navigateTo();
 
-    this.getTableCount()
-      .getText()
-      .then((hostcount) => {
-        expect(hostcount.includes('0 total')).toBe(false);
-      });
+    const hostcount = await this.getTableCount().getText();
+    expect(await hostcount.includes('0 total')).toBe(false);
   }
 
   // function that checks all services links work for first
   // host in table
-  check_services_links() {
-    this.navigateTo();
+  async check_services_links() {
+    await this.navigateTo();
     let links_tested = 0;
 
     // grab services column for first host
     const services = element.all(by.css('.datatable-body-cell')).get(1);
     // check is any services links are present
-    services
-      .getText()
-      .then((txt) => {
-        // check that text (links) is present in services box
-        expect(txt.length).toBeGreaterThan(0, 'No services links exist on first host');
-        if (txt.length === 0) {
-          return;
-        }
-        const links = services.all(by.css('a.ng-star-inserted'));
-        links.count().then((num_links) => {
-          for (let i = 0; i < num_links; i++) {
-            // click link, check it worked by looking for changed breadcrumb,
-            // navigate back to hosts page, repeat until all links checked
-            links.get(i).click();
-            expect(this.getBreadcrumbText()).toEqual('Performance Counters');
-            this.navigateTo();
-            expect(this.getBreadcrumbText()).toEqual('Hosts');
-            links_tested++;
-          }
-        });
-      })
-      .then(() => {
-        // check if any links were actually tested
-        expect(links_tested > 0).toBe(true, 'No links were tested. Test failed');
-      });
+    const txt = await services.getText();
+    // check that text (links) is present in services box
+    expect(txt.length).toBeGreaterThan(0, 'No services links exist on first host');
+    if (txt.length === 0) {
+      return;
+    }
+    const links = services.all(by.css('a.service-link'));
+    const num_links = await links.count();
+    for (let i = 0; i < num_links; i++) {
+      // click link, check it worked by looking for changed breadcrumb,
+      // navigate back to hosts page, repeat until all links checked
+      await links.get(i).click();
+      expect(await this.getBreadcrumbText()).toEqual('Performance Counters');
+      await this.navigateTo();
+      expect(await this.getBreadcrumbText()).toEqual('Hosts');
+      links_tested++;
+    }
+    // check if any links were actually tested
+    expect(links_tested > 0).toBe(true, 'No links were tested. Test failed');
   }
 }
index bb2c3f0c7dc3b8550616d7dcaea31902f4abbb3b..5f734e0e544732a296d50c64523647f81f526e29 100644 (file)
@@ -1,6 +1,7 @@
 import { browser } from 'protractor';
 import { Logs } from 'selenium-webdriver';
 import { ImagesPageHelper } from './block/images.po';
+import { HostsPageHelper } from './cluster/hosts.po';
 import { LogsPageHelper } from './cluster/logs.po';
 import { ManagerModulesPageHelper } from './cluster/mgr-modules.po';
 import { MonitorsPageHelper } from './cluster/monitors.po';
@@ -32,6 +33,7 @@ export class Helper {
   monitors: MonitorsPageHelper;
   mgrModules: ManagerModulesPageHelper;
   logs: LogsPageHelper;
+  hosts: HostsPageHelper;
 
   constructor() {
     this.pools = new PoolPageHelper();
@@ -49,6 +51,7 @@ export class Helper {
     this.monitors = new MonitorsPageHelper();
     this.mgrModules = new ManagerModulesPageHelper();
     this.logs = new LogsPageHelper();
+    this.hosts = new HostsPageHelper();
   }
 
   /**
index 39dcedb313ed561b7d21ba63996de4138900d3ab..799af3e471e314d845b3390f3c201b5be12d751b 100644 (file)
@@ -9,7 +9,8 @@
               (updateSelection)="updateSelection($event)">
       <ng-template #servicesTpl let-value="value">
         <span *ngFor="let service of value; last as isLast">
-          <a [routerLink]="[service.cdLink]"
+          <a class="service-link"
+             [routerLink]="[service.cdLink]"
              [queryParams]="cdParams"
              *ngIf="service.canRead">{{ service.type }}.{{ service.id }}
           </a>