]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
mgr/dashboard: E2E: Add navigateEdit method 34285/head
authorTiago Melo <tmelo@suse.com>
Wed, 22 Apr 2020 13:46:49 +0000 (13:46 +0000)
committerTiago Melo <tmelo@suse.com>
Tue, 28 Apr 2020 09:43:50 +0000 (09:43 +0000)
This method should be use to navigate to the edit page.

Signed-off-by: Tiago Melo <tmelo@suse.com>
src/pybind/mgr/dashboard/frontend/cypress/integration/block/images.po.ts
src/pybind/mgr/dashboard/frontend/cypress/integration/cluster/configuration.po.ts
src/pybind/mgr/dashboard/frontend/cypress/integration/cluster/mgr-modules.po.ts
src/pybind/mgr/dashboard/frontend/cypress/integration/page-helper.po.ts
src/pybind/mgr/dashboard/frontend/cypress/integration/pools/pools.po.ts
src/pybind/mgr/dashboard/frontend/cypress/integration/rgw/buckets.po.ts
src/pybind/mgr/dashboard/frontend/cypress/integration/rgw/users.po.ts
src/pybind/mgr/dashboard/frontend/cypress/integration/ui/role-mgmt.po.ts
src/pybind/mgr/dashboard/frontend/cypress/integration/ui/user-mgmt.po.ts
src/pybind/mgr/dashboard/frontend/src/app/app-routing.module.ts

