Skip to content

Commit

Permalink
tests for eda roles
Browse files Browse the repository at this point in the history
  • Loading branch information
appuk committed May 8, 2024
1 parent 112911d commit 47eafcf
Show file tree
Hide file tree
Showing 3 changed files with 118 additions and 50 deletions.
75 changes: 75 additions & 0 deletions cypress/e2e/eda/Roles/custom-roles-crud.cy.ts
Original file line number Diff line number Diff line change
@@ -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');
});
});
53 changes: 23 additions & 30 deletions cypress/e2e/eda/Roles/eda-role-details.cy.ts
Original file line number Diff line number Diff line change
@@ -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');
}
});
});
});
});
});
40 changes: 20 additions & 20 deletions cypress/e2e/eda/Roles/eda-roles-list.cy.ts
Original file line number Diff line number Diff line change
@@ -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$/);
});
});
});
});

0 comments on commit 47eafcf

Please sign in to comment.