diff --git a/app/cypress/e2e/0-ndr-core-tests/auth_routes/auth_gp_admin_path_access.cy.js b/app/cypress/e2e/0-ndr-core-tests/auth_routes/auth_gp_admin_path_access.cy.js index 0c2263b2f..253a25b64 100644 --- a/app/cypress/e2e/0-ndr-core-tests/auth_routes/auth_gp_admin_path_access.cy.js +++ b/app/cypress/e2e/0-ndr-core-tests/auth_routes/auth_gp_admin_path_access.cy.js @@ -30,8 +30,11 @@ describe('GP Admin user role has access to the expected GP_ADMIN workflow paths' cy.login(Roles.GP_ADMIN, isBSOL); - cy.getByTestId('search-patient-btn').should('exist'); - cy.getByTestId('search-patient-btn').click(); + if (!isBSOL) { + cy.getByTestId('search-patient-btn').should('exist'); + cy.getByTestId('search-patient-btn').click(); + } + cy.url().should('eq', baseUrl + '/search/patient'); cy.get('#nhs-number-input').click(); diff --git a/app/cypress/e2e/0-ndr-core-tests/auth_routes/auth_gp_clinical_path_access.cy.js b/app/cypress/e2e/0-ndr-core-tests/auth_routes/auth_gp_clinical_path_access.cy.js index 31d37312b..02e677b1d 100644 --- a/app/cypress/e2e/0-ndr-core-tests/auth_routes/auth_gp_clinical_path_access.cy.js +++ b/app/cypress/e2e/0-ndr-core-tests/auth_routes/auth_gp_clinical_path_access.cy.js @@ -16,32 +16,40 @@ const baseUrl = Cypress.config('baseUrl'); const forbiddenRoutes = ['/patient/download']; +const bsolOptions = [true, false]; + describe('GP Clinical user role has access to the expected GP_CLINICAL workflow paths', () => { - context('GP Clinical role has access to expected routes', () => { - it('GP Clinical role has access to Lloyd George View', { tags: 'regression' }, () => { - cy.intercept('GET', '/SearchPatient*', { - statusCode: 200, - body: patient, - }).as('search'); + bsolOptions.forEach((isBSOL) => { + const prefix = isBSOL ? '[BSOL]' : '[Non-BSOL]'; + context(`${prefix} GP Clinical role has access to expected routes`, () => { + it('GP Clinical role has access to Lloyd George View', { tags: 'regression' }, () => { + cy.intercept('GET', '/SearchPatient*', { + statusCode: 200, + body: patient, + }).as('search'); + + cy.login(Roles.GP_CLINICAL, isBSOL); - cy.login(Roles.GP_CLINICAL); + if (!isBSOL) { + cy.getByTestId('search-patient-btn').should('exist'); + cy.getByTestId('search-patient-btn').click(); + } - cy.getByTestId('search-patient-btn').should('exist'); - cy.getByTestId('search-patient-btn').click(); - cy.url().should('eq', baseUrl + '/search/patient'); + cy.url().should('eq', baseUrl + '/search/patient'); - cy.get('#nhs-number-input').click(); - cy.get('#nhs-number-input').type(testPatient); - cy.get('#search-submit').click(); - cy.wait('@search'); + cy.get('#nhs-number-input').click(); + cy.get('#nhs-number-input').type(testPatient); + cy.get('#search-submit').click(); + cy.wait('@search'); - cy.url().should('include', 'verify'); - cy.url().should('eq', baseUrl + '/search/patient/verify'); + cy.url().should('include', 'verify'); + cy.url().should('eq', baseUrl + '/search/patient/verify'); - cy.get('#verify-submit').click(); + cy.get('#verify-submit').click(); - cy.url().should('include', 'lloyd-george-record'); - cy.url().should('eq', baseUrl + '/patient/view/lloyd-george-record'); + cy.url().should('include', 'lloyd-george-record'); + cy.url().should('eq', baseUrl + '/patient/view/lloyd-george-record'); + }); }); }); }); diff --git a/app/cypress/e2e/0-ndr-core-tests/auth_routes/auth_pcse_path_access.cy.js b/app/cypress/e2e/0-ndr-core-tests/auth_routes/auth_pcse_path_access.cy.js index 1eaad1986..9b92ca287 100644 --- a/app/cypress/e2e/0-ndr-core-tests/auth_routes/auth_pcse_path_access.cy.js +++ b/app/cypress/e2e/0-ndr-core-tests/auth_routes/auth_pcse_path_access.cy.js @@ -26,8 +26,6 @@ describe('PCSE user role has access to the expected GP_ADMIN workflow paths', () cy.login(Roles.PCSE); - cy.getByTestId('search-patient-btn').should('exist'); - cy.getByTestId('search-patient-btn').click(); cy.url().should('eq', baseUrl + '/search/patient'); cy.get('#nhs-number-input').click(); diff --git a/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/download_lloyd_george_workflow.cy.js b/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/download_lloyd_george_workflow.cy.js index fc9abf37a..8106851d5 100644 --- a/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/download_lloyd_george_workflow.cy.js +++ b/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/download_lloyd_george_workflow.cy.js @@ -3,13 +3,13 @@ import searchPatientPayload from '../../../fixtures/requests/GET_SearchPatient.j import { Roles } from '../../../support/roles'; const baseUrl = Cypress.config('baseUrl'); +const searchPatientUrl = '/search/patient'; describe('GP Workflow: View Lloyd George record', () => { const beforeEachConfiguration = (role) => { cy.login(role); + cy.visit(searchPatientUrl); - cy.getByTestId('search-patient-btn').should('exist'); - cy.getByTestId('search-patient-btn').click(); // search patient cy.intercept('GET', '/SearchPatient*', { statusCode: 200, diff --git a/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js b/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js index 396e14577..7e39cd0d0 100644 --- a/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js +++ b/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/patient_search_and_verify_workflow.cy.js @@ -3,6 +3,7 @@ import { Roles, roleName } from '../../../support/roles'; describe('GP Workflow: Patient search and verify', () => { // env vars const baseUrl = Cypress.config('baseUrl'); + const searchPatientUrl = '/search/patient'; const gpRoles = [Roles.GP_ADMIN, Roles.GP_CLINICAL]; const noPatientError = 400; @@ -22,9 +23,7 @@ describe('GP Workflow: Patient search and verify', () => { gpRoles.forEach((role) => { beforeEach(() => { cy.login(role); - - cy.getByTestId('search-patient-btn').should('exist'); - cy.getByTestId('search-patient-btn').click(); + cy.visit(searchPatientUrl); }); afterEach(() => { 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 3d7d3570d..9a3072793 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 @@ -2,6 +2,7 @@ import { Roles, roleName } from '../../../support/roles'; // env vars const baseUrl = Cypress.config('baseUrl'); +const searchPatientUrl = '/search/patient'; const formTypes = Object.freeze({ LG: 'LG', @@ -33,8 +34,7 @@ const navigateToUploadPage = () => { body: patient, }).as('search'); - cy.getByTestId('search-patient-btn').should('exist'); - cy.getByTestId('search-patient-btn').click(); + cy.visit(searchPatientUrl); cy.get('#nhs-number-input').click(); cy.get('#nhs-number-input').type(testPatient); diff --git a/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/view_lloyd_george_is_bsol_workflow.cy.js b/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/view_lloyd_george_is_bsol_workflow.cy.js index 9d79fc49e..06677dd40 100644 --- a/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/view_lloyd_george_is_bsol_workflow.cy.js +++ b/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/view_lloyd_george_is_bsol_workflow.cy.js @@ -49,8 +49,6 @@ describe('GP Workflow: View Lloyd George record', () => { statusCode: 200, body: searchPatientPayload, }).as('search'); - cy.getByTestId('search-patient-btn').should('exist'); - cy.getByTestId('search-patient-btn').click(); cy.getByTestId('nhs-number-input').type(searchPatientPayload.nhsNumber); cy.getByTestId('search-submit-btn').click(); cy.wait('@search'); diff --git a/app/cypress/e2e/0-ndr-core-tests/homepage.cy.js b/app/cypress/e2e/0-ndr-core-tests/homepage.cy.js index 339bf7eec..4d6f3d839 100644 --- a/app/cypress/e2e/0-ndr-core-tests/homepage.cy.js +++ b/app/cypress/e2e/0-ndr-core-tests/homepage.cy.js @@ -4,6 +4,7 @@ describe('Home Page', () => { const baseUrl = Cypress.config('baseUrl'); const startUrl = '/'; const homeUrl = '/home'; + const searchPatientUrl = '/search/patient'; beforeEach(() => { cy.visit(startUrl); @@ -51,43 +52,66 @@ describe('Home Page', () => { cy.get('.nhsuk-header__navigation').should('not.exist'); cy.get('.nhsuk-header__navigation-list').should('not.exist'); - cy.login(Roles.GP_CLINICAL); + cy.login(Roles.GP_CLINICAL, true); - cy.url().should('eq', baseUrl + homeUrl); + cy.url().should('eq', baseUrl + searchPatientUrl); cy.get('.nhsuk-header__navigation').should('exist'); cy.get('.nhsuk-header__navigation-list').should('exist'); }, ); - it( - 'should display non-BSOL landing page when user is GP_ADMIN role in non-BSOL area', - { tags: 'regression' }, - () => { - cy.login(Roles.GP_ADMIN, false); - - cy.url().should('eq', baseUrl + homeUrl); - cy.get('h1').should( - 'include.text', - 'You’re outside of Birmingham and Solihull (BSOL)', - ); - - cy.get('.govuk-warning-text__text').should('exist'); - cy.get('.govuk-warning-text__text').should( - 'include.text', - 'Downloading a record will remove it from our storage.', - ); + const gpRoles = [Roles.GP_ADMIN, Roles.GP_CLINICAL]; + gpRoles.forEach((role) => { + it( + `should display non-BSOL landing page when user is ${Roles[role]} role in non-BSOL area`, + { tags: 'regression' }, + () => { + cy.login(Roles.GP_ADMIN, false); + + cy.url().should('eq', baseUrl + homeUrl); + cy.get('h1').should( + 'include.text', + 'You’re outside of Birmingham and Solihull (BSOL)', + ); + + cy.get('.govuk-warning-text__text').should('exist'); + cy.get('.govuk-warning-text__text').should( + 'include.text', + 'Downloading a record will remove it from our storage.', + ); + + cy.get('.nhsuk-header__navigation').should('exist'); + cy.get('.nhsuk-header__navigation-list').should('exist'); + }, + ); + }); + + gpRoles.forEach((role) => { + it( + `should display patient search page when user is ${Roles[role]} role in BSOL area`, + { tags: 'regression' }, + () => { + cy.login(role, true); + + cy.url().should('eq', baseUrl + searchPatientUrl); + cy.get('h1').should( + 'not.include.text', + 'You’re outside of Birmingham and Solihull (BSOL)', + ); + + cy.get('.nhsuk-header__navigation').should('exist'); + cy.get('.nhsuk-header__navigation-list').should('exist'); + }, + ); + }); - cy.get('.nhsuk-header__navigation').should('exist'); - cy.get('.nhsuk-header__navigation-list').should('exist'); - }, - ); it( - 'should display patient search page when user is GP_ADMIN role in BSOL area', + 'should display patient search page when user is PCSE Role', { tags: 'regression' }, () => { - cy.login(Roles.GP_ADMIN, true); + cy.login(Roles.PCSE); - cy.url().should('eq', baseUrl + homeUrl); + cy.url().should('eq', baseUrl + searchPatientUrl); cy.get('h1').should( 'not.include.text', 'You’re outside of Birmingham and Solihull (BSOL)', @@ -121,7 +145,6 @@ describe('Home Page', () => { cy.login(Roles.GP_CLINICAL); - cy.url().should('eq', baseUrl + homeUrl); cy.get('.nhsuk-header__navigation').should('exist'); cy.get('.nhsuk-header__navigation-list').should('exist'); diff --git a/app/cypress/e2e/0-ndr-core-tests/pcse_user_workflows/download_patient_files_workflow.cy.js b/app/cypress/e2e/0-ndr-core-tests/pcse_user_workflows/download_patient_files_workflow.cy.js index 5551b0ead..fcf19a77f 100644 --- a/app/cypress/e2e/0-ndr-core-tests/pcse_user_workflows/download_patient_files_workflow.cy.js +++ b/app/cypress/e2e/0-ndr-core-tests/pcse_user_workflows/download_patient_files_workflow.cy.js @@ -38,8 +38,6 @@ describe('PCSE Workflow: Access and download found files', () => { beforeEach(() => { cy.login(Roles.PCSE); - cy.getByTestId('search-patient-btn').should('exist'); - cy.getByTestId('search-patient-btn').click(); }); const navigateToVerify = () => { diff --git a/app/cypress/e2e/0-ndr-core-tests/pcse_user_workflows/patient_search_and_verify_workflow.cy.js b/app/cypress/e2e/0-ndr-core-tests/pcse_user_workflows/patient_search_and_verify_workflow.cy.js index ea96a22d1..0d02f50ce 100644 --- a/app/cypress/e2e/0-ndr-core-tests/pcse_user_workflows/patient_search_and_verify_workflow.cy.js +++ b/app/cypress/e2e/0-ndr-core-tests/pcse_user_workflows/patient_search_and_verify_workflow.cy.js @@ -17,9 +17,6 @@ describe('PCSE Workflow: patient search and verify', () => { beforeEach(() => { cy.visit(homeUrl); cy.login(Roles.PCSE); - - cy.getByTestId('search-patient-btn').should('exist'); - cy.getByTestId('search-patient-btn').click(); }); it( diff --git a/app/cypress/fixtures/requests/auth/GET_TokenRequest_GP_CLINICAL.json b/app/cypress/fixtures/requests/auth/GET_TokenRequest_GP_CLINICAL.json index d76ca6b3e..421e0487b 100644 --- a/app/cypress/fixtures/requests/auth/GET_TokenRequest_GP_CLINICAL.json +++ b/app/cypress/fixtures/requests/auth/GET_TokenRequest_GP_CLINICAL.json @@ -1,4 +1,5 @@ { "role": "GP_CLINICAL", - "authorisation_token": "111xxx222" + "authorisation_token": "111xxx222", + "isBSOL": true } \ No newline at end of file diff --git a/app/cypress/fixtures/requests/auth/GET_TokenRequest_GP_CLINICAL_non_bsol.json b/app/cypress/fixtures/requests/auth/GET_TokenRequest_GP_CLINICAL_non_bsol.json new file mode 100644 index 000000000..e6162e0e7 --- /dev/null +++ b/app/cypress/fixtures/requests/auth/GET_TokenRequest_GP_CLINICAL_non_bsol.json @@ -0,0 +1,5 @@ +{ + "role": "GP_CLINICAL", + "authorisation_token": "111xxx222", + "isBSOL": false +} \ No newline at end of file diff --git a/app/cypress/support/e2e.ts b/app/cypress/support/e2e.ts index c8b94b0d9..c73bc37ea 100644 --- a/app/cypress/support/e2e.ts +++ b/app/cypress/support/e2e.ts @@ -15,8 +15,8 @@ Cypress.Commands.add('login', (role, isBSOL = true) => { // Login for regression tests const authCallback = '/auth-callback'; const fixturePath = - role === Roles.GP_ADMIN && !isBSOL - ? 'requests/auth/GET_TokenRequest_GP_ADMIN_non_bsol.json' + [Roles.GP_ADMIN, Roles.GP_CLINICAL].includes(role) && !isBSOL + ? 'requests/auth/GET_TokenRequest_' + roleName + '_non_bsol.json' : 'requests/auth/GET_TokenRequest_' + roleName + '.json'; cy.intercept('GET', '/Auth/TokenRequest*', { diff --git a/app/src/pages/homePage/HomePage.test.tsx b/app/src/pages/homePage/HomePage.test.tsx index 981dcd602..7d0c277d6 100644 --- a/app/src/pages/homePage/HomePage.test.tsx +++ b/app/src/pages/homePage/HomePage.test.tsx @@ -2,6 +2,8 @@ import { render, screen, waitFor } from '@testing-library/react'; import HomePage from './HomePage'; import useIsBSOL from '../../helpers/hooks/useIsBSOL'; import { routes } from '../../types/generic/routes'; +import useRole from '../../helpers/hooks/useRole'; +import { REPOSITORY_ROLE } from '../../types/generic/authRole'; const mockedUseNavigate = jest.fn(); jest.mock('react-router', () => ({ @@ -9,70 +11,38 @@ jest.mock('react-router', () => ({ })); jest.mock('../../helpers/hooks/useIsBSOL'); +jest.mock('../../helpers/hooks/useRole'); const mockUseIsBsol = useIsBSOL as jest.Mock; +const mockUseRole = useRole as jest.Mock; describe('HomePage', () => { afterEach(() => { jest.clearAllMocks(); }); - describe('BSOL Rendering', () => { + + const gpRoles = [REPOSITORY_ROLE.GP_ADMIN, REPOSITORY_ROLE.GP_CLINICAL]; + + describe('BSOL Rendering for GP roles', () => { beforeEach(() => { mockUseIsBsol.mockReturnValue(true); }); - - it('renders homepage content', () => { - const contentStrings = [ - 'This service gives you access to Lloyd George digital health records. ' + - 'You may have received a note within a patient record, stating that the record has been digitised.', - 'If you are part of a GP practice, you can use this service to:', - 'view a patient record', - 'remove a patient record', - 'If you are managing records on behalf of NHS England, you can:', - 'Not every patient will have a digital record available.', - 'Before you start', - 'You’ll be asked for:', - 'your NHS smartcard', - 'patient details including their name, date of birth and NHS number', - ]; + it.each(gpRoles)('[%s] redirect user to search patient page', (role) => { + mockUseRole.mockReturnValue(role); render(); - contentStrings.forEach((s) => { - expect(screen.getByText(s)).toBeInTheDocument(); - }); - - const downloadPatientRecord = screen.getAllByText('download a patient record'); - expect(downloadPatientRecord).toHaveLength(2); - - expect(screen.getByText(/Contact the/i)).toBeInTheDocument(); - expect( - screen.getByRole('link', { - name: /NHS National Service Desk/i, - }), - ).toBeInTheDocument(); - expect( - screen.getByText(/if there is an issue with this service or call 0300 303 5678\./i), - ).toBeInTheDocument(); - - expect(screen.getByTestId('search-patient-btn')).toBeInTheDocument(); + expect(mockedUseNavigate).toHaveBeenCalledWith(routes.SEARCH_PATIENT); }); + }); - it('renders a service link that takes you to service help-desk in a new tab', () => { + describe('PCSE Rendering', () => { + beforeEach(() => { + mockUseRole.mockReturnValue(REPOSITORY_ROLE.PCSE); + }); + it('redirect user to search patient page', () => { render(); - expect(screen.getByText(/Contact the/i)).toBeInTheDocument(); - const nationalServiceDeskLink = screen.getByRole('link', { - name: /NHS National Service Desk/i, - }); - expect( - screen.getByText(/if there is an issue with this service or call 0300 303 5678/i), - ).toBeInTheDocument(); - - expect(nationalServiceDeskLink).toHaveAttribute( - 'href', - 'https://digital.nhs.uk/about-nhs-digital/contact-us#nhs-digital-service-desks', - ); - expect(nationalServiceDeskLink).toHaveAttribute('target', '_blank'); + expect(mockedUseNavigate).toHaveBeenCalledWith(routes.SEARCH_PATIENT); }); }); diff --git a/app/src/pages/homePage/HomePage.tsx b/app/src/pages/homePage/HomePage.tsx index 731f49e04..f64610285 100644 --- a/app/src/pages/homePage/HomePage.tsx +++ b/app/src/pages/homePage/HomePage.tsx @@ -3,13 +3,27 @@ import { ButtonLink } from 'nhsuk-react-components'; import { useNavigate } from 'react-router'; import { routes } from '../../types/generic/routes'; import useIsBSOL from '../../helpers/hooks/useIsBSOL'; +import React, { useEffect } from 'react'; +import useRole from '../../helpers/hooks/useRole'; +import { REPOSITORY_ROLE } from '../../types/generic/authRole'; type Props = {}; +const RedirectToSearchPage = () => { + const navigate = useNavigate(); + useEffect(() => { + navigate(routes.SEARCH_PATIENT); + }); + return <>; +}; + const HomePage = (props: Props) => { const navigate = useNavigate(); const isBsol = useIsBSOL(); + const role = useRole(); + const userIsPCSE = role === REPOSITORY_ROLE.PCSE; + const SearchButton = () => ( { ); - const BsolContent = () => ( - <> -

Access and store digital GP records

-

- This service gives you access to Lloyd George digital health records. You may have - received a note within a patient record, stating that the record has been digitised. -

-

If you are part of a GP practice, you can use this service to:

- -

If you are managing records on behalf of NHS England, you can:

- -

Not every patient will have a digital record available.

-

Before you start

-

You’ll be asked for:

- - - -

Get support with the service

- {'Contact the '} - - NHS National Service Desk - - {' if there is an issue with this service or call 0300 303 5678.'} - - ); - const NonBsolContent = () => ( <>

You’re outside of Birmingham and Solihull (BSOL)

@@ -98,7 +73,7 @@ const HomePage = (props: Props) => { ); - return isBsol ? : ; + return isBsol || userIsPCSE ? : ; }; export default HomePage;