]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
mgr/dashboard: Extract delete method into page-helper
authorTiago Melo <tmelo@suse.com>
Thu, 29 Aug 2019 18:19:56 +0000 (18:19 +0000)
committerTiago Melo <tmelo@suse.com>
Wed, 11 Sep 2019 11:11:01 +0000 (11:11 +0000)
Signed-off-by: Tiago Melo <tmelo@suse.com>
15 files changed:
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.e2e-spec.ts
src/pybind/mgr/dashboard/frontend/e2e/cluster/logs.e2e-spec.ts
src/pybind/mgr/dashboard/frontend/e2e/page-helper.po.ts
src/pybind/mgr/dashboard/frontend/e2e/pools/pools.e2e-spec.ts
src/pybind/mgr/dashboard/frontend/e2e/pools/pools.po.ts
src/pybind/mgr/dashboard/frontend/e2e/rgw/buckets.e2e-spec.ts
src/pybind/mgr/dashboard/frontend/e2e/rgw/buckets.po.ts
src/pybind/mgr/dashboard/frontend/e2e/rgw/users.e2e-spec.ts
src/pybind/mgr/dashboard/frontend/e2e/rgw/users.po.ts
src/pybind/mgr/dashboard/frontend/e2e/ui/role-mgmt.e2e-spec.ts
src/pybind/mgr/dashboard/frontend/e2e/ui/role-mgmt.po.ts
src/pybind/mgr/dashboard/frontend/e2e/ui/user-mgmt.e2e-spec.ts
src/pybind/mgr/dashboard/frontend/e2e/ui/user-mgmt.po.ts

index 93b37627cb69d033f37481d3cfa1741761151de3..aee484a21a4f9194deca189398ac1f099cc752cd 100644 (file)
@@ -59,15 +59,13 @@ describe('Images page', () => {
     });
 
     it('should delete image', async () => {
-      await images.deleteImage(newImageName);
-      await expect(images.getTableCell(newImageName).isPresent()).toBe(false);
+      await images.navigateTo();
+      await images.delete(newImageName);
     });
 
     afterAll(async () => {
-      await pools.navigateTo(); // Deletes images test pool
-      await pools.delete(poolName);
       await pools.navigateTo();
-      await pools.exist(poolName, false);
+      await pools.delete(poolName);
     });
   });
 
index 52cb7b497b8cef23ca9feec48e9436e3b26f86a1..cebdf526348be25f7237df392137decd92fe0bc8 100644 (file)
@@ -60,22 +60,6 @@ export class ImagesPageHelper extends PageHelper {
     ).toMatch(newSize);
   }
 
-  // Deletes RBD image from table and checks that it is not present
-  async deleteImage(name) {
-    await this.navigateTo();
-
-    // wait for table to load
-    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
-    await this.clickCheckbox($('.custom-control-label'));
-    await element(by.cssContainingText('button', 'Delete RBD')).click();
-    await this.waitStaleness(this.getTableCell(name));
-  }
-
   // Selects RBD image and moves it to the trash, checks that it is present in the
   // trash table
   async moveToTrash(name) {
index 51d7dba110d75a9e6a702e40d26f4b187da99983..6daddf9317368548d6a908fc38c5bd56489e89f8 100644 (file)
@@ -59,8 +59,6 @@ describe('Mirroring page', () => {
     afterAll(async () => {
       await pools.navigateTo();
       await pools.delete(poolName);
-      await pools.navigateTo();
-      await pools.exist(poolName, false);
     });
   });
 });
index 71127f4a3a2795f87a31e859d6c889937def5bd1..bd4ac4484e5c85470936dfe5577765c24c9643bf 100644 (file)
@@ -64,9 +64,6 @@ describe('Logs page', () => {
       await pools.navigateTo();
       await pools.delete(poolname);
 
-      await pools.navigateTo();
-      await pools.exist(poolname, false);
-
       await logs.navigateTo();
       await logs.checkAuditForPoolFunction(poolname, 'delete', hour, minute);
     });
