From 47eafcf02a8aa8a62338c339000df8847df15381 Mon Sep 17 00:00:00 2001 From: abakshi Date: Tue, 7 May 2024 23:18:14 -0500 Subject: [PATCH] tests for eda roles --- cypress/e2e/eda/Roles/custom-roles-crud.cy.ts | 75 +++++++++++++++++++ cypress/e2e/eda/Roles/eda-role-details.cy.ts | 53 ++++++------- cypress/e2e/eda/Roles/eda-roles-list.cy.ts | 40 +++++----- 3 files changed, 118 insertions(+), 50 deletions(-) create mode 100644 cypress/e2e/eda/Roles/custom-roles-crud.cy.ts diff --git a/cypress/e2e/eda/Roles/custom-roles-crud.cy.ts b/cypress/e2e/eda/Roles/custom-roles-crud.cy.ts new file mode 100644 index 0000000000..716b3524f4 --- /dev/null +++ b/cypress/e2e/eda/Roles/custom-roles-crud.cy.ts @@ -0,0 +1,75 @@ +//Tests a user's ability to create, edit, and delete a custom role in the EDA UI. +import { randomString } from '../../../../framework/utils/random-string'; + +describe('EDA Custom Roles- Create', () => { + const name = 'E2E Custom Role ' + randomString(4); + before(() => { + cy.edaLogin(); + }); + + after(() => { + cy.navigateTo('eda', 'roles'); + cy.get('h1').should('contain', 'Roles'); + cy.clickTableRow(name, true); + cy.verifyPageTitle(name); + cy.clickPageAction('delete-role'); + cy.clickModalConfirmCheckbox(); + cy.clickModalButton('Delete role'); + cy.verifyPageTitle('Roles'); + }); + + it('can create a custom role', () => { + cy.navigateTo('eda', 'roles'); + cy.get('h1').should('contain', 'Roles'); + cy.get('[id="create-role"]').click(); + cy.get('[data-cy="name"]').type(name); + cy.get('[data-cy="description"]').type('This is a Custom Role.'); + cy.get('[data-cy="content-type-form-group"]').click() + cy.get('[id="activation"]').click(); + cy.get('[data-cy="permissions"]').click(); + cy.get('[data-cy="view-activation"] input').click(); + cy.clickButton(/^Create role$/); + cy.hasDetail('Name', name); + cy.hasDetail('Description', 'This is a Custom Role.'); + }); +}); + +describe('EDA Custom Roles- Edit & Delete', () => { + const name = 'E2E Custom Role ' + randomString(4); + before(() => { + cy.edaLogin(); + cy.navigateTo('eda', 'roles'); + cy.get('h1').should('contain', 'Roles'); + cy.get('[id="create-role"]').click(); + cy.get('[data-cy="name"]').type(name); + cy.get('[data-cy="description"]').type('This is a Custom Role.'); + cy.get('[data-cy="content-type-form-group"]').click() + cy.get('[id="activation"]').click(); + cy.get('[data-cy="permissions"]').click(); + cy.get('[data-cy="view-activation"] input').click(); + cy.clickButton(/^Create role$/); + cy.hasDetail('Name', name); + }); + + it('can edit a custom role', () => { + cy.navigateTo('eda', 'roles'); + cy.get('h1').should('contain', 'Roles'); + cy.clickTableRow(name, true); + cy.clickButton(/^Edit role$/); + cy.verifyPageTitle(`Edit Role`); + cy.get('[data-cy="description"]').type('this custom role has been changed'); + cy.clickButton(/^Save role$/); + cy.hasDetail('Description', 'this custom role has been changed'); + }); + + it('can delete a custom role', () => { + cy.navigateTo('eda', 'roles'); + cy.get('h1').should('contain', 'Roles'); + cy.clickTableRow(name); + cy.verifyPageTitle(name); + cy.clickPageAction('delete-role'); + cy.clickModalConfirmCheckbox(); + cy.clickModalButton('Delete role'); + cy.verifyPageTitle('Roles'); + }); +}); diff --git a/cypress/e2e/eda/Roles/eda-role-details.cy.ts b/cypress/e2e/eda/Roles/eda-role-details.cy.ts index b434a8b3b0..8aaf9681ca 100644 --- a/cypress/e2e/eda/Roles/eda-role-details.cy.ts +++ b/cypress/e2e/eda/Roles/eda-role-details.cy.ts @@ -1,31 +1,24 @@ -// describe('Eda Role Details', () => { -// before(() => { -// cy.edaLogin(); -// }); +describe('Eda Role Details', () => { + before(() => { + cy.edaLogin(); + }); -// it('Role Details Pages Should Show', () => { -// cy.getEdaRoles().then((roles) => { -// roles.forEach((role) => { -// cy.navigateTo('eda', 'roles'); -// cy.clickLink(role.name); -// cy.verifyPageTitle(role.name); -// cy.get('[data-cy=name]').should('have.text', role.name); -// cy.get('[data-cy=description]').should('have.text', role.description); -// cy.getEdaRoleDetail(role.id).then((roleDetail) => { -// cy.get('[data-cy=permissions-description-list]').within(() => { -// for (const detail of roleDetail.permissions) { -// cy.get(`[data-cy=${detail.resource_type}]`).should('be.visible'); -// cy.get(`[data-cy=${detail.resource_type}]`) -// .parent() -// .within(() => { -// for (const action of detail.action) { -// cy.get(`[data-cy=${action}]`).should('be.visible'); -// } -// }); -// } -// }); -// }); -// }); -// }); -// }); -// }); + it('Role Details Pages Should Show', () => { + cy.getEdaRoles().then((roles) => { + roles.forEach((role) => { + cy.navigateTo('eda', 'roles'); + cy.clickTableRow(role.name, true); + cy.get('[data-cy=name]').should('have.text', role.name); + cy.get('[data-cy=description]').should('have.text', role.description); + cy.getEdaRoleDetail(role.id).then((roleDetail) => { + if (roleDetail.permissions.length > 3) { + cy.get('[data-cy="permissions-description-list"] button').click(); + } + for (const detail of roleDetail.permissions) { + cy.get(`[data-cy="${detail}"]`).should('be.visible'); + } + }); + }); + }); + }); +}); diff --git a/cypress/e2e/eda/Roles/eda-roles-list.cy.ts b/cypress/e2e/eda/Roles/eda-roles-list.cy.ts index 0c6922491c..48aa0807cd 100644 --- a/cypress/e2e/eda/Roles/eda-roles-list.cy.ts +++ b/cypress/e2e/eda/Roles/eda-roles-list.cy.ts @@ -1,23 +1,23 @@ -/** The Roles endpoint is going to change with the EDA server's RBAC branch and these tests will need to be updated to reflect the new endpoint */ //Tests a user's ability to perform certain actions on the Roles list in the EDA UI. -// describe('EDA Roles List', () => { -// before(() => { -// cy.edaLogin(); -// }); +describe('EDA Roles List', () => { + before(() => { + cy.edaLogin(); + }); -// it('can render the Roles list view and utilize the Roles links to view details', () => { -// cy.navigateTo('eda', 'roles'); -// cy.verifyPageTitle('Roles'); -// cy.getEdaRoles().then((roles) => { -// cy.get('tbody').find('tr').should('have.length', roles.length); -// roles.forEach((role) => { -// cy.verifyPageTitle('Roles'); -// cy.clickLink(role.name); -// cy.verifyPageTitle(role.name); -// cy.get('#description').should('contain', role.description); -// cy.clickLink(/^Roles$/); -// }); -// }); -// }); -// }); + it('can render the Roles list view and utilize the Roles links to view details', () => { + cy.navigateTo('eda', 'roles'); + cy.verifyPageTitle('Roles'); + cy.getEdaRoles().then((roles) => { + cy.setTablePageSize('20'); + cy.get('tbody').find('tr').should('have.length', roles.length); + roles.forEach((role) => { + cy.verifyPageTitle('Roles'); + cy.clickTableRow(role.name, true); + cy.verifyPageTitle(role.name); + cy.get('#description').should('contain', role.description); + cy.clickLink(/^Roles$/); + }); + }); + }); +});