]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: Add click call inside waitClickable
authorTiago Melo <tmelo@suse.com>
Mon, 9 Sep 2019 16:03:16 +0000 (16:03 +0000)
committerTiago Melo <tmelo@suse.com>
Wed, 11 Sep 2019 11:13:08 +0000 (11:13 +0000)
All waitClickable calls were being followed by a click.
This will remove the need for the click call.

Signed-off-by: Tiago Melo <tmelo@suse.com>
src/pybind/mgr/dashboard/frontend/e2e/block/images.e2e-spec.ts
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/mgr-modules.po.ts
src/pybind/mgr/dashboard/frontend/e2e/page-helper.po.ts
src/pybind/mgr/dashboard/frontend/e2e/rgw/buckets.po.ts
src/pybind/mgr/dashboard/frontend/e2e/rgw/users.po.ts

index 8aab7eae6125988d1202447223897467e94a29e8..2b1fa1db2f3caeb418e493b4cd3e0d31f2522917 100644 (file)
@@ -101,10 +101,6 @@ describe('Images page', () => {
         images.getFirstTableCellWithText(newImageName),
         'Timed out waiting for image to restore'
       );
-      await images.waitClickable(
-        images.getFirstTableCellWithText(newImageName),
-        'Timed out waiting for image to be clickable'
-      );
       await images.moveToTrash(newImageName);
       await images.purgeTrash(newImageName, poolName);
     });