index f6cc1b987391724f52321c07a46b6223e21e7c36..c43b838e3f08e2f8163d503f74afa199e4800aa7 100644 (file)
@@ -27,12 +27,7 @@ export class ImagesPageHelper extends PageHelper {
   }
 
   editImage(name: string, pool: string, newName: string, newSize: string) {
-    const base_url = '#/block/rbd/edit/';
-    const editURL = base_url
-      .concat(encodeURIComponent(pool))
-      .concat('%2F')
-      .concat(encodeURIComponent(name));
-    cy.visit(editURL);
+    this.navigateEdit(name);
 
     // Wait until data is loaded
     cy.get('#pool').should('contain.value', pool);
index 131ad2708a2a03835acd51df7e5f98ecf970d4d7..eb160b052e11f970d0629546bba7078b5dc471be 100644 (file)
@@ -10,17 +10,10 @@ export class ConfigurationPageHelper extends PageHelper {
    * Does not work for configs with checkbox only, possible future PR
    */
   configClear(name: string) {
-    this.navigateTo();
     const valList = ['global', 'mon', 'mgr', 'osd', 'mds', 'client']; // Editable values
 
-    // Enter config setting name into filter box
-    this.seachTable(name);
-
-    // Selects config that we want to clear
-    this.getFirstTableCell(name).click(); // waits for config to be clickable and click
-    cy.contains('button', 'Edit').click(); // clicks button to edit
-
-    // Wait for the data to load
+    this.navigateEdit(name);
+    // Waits for the data to load
     cy.contains('.card-header', `Edit ${name}`);
 
     for (const i of valList) {
@@ -52,14 +45,9 @@ export class ConfigurationPageHelper extends PageHelper {
    * Ex: [global, '2'] is the global value with an input of 2
    */
   edit(name: string, ...values: [string, string][]) {
+    this.navigateEdit(name);
 
-    // Enter config setting name into filter box
-    this.seachTable(name);
-
-    // Selects config that we want to edit
-    this.getFirstTableCell(name).click(); // waits for config to be clickable and click
-    cy.contains('button', 'Edit').click(); // clicks button to edit
-
+    // Waits for data to load
     cy.contains('.card-header', `Edit ${name}`);
 
     values.forEach((valtuple) => {
index eaf93f9465fefa28cb81b21e2e15480f50922f16..bee538e47c50d742c3e2e3f88a5270bb3002f2af 100644 (file)
@@ -9,8 +9,7 @@ export class ManagerModulesPageHelper extends PageHelper {
    * DOES NOT WORK FOR ALL MGR MODULES, for example, Device health
    */
   editMgrModule(name: string, tuple: string[][]) {
-    this.getFirstTableCell(name).click();
-    cy.contains('button', 'Edit').click();
+    this.navigateEdit(name);
 
     for (const entry of tuple) {
       // Clears fields and adds edits
@@ -25,8 +24,7 @@ export class ManagerModulesPageHelper extends PageHelper {
     }
 
     // Clear mgr module of all edits made to it
-    this.getFirstTableCell(name).click();
-    cy.contains('button', 'Edit').click();
+    this.navigateEdit(name);
 
     // Clears the editable fields
     for (const entry of tuple) {
@@ -64,8 +62,7 @@ export class ManagerModulesPageHelper extends PageHelper {
       [warn, 'warn_threshold']
     ];
 
-    this.getFirstTableCell('devicehealth').click();
-    cy.contains('button', 'Edit').click();
+    this.navigateEdit('devicehealth');
     for (let i = 0, devHealthTuple; (devHealthTuple = devHealthArray[i]); i++) {
       if (devHealthTuple[0] !== undefined) {
         // Clears and inputs edits
@@ -89,8 +86,8 @@ export class ManagerModulesPageHelper extends PageHelper {
     // to be made when the values are cleared. Therefore, I restored them to their original values
     // (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.
-    this.getFirstTableCell('devicehealth').click();
-    cy.contains('button', 'Edit').click();
+    this.navigateEdit('devicehealth');
+
     cy.get('#mark_out_threshold').clear().type('2419200');
 
     cy.get('#pool_name').clear().type('device_health_metrics');
index cff33a7441371c4bc70a06ac59c585109aade52b..2aaf901bd53009403bfe5622c2b54a85a29bd11c 100644 (file)
@@ -49,6 +49,18 @@ export abstract class PageHelper {
     });
   }
 
+  /**
+   * Navigates to the edit page
+   */
+  navigateEdit(name: string, select = true) {
+    if (select) {
+      this.navigateTo();
+      this.getFirstTableCell(name).click();
+    }
+    cy.contains('button', 'Edit').click();
+    this.expectBreadcrumbText('Edit');
+  }
+
   /**
    * Checks the active breadcrumb value.
    */
index 24f4d4244bf858903bb0113a36801a8af37ad24d..31d1698ba1d96150ec62993c70cf6a8685b17b1e 100644 (file)
@@ -36,9 +36,8 @@ export class PoolPageHelper extends PageHelper {
 
   edit_pool_pg(name: string, new_pg: number, wait = true) {
     this.isPowerOf2(new_pg);
-    this.getFirstTableCell(name).click(); // select pool from the table
-    cy.contains('button', 'Edit').click(); // click edit button
-    this.expectBreadcrumbText('Edit'); // verify we are now on edit page
+    this.navigateEdit(name);
+
     cy.get('input[name=pgNum]').clear().type(`${new_pg}`);
     cy.get('cd-submit-button').click();
     const str = `${new_pg} active+clean`;
index 7d1f6e55d065ea515dad0f45dad8fe96528f53a7..0cb1f76fef1855ffe496d545620bc25433e55fd5 100644 (file)
@@ -40,9 +40,8 @@ export class BucketsPageHelper extends PageHelper {
 
   @PageHelper.restrictTo(pages.index.url)
   edit(name: string, new_owner: string) {
-    this.getFirstTableCell(name).click(); // wait for table to load and click
-    cy.contains('button', 'Edit').click(); // click button to move to edit page
-    this.expectBreadcrumbText('Edit');
+    this.navigateEdit(name);
+
     cy.get('input[name=placement-target]').should('have.value', 'default-placement');
     this.selectOwner(new_owner);
 
@@ -69,8 +68,8 @@ export class BucketsPageHelper extends PageHelper {
     cy.get('@versioningValueCell').should('have.text', this.versioningStateEnabled);
 
     // Disable versioning:
-    cy.contains('button', 'Edit').click(); // click button to move to edit page
-    this.expectBreadcrumbText('Edit');
+    this.navigateEdit(name, false);
+
     cy.get('label[for=versioning]').click();
     cy.get('input[id=versioning]').should('not.be.checked');
     cy.contains('button', 'Edit Bucket').click();
@@ -134,12 +133,7 @@ export class BucketsPageHelper extends PageHelper {
   }
 
   testInvalidEdit(name: string) {
-    this.navigateTo();
-
-    this.getFirstTableCell(name).click(); // wait for table to load and click
-    cy.contains('button', 'Edit').click(); // click button to move to edit page
-
-    this.expectBreadcrumbText('Edit');
+    this.navigateEdit(name);
 
     cy.get('input[id=versioning]').should('exist').and('not.be.checked');
 
index 66cff75dc289f3a5181158a5206cd7f1bb586e1a..f65464537ac4355c940fc5dd2eafba05906a5085 100644 (file)
@@ -30,10 +30,7 @@ export class UsersPageHelper extends PageHelper {
 
   @PageHelper.restrictTo(pages.index.url)
   edit(name: string, new_fullname: string, new_email: string, new_maxbuckets: string) {
-    this.getFirstTableCell(name).click(); // wait for table to load and click
-    cy.contains('button', 'Edit').click(); // click button to move to edit page
-
-    this.expectBreadcrumbText('Edit');
+    this.navigateEdit(name);
 
     // Change the full name field
     cy.get('#display_name').click().clear().type(new_fullname);
@@ -107,13 +104,7 @@ export class UsersPageHelper extends PageHelper {
     this.navigateTo('create');
     this.create(uname, 'xxx', 'xxx@xxx', '1');
 
-    this.navigateTo();
-
-    // wait for table to load and click on the bucket you want to edit in the table
-    this.getFirstTableCell(uname).click();
-    cy.contains('button', 'Edit').click(); // click button to move to edit page
-
-    this.expectBreadcrumbText('Edit');
+    this.navigateEdit(name);
 
     // put invalid email to make field invalid
     cy.get('#email')
index b90da23738022e3a8a3bdbc2634e2aeea811cede..1f9c7616b8cb25f084f28a70fc253711ec8dfba6 100644 (file)
@@ -8,6 +8,8 @@ export class RoleMgmtPageHelper extends PageHelper {
 
   create(name: string, description: string) {
     this.navigateTo('create');
+    // Waits for data to load
+    cy.contains('grafana');
 
     // fill in fields
     cy.get('#name').type(name);
@@ -15,19 +17,22 @@ export class RoleMgmtPageHelper extends PageHelper {
 
     // Click the create button and wait for role to be made
     cy.contains('button', 'Create Role').click();
+    cy.get('.breadcrumb-item.active').should('not.have.text', name);
 
     this.getFirstTableCell(name).should('exist');
   }
 
   edit(name: string, description: string) {
-    this.getFirstTableCell(name).click(); // select role from table
-    cy.contains('button', 'Edit').click(); // click button to move to edit page
+    this.navigateEdit(name);
+    // Waits for data to load
+    cy.contains('grafana');
 
     // fill in fields with new values
     cy.get('#description').clear().type(description);
 
     // Click the edit button and check new values are present in table
     cy.contains('button', 'Edit Role').click();
+    cy.get('.breadcrumb-item.active').should('not.have.text', name);
 
     this.getFirstTableCell(name).should('exist');
     this.getFirstTableCell(description).should('exist');
index 904cc6ed0bc109d0cfc51d2ee6d4f06c67ea1c42..5afcdf37ca52881c5f5ef95285c8a0ffa60a2611 100644 (file)
@@ -22,8 +22,7 @@ export class UserMgmtPageHelper extends PageHelper {
   }
 
   edit(username: string, password: string, name: string, email: string) {
-    this.getFirstTableCell(username).click(); // select user from table
-    cy.contains('button', 'Edit').click(); // click button to move to edit page
+    this.navigateEdit(username);
 
     // fill in fields with new values
     cy.get('#password').clear().type(password);
index 99208d37c6fa6f8af189a86d9a4da2abb0009e40..cbdef74b61da2de6c4f0fe588368dc6bec4eebd3 100644 (file)
@@ -67,7 +67,7 @@ export class StartCaseBreadcrumbsResolver extends BreadcrumbsResolver {
   resolve(route: ActivatedRouteSnapshot) {
     const path = route.params.name;
     const text = _.startCase(path);
-    return [{ text: text, path: path }];
+    return [{ text: `${text}/Edit`, path: path }];
   }
 }