Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

tests for eda roles #2261

Merged
merged 1 commit into from
May 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 46 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,46 @@
//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();
});

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.');
});

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"]').clear().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', () => {
appuk marked this conversation as resolved.
Show resolved Hide resolved
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(() => {
appuk marked this conversation as resolved.
Show resolved Hide resolved
// 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 display role name, description, and permissions', () => {
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.toString()).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.

appuk marked this conversation as resolved.
Show resolved Hide resolved
// 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$/);
});
});
});
});
6 changes: 3 additions & 3 deletions cypress/support/commands.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import {
EdaRulebookActivationCreate,
} from '../../frontend/eda/interfaces/EdaRulebookActivation';
import { EdaUser, EdaUserCreateUpdate } from '../../frontend/eda/interfaces/EdaUser';
import { RoleDetail } from '../../frontend/eda/interfaces/EdaRole';
import { EdaRbacRole } from '../../frontend/eda/interfaces/EdaRbacRole';
import { Role as HubRole } from '../../frontend/hub/access/roles/Role';
import { RemoteRegistry } from '../../frontend/hub/administration/remote-registries/RemoteRegistry';
import { HubRemote } from '../../frontend/hub/administration/remotes/Remotes';
Expand Down Expand Up @@ -1287,7 +1287,7 @@ declare global {
* getEdaRoleDetail returns the detail of a given role id of a role
* @param roleID get
*/
getEdaRoleDetail(roleID: string): Chainable<RoleDetail>;
getEdaRoleDetail(roleID: string): Chainable<EdaRbacRole>;

/**
* Deletes an EDA credential which is provided.
Expand All @@ -1310,7 +1310,7 @@ declare global {
*/
deleteEdaCredentialType(delete_cred_type: EdaCredentialType): Chainable<void>;

getEdaRoles(content_type__model?: string): Chainable<EdaRole[]>;
getEdaRoles(content_type__model?: string): Chainable<EdaRbacRole[]>;
/**
* Creates an EDA user and returns the same.
*
Expand Down
6 changes: 3 additions & 3 deletions cypress/support/eda-commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
import { EdaDecisionEnvironment } from '../../frontend/eda/interfaces/EdaDecisionEnvironment';
import { EdaProject } from '../../frontend/eda/interfaces/EdaProject';
import { EdaResult } from '../../frontend/eda/interfaces/EdaResult';
import { EdaRole, RoleDetail } from '../../frontend/eda/interfaces/EdaRole';
import { EdaRbacRole } from '../../frontend/eda/interfaces/EdaRbacRole';
import { EdaRulebook } from '../../frontend/eda/interfaces/EdaRulebook';
import {
EdaRulebookActivation,
Expand Down Expand Up @@ -336,7 +336,7 @@ Cypress.Commands.add('getEdaRoles', (content_type__model?: string) => {
const roleDefinitionsUrl = content_type__model
? edaAPI`/role_definitions?content_type__model=${content_type__model}`
: edaAPI`/role_definitions/`;
cy.requestGet<EdaResult<EdaRole>>(roleDefinitionsUrl).then((response) => {
cy.requestGet<EdaResult<EdaRbacRole>>(roleDefinitionsUrl).then((response) => {
const edaRoles = response.results;
return edaRoles;
});
Expand Down Expand Up @@ -364,7 +364,7 @@ Cypress.Commands.add('checkResourceNameAndAction', (resourceTypes: string[], act
});

Cypress.Commands.add('getEdaRoleDetail', (roleID: string) => {
cy.requestGet<RoleDetail>(edaAPI`/role_definitions/${roleID}`);
cy.requestGet<EdaRbacRole>(edaAPI`/role_definitions/${roleID}`);
});

Cypress.Commands.add(
Expand Down
Loading