diff --git a/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/upload_workflow.cy.js b/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/upload_workflow.cy.js index 81698f5cf..c90e8c79a 100644 --- a/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/upload_workflow.cy.js +++ b/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/upload_workflow.cy.js @@ -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'); diff --git a/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/view_lloyd_george_workflow.cy.js b/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/view_lloyd_george_workflow.cy.js index e5e0cf461..29e4b7da6 100644 --- a/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/view_lloyd_george_workflow.cy.js +++ b/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/view_lloyd_george_workflow.cy.js @@ -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' }, @@ -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*', { diff --git a/app/cypress/support/e2e.ts b/app/cypress/support/e2e.ts index eca8f219a..ee2a47ba9 100644 --- a/app/cypress/support/e2e.ts +++ b/app/cypress/support/e2e.ts @@ -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)) { @@ -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