From 9144e44cb945d1e0dfaa4aaada2a37296eef1eb0 Mon Sep 17 00:00:00 2001 From: Tiago Melo Date: Mon, 9 Sep 2019 16:03:16 +0000 Subject: [PATCH] mgr/dashboard: Add click call inside waitClickable All waitClickable calls were being followed by a click. This will remove the need for the click call. Signed-off-by: Tiago Melo --- .../frontend/e2e/block/images.e2e-spec.ts | 4 ---- .../dashboard/frontend/e2e/block/images.po.ts | 16 +++++----------- .../dashboard/frontend/e2e/block/mirroring.po.ts | 6 ++---- .../frontend/e2e/cluster/configuration.po.ts | 9 +++------ .../frontend/e2e/cluster/mgr-modules.po.ts | 15 +++++---------- .../mgr/dashboard/frontend/e2e/page-helper.po.ts | 14 ++++++++------ .../mgr/dashboard/frontend/e2e/rgw/buckets.po.ts | 16 ++++++---------- .../mgr/dashboard/frontend/e2e/rgw/users.po.ts | 10 ++++------ 8 files changed, 33 insertions(+), 57 deletions(-) diff --git a/src/pybind/mgr/dashboard/frontend/e2e/block/images.e2e-spec.ts b/src/pybind/mgr/dashboard/frontend/e2e/block/images.e2e-spec.ts index 8aab7eae612..2b1fa1db2f3 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/block/images.e2e-spec.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/block/images.e2e-spec.ts @@ -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); }); diff --git a/src/pybind/mgr/dashboard/frontend/e2e/block/images.po.ts b/src/pybind/mgr/dashboard/frontend/e2e/block/images.po.ts index 73ef05fcebd..c9878c08998 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/block/images.po.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/block/images.po.ts @@ -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), diff --git a/src/pybind/mgr/dashboard/frontend/e2e/block/mirroring.po.ts b/src/pybind/mgr/dashboard/frontend/e2e/block/mirroring.po.ts index 6091b1a26ac..1cb31168425 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/block/mirroring.po.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/block/mirroring.po.ts @@ -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 diff --git a/src/pybind/mgr/dashboard/frontend/e2e/cluster/configuration.po.ts b/src/pybind/mgr/dashboard/frontend/e2e/cluster/configuration.po.ts index 3ddc22f4190..c92dbfcaae3 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/cluster/configuration.po.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/cluster/configuration.po.ts @@ -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'); diff --git a/src/pybind/mgr/dashboard/frontend/e2e/cluster/mgr-modules.po.ts b/src/pybind/mgr/dashboard/frontend/e2e/cluster/mgr-modules.po.ts index 784b6a1d946..f9ff2690fa5 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/cluster/mgr-modules.po.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/cluster/mgr-modules.po.ts @@ -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(); diff --git a/src/pybind/mgr/dashboard/frontend/e2e/page-helper.po.ts b/src/pybind/mgr/dashboard/frontend/e2e/page-helper.po.ts index 5fcbfd65e59..1cacf01dff8 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/page-helper.po.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/page-helper.po.ts @@ -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 { // 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') diff --git a/src/pybind/mgr/dashboard/frontend/e2e/rgw/buckets.po.ts b/src/pybind/mgr/dashboard/frontend/e2e/rgw/buckets.po.ts index a0ab86e56c5..6a11c92f25a 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/rgw/buckets.po.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/rgw/buckets.po.ts @@ -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(); diff --git a/src/pybind/mgr/dashboard/frontend/e2e/rgw/users.po.ts b/src/pybind/mgr/dashboard/frontend/e2e/rgw/users.po.ts index 4d21fb5c497..735f9cf8790 100644 --- a/src/pybind/mgr/dashboard/frontend/e2e/rgw/users.po.ts +++ b/src/pybind/mgr/dashboard/frontend/e2e/rgw/users.po.ts @@ -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');