Skip to content

Commit

Permalink
Add rolename helper
Browse files Browse the repository at this point in the history
  • Loading branch information
RioKnightleyNHS committed Dec 20, 2023
1 parent 103942d commit 1ac6cf7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ describe('GP Workflow: Upload docs and verify', () => {
});

it(
'On Start now button click as ' + role + ', redirect to uploads is successful',
`On Start now button click as ${cy.roleName(role)} redirect to uploads is successful`,
{ tags: 'regression' },
() => {
cy.url().should('include', 'upload');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ describe('GP Workflow: View Lloyd George record', () => {
beforeEachConfiguration(role);
});

context('View Lloyd George document for ' + role + ' role', () => {
context(`View Lloyd George document for ${cy.roleName(role)} role`, () => {
it(
role + ' can view a Lloyd George document of an active patient',
{ tags: 'regression' },
Expand Down Expand Up @@ -114,7 +114,9 @@ describe('GP Workflow: View Lloyd George record', () => {
);

it(
'It displays an error when the Lloyd George Stitch API call fails for a ' + role,
`It displays an error when the Lloyd George Stitch API call fails for a ${cy.roleName(
role,
)}`,
{ tags: 'regression' },
() => {
cy.intercept('GET', '/LloydGeorgeStitch*', {
Expand Down
12 changes: 12 additions & 0 deletions app/cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ Cypress.Commands.add('login', (role) => {
}
});

Cypress.Commands.add(
'roleName',
(role) => roleList.find((roleName) => Roles[roleName] === role) ?? '',
);

Cypress.Commands.add('smokeLogin', (role) => {
// Login for smoke tests
if (roleIds.includes(role)) {
Expand Down Expand Up @@ -94,6 +99,13 @@ declare global {
* @return {HTMLElement} - Target DOM element.
*/
getByTestId(value: string);
/**
* Get name of role from value of role
*
* @param {Roles} role - The user role to login with. Must be an enum of Roles
* @return {string} - Role name as string
*/
roleName(role: Roles);
/**
* Mock user login by intercepting the {baseUrl}/auth-callback request
* @param {Roles} role - The user role to login with. Must be an enum of Roles
Expand Down

0 comments on commit 1ac6cf7

Please sign in to comment.