index 73ef05fcebd97c35b5d0233e81fc1830c040b6a7..c9878c08998bb1e32eec4d425ec3764f2fbc21f7 100644 (file)
@@ -49,9 +49,7 @@ export class ImagesPageHelper extends PageHelper {
 
     await element(by.cssContainingText('button', 'Edit RBD')).click();
     await this.navigateTo();
-    await this.waitClickable(this.getFirstTableCellWithText(newName));
-    // click edit button and wait to make sure new owner is present in table
-    await this.getFirstTableCellWithText(newName).click();
+    await this.waitClickableAndClick(this.getFirstTableCellWithText(newName));
     await expect(
       element
         .all(by.css('.table.table-striped.table-bordered'))
@@ -66,8 +64,7 @@ export class ImagesPageHelper extends PageHelper {
     await this.navigateTo();
     // wait for image to be created
     await this.waitTextNotPresent($$('.datatable-body').first(), '(Creating...)');
-    await this.waitClickable(this.getFirstTableCellWithText(name));
-    await this.getFirstTableCellWithText(name).click();
+    await this.waitClickableAndClick(this.getFirstTableCellWithText(name));
     // click on the drop down and selects the move to trash option
     await $$('.table-actions button.dropdown-toggle')
       .first()
@@ -77,8 +74,7 @@ export class ImagesPageHelper extends PageHelper {
     await element(by.cssContainingText('button', 'Move Image')).click();
     await this.navigateTo();
     // Clicks trash tab
-    await this.waitClickable(element(by.cssContainingText('.nav-link', 'Trash')));
-    await element(by.cssContainingText('.nav-link', 'Trash')).click();
+    await this.waitClickableAndClick(element(by.cssContainingText('.nav-link', 'Trash')));
     await this.waitPresence(this.getFirstTableCellWithText(name));
   }
 
@@ -89,8 +85,7 @@ export class ImagesPageHelper extends PageHelper {
     // clicks on trash tab
     await element(by.cssContainingText('.nav-link', 'Trash')).click();
     // wait for table to load
-    await this.waitClickable(this.getFirstTableCellWithText(name));
-    await this.getFirstTableCellWithText(name).click();
+    await this.waitClickableAndClick(this.getFirstTableCellWithText(name));
     await element(by.cssContainingText('button', 'Restore')).click();
     // wait for pop-up to be visible (checks for title of pop-up)
     await this.waitVisibility(element(by.id('name')));
@@ -125,8 +120,7 @@ export class ImagesPageHelper extends PageHelper {
       await $(getPoolName).click();
       await expect(element(by.id('poolName')).getAttribute('class')).toContain('ng-valid'); // check if pool is selected
     }
-    await this.waitClickable(element(by.id('purgeFormButton')));
-    await element(by.id('purgeFormButton')).click();
+    await this.waitClickableAndClick(element(by.id('purgeFormButton')));
     // Wait for image to delete and check it is not present
     await this.waitStaleness(
       this.getFirstTableCellWithText(name),
index 6091b1a26acdc8eefabb69b82fa566b78ca26921..1cb31168425ac4e7442a2d0c199a91bfb0d29216 100644 (file)
@@ -13,13 +13,11 @@ export class MirroringPageHelper extends PageHelper {
   @PageHelper.restrictTo(pages.index)
   async editMirror(name, option) {
     // Clicks the pool in the table
-    await this.waitClickable(this.getFirstTableCellWithText(name));
-    await this.getFirstTableCellWithText(name).click();
+    await this.waitClickableAndClick(this.getFirstTableCellWithText(name));
 
     // Clicks the Edit Mode button
     const editModeButton = element(by.cssContainingText('button', 'Edit Mode'));
-    await this.waitClickable(editModeButton);
-    await editModeButton.click();
+    await this.waitClickableAndClick(editModeButton);
     // Clicks the drop down in the edit pop-up, then clicks the Update button
     await this.waitVisibility($('.modal-content'));
     await element(by.id('mirrorMode')).click(); // Mode select box
index 3ddc22f4190c0cf4b4851553e94cd97bd07ec1d1..c92dbfcaae320097660d906a156a638d78f971e7 100644 (file)
@@ -18,8 +18,7 @@ export class ConfigurationPageHelper extends PageHelper {
     await $('input.form-control.ng-valid').sendKeys(name);
 
     // Selects config that we want to clear
-    await this.waitClickable(this.getFirstTableCellWithText(name)); // waits for config to be clickable
-    await this.getFirstTableCellWithText(name).click(); // click on the config to edit
+    await this.waitClickableAndClick(this.getFirstTableCellWithText(name)); // waits for config to be clickable and click
     await element(by.cssContainingText('button', 'Edit')).click(); // clicks button to edit
 
     for (const i of valList) {
@@ -34,8 +33,7 @@ export class ConfigurationPageHelper extends PageHelper {
     await $('input.form-control.ng-valid').clear();
     await $('input.form-control.ng-valid').sendKeys(name);
 
-    await this.waitClickable(this.getFirstTableCellWithText(name));
-    await this.getFirstTableCellWithText(name).click();
+    await this.waitClickableAndClick(this.getFirstTableCellWithText(name));
     // Clicks desired config
     await this.waitVisibility(
       $('.table.table-striped.table-bordered'), // Checks for visibility of details tab
@@ -59,8 +57,7 @@ export class ConfigurationPageHelper extends PageHelper {
     await $('input.form-control.ng-valid').sendKeys(name);
 
     // Selects config that we want to edit
-    await this.waitClickable(this.getFirstTableCellWithText(name)); // waits for config to be clickable
-    await this.getFirstTableCellWithText(name).click(); // click on the config to edit
+    await this.waitClickableAndClick(this.getFirstTableCellWithText(name)); // waits for config to be clickable and click
     await element(by.cssContainingText('button', 'Edit')).click(); // clicks button to edit
 
     await this.waitTextToBePresent(this.getBreadcrumb(), 'Edit');
index 784b6a1d94608e0b6566ca1de83023598fa234c6..f9ff2690fa5ec2e01d819efc60e5269d47daf882 100644 (file)
@@ -16,8 +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 this.waitClickable(this.getFirstTableCellWithText(name));
-    await this.getFirstTableCellWithText(name).click();
+    await this.waitClickableAndClick(this.getFirstTableCellWithText(name));
     await element(by.cssContainingText('button', 'Edit')).click();
 
     for (const entry of tuple) {
@@ -37,8 +36,7 @@ export class ManagerModulesPageHelper extends PageHelper {
 
     // Clear mgr module of all edits made to it
     await this.navigateTo();
-    await this.waitClickable(this.getFirstTableCellWithText(name));
-    await this.getFirstTableCellWithText(name).click();
+    await this.waitClickableAndClick(this.getFirstTableCellWithText(name));
     await element(by.cssContainingText('button', 'Edit')).click();
 
     // Clears the editable fields
@@ -79,8 +77,7 @@ export class ManagerModulesPageHelper extends PageHelper {
       [warn, 'warn_threshold']
     ];
 
-    await this.waitClickable(this.getFirstTableCellWithText('devicehealth'));
-    await this.getFirstTableCellWithText('devicehealth').click();
+    await this.waitClickableAndClick(this.getFirstTableCellWithText('devicehealth'));
     await element(by.cssContainingText('button', 'Edit')).click();
     for (let i = 0, devHealthTuple; (devHealthTuple = devHealthArray[i]); i++) {
       if (devHealthTuple[0] !== undefined) {
@@ -110,8 +107,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 this.waitClickable(this.getFirstTableCellWithText('devicehealth')); // checks ansible
-    await this.getFirstTableCellWithText('devicehealth').click();
+    await this.waitClickableAndClick(this.getFirstTableCellWithText('devicehealth')); // checks ansible
     await element(by.cssContainingText('button', 'Edit')).click();
     await this.clearInput(element(by.id('mark_out_threshold')));
     await element(by.id('mark_out_threshold')).sendKeys('2419200');
@@ -132,8 +128,7 @@ export class ManagerModulesPageHelper extends PageHelper {
     await element(by.id('warn_threshold')).sendKeys('7257600');
 
     // Checks that clearing represents in details tab of ansible
-    await this.waitClickable(element(by.cssContainingText('button', 'Update')));
-    await element(by.cssContainingText('button', 'Update')).click();
+    await this.waitClickableAndClick(element(by.cssContainingText('button', 'Update')));
     await this.navigateTo();
     await this.waitVisibility(this.getFirstTableCellWithText('devicehealth'));
     await this.getFirstTableCellWithText('devicehealth').click();
index 5fcbfd65e596258ba5b9bd05d0be5d5d155f9b55..1cacf01dff893d8762d4b55c5bda4b390f820a7a 100644 (file)
@@ -176,8 +176,7 @@ export abstract class PageHelper {
       );
     }
 
-    await this.waitClickable(label);
-    return label.click();
+    return this.waitClickableAndClick(label);
   }
 
   /**
@@ -270,8 +269,12 @@ export abstract class PageHelper {
     return browser.wait(EC.stalenessOf(elem), TIMEOUT, message);
   }
 
-  async waitClickable(elem: ElementFinder, message?: string) {
-    return browser.wait(EC.elementToBeClickable(elem), TIMEOUT, message);
+  /**
+   * This method will wait for the element to be clickable and then click it.
+   */
+  async waitClickableAndClick(elem: ElementFinder, message?: string) {
+    await browser.wait(EC.elementToBeClickable(elem), TIMEOUT, message);
+    return elem.click();
   }
 
   async waitVisibility(elem: ElementFinder, message?: string) {
@@ -305,8 +308,7 @@ export abstract class PageHelper {
    */
   async delete(name: string): Promise<any> {
     // Selects row
-    await this.waitClickable(this.getFirstTableCellWithText(name));
-    await this.getFirstTableCellWithText(name).click();
+    await this.waitClickableAndClick(this.getFirstTableCellWithText(name));
 
     // Clicks on table Delete button
     await $$('.table-actions button.dropdown-toggle')
index a0ab86e56c5529a08afbd92ca2d5fb95d1e2d95a..6a11c92f25a468afb03f86050ba019dbf6676185 100644 (file)
@@ -52,19 +52,17 @@ export class BucketsPageHelper extends PageHelper {
     await element(by.cssContainingText('select[name=owner] option', new_owner)).click(); // select the new user
     await element(by.cssContainingText('button', 'Edit Bucket')).click();
 
-    // wait to be back on buckets page with table visible
-    await this.waitClickable(
+    // wait to be back on buckets page with table visible and click
+    await this.waitClickableAndClick(
       this.getFirstTableCellWithText(name),
       'Could not return to buckets page and load table after editing bucket'
     );
 
-    // click on edited bucket and check its details table for edited owner field
-    const promise = await this.getFirstTableCellWithText(name).click();
+    // check its details table for edited owner field
     const element_details_table = element
       .all(by.css('.table.table-striped.table-bordered'))
       .first();
-    await expect(element_details_table.getText()).toMatch(new_owner);
-    return promise;
+    return expect(element_details_table.getText()).toMatch(new_owner);
   }
 
   async testInvalidCreate() {
@@ -139,11 +137,10 @@ export class BucketsPageHelper extends PageHelper {
   async testInvalidEdit(name) {
     await this.navigateTo();
 
-    await this.waitClickable(
+    await this.waitClickableAndClick(
       this.getFirstTableCellWithText(name),
       'Failed waiting for bucket to be present in table'
     ); // wait for table to load
-    await this.getFirstTableCellWithText(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
 
     await this.waitTextToBePresent(this.getBreadcrumb(), 'Edit');
@@ -151,8 +148,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 this.waitClickable(ownerDropDown);
-    await ownerDropDown.click(); // Clicks the Owner drop down on the Create Bucket page
+    await this.waitClickableAndClick(ownerDropDown);
 
     // select the first option, which is invalid because it is a placeholder
     await element(by.cssContainingText('select[name=owner] option', 'Select a user')).click();
index 4d21fb5c49778cc3bc52a799a46c87171f611131..735f9cf8790d11b92ec2bb85cfd5e891e5d216ad 100644 (file)
@@ -35,8 +35,7 @@ export class UsersPageHelper extends PageHelper {
   async edit(name, new_fullname, new_email, new_maxbuckets) {
     await this.navigateTo();
 
-    await this.waitClickable(this.getFirstTableCellWithText(name)); // wait for table to load
-    await this.getFirstTableCellWithText(name).click(); // click on the bucket you want to edit in the table
+    await this.waitClickableAndClick(this.getFirstTableCellWithText(name)); // wait for table to load and click
     await element(by.cssContainingText('button', 'Edit')).click(); // click button to move to edit page
 
     await this.waitTextToBePresent(this.getBreadcrumb(), 'Edit');
@@ -58,9 +57,8 @@ export class UsersPageHelper extends PageHelper {
 
     const editbutton = element(by.cssContainingText('button', 'Edit User'));
     await editbutton.click();
-    await this.waitClickable(this.getFirstTableCellWithText(name));
     // Click the user and check its details table for updated content
-    await this.getFirstTableCellWithText(name).click();
+    await this.waitClickableAndClick(this.getFirstTableCellWithText(name));
     await expect($('.active.tab-pane').getText()).toMatch(new_fullname); // check full name was changed
     await expect($('.active.tab-pane').getText()).toMatch(new_email); // check email was changed
     await expect($('.active.tab-pane').getText()).toMatch(new_maxbuckets); // check max buckets was changed
@@ -143,8 +141,8 @@ export class UsersPageHelper extends PageHelper {
 
     await this.navigateTo();
 
-    await this.waitClickable(this.getFirstTableCellWithText(uname)); // wait for table to load
-    await this.getFirstTableCellWithText(uname).click(); // click on the bucket you want to edit in the table
+    // wait for table to load and click on the bucket you want to edit in the table
+    await this.waitClickableAndClick(this.getFirstTableCellWithText(uname));
     await element(by.cssContainingText('button', 'Edit')).click(); // click button to move to edit page
 
     await this.waitTextToBePresent(this.getBreadcrumb(), 'Edit');