]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: migrate E2E dashboards to async/await
authorPatrick Seidensal <pseidensal@suse.com>
Wed, 21 Aug 2019 07:18:06 +0000 (09:18 +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/dashboard.e2e-spec.ts
src/pybind/mgr/dashboard/frontend/e2e/dashboard.po.ts
src/pybind/mgr/dashboard/frontend/e2e/helper.po.ts
src/pybind/mgr/dashboard/frontend/e2e/page-helper.po.ts

index b3786120f871aa415594d802552d34ec7ac96e7a..2f3ba4c16b7285406310413dc315e22a292c2811 100644 (file)
@@ -20,203 +20,175 @@ describe('Dashboard Main Page', () => {
     iscsi = new Helper().iscsi;
   });
 
-  afterEach(() => {
-    Helper.checkConsole();
+  afterEach(async () => {
+    await Helper.checkConsole();
   });
 
   describe('Check that all hyperlinks on cells lead to the correct page and fields exist', () => {
-    beforeAll(() => {
-      dashboard.navigateTo();
+    beforeEach(async () => {
+      await dashboard.navigateTo();
     });
 
-    it('should check all linked cells lead to correct page', () => {
+    it('should check all linked cells lead to correct page', async () => {
       // Grabs cell and then clicks the hyperlink, some cells require different
       // methods as stated below
 
       // Monitors Cell
-      expect(browser.getCurrentUrl()).toContain('/#/dashboard');
-      dashboard.cellLink('Monitors');
-      expect(dashboard.getBreadcrumbText()).toEqual('Monitors');
+      expect(await browser.getCurrentUrl()).toContain('/#/dashboard');
+      await dashboard.cellLink('Monitors');
+      expect(await dashboard.getBreadcrumbText()).toEqual('Monitors');
 
       // OSDs Cell
-      browser.navigate().back();
-      expect(browser.getCurrentUrl()).toContain('/#/dashboard');
-      dashboard.cellLink('OSDs');
-      expect(dashboard.getBreadcrumbText()).toEqual('OSDs');
+      // await browser.navigate().back();
+      await dashboard.navigateBack();
+      expect(await browser.getCurrentUrl()).toContain('/#/dashboard');
+      await dashboard.cellLink('OSDs');
+      expect(await dashboard.getBreadcrumbText()).toEqual('OSDs');
 
       // Hosts Cell
-      browser.navigate().back();
-      expect(browser.getCurrentUrl()).toContain('/#/dashboard');
-      dashboard.cellLink('Hosts');
-      expect(dashboard.getBreadcrumbText()).toEqual('Hosts');
+      // await browser.navigate().back();
+      await dashboard.navigateBack();
+      expect(await browser.getCurrentUrl()).toContain('/#/dashboard');
+      await dashboard.cellLink('Hosts');
+      expect(await dashboard.getBreadcrumbText()).toEqual('Hosts');
 
       // Object Gateways Cell
-      browser.navigate().back();
-      expect(browser.getCurrentUrl()).toContain('/#/dashboard');
-      element
+      // await browser.navigate().back();
+      await dashboard.navigateBack();
+      expect(await browser.getCurrentUrl()).toContain('/#/dashboard');
+      await element
         .all(by.partialLinkText('Object'))
         .last()
         .click(); // Since there is a space and there are 2 occurances of
-      expect(dashboard.getBreadcrumbText()).toEqual('Daemons'); // 'Object Gateways', this method was used to grab the link
+      expect(await dashboard.getBreadcrumbText()).toEqual('Daemons'); // 'Object Gateways', this method was used to grab the link
 
       // iSCSI Gateways Cell
-      browser.navigate().back();
-      expect(browser.getCurrentUrl()).toContain('/#/dashboard');
-      dashboard.partialCellLink('iSCSI'); // Since there is a space between iSCSI and Gateways this method was
-      expect(dashboard.getBreadcrumbText()).toEqual('Overview'); // used to grab and click the link
+      // await browser.navigate().back();
+      await dashboard.navigateBack();
+      expect(await browser.getCurrentUrl()).toContain('/#/dashboard');
+      await dashboard.partialCellLink('iSCSI'); // Since there is a space between iSCSI and Gateways this method was
+      expect(await dashboard.getBreadcrumbText()).toEqual('Overview'); // used to grab and click the link
 
       // Pools Cell
-      browser.navigate().back();
-      expect(browser.getCurrentUrl()).toContain('/#/dashboard');
-      dashboard.cellLink('Pools');
-      expect(dashboard.getBreadcrumbText()).toEqual('Pools');
+      // await browser.navigate().back();
+      await dashboard.navigateBack();
+      expect(await browser.getCurrentUrl()).toContain('/#/dashboard');
+      await dashboard.cellLink('Pools');
+      expect(await dashboard.getBreadcrumbText()).toEqual('Pools');
     });
 
-    it('should verify that cells exist on dashboard in proper order', () => {
+    it('should verify that cells exist on dashboard in proper order', async () => {
       // Ensures that info cards are all displayed on the dashboard tab while being
       // in the proper order, checks for card title and position via indexing into
       // a list of all info cards
-      dashboard.navigateTo();
-      expect(browser.getCurrentUrl()).toContain('/#/dashboard');
-      expect(dashboard.dashContain(0, 'Cluster Status'));
-      expect(dashboard.dashContain(1, 'Monitors'));
-      expect(dashboard.dashContain(2, 'OSDs'));
-      expect(dashboard.dashContain(3, 'Manager Daemons'));
-      expect(dashboard.dashContain(4, 'Hosts'));
-      expect(dashboard.dashContain(5, 'Object Gateways'));
-      expect(dashboard.dashContain(6, 'Metadata Servers'));
-      expect(dashboard.dashContain(7, 'iSCSI Gateways'));
-      expect(dashboard.dashContain(8, 'Client IOPS'));
-      expect(dashboard.dashContain(9, 'Client Throughput'));
-      expect(dashboard.dashContain(10, 'Clinet Read/Write'));
-      expect(dashboard.dashContain(11, 'Recovery Throughput'));
-      expect(dashboard.dashContain(12, 'Scrub'));
-      expect(dashboard.dashContain(13, 'Pools'));
-      expect(dashboard.dashContain(14, 'Raw Capacity'));
-      expect(dashboard.dashContain(15, 'Objects'));
-      expect(dashboard.dashContain(16, 'PGs per OSD'));
-      expect(dashboard.dashContain(17, 'PG Status'));
+      await dashboard.navigateTo();
+      expect(await browser.getCurrentUrl()).toContain('/#/dashboard');
+      expect(await dashboard.infoCardText(0)).toContain('Cluster Status');
+      expect(await dashboard.infoCardText(1)).toContain('Monitors');
+      expect(await dashboard.infoCardText(2)).toContain('OSDs');
+      expect(await dashboard.infoCardText(3)).toContain('Manager Daemons');
+      expect(await dashboard.infoCardText(4)).toContain('Hosts');
+      expect(await dashboard.infoCardText(5)).toContain('Object Gateways');
+      expect(await dashboard.infoCardText(6)).toContain('Metadata Servers');
+      expect(await dashboard.infoCardText(7)).toContain('iSCSI Gateways');
+      expect(await dashboard.infoCardText(8)).toContain('Client IOPS');
+      expect(await dashboard.infoCardText(9)).toContain('Client Throughput');
+      expect(await dashboard.infoCardText(10)).toContain('Client Read/Write');
+      expect(await dashboard.infoCardText(11)).toContain('Recovery Throughput');
+      expect(await dashboard.infoCardText(12)).toContain('Scrub');
+      expect(await dashboard.infoCardText(13)).toContain('Pools');
+      expect(await dashboard.infoCardText(14)).toContain('Raw Capacity');
+      expect(await dashboard.infoCardText(15)).toContain('Objects');
+      expect(await dashboard.infoCardText(16)).toContain('PGs per OSD');
+      expect(await dashboard.infoCardText(17)).toContain('PG Status');
     });
 
-    it('should verify that info card group titles are present and in the right order', () => {
+    it('should verify that info card group titles are present and in the right order', async () => {
       // Checks that the group titles on the dashboard are correct and in the right order
-      dashboard.navigateTo();
-      expect(browser.getCurrentUrl()).toContain('/#/dashboard');
-      expect(dashboard.checkGroupTitles(0, 'Status'));
-      expect(dashboard.checkGroupTitles(1, 'Peformance'));
-      expect(dashboard.checkGroupTitles(2, 'Capacity'));
+      await dashboard.navigateTo();
+      expect(await browser.getCurrentUrl()).toContain('/#/dashboard');
+      expect(await dashboard.checkGroupTitles(0, 'Status'));
+      expect(await dashboard.checkGroupTitles(1, 'Performance'));
+      expect(await dashboard.checkGroupTitles(2, 'Capacity'));
     });
   });
 
   describe('Should check that dashboard cells have correct information', () => {
-    beforeAll(() => {
-      dashboard.navigateTo();
+    beforeAll(async () => {
+      await dashboard.navigateTo();
     });
 
-    it('should verify that proper number of object gateway daemons on dashboard', () => {
+    it('should verify that proper number of object gateway daemons on dashboard', async () => {
       // Checks that dashboard id card for Object Gateway has the correct number of Daemons
       // by checking the Daemons page and taking the count found at the bottom of the table
-      dashboard.navigateTo();
-      let dashCount = '';
-      dashboard.cardNumb(5).then((num) => {
-        dashCount = num; // Grabs number of daemons from dashboard Object Gateway card
-      });
-      daemons.navigateTo();
-      daemons
-        .getTableCount()
-        .getText()
-        .then((tableCount) => {
-          tableCount = tableCount.slice(13); // Grabs number of daemons from table footer
-          expect(dashCount).toContain(tableCount);
-        });
+      await dashboard.navigateTo();
+      const dashCount = await dashboard.cardNumb(5); // Grabs number of daemons from dashboard Object Gateway card
+      await daemons.navigateTo();
+      // Grabs number of daemons from table footer
+      const tableCount = (await daemons.getTableCount().getText()).slice(13);
+      expect(dashCount).toContain(tableCount);
     });
 
-    it('should verify that proper number of monitors on dashboard', () => {
+    it('should verify that proper number of monitors on dashboard', async () => {
       // Checks that dashboard id card for Monitors has the correct number of Monitors
       // by checking the Monitors page and taking the count found at the bottom of the table
-      dashboard.navigateTo();
-      let dashCount = '';
-      dashboard.cardNumb(1).then((num) => {
-        dashCount = num; // Grabs number of monitors from dashboard Monitor card
-      });
-      monitors.navigateTo();
-      $$('.datatable-footer-inner')
+      await dashboard.navigateTo();
+      // Grabs number of monitors from dashboard Monitor card
+      const dashCount = await dashboard.cardNumb(1);
+      await monitors.navigateTo();
+      // Grabs number of monitors from table footer
+      const tableCount = (await $$('.datatable-footer-inner')
         .first()
-        .getText()
-        .then((tableCount) => {
-          tableCount = tableCount.slice(0, -6); // Grabs number of monitors from table footer
-          expect(dashCount).toContain(tableCount);
-        });
+        .getText()).slice(0, -6);
+      expect(dashCount).toContain(tableCount);
     });
 
-    it('should verify that proper number of hosts on dashboard', () => {
+    it('should verify that proper number of hosts on dashboard', async () => {
       // Checks that dashboard id card for Hosts has the correct number of hosts
       // by checking the Hosts page and taking the count found at the bottom of the table
-      dashboard.navigateTo();
-      let dashCount = '';
-      dashboard.cardNumb(4).then((num) => {
-        dashCount = num; // Grabs number of hosts from dashboard Hosts card
-      });
-      hosts.navigateTo();
-      hosts
-        .getTableCount()
-        .getText()
-        .then((tableCount) => {
-          tableCount = tableCount.slice(13, -6); // Grabs number of hosts from table footer
-          expect(dashCount).toContain(tableCount);
-        });
+      await dashboard.navigateTo();
+      // Grabs number of hosts from dashboard Hosts card
+      const dashCount = await dashboard.cardNumb(4);
+      await hosts.navigateTo();
+      // Grabs number of hosts from table footer
+      const tableCount = (await hosts.getTableCount().getText()).slice(13, -6);
+      expect(dashCount).toContain(tableCount);
     });
 
-    it('should verify that proper number of osds on dashboard', () => {
+    it('should verify that proper number of osds on dashboard', async () => {
       // Checks that dashboard id card for Hosts has the correct number of hosts
       // by checking the Hosts page and taking the count found at the bottom of the table
-      dashboard.navigateTo();
-      let dashCount = '';
-      dashboard.cardNumb(2).then((num) => {
-        dashCount = num.slice(0, -17); // Grabs number of hosts from dashboard Hosts card
-      });
-      osds.navigateTo();
-      osds
-        .getTableCount()
-        .getText()
-        .then((tableCount) => {
-          tableCount = tableCount.slice(13, -6); // Grabs number of hosts from table footer
-          expect(dashCount).toContain(tableCount);
-        });
+      await dashboard.navigateTo();
+      // Grabs number of hosts from dashboard Hosts card
+      const dashCount = (await dashboard.cardNumb(2)).slice(0, -17);
+      await osds.navigateTo();
+      // Grabs number of hosts from table footer
+      const tableCount = (await osds.getTableCount().getText()).slice(13, -6);
+      expect(dashCount).toContain(tableCount);
     });
 
-    it('should verify that proper number of pools on dashboard', () => {
-      dashboard.navigateTo();
-      let dashCount = '';
-      dashboard.cardNumb(13).then((num) => {
-        dashCount = num.slice(4); // Grabs number of hosts from dashboard Pools card
-        pools.navigateTo();
-        pools
-          .getTableCount()
-          .getText()
-          .then((tableCount) => {
-            tableCount = tableCount.slice(13, -6); // Grabs number of pools from table footer
-            expect(dashCount).toContain(tableCount);
-          });
-      });
+    it('should verify that proper number of pools on dashboard', async () => {
+      await dashboard.navigateTo();
+      // Grabs number of hosts from dashboard Pools card
+      const dashCount = (await dashboard.cardNumb(13)).slice(4);
+      await pools.navigateTo();
+      // Grabs number of pools from table footer
+      const tableCount = (await pools.getTableCount().getText()).slice(13, -6);
+      expect(dashCount).toContain(tableCount);
     });
 
-    it('should verify that proper number of iscsi gateways on dashboard', () => {
+    it('should verify that proper number of iscsi gateways on dashboard', async () => {
       // Checks that dashboard id card for iSCSI has the correct number of gateways
       // by checking the iSCSI page and taking the count found at the bottom of the table (first)
-      dashboard.navigateTo();
-      let dashCount = '';
-      dashboard.cardNumb(7).then((num) => {
-        dashCount = num; // Grabs number of gateways from dashboard iSCSI card
-      });
-      iscsi.navigateTo();
-      $$('.datatable-footer-inner')
+      await dashboard.navigateTo();
+      // Grabs number of gateways from dashboard iSCSI card
+      const dashCount = await dashboard.cardNumb(7);
+      await iscsi.navigateTo();
+      // Grabs number of monitors from table footer
+      const tableCount = (await $$('.datatable-footer-inner')
         .first()
-        .getText()
-        .then((tableCount) => {
-          tableCount = tableCount.slice(0, -6); // Grabs number of monitors from table footer
-          expect(dashCount).toContain(tableCount);
-        });
+        .getText()).slice(0, -6);
+      expect(dashCount).toContain(tableCount);
     });
   });
 });
index 039d695e9fd3e4f8aa748b979b49a43dadad684d..724608de753d53d6b3fe822c618826b9e1288d2c 100644 (file)
@@ -6,15 +6,11 @@ export class DashboardPageHelper extends PageHelper {
     index: '/#/dashboard'
   };
 
-  checkGroupTitles(index, name) {
+  async checkGroupTitles(index, name) {
     // Checks that the titles of all the groups on the dashboard are correct
     const titles = element.all(by.className('info-group-title'));
-    titles
-      .get(index)
-      .getText()
-      .then((txt) => {
-        expect(txt === name);
-      });
+    const text = await titles.get(index).getText();
+    expect(text).toBe(name);
   }
 
   cellFromGroup(cardName) {
@@ -23,34 +19,29 @@ export class DashboardPageHelper extends PageHelper {
     return $(`cd-info-card[cardtitle=${cardName}]`);
   }
 
-  cellLink(cardName) {
+  async cellLink(cardName) {
     // Grabs the link from the correct card using the cellFromGroup function,
     // then clicks the hyperlinked title
-    this.navigateTo();
-    this.cellFromGroup(cardName)
+    await this.navigateTo();
+    await this.cellFromGroup(cardName)
       .element(by.linkText(cardName))
       .click();
   }
 
-  partialCellLink(partName) {
+  async partialCellLink(partName) {
     // Used for cases in which there was a space inbetween two words in the hyperlink,
     // has the same functionality as cellLink
-    element(by.partialLinkText(partName)).click();
+    await element(by.partialLinkText(partName)).click();
   }
 
-  dashContain(index, name) {
+  async infoCardText(index) {
     // Grabs a list of all info cards, then checks by index that the title text
     // is equal to the desired title, thus checking the presence of the card
     const cardList = element.all(by.tagName('cd-info-card'));
-    cardList
-      .get(index)
-      .getText()
-      .then((txt) => {
-        expect(txt === name);
-      });
+    return cardList.get(index).getText();
   }
 
-  cardNumb(index) {
+  async cardNumb(index) {
     // Grabs a list of all info cards and returns the text on the card via
     // the index of the card in the list
     const cardList = element.all(by.tagName('cd-info-card'));
index 3b0e6fbdfc67c5e91f99ca05452eda9a3c6a0d36..a27e57e394a4e2cda2d1f31e3d8d720a4da97339 100644 (file)
@@ -10,6 +10,7 @@ import { LogsPageHelper } from './cluster/logs.po';
 import { ManagerModulesPageHelper } from './cluster/mgr-modules.po';
 import { MonitorsPageHelper } from './cluster/monitors.po';
 import { OSDsPageHelper } from './cluster/osds.po';
+import { DashboardPageHelper } from './dashboard.po';
 import { FilesystemsPageHelper } from './filesystems/filesystems.po';
 import { NfsPageHelper } from './nfs/nfs.po';
 import { PoolPageHelper } from './pools/pools.po';
@@ -43,6 +44,7 @@ export class Helper {
   alerts: AlertsPageHelper;
   mirroring: MirroringPageHelper;
   iscsi: IscsiPageHelper;
+  dashboard: DashboardPageHelper;
 
   constructor() {
     this.pools = new PoolPageHelper();
@@ -66,6 +68,7 @@ export class Helper {
     this.alerts = new AlertsPageHelper();
     this.mirroring = new MirroringPageHelper();
     this.iscsi = new IscsiPageHelper();
+    this.dashboard = new DashboardPageHelper();
   }
 
   /**
index 10b445b7d556a2b2d8cccc505b3f8ca27299be49..11bc0eb79d91dabf09dfe3d1a10c5e5d1eebe817 100644 (file)
@@ -88,11 +88,11 @@ export abstract class PageHelper {
       .get(idx)
       .getText();
   }
-  //
-  // getTableCount() {
-  //   return $('.datatable-footer-inner.selected-count');
-  // }
-  //
+
+  getTableCount() {
+    return $('.datatable-footer-inner.selected-count');
+  }
+
   // getTitleText() {
   //   let title;
   //   return browser