index 6ef40b3e80d0eb11a986c6f6c741685b45c89a75..c3dc9aaf336afe16220bc8b7d336da1a3eef12f5 100644 (file)
@@ -283,4 +283,28 @@ export abstract class PageHelper {
   getFirstCell(): ElementFinder {
     return $$('.datatable-body-cell-label').first();
   }
+
+  /**
+   * This is a generic method to delete table rows.
+   * It will select the first row that contains the provided name and delete it.
+   * After that it will wait until the row is no longer displayed.
+   */
+  async delete(name: string): Promise<any> {
+    // Selects row
+    await this.waitClickable(this.getTableCell(name));
+    await this.getTableCell(name).click();
+
+    // Clicks on table Delete button
+    await $$('.table-actions button.dropdown-toggle')
+      .first()
+      .click(); // open submenu
+    await $('li.delete a').click(); // click on "delete" menu item
+
+    // Confirms deletion
+    await this.clickCheckbox($('.custom-control-label'));
+    await element(by.cssContainingText('button', 'Delete')).click();
+
+    // Waits for item to be removed from table
+    return this.waitStaleness(this.getTableCell(name));
+  }
 }
index e98101ed54beca574f5b975f711a230c38d81d0c..83176962227b3254372df38ea62ea4d6f3f947f8 100644 (file)
@@ -47,9 +47,7 @@ describe('Pools page', () => {
   });
 
   it('should delete a pool', async () => {
-    await pools.exist(poolName);
-    await pools.delete(poolName);
     await pools.navigateTo();
-    await pools.exist(poolName, false);
+    await pools.delete(poolName);
   });
 });
index c5c59daac390caaa0bc2ea2f310020916c7f3436..36a000a3fdfe5015a09f1bc28787e627da9b3a21 100644 (file)
@@ -82,15 +82,4 @@ export class PoolPageHelper extends PageHelper {
       async (app) => await element(by.cssContainingText('.select-menu-item-content', app)).click()
     );
   }
-
-  @PageHelper.restrictTo(pages.index)
-  async delete(name: string): Promise<any> {
-    await this.waitClickable(this.getTableCell(name));
-    await this.getTableCell(name).click();
-    await $('.table-actions button.dropdown-toggle').click(); // open submenu
-    await $('li.delete a').click(); // click on "delete" menu item
-    await this.clickCheckbox($('.custom-control-label'));
-    await element(by.cssContainingText('button', 'Delete Pool')).click();
-    return this.waitStaleness(this.getTableCell(name));
-  }
 }
