]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: Extract E2E wait calls into PageHelper 29789/head
authorTiago Melo <tmelo@suse.com>
Tue, 20 Aug 2019 16:45:23 +0000 (16:45 +0000)
committerTiago Melo <tmelo@suse.com>
Wed, 28 Aug 2019 23:03:05 +0000 (23:03 +0000)
Signed-off-by: Tiago Melo <tmelo@suse.com>
12 files changed:
src/pybind/mgr/dashboard/frontend/e2e/block/images.po.ts
src/pybind/mgr/dashboard/frontend/e2e/block/mirroring.po.ts
src/pybind/mgr/dashboard/frontend/e2e/cluster/configuration.po.ts
src/pybind/mgr/dashboard/frontend/e2e/cluster/crush-map.e2e-spec.ts
src/pybind/mgr/dashboard/frontend/e2e/cluster/logs.po.ts
src/pybind/mgr/dashboard/frontend/e2e/cluster/mgr-modules.po.ts
src/pybind/mgr/dashboard/frontend/e2e/helper.po.ts
src/pybind/mgr/dashboard/frontend/e2e/page-helper.po.ts
src/pybind/mgr/dashboard/frontend/e2e/pools/pools.po.ts
src/pybind/mgr/dashboard/frontend/e2e/rgw/buckets.po.ts
src/pybind/mgr/dashboard/frontend/e2e/rgw/users.po.ts
src/pybind/mgr/dashboard/frontend/e2e/user-mgmt.po.ts

index 97b4ab139d48201625106bf77af5005b4c99ae77..0b82b7131d905b6560d3872679aede31c27ee9bd 100644 (file)
@@ -1,5 +1,4 @@
 import { $, $$, browser, by, element } from 'protractor';
