From: saif Date: Mon, 21 Apr 2025 18:47:12 +0000 (+0000) Subject: mgr/dashboard: Replace `data-cy` to `data-testid` X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=bb8f0ce3bf58b03beb88d78e75ae8946fb68d0c2;p=ceph.git mgr/dashboard: Replace `data-cy` to `data-testid` Issue: There was some inconsistency in naming attributes of cypress test IDs, both `data-testid` and `data-cy` were being used across the code. Changes: Replaces all `data-cy` attributes with `data-testid` to keep it consistent across the codebase. Fixes: https://tracker.ceph.com/issues/70986 Signed-off-by: Mohammad saif --- diff --git a/src/pybind/mgr/dashboard/frontend/cypress/e2e/block/images.po.ts b/src/pybind/mgr/dashboard/frontend/cypress/e2e/block/images.po.ts index cdf7d7cb531d..704f922fb548 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/e2e/block/images.po.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/e2e/block/images.po.ts @@ -22,7 +22,7 @@ export class ImagesPageHelper extends PageHelper { cy.get('#size').type(size); // Click the create button and wait for image to be made - cy.get('[data-cy=submitBtn]').click(); + cy.get('[data-testid=submitBtn]').click(); this.getFirstTableCell(name).should('exist'); } @@ -35,7 +35,7 @@ export class ImagesPageHelper extends PageHelper { cy.get('#name').clear().type(newName); cy.get('#size').clear().type(newSize); // click the size box and send new size - cy.get('[data-cy=submitBtn]').click(); + cy.get('[data-testid=submitBtn]').click(); this.getExpandCollapseElement(newName).click(); cy.get('[data-testid=rbd-details-table]').contains('td', newSize); @@ -53,7 +53,7 @@ export class ImagesPageHelper extends PageHelper { cy.get('[data-testid="table-action-btn"]').click({ multiple: true }); cy.get('button.move-to-trash').click({ force: true }); - cy.get('[data-cy=submitBtn] button').should('be.visible').click({ force: true }); + cy.get('[data-testid=submitBtn] button').should('be.visible').click({ force: true }); // Clicks trash tab cy.contains('.nav-link', 'Trash').click(); @@ -80,7 +80,7 @@ export class ImagesPageHelper extends PageHelper { cy.get('cds-modal #name').clear().type(newName); } - cy.get('[data-cy=submitBtn]').click(); + cy.get('[data-testid=submitBtn]').click(); // clicks images tab cy.contains('.nav-link', 'Images').click(); @@ -103,7 +103,7 @@ export class ImagesPageHelper extends PageHelper { this.selectOption('poolName', pool); cy.get('#poolName').should('have.class', 'ng-valid'); // check if pool is selected } - cy.get('[data-cy=submitBtn]').click(); + cy.get('[data-testid=submitBtn]').click(); // Wait for image to delete and check it is not present this.getFirstTableCell(name).should('not.exist'); diff --git a/src/pybind/mgr/dashboard/frontend/cypress/e2e/cluster/configuration.po.ts b/src/pybind/mgr/dashboard/frontend/cypress/e2e/cluster/configuration.po.ts index 4132387d0f1a..920d118be87e 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/e2e/cluster/configuration.po.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/e2e/cluster/configuration.po.ts @@ -21,7 +21,7 @@ export class ConfigurationPageHelper extends PageHelper { cy.get(`#${i}`).clear(); } // Clicks save button and checks that values are not present for the selected config - cy.get('[data-cy=submitBtn]').click(); + cy.get('[data-testid=submitBtn]').click(); cy.wait(3 * 1000); @@ -64,7 +64,7 @@ export class ConfigurationPageHelper extends PageHelper { // Clicks save button then waits until the desired config is visible, clicks it, // then checks that each desired value appears with the desired number - cy.get('[data-cy=submitBtn]').click(); + cy.get('[data-testid=submitBtn]').click(); cy.wait(3 * 1000); // Enter config setting name into filter box diff --git a/src/pybind/mgr/dashboard/frontend/cypress/e2e/common/forms-helper.feature.po.ts b/src/pybind/mgr/dashboard/frontend/cypress/e2e/common/forms-helper.feature.po.ts index dcc1a1592106..7f0617920eaa 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/e2e/common/forms-helper.feature.po.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/e2e/common/forms-helper.feature.po.ts @@ -67,7 +67,7 @@ And('{string} option {string}', (action: string, labels: string) => { }); And('I click on submit button', () => { - cy.get('[data-cy=submitBtn]').click(); + cy.get('[data-testid=submitBtn]').click(); }); /** diff --git a/src/pybind/mgr/dashboard/frontend/cypress/e2e/ui/role-mgmt.po.ts b/src/pybind/mgr/dashboard/frontend/cypress/e2e/ui/role-mgmt.po.ts index f7734a0e7cf0..f6bfc7f1d6e1 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/e2e/ui/role-mgmt.po.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/e2e/ui/role-mgmt.po.ts @@ -16,7 +16,7 @@ export class RoleMgmtPageHelper extends PageHelper { cy.get('#description').type(description); // Click the create button and wait for role to be made - cy.get('[data-cy=submitBtn]').click(); + cy.get('[data-testid=submitBtn]').click(); cy.get('[data-testid="active-breadcrumb-item"]').should('not.have.text', 'Create'); this.getFirstTableCell(name).should('exist'); @@ -31,7 +31,7 @@ export class RoleMgmtPageHelper extends PageHelper { cy.get('#description').clear().type(description); // Click the edit button and check new values are present in table - cy.get('[data-cy=submitBtn]').click(); + cy.get('[data-testid=submitBtn]').click(); cy.get('[data-testid="active-breadcrumb-item"]').should('not.have.text', 'Edit'); this.getFirstTableCell(name).should('exist'); diff --git a/src/pybind/mgr/dashboard/frontend/cypress/e2e/ui/user-mgmt.po.ts b/src/pybind/mgr/dashboard/frontend/cypress/e2e/ui/user-mgmt.po.ts index fb2b79129443..76679806a883 100644 --- a/src/pybind/mgr/dashboard/frontend/cypress/e2e/ui/user-mgmt.po.ts +++ b/src/pybind/mgr/dashboard/frontend/cypress/e2e/ui/user-mgmt.po.ts @@ -17,7 +17,7 @@ export class UserMgmtPageHelper extends PageHelper { cy.get('#email').type(email); // Click the create button and wait for user to be made - cy.get('[data-cy=submitBtn]').click(); + cy.get('[data-testid=submitBtn]').click(); this.getFirstTableCell(username).should('exist'); } @@ -31,7 +31,7 @@ export class UserMgmtPageHelper extends PageHelper { cy.get('#email').clear().type(email); // Click the edit button and check new values are present in table - const editButton = cy.get('[data-cy=submitBtn]'); + const editButton = cy.get('[data-testid=submitBtn]'); editButton.click(); this.getFirstTableCell(email).should('exist'); this.getFirstTableCell(name).should('exist'); diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/form-button-panel/form-button-panel.component.html b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/form-button-panel/form-button-panel.component.html index 70a368cf71d7..aa161811b122 100644 --- a/src/pybind/mgr/dashboard/frontend/src/app/shared/components/form-button-panel/form-button-panel.component.html +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/components/form-button-panel/form-button-panel.component.html @@ -8,7 +8,7 @@ [disabled]="disabled" [form]="form" [ariaLabel]="submitText" - data-cy="submitBtn" + data-testid="submitBtn" [buttonType]="submitBtnType">{{ submitText }} @@ -26,7 +26,7 @@ [disabled]="disabled" [form]="form" [ariaLabel]="submitText" - data-cy="submitBtn" + data-testid="submitBtn" [modalForm]="modalForm" [buttonType]="submitBtnType" class="w-100">{{ submitText }}