index 3930ea50756aac13cc9acc4fb5c4b5fe64997234..a6ef61ac7433e05fbe3daa30ecf74ab828ed107a 100644 (file)
@@ -37,7 +37,6 @@ describe('RGW buckets page', () => {
   it('should delete bucket', async () => {
     await buckets.navigateTo();
     await buckets.delete('000test');
-    await expect(buckets.getTableCell('000test').isPresent()).toBe(false);
   });
 
   describe('Invalid Input in Create and Edit tests', () => {
index ab902d2d2ca55113ccc3eecb8198c80b7fe16bb8..9a90818cd7c110a22cb74b7ddd7a79ad2fae6f3d 100644 (file)
@@ -1,4 +1,4 @@
-import { $, by, element } from 'protractor';
+import { by, element } from 'protractor';
 import { PageHelper } from '../page-helper.po';
 
 const pages = {
@@ -64,23 +64,6 @@ export class BucketsPageHelper extends PageHelper {
     return promise;
   }
 
-  @PageHelper.restrictTo(pages.index)
-  async delete(name) {
-    // wait for table to load
-    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 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 this.waitStaleness(this.getTableCell(name));
-  }
-
   async testInvalidCreate() {
     await this.navigateTo('create');
     const nameInputField = element(by.id('bid')); // Grabs name box field
index 2afea64b5d74ae049d89e1d47d96c5a71f13c422..12cc327a35f2dddc050e9b43bacd1eae0cde80bd 100644 (file)
@@ -40,7 +40,6 @@ describe('RGW users page', () => {
 
     it('should delete user', async () => {
       await users.delete(user_name);
-      await expect(users.getTableCell(user_name).isPresent()).toBe(false);
     });
   });
 
index cf880d6f338be510a656242187b770cb50f98c1d..fbef4aba9682fe766d11c370c020f143de09a3cc 100644 (file)
@@ -66,25 +66,6 @@ export class UsersPageHelper extends PageHelper {
     await expect($('.active.tab-pane').getText()).toMatch(new_maxbuckets); // check max buckets was changed
   }
 
-  async delete(name) {
-    await this.navigateTo();
-
-    // wait for table to load
-    const my_user = this.getFirstTableCellWithText(name);
-    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 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 this.waitStaleness(this.getFirstTableCellWithText(name));
-  }
-
   async invalidCreate() {
     const uname = '000invalid_create_user';
     // creating this user in order to check that you can't give two users the same name
@@ -151,6 +132,7 @@ export class UsersPageHelper extends PageHelper {
       'The entered value must be >= 0.'
     );
 
+    await this.navigateTo();
     await this.delete(uname);
   }
 
@@ -201,6 +183,7 @@ export class UsersPageHelper extends PageHelper {
       'The entered value must be >= 0.'
     );
 
+    await this.navigateTo();
     await this.delete(uname);
   }
 }
index a689a76f9fc76cf438faff70af83de4e945d1706..0bff2733058c33400c84caa10d6def616c3a205c 100644 (file)
@@ -35,6 +35,7 @@ describe('Role Management page', () => {
     });
 
     it('should delete a role', async () => {
+      await roleMgmt.navigateTo();
       await roleMgmt.delete(role_name);
     });
   });
index ca8d569b3c063464ce06d31101221de74846e893..998fa7edced3477bfcd5599e2e1b433463dda715 100644 (file)
@@ -1,4 +1,4 @@
-import { $, by, element } from 'protractor';
+import { by, element } from 'protractor';
 import { PageHelper } from '../page-helper.po';
 
 export class RoleMgmtPageHelper extends PageHelper {
@@ -38,17 +38,4 @@ export class RoleMgmtPageHelper extends PageHelper {
     await this.waitPresence(this.getTableCell(name));
     await this.waitPresence(this.getTableCell(description));
   }
-
-  async delete(name) {
-    await this.navigateTo();
-
-    await this.getTableCell(name).click(); // select role from table
-    await $('.table-actions button.dropdown-toggle').click(); // click toggle menu
-    await $('li.delete a').click(); // click delete
-
-    await this.waitVisibility($('.custom-control-label'));
-    await $('.custom-control-label').click(); // click confirmation checkbox
-    await element(by.cssContainingText('button', 'Delete Role')).click();
-    await this.waitStaleness(this.getFirstTableCellWithText(name));
-  }
 }
index a0e24d9bea418e428896d8bce654ab85d7540e49..a0ae3f55c6e6ede26ab53fb9255e135516b6d88a 100644 (file)
@@ -35,7 +35,8 @@ describe('User Management page', () => {
     });
 
     it('should delete a user', async () => {
-      await userMgmt.userDelete(user_name);
+      await userMgmt.navigateTo();
+      await userMgmt.delete(user_name);
     });
   });
 });
index 57d90716067a02ef688cf262a07d287db2113303..a16dae56dbbda2e1e99fcf5527a6c8ecd506e6f4 100644 (file)
@@ -1,4 +1,4 @@
-import { $, by, element } from 'protractor';
+import { by, element } from 'protractor';
 import { PageHelper } from '../page-helper.po';
 
 export class UserMgmtPageHelper extends PageHelper {
@@ -45,17 +45,4 @@ export class UserMgmtPageHelper extends PageHelper {
     await this.waitPresence(this.getTableCell(email));
     await this.waitPresence(this.getTableCell(name));
   }
-
-  async userDelete(username): Promise<void> {
-    await this.navigateTo();
-
-    await this.getTableCell(username).click(); // select user from table
-    await $('.table-actions button.dropdown-toggle').click(); // click toggle menu
-    await $('li.delete a').click(); // click delete
-
-    await this.waitVisibility($('.custom-control-label'));
-    await $('.custom-control-label').click(); // click confirmation checkbox
-    await element(by.cssContainingText('button', 'Delete User')).click();
-    await this.waitStaleness(this.getFirstTableCellWithText(username));
-  }
 }