-import { Helper } from '../helper.po';
 import { PageHelper } from '../page-helper.po';
 
 export class ImagesPageHelper extends PageHelper {
@@ -30,7 +29,7 @@ export class ImagesPageHelper extends PageHelper {
 
     // Click the create button and wait for image to be made
     await element(by.cssContainingText('button', 'Create RBD')).click();
-    await browser.wait(Helper.EC.presenceOf(this.getTableCell(name)), Helper.TIMEOUT);
+    await this.waitPresence(this.getTableCell(name));
   }
 
   async editImage(name, pool, newName, newSize) {
@@ -50,7 +49,7 @@ export class ImagesPageHelper extends PageHelper {
 
     await element(by.cssContainingText('button', 'Edit RBD')).click();
     await this.navigateTo();
-    await browser.wait(Helper.EC.elementToBeClickable(this.getTableCell(newName)), Helper.TIMEOUT);
+    await this.waitClickable(this.getTableCell(newName));
     // click edit button and wait to make sure new owner is present in table
     await this.getTableCell(newName).click();
     await expect(
@@ -65,16 +64,16 @@ export class ImagesPageHelper extends PageHelper {
     await this.navigateTo();
 
     // wait for table to load
-    await browser.wait(Helper.EC.elementToBeClickable(this.getTableCell(name)), Helper.TIMEOUT);
+    await this.waitClickable(this.getTableCell(name));
     await this.getTableCell(name).click(); // click on the image you want to delete in the table
     await $$('.table-actions button.dropdown-toggle')
       .first()
       .click(); // click toggle menu
     await $('li.delete.ng-star-inserted').click(); // click delete
     // wait for pop-up to be visible (checks for title of pop-up)
-    await browser.wait(Helper.EC.visibilityOf($('.modal-body')), Helper.TIMEOUT);
+    await this.waitVisibility($('.modal-body'));
     await this.clickCheckbox($('.custom-control-label'));
     await element(by.cssContainingText('button', 'Delete RBD')).click();
-    await browser.wait(Helper.EC.stalenessOf(this.getTableCell(name)), Helper.TIMEOUT);
+    await this.waitStaleness(this.getTableCell(name));
   }
 }
index d428288a3f8d36e2433a09fecddaf66cf99580e3..6091b1a26acdc8eefabb69b82fa566b78ca26921 100644 (file)
@@ -1,5 +1,4 @@
-import { $, browser, by, element } from 'protractor';
-import { Helper } from '../helper.po';
+import { $, by, element } from 'protractor';
 import { PageHelper } from '../page-helper.po';
 
 const pages = { index: '/#/block/mirroring' };
@@ -14,30 +13,24 @@ export class MirroringPageHelper extends PageHelper {
   @PageHelper.restrictTo(pages.index)
   async editMirror(name, option) {
     // Clicks the pool in the table
-    await browser.wait(
-      Helper.EC.elementToBeClickable(this.getFirstTableCellWithText(name)),
-      Helper.TIMEOUT
-    );
+    await this.waitClickable(this.getFirstTableCellWithText(name));
     await this.getFirstTableCellWithText(name).click();
 
     // Clicks the Edit Mode button
     const editModeButton = element(by.cssContainingText('button', 'Edit Mode'));
-    await browser.wait(Helper.EC.elementToBeClickable(editModeButton), Helper.TIMEOUT);
+    await this.waitClickable(editModeButton);
     await editModeButton.click();
     // Clicks the drop down in the edit pop-up, then clicks the Update button
-    await browser.wait(Helper.EC.visibilityOf($('.modal-content')), Helper.TIMEOUT);
+    await this.waitVisibility($('.modal-content'));
     await element(by.id('mirrorMode')).click(); // Mode select box
     await element(by.cssContainingText('select[name=mirrorMode] option', option)).click();
 
     // Clicks update button and checks if the mode has been changed
     await element(by.cssContainingText('button', 'Update')).click();
-    await browser.wait(
-      Helper.EC.stalenessOf(
-        element(by.cssContainingText('.modal-dialog', 'Edit pool mirror mode'))
-      ),
-      Helper.TIMEOUT
+    await this.waitStaleness(
+      element(by.cssContainingText('.modal-dialog', 'Edit pool mirror mode'))
     );
     const val = option.toLowerCase(); // used since entries in table are lower case
-    await browser.wait(Helper.EC.visibilityOf(this.getFirstTableCellWithText(val)), Helper.TIMEOUT);
+    await this.waitVisibility(this.getFirstTableCellWithText(val));
   }
 }
index c489d9e9c26f99ab8be4d3068407e3d33386fdd7..c0f6d930afd083cc34106ffa9e04cd28528382d8 100644 (file)
@@ -1,5 +1,4 @@
-import { $, browser, by, element, protractor } from 'protractor';
-import { Helper } from '../helper.po';
+import { $, by, element, protractor } from 'protractor';
 import { PageHelper } from '../page-helper.po';
 
 export class ConfigurationPageHelper extends PageHelper {
@@ -19,7 +18,7 @@ export class ConfigurationPageHelper extends PageHelper {
     await $('input.form-control.ng-valid').sendKeys(name);
 
     // Selects config that we want to clear
-    await browser.wait(Helper.EC.elementToBeClickable(this.getTableCell(name)), Helper.TIMEOUT); // waits for config to be clickable
+    await this.waitClickable(this.getTableCell(name)); // waits for config to be clickable
     await this.getTableCell(name).click(); // click on the config to edit
     await element(by.cssContainingText('button', 'Edit')).click(); // clicks button to edit
 
@@ -35,22 +34,16 @@ export class ConfigurationPageHelper extends PageHelper {
     await $('input.form-control.ng-valid').clear();
     await $('input.form-control.ng-valid').sendKeys(name);
 
-    await browser.wait(Helper.EC.elementToBeClickable(this.getTableCell(name)), Helper.TIMEOUT);
+    await this.waitClickable(this.getTableCell(name));
     await this.getTableCell(name).click();
     // Clicks desired config
-    await browser.wait(
-      Helper.EC.visibilityOf($('.table.table-striped.table-bordered')), // Checks for visibility of details tab
-      Helper.TIMEOUT,
+    await this.waitVisibility(
+      $('.table.table-striped.table-bordered'), // Checks for visibility of details tab
       'config details did not appear'
     );
     for (const i of valList) {
       // Waits until values are not present in the details table
-      await browser.wait(
-        Helper.EC.not(
-          Helper.EC.textToBePresentInElement($('.table.table-striped.table-bordered'), i + ':')
-        ),
-        Helper.TIMEOUT
-      );
+      await this.waitTextNotPresent($('.table.table-striped.table-bordered'), i + ':');
     }
   }
 
@@ -66,7 +59,7 @@ export class ConfigurationPageHelper extends PageHelper {
     await $('input.form-control.ng-valid').sendKeys(name);
 
     // Selects config that we want to edit
-    await browser.wait(Helper.EC.elementToBeClickable(this.getTableCell(name)), Helper.TIMEOUT); // waits for config to be clickable
+    await this.waitClickable(this.getTableCell(name)); // waits for config to be clickable
     await this.getTableCell(name).click(); // click on the config to edit
     await element(by.cssContainingText('button', 'Edit')).click(); // clicks button to edit
 
@@ -86,19 +79,16 @@ export class ConfigurationPageHelper extends PageHelper {
     await $('input.form-control.ng-valid').clear();
     await $('input.form-control.ng-valid').sendKeys(name);
 
-    await browser.wait(Helper.EC.visibilityOf(this.getTableCell(name)), Helper.TIMEOUT);
+    await this.waitVisibility(this.getTableCell(name));
     // Checks for visibility of config in table
     await this.getTableCell(name).click();
     // Clicks config
     for (let i = 0, valtuple; (valtuple = values[i]); i++) {
       // iterates through list of values and
-      await browser.wait(
+      await this.waitTextToBePresent(
         // checks if the value appears in details with the correct number attatched
-        Helper.EC.textToBePresentInElement(
-          $('.table.table-striped.table-bordered'),
-          valtuple[0] + ': ' + valtuple[1]
-        ),
-        Helper.TIMEOUT
+        $('.table.table-striped.table-bordered'),
+        valtuple[0] + ': ' + valtuple[1]
       );
     }
   }
index 2ecfcd4c69a851274f2b4e9c45d265ee00b58a54..4761b6a2672c88d5272739b19443af53153191f2 100644 (file)
@@ -1,4 +1,4 @@
-import { $, browser } from 'protractor';
+import { $ } from 'protractor';
 import { Helper } from '../helper.po';
 import { CrushMapPageHelper } from './crush-map.po';
 
@@ -38,7 +38,7 @@ describe('CRUSH map page', () => {
       await expect(crushmap.getCrushNode(1).getText()).toEqual(label);
 
       // Check that table appears once OSD is clicked
-      await browser.wait(Helper.EC.visibilityOf($('.datatable-body')));
+      await crushmap.waitVisibility($('.datatable-body'));
       await expect($('.datatable-body').isDisplayed()).toBe(true);
     });
   });
index 2451e0dd20a51bda3c6c44b36c9d3afd8b5b419b..6bee8eb316a03273ccca6de15e39a343d2f0f2cc 100644 (file)
@@ -1,5 +1,4 @@
 import { $, $$, browser, by, element, protractor } from 'protractor';
-import { Helper } from '../helper.po';
 import { PageHelper } from '../page-helper.po';
 
 browser.ignoreSynchronization = true;
@@ -12,10 +11,7 @@ export class LogsPageHelper extends PageHelper {
 
     // sometimes the modal from deleting pool is still present at this point.
     // This wait makes sure it isn't
-    await browser.wait(
-      Helper.EC.stalenessOf(element(by.cssContainingText('.modal-dialog', 'Delete Pool'))),
-      Helper.TIMEOUT
-    );
+    await this.waitStaleness(element(by.cssContainingText('.modal-dialog', 'Delete Pool')));
 
     // go to audit logs tab
     await element(by.cssContainingText('.nav-link', 'Audit Logs')).click();
@@ -122,7 +118,7 @@ export class LogsPageHelper extends PageHelper {
     const audit_logs_body = audit_logs_tab.element(by.css('.card-body'));
     const logs = audit_logs_body.all(by.cssContainingText('.ng-star-inserted', configname));
 
-    await browser.wait(Helper.EC.presenceOf(logs.first()), Helper.TIMEOUT);
+    await this.waitPresence(logs.first());
 
     await expect(logs.getText()).toMatch(configname);
     await expect(logs.getText()).toMatch(setting);
index 03ece75d69c6decb90c772232f9061ec4e99d3de..28e3edf30ed14688c56488988b140df4ca1bc20f 100644 (file)
@@ -1,5 +1,4 @@
-import { $$, browser, by, element } from 'protractor';
-import { Helper } from '../helper.po';
+import { $$, by, element } from 'protractor';
 import { PageHelper } from '../page-helper.po';
 
 export class ManagerModulesPageHelper extends PageHelper {
@@ -17,7 +16,7 @@ export class ManagerModulesPageHelper extends PageHelper {
     // Doesn't check/uncheck boxes because it is not reflected in the details table.
     // DOES NOT WORK FOR ALL MGR MODULES, for example, Device health
     await this.navigateTo();
-    await browser.wait(Helper.EC.elementToBeClickable(this.getTableCell(name)), Helper.TIMEOUT);
+    await this.waitClickable(this.getTableCell(name));
     await this.getTableCell(name).click();
     await element(by.cssContainingText('button', 'Edit')).click();
 
@@ -30,18 +29,15 @@ export class ManagerModulesPageHelper extends PageHelper {
     await element(by.cssContainingText('button', 'Update')).click();
     // Checks if edits appear
     await this.navigateTo();
-    await browser.wait(Helper.EC.visibilityOf(this.getTableCell(name)), Helper.TIMEOUT);
+    await this.waitVisibility(this.getTableCell(name));
     await this.getTableCell(name).click();
     for (const entry of tuple) {
-      await browser.wait(
-        Helper.EC.textToBePresentInElement($$('.datatable-body').last(), entry[0]),
-        Helper.TIMEOUT
-      );
+      await this.waitTextToBePresent($$('.datatable-body').last(), entry[0]);
     }
 
     // Clear mgr module of all edits made to it
     await this.navigateTo();
-    await browser.wait(Helper.EC.elementToBeClickable(this.getTableCell(name)), Helper.TIMEOUT);
+    await this.waitClickable(this.getTableCell(name));
     await this.getTableCell(name).click();
     await element(by.cssContainingText('button', 'Edit')).click();
 
@@ -53,13 +49,10 @@ export class ManagerModulesPageHelper extends PageHelper {
     // Checks that clearing represents in details tab of module
     await element(by.cssContainingText('button', 'Update')).click();
     await this.navigateTo();
-    await browser.wait(Helper.EC.visibilityOf(this.getTableCell(name)), Helper.TIMEOUT);
+    await this.waitVisibility(this.getTableCell(name));
     await this.getTableCell(name).click();
     for (const entry of tuple) {
-      await browser.wait(
-        Helper.EC.not(Helper.EC.textToBePresentInElement($$('.datatable-body').last(), entry[0])),
-        Helper.TIMEOUT
-      );
+      await this.waitTextNotPresent($$('.datatable-body').last(), entry[0]);
     }
   }
 
@@ -86,10 +79,7 @@ export class ManagerModulesPageHelper extends PageHelper {
       [warn, 'warn_threshold']
     ];
 
-    await browser.wait(
-      Helper.EC.elementToBeClickable(this.getTableCell('devicehealth')),
-      Helper.TIMEOUT
-    );
+    await this.waitClickable(this.getTableCell('devicehealth'));
     await this.getTableCell('devicehealth').click();
     await element(by.cssContainingText('button', 'Edit')).click();
     for (let i = 0, devHealthTuple; (devHealthTuple = devHealthArray[i]); i++) {
@@ -102,19 +92,16 @@ export class ManagerModulesPageHelper extends PageHelper {
 
     await element(by.cssContainingText('button', 'Update')).click();
     await this.navigateTo();
-    await browser.wait(Helper.EC.visibilityOf(this.getTableCell('devicehealth')), Helper.TIMEOUT);
+    await this.waitVisibility(this.getTableCell('devicehealth'));
     // Checks for visibility of devicehealth in table
     await this.getTableCell('devicehealth').click();
     for (let i = 0, devHealthTuple; (devHealthTuple = devHealthArray[i]); i++) {
       if (devHealthTuple[0] !== undefined) {
-        await browser.wait(async function() {
+        await this.waitFn(async () => {
           // Repeatedly reclicks the module to check if edits has been done
           await element(by.cssContainingText('.datatable-body-cell-label', 'devicehealth')).click();
-          return Helper.EC.textToBePresentInElement(
-            $$('.datatable-body').last(),
-            devHealthTuple[0]
-          );
-        }, Helper.TIMEOUT);
+          return this.waitTextToBePresent($$('.datatable-body').last(), devHealthTuple[0]);
+        });
       }
     }
 
@@ -123,10 +110,7 @@ export class ManagerModulesPageHelper extends PageHelper {
     // (on my local run of ceph-dev, this is subject to change i would assume). I'd imagine there is a
     // better way of doing this.
     await this.navigateTo();
-    await browser.wait(
-      Helper.EC.elementToBeClickable(this.getTableCell('devicehealth')),
-      Helper.TIMEOUT
-    ); // checks ansible
+    await this.waitClickable(this.getTableCell('devicehealth')); // checks ansible
     await this.getTableCell('devicehealth').click();
     await element(by.cssContainingText('button', 'Edit')).click();
     await this.clearInput(element(by.id('mark_out_threshold')));
@@ -148,22 +132,18 @@ export class ManagerModulesPageHelper extends PageHelper {
     await element(by.id('warn_threshold')).sendKeys('7257600');
 
     // Checks that clearing represents in details tab of ansible
-    await browser.wait(
-      Helper.EC.elementToBeClickable(element(by.cssContainingText('button', 'Update')))
-    );
+    await this.waitClickable(element(by.cssContainingText('button', 'Update')));
     await element(by.cssContainingText('button', 'Update')).click();
     await this.navigateTo();
-    await browser.wait(Helper.EC.visibilityOf(this.getTableCell('devicehealth')), Helper.TIMEOUT);
+    await this.waitVisibility(this.getTableCell('devicehealth'));
     await this.getTableCell('devicehealth').click();
     for (let i = 0, devHealthTuple; (devHealthTuple = devHealthArray[i]); i++) {
       if (devHealthTuple[0] !== undefined) {
-        await browser.wait(async function() {
+        await this.waitFn(async () => {
           // Repeatedly reclicks the module to check if clearing has been done
           await element(by.cssContainingText('.datatable-body-cell-label', 'devicehealth')).click();
-          return Helper.EC.not(
-            Helper.EC.textToBePresentInElement($$('.datatable-body').last(), devHealthTuple[0])
-          );
-        }, Helper.TIMEOUT);
+          return this.waitTextNotPresent($$('.datatable-body').last(), devHealthTuple[0]);
+        });
       }
     }
   }
index aac6416e81ae5fd92af2d415d564d5f5350b1c9f..1bf9ca2131bdbdc0d5c411e3d6a7a48beeccb4f2 100644 (file)
@@ -20,9 +20,6 @@ import { UsersPageHelper } from './rgw/users.po';
 import { UserMgmtPageHelper } from './user-mgmt.po';
 
 export class Helper {
-  static EC = browser.ExpectedConditions;
-  static TIMEOUT = 10000;
-
   pools: PoolPageHelper;
   buckets: BucketsPageHelper;
   images: ImagesPageHelper;
index 70b34fbc6645897849a1c92f34b1bbd138123a02..519344a364fdc1f04f3b7b2128a14eba53fe56e1 100644 (file)
@@ -8,9 +8,9 @@ import {
   ElementFinder,
   protractor
 } from 'protractor';
-import { Helper } from './helper.po';
 
 const EC = browser.ExpectedConditions;
+const TIMEOUT = 20000;
 
 interface Pages {
   index: string;
@@ -64,7 +64,7 @@ export abstract class PageHelper {
         if (tableCount > 0) {
           const progressBars = element.all(by.css('cd-table datatable-progress'));
           await progressBars.each(async (progressBar) => {
-            await browser.wait(EC.not(EC.presenceOf(progressBar)), Helper.TIMEOUT);
+            await browser.wait(EC.stalenessOf(progressBar), TIMEOUT);
           });
         }
 
@@ -234,4 +234,36 @@ export abstract class PageHelper {
   getLegends(): ElementArrayFinder {
     return $$('legend');
   }
+
+  async waitPresence(elem: ElementFinder, message?: string) {
+    return browser.wait(EC.presenceOf(elem), TIMEOUT, message);
+  }
+
+  async waitStaleness(elem: ElementFinder, message?: string) {
+    return browser.wait(EC.stalenessOf(elem), TIMEOUT, message);
+  }
+
+  async waitClickable(elem: ElementFinder, message?: string) {
+    return browser.wait(EC.elementToBeClickable(elem), TIMEOUT, message);
+  }
+
+  async waitVisibility(elem: ElementFinder, message?: string) {
+    return browser.wait(EC.visibilityOf(elem), TIMEOUT, message);
+  }
+
+  async waitInvisibility(elem: ElementFinder, message?: string) {
+    return browser.wait(EC.invisibilityOf(elem), TIMEOUT, message);
+  }
+
+  async waitTextToBePresent(elem: ElementFinder, text: string, message?: string) {
+    return browser.wait(EC.textToBePresentInElement(elem, text), TIMEOUT, message);
+  }
+
+  async waitTextNotPresent(elem: ElementFinder, text: string, message?: string) {
+    return browser.wait(EC.not(EC.textToBePresentInElement(elem, text)), TIMEOUT, message);
+  }
+
+  async waitFn(func: Function, message?: string) {
+    return browser.wait(func, TIMEOUT, message);
+  }
 }
index cf9e94c073a04d960c288c011be996922638e9bf..404811ecbb02cdf29ee1d624b0a3c7b3be0b4d19 100644 (file)
@@ -1,8 +1,6 @@
-import { $, browser, by, element, protractor } from 'protractor';
-import { Helper } from '../helper.po';
+import { $, by, element, protractor } from 'protractor';
 import { PageHelper } from '../page-helper.po';
 
-const EC = protractor.ExpectedConditions;
 const pages = {
   index: '/#/pool',
   create: '/#/pool/create'
@@ -19,9 +17,9 @@ export class PoolPageHelper extends PageHelper {
   @PageHelper.restrictTo(pages.index)
   async exist(name: string, oughtToBePresent = true) {
     const tableCell = await this.getTableCellByContent(name);
-    const waitFn = oughtToBePresent ? EC.visibilityOf(tableCell) : EC.invisibilityOf(tableCell);
+    const waitFn = oughtToBePresent ? this.waitVisibility : this.waitInvisibility;
     try {
-      await browser.wait(waitFn, Helper.TIMEOUT);
+      await waitFn(tableCell);
     } catch (e) {
       const visibility = oughtToBePresent ? 'invisible' : 'visible';
       const msg = `Pool "${name}" is ${visibility}, but should not be. Waiting for a change timed out`;
@@ -66,14 +64,10 @@ export class PoolPageHelper extends PageHelper {
     await $('input[name=pgNum]').sendKeys(protractor.Key.CONTROL, 'a', protractor.Key.NULL, new_pg);
     await element(by.css('cd-submit-button')).click();
     const str = `${new_pg} active+clean`;
-    await browser.wait(
-      EC.visibilityOf(this.getTableRow(name)),
-      Helper.TIMEOUT,
-      'Timed out waiting for table row to load'
-    );
-    await browser.wait(
-      EC.textToBePresentInElement(this.getTableRow(name), str),
-      Helper.TIMEOUT,
+    await this.waitVisibility(this.getTableRow(name), 'Timed out waiting for table row to load');
+    await this.waitTextToBePresent(
+      this.getTableRow(name),
+      str,
       'Timed out waiting for placement group to be updated'
     );
   }
@@ -83,10 +77,7 @@ export class PoolPageHelper extends PageHelper {
       return;
     }
     await element(by.css('.float-left.mr-2.select-menu-edit')).click();
-    await browser.wait(
-      Helper.EC.visibilityOf(element(by.css('.popover-content.popover-body'))),
-      Helper.TIMEOUT
-    );
+    await this.waitVisibility(element(by.css('.popover-content.popover-body')));
     apps.forEach(
       async (app) => await element(by.cssContainingText('.select-menu-item-content', app)).click()
     );
@@ -99,7 +90,7 @@ export class PoolPageHelper extends PageHelper {
     await $('.table-actions button.dropdown-toggle').click(); // open submenu
     await $('li.delete a').click(); // click on "delete" menu item
     const confirmationInput = () => $('#confirmation');
-    await browser.wait(() => EC.visibilityOf(confirmationInput()), Helper.TIMEOUT);
+    await this.waitPresence(confirmationInput());
     await this.clickCheckbox(confirmationInput());
     await element(by.cssContainingText('button', 'Delete Pool')).click(); // Click Delete item
 
index 8db2b4fd4093b300cbf3f6885683c5b510973539..57d9041819de7d04463c1106dfdf9954adc03cec 100644 (file)
@@ -1,5 +1,4 @@
-import { $, browser, by, element } from 'protractor';
-import { Helper } from '../helper.po';
+import { $, by, element } from 'protractor';
 import { PageHelper } from '../page-helper.po';
 
 const pages = {
@@ -35,11 +34,7 @@ export class BucketsPageHelper extends PageHelper {
     const createButton = element(by.cssContainingText('button', 'Create Bucket'));
     await createButton.click();
 
-    return browser.wait(
-      Helper.EC.presenceOf(this.getTableCell(name)),
-      Helper.TIMEOUT,
-      'Timed out waiting for bucket creation'
-    );
+    return this.waitPresence(this.getTableCell(name), 'Timed out waiting for bucket creation');
   }
 
   @PageHelper.restrictTo(pages.index)
@@ -55,9 +50,8 @@ export class BucketsPageHelper extends PageHelper {
     await element(by.cssContainingText('button', 'Edit Bucket')).click();
 
     // wait to be back on buckets page with table visible
-    await browser.wait(
-      Helper.EC.elementToBeClickable(this.getTableCell(name)),
-      10000,
+    await this.waitClickable(
+      this.getTableCell(name),
       'Could not return to buckets page and load table after editing bucket'
     );
 
@@ -73,21 +67,18 @@ export class BucketsPageHelper extends PageHelper {
   @PageHelper.restrictTo(pages.index)
   async delete(name) {
     // wait for table to load
-    await browser.wait(Helper.EC.elementToBeClickable(this.getTableCell(name)), Helper.TIMEOUT);
+    await this.waitClickable(this.getTableCell(name));
 
     await this.getTableCell(name).click(); // click on the bucket you want to delete in the table
     await $('.table-actions button.dropdown-toggle').click(); // click toggle menu
     await $('li.delete a').click(); // click delete
     // wait for pop-up to be visible (checks for title of pop-up)
-    await browser.wait(Helper.EC.visibilityOf($('.modal-title.float-left')), Helper.TIMEOUT);
-    await browser.wait(Helper.EC.visibilityOf($('.custom-control-label')), Helper.TIMEOUT);
+    await this.waitVisibility($('.modal-title.float-left'));
+    await this.waitVisibility($('.custom-control-label'));
     await $('.custom-control-label').click();
     await element(by.cssContainingText('button', 'Delete bucket')).click();
     await this.navigateTo();
-    return browser.wait(
-      Helper.EC.not(Helper.EC.presenceOf(this.getTableCell(name))),
-      Helper.TIMEOUT
-    );
+    return this.waitStaleness(this.getTableCell(name));
   }
 
   async testInvalidCreate() {
@@ -100,15 +91,11 @@ export class BucketsPageHelper extends PageHelper {
 
     await ownerDropDown.click(); // To trigger a validation
 
-    await browser.wait(
-      async () => {
-        // Waiting for website to decide if name is valid or not
-        const klass = await nameInputField.getAttribute('class');
-        return !klass.includes('ng-pending');
-      },
-      5000,
-      'Timed out waiting for dashboard to decide bucket name validity'
-    );
+    await this.waitFn(async () => {
+      // Waiting for website to decide if name is valid or not
+      const klass = await nameInputField.getAttribute('class');
+      return !klass.includes('ng-pending');
+    }, 'Timed out waiting for dashboard to decide bucket name validity');
 
     // Check that name input field was marked invalid in the css
     await expect(nameInputField.getAttribute('class')).toContain('ng-invalid');
@@ -166,9 +153,8 @@ export class BucketsPageHelper extends PageHelper {
   async testInvalidEdit(name) {
     await this.navigateTo();
 
-    await browser.wait(
-      Helper.EC.elementToBeClickable(this.getTableCell(name)),
-      10000,
+    await this.waitClickable(
+      this.getTableCell(name),
       'Failed waiting for bucket to be present in table'
     ); // wait for table to load
     await this.getTableCell(name).click(); // click on the bucket you want to edit in the table
@@ -179,7 +165,7 @@ export class BucketsPageHelper extends PageHelper {
     // Chooses 'Select a user' rather than a valid owner on Edit Bucket page
     // and checks if it's an invalid input
     const ownerDropDown = element(by.id('owner'));
-    await browser.wait(Helper.EC.elementToBeClickable(ownerDropDown), Helper.TIMEOUT);
+    await this.waitClickable(ownerDropDown);
     await ownerDropDown.click(); // Clicks the Owner drop down on the Create Bucket page
 
     // select the first option, which is invalid because it is a placeholder
index 96734b0074085666455169d947aa8f3bbdfb736a..ff988b10661eb7f76e32416f31dc2d15757fd410 100644 (file)
@@ -1,6 +1,5 @@
-import { $, browser, by, element } from 'protractor';
+import { $, by, element } from 'protractor';
 import { protractor } from 'protractor/built/ptor';
-import { Helper } from '../helper.po';
 import { PageHelper } from '../page-helper.po';
 
 export class UsersPageHelper extends PageHelper {
@@ -30,13 +29,13 @@ export class UsersPageHelper extends PageHelper {
 
     // Click the create button and wait for user to be made
     await element(by.cssContainingText('button', 'Create User')).click();
-    await browser.wait(Helper.EC.presenceOf(this.getTableCell(username)), 10000);
+    await this.waitPresence(this.getTableCell(username));
   }
 
   async edit(name, new_fullname, new_email, new_maxbuckets) {
     await this.navigateTo();
 
-    await browser.wait(Helper.EC.elementToBeClickable(this.getTableCell(name)), 10000); // wait for table to load
+    await this.waitClickable(this.getTableCell(name)); // wait for table to load
     await this.getTableCell(name).click(); // click on the bucket you want to edit in the table
     await element(by.cssContainingText('button', 'Edit')).click(); // click button to move to edit page
 
@@ -59,7 +58,7 @@ export class UsersPageHelper extends PageHelper {
 
     const editbutton = element(by.cssContainingText('button', 'Edit User'));
     await editbutton.click();
-    await browser.wait(Helper.EC.elementToBeClickable(this.getTableCell(name)), 10000);
+    await this.waitClickable(this.getTableCell(name));
     // Click the user and check its details table for updated content
     await this.getTableCell(name).click();
     await expect($('.active.tab-pane').getText()).toMatch(new_fullname); // check full name was changed
@@ -72,21 +71,18 @@ export class UsersPageHelper extends PageHelper {
 
     // wait for table to load
     const my_user = this.getFirstTableCellWithText(name);
-    await browser.wait(Helper.EC.elementToBeClickable(my_user), 10000);
+    await this.waitClickable(my_user);
 
     await my_user.click(); // click on the user you want to delete in the table
     await $('.table-actions button.dropdown-toggle').click(); // click toggle menu
     await $('li.delete a').click(); // click delete
 
     // wait for pop-up to be visible (checks for title of pop-up)
-    await browser.wait(Helper.EC.visibilityOf($('.modal-title.float-left')), 10000);
-    await browser.wait(Helper.EC.visibilityOf($('.custom-control-label')), 5000);
+    await this.waitVisibility($('.modal-title.float-left'));
+    await this.waitVisibility($('.custom-control-label'));
     await $('.custom-control-label').click(); // click confirmation checkbox
     await element(by.cssContainingText('button', 'Delete user')).click();
-    await browser.wait(
-      Helper.EC.not(Helper.EC.presenceOf(this.getFirstTableCellWithText(name))),
-      10000
-    );
+    await this.waitStaleness(this.getFirstTableCellWithText(name));
   }
 
   async invalidCreate() {
@@ -104,9 +100,8 @@ export class UsersPageHelper extends PageHelper {
     // Try to give user already taken name. Should make field invalid.
     await username_field.clear();
     await username_field.sendKeys(uname);
-    await browser.wait(
-      async () => !(await username_field.getAttribute('class')).includes('ng-pending'),
-      6000
+    await this.waitFn(
+      async () => !(await username_field.getAttribute('class')).includes('ng-pending')
     );
     await expect(username_field.getAttribute('class')).toContain('ng-invalid');
     await element(by.id('display_name')).click(); // trigger validation check
@@ -166,7 +161,7 @@ export class UsersPageHelper extends PageHelper {
 
     await this.navigateTo();
 
-    await browser.wait(Helper.EC.elementToBeClickable(this.getTableCell(uname)), 10000); // wait for table to load
+    await this.waitClickable(this.getTableCell(uname)); // wait for table to load
     await this.getTableCell(uname).click(); // click on the bucket you want to edit in the table
     await element(by.cssContainingText('button', 'Edit')).click(); // click button to move to edit page
 
@@ -176,9 +171,8 @@ export class UsersPageHelper extends PageHelper {
     await element(by.id('email')).click();
     await element(by.id('email')).clear();
     await element(by.id('email')).sendKeys('a');
-    await browser.wait(
-      async () => !(await element(by.id('email')).getAttribute('class')).includes('ng-pending'),
-      6000
+    await this.waitFn(
+      async () => !(await element(by.id('email')).getAttribute('class')).includes('ng-pending')
     );
     await expect(element(by.id('email')).getAttribute('class')).toContain('ng-invalid');
     await element(by.id('display_name')).click(); // trigger validation check
index 48a2fadb1664c2abd7c1018b20c32763515bb327..8b4de347a2a91dc25cdf136c05970dd7388b9ae1 100644 (file)
@@ -1,5 +1,4 @@
-import { $, browser, by, element } from 'protractor';
-import { Helper } from './helper.po';
+import { $, by, element } from 'protractor';
 import { PageHelper } from './page-helper.po';
 
 export class UserMgmtPageHelper extends PageHelper {
@@ -24,7 +23,7 @@ export class UserMgmtPageHelper extends PageHelper {
     // Click the create button and wait for user to be made
     const createButton = element(by.cssContainingText('button', 'Create User'));
     await createButton.click();
-    await browser.wait(Helper.EC.presenceOf(this.getTableCell(username)), Helper.TIMEOUT);
+    await this.waitPresence(this.getTableCell(username));
   }
 
   async userEdit(username, password, name, email): Promise<void> {
@@ -46,8 +45,8 @@ export class UserMgmtPageHelper extends PageHelper {
     // Click the edit button and check new values are present in table
     const editButton = element(by.cssContainingText('button', 'Edit User'));
     await editButton.click();
-    await browser.wait(Helper.EC.presenceOf(this.getTableCell(email)), Helper.TIMEOUT);
-    await browser.wait(Helper.EC.presenceOf(this.getTableCell(name)), Helper.TIMEOUT);
+    await this.waitPresence(this.getTableCell(email));
+    await this.waitPresence(this.getTableCell(name));
   }
 
   async userDelete(username): Promise<void> {
@@ -57,13 +56,10 @@ export class UserMgmtPageHelper extends PageHelper {
     await $('.table-actions button.dropdown-toggle').click(); // click toggle menu
     await $('li.delete a').click(); // click delete
 
-    await browser.wait(Helper.EC.visibilityOf($('.custom-control-label')), Helper.TIMEOUT);
+    await this.waitVisibility($('.custom-control-label'));
     await $('.custom-control-label').click(); // click confirmation checkbox
     await element(by.cssContainingText('button', 'Delete User')).click();
-    await browser.wait(
-      Helper.EC.stalenessOf(this.getFirstTableCellWithText(username)),
-      Helper.TIMEOUT
-    );
+    await this.waitStaleness(this.getFirstTableCellWithText(username));
   }
 
   async roleCreate(name, description): Promise<void> {
@@ -76,7 +72,7 @@ export class UserMgmtPageHelper extends PageHelper {
     // Click the create button and wait for user to be made
     const createButton = element(by.cssContainingText('button', 'Create Role'));
     await createButton.click();
-    await browser.wait(Helper.EC.presenceOf(this.getTableCell(name)), Helper.TIMEOUT);
+    await this.waitPresence(this.getTableCell(name));
   }
 
   async roleEdit(name, description): Promise<void> {
@@ -93,8 +89,8 @@ export class UserMgmtPageHelper extends PageHelper {
     const editButton = element(by.cssContainingText('button', 'Edit Role'));
     await editButton.click();
 
-    await browser.wait(Helper.EC.presenceOf(this.getTableCell(name)), Helper.TIMEOUT);
-    await browser.wait(Helper.EC.presenceOf(this.getTableCell(description)), Helper.TIMEOUT);
+    await this.waitPresence(this.getTableCell(name));
+    await this.waitPresence(this.getTableCell(description));
   }
 
   async roleDelete(name) {
@@ -104,9 +100,9 @@ export class UserMgmtPageHelper extends PageHelper {
     await $('.table-actions button.dropdown-toggle').click(); // click toggle menu
     await $('li.delete a').click(); // click delete
 
-    await browser.wait(Helper.EC.visibilityOf($('.custom-control-label')), Helper.TIMEOUT);
+    await this.waitVisibility($('.custom-control-label'));
     await $('.custom-control-label').click(); // click confirmation checkbox
     await element(by.cssContainingText('button', 'Delete Role')).click();
-    await browser.wait(Helper.EC.stalenessOf(this.getFirstTableCellWithText(name)), Helper.TIMEOUT);
+    await this.waitStaleness(this.getFirstTableCellWithText(name));
   }
 }