Skip to content

Commit

Permalink
PRMDR-555 Patient Smoke (#218)
Browse files Browse the repository at this point in the history
Add patient search smoke tests
  • Loading branch information
RioKnightleyNHS authored Jan 9, 2024
1 parent bc081ef commit 259d582
Show file tree
Hide file tree
Showing 13 changed files with 289 additions and 213 deletions.
27 changes: 26 additions & 1 deletion .github/workflows/ui-smoketest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ permissions:
contents: read # This is required for actions/checkout

jobs:

cypress-run-chrome:
runs-on: ubuntu-22.04
environment: ${{ github.event.inputs.environment }}
Expand All @@ -51,8 +50,23 @@ jobs:
env:
CYPRESS_BASE_URL: 'https://${{ github.event.inputs.sandbox }}.access-request-fulfilment.patient-deductions.nhs.uk'
CYPRESS_grepTags: 'smoke'
CYPRESS_WORKSPACE: ${{ github.event.inputs.sandbox }}
CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }}
CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }}
CYPRESS_OUTPUT_VIDEO: true

- uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-screenshots
path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/screenshots
if-no-files-found: ignore
- uses: actions/upload-artifact@v4
if: failure()
with:
name: cypress-videos
path: /home/runner/work/national-document-repository/national-document-repository/app/cypress/videos
if-no-files-found: ignore

cypress-run-firefox:
runs-on: ubuntu-22.04
Expand All @@ -64,6 +78,13 @@ jobs:
repository: 'nhsconnect/national-document-repository'
ref: ${{ github.event.inputs.build_branch}}

- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
role-to-assume: ${{ secrets.AWS_ASSUME_ROLE }}
role-skip-session-tagging: true
aws-region: ${{ vars.AWS_REGION }}

- name: Cypress install
run: |
npm install --legacy-peer-deps
Expand All @@ -78,8 +99,10 @@ jobs:
env:
CYPRESS_BASE_URL: 'https://${{ github.event.inputs.sandbox }}.access-request-fulfilment.patient-deductions.nhs.uk'
CYPRESS_grepTags: 'smoke'
CYPRESS_WORKSPACE: ${{ github.event.inputs.sandbox }}
CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }}
CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }}
CYPRESS_OUTPUT_VIDEO: false

cypress-run-edge:
runs-on: ubuntu-22.04
Expand All @@ -105,5 +128,7 @@ jobs:
env:
CYPRESS_BASE_URL: 'https://${{ github.event.inputs.sandbox }}.access-request-fulfilment.patient-deductions.nhs.uk'
CYPRESS_grepTags: 'smoke'
CYPRESS_WORKSPACE: ${{ github.event.inputs.sandbox }}
CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }}
CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }}
CYPRESS_OUTPUT_VIDEO: false
6 changes: 6 additions & 0 deletions app/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ REACT_APP_IMAGE_VERSION="%IMAGE_VERSION%"
CONTAINER_PORT=xx # Port number within the container. Needed for building the docker image
HOST_PORT=xxxx # Port number that the docker-compose localhost exposes. Only need this if we run docker-compose
PORT=xxxx # Port number of the localhost dev server when we run `make start`

# Cypress Smoke Testing
CYPRESS_BASE_URL=http://localhost:xxxx # Use the port number same as above PORT
CYPRESS_USERNAME=xxxx # For Cypress CIS2 Login during smoke tests
CYPRESS_PASSWORD=xxxx # For Cypress CIS2 Login during smoke tests
CYPRESS_WORKSPACE=local # Helps find the correct patient data relative to the workspace
AWS_ACCESS_KEY_ID=xxxx # If workspace is a sandbox, data is seeded with these credentials
AWS_SECRET_ACCESS_KEY=xxxx # If workspace is a sandbox, data is seeded with these credentials
AWS_SESSION_TOKEN=xxxx # If workspace is a sandbox, data is seeded with these credentials
7 changes: 7 additions & 0 deletions app/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ export default defineConfig({
env: {
USERNAME: process.env.CYPRESS_USERNAME,
PASSWORD: process.env.CYPRESS_PASSWORD,
WORKSPACE: process.env.CYPRESS_WORKSPACE ?? 'local',
AWS_ACCESS_KEY_ID: process.env.AWS_ACCESS_KEY_ID,
AWS_SECRET_ACCESS_KEY: process.env.AWS_SECRET_ACCESS_KEY,
AWS_REGION: process.env.AWS_REGION,
AWS_SESSION_TOKEN: process.env.AWS_SESSION_TOKEN,
},
component: {
devServer: {
Expand All @@ -28,4 +33,6 @@ export default defineConfig({
html: false,
json: true,
},
video: process.env.CYPRESS_OUTPUT_VIDEO ? true : false,
videoCompression: 15,
});
60 changes: 43 additions & 17 deletions app/cypress/e2e/0-ndr-core-tests/homepage.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,25 @@ describe('Home Page', () => {
cy.url().should('eq', baseUrl + homeUrl);
});

it('displays correct page title on home page', { tags: 'regression' }, () => {
cy.get('.app-homepage-content h1').should(
'have.text',
'Access and store digital GP records',
);
});

it('displays start now button on home page', { tags: 'regression' }, () => {
cy.get('.nhsuk-button').should('have.text', 'Start now');
});

it('displays service banner', { tags: 'regression' }, () => {
cy.get('.govuk-phase-banner__content__tag').should('have.text', 'New Service');
cy.get('.govuk-phase-banner__text').should(
'have.text',
'Your feedback will help us to improve this service.',
);
});

context('Login tests', () => {
it(
'should display patient search page with navigation after user log in from homepage',
Expand Down Expand Up @@ -42,37 +61,44 @@ describe('Home Page', () => {
});

context('Logout tests', () => {
// TODO: Align with smoke logout test
it(
'should display home page with no navigation after user log out',
{ tags: 'regression' },
() => {
cy.get('header').should('have.length', 1);
cy.get('header').should('exist');

cy.get('.nhsuk-logo__background').should('have.length', 1);
cy.get('.nhsuk-header__transactional-service-name').should('have.length', 1);
cy.get('.nhsuk-logo__background').should('exist');
cy.get('.nhsuk-header__transactional-service-name').should('exist');
cy.get('.nhsuk-header__transactional-service-name')
.children()
.should('have.length', 1);
cy.get('.nhsuk-header__transactional-service-name--link').should('exist');
cy.get('.nhsuk-header__transactional-service-name--link').should(
'have.text',
'Access and store digital GP records',
);
cy.get('.nhsuk-header__navigation').should('not.exist');
cy.get('.nhsuk-header__navigation-list').should('not.exist');

cy.get('.nhsuk-header__navigation').should('have.length', 0);
cy.get('.nhsuk-header__navigation-list').should('have.length', 0);
},
);
cy.login(Roles.GP_CLINICAL);

cy.url().should('eq', baseUrl + searchUrl);
cy.get('.nhsuk-header__navigation').should('exist');
cy.get('.nhsuk-header__navigation-list').should('exist');

it('displays correct page title on home page', { tags: 'regression' }, () => {
cy.get('.app-homepage-content h1').should(
'have.text',
'Access and store digital GP records',
);
});
cy.intercept('GET', '/Auth/Logout', {
statusCode: 200,
}).as('logout');

it('displays start now button on home page', { tags: 'regression' }, () => {
cy.get('.nhsuk-button').should('have.text', 'Start now');
});
cy.getByTestId('logout-btn').should('exist');
cy.getByTestId('logout-btn').click();

cy.wait('@logout');
cy.url({ timeout: 10000 }).should('contain', baseUrl + homeUrl);

cy.get('.nhsuk-header__navigation').should('not.exist');
cy.get('.nhsuk-header__navigation-list').should('not.exist');
},
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ describe('PCSE Workflow: patient search and verify', () => {
// env vars
const baseUrl = Cypress.config('baseUrl');
const homeUrl = '/';
const testPatient = '9000000009';
const patient = {
birthDate: '1970-01-01',
familyName: 'Default Surname',
givenName: ['Default Given Name'],
nhsNumber: testPatient,
nhsNumber: '9000000009',
postalCode: 'AA1 1AA',
superseded: false,
restricted: false,
Expand All @@ -19,37 +18,11 @@ describe('PCSE Workflow: patient search and verify', () => {
cy.visit(homeUrl);
});

it(
'It redirects to the patient download screen when patient search successfully by a PCSE user',
{ tags: 'regression' },
() => {
cy.intercept('GET', '/SearchPatient*', {
statusCode: 200,
body: patient,
}).as('search');

cy.login(Roles.PCSE);
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', 'result');
cy.url().should('eq', baseUrl + '/search/patient/result');
cy.get('#gp-message').should('not.exist');

cy.get('#verify-submit').click();

cy.url().should('include', 'results');
cy.url().should('eq', baseUrl + '/search/results');
},
);

it(
'It shows the download documents page when download patient is verified by a PCSE user',
{ tags: 'regression' },
() => {
const testPatient = '9000000009';
cy.login(Roles.PCSE);
cy.intercept('GET', '/SearchPatient*', {
statusCode: 200,
Expand All @@ -66,31 +39,11 @@ describe('PCSE Workflow: patient search and verify', () => {
},
);

it(
'It searches for a valid patient successfully when the user enters a known nhs number by a PCSE user',
{ tags: 'regression' },
() => {
cy.intercept('GET', '/SearchPatient*', {
statusCode: 200,
body: patient,
}).as('search');

cy.login(Roles.PCSE);
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', 'result');
cy.url().should('eq', baseUrl + '/search/patient/result');
},
);

it(
'It searches for a valid patient successfully when the user enters a known nhs number with spaces by a PCSE user',
{ tags: 'regression' },
() => {
const testPatient = '900 000 0009';
cy.intercept('GET', '/SearchPatient*', {
statusCode: 200,
body: {
Expand All @@ -114,6 +67,7 @@ describe('PCSE Workflow: patient search and verify', () => {
'It searches for a valid patient successfully when the user enters a known nhs number with dashes by a PCSE user',
{ tags: 'regression' },
() => {
const testPatient = '900-000-0009';
cy.intercept('GET', '/SearchPatient*', {
statusCode: 200,
body: {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Roles, roleName } from '../../../support/roles';

describe('GP Workflow: Patient search and verify', () => {
// env vars
const baseUrl = Cypress.config('baseUrl');
const gpRoles = [Roles.GP_ADMIN, Roles.GP_CLINICAL];

const workspace = Cypress.env('WORKSPACE');
const activePatient = workspace === 'ndr-dev' ? '9730153817' : '9000000002';

gpRoles.forEach((role) => {
it(
`[Smoke] Shows the Lloyd george view page when upload patient is verified and active as a ${roleName(
role,
)} `,
{ tags: 'smoke' },
() => {
cy.smokeLogin(role);
cy.get('#nhs-number-input').click();
cy.get('#nhs-number-input').type(activePatient);
cy.get('#search-submit').click();

cy.url({ timeout: 10000 }).should('eq', baseUrl + '/search/upload/result');
cy.get('#verify-submit').click();

cy.url({ timeout: 10000 }).should(
'eq',
baseUrl + '/search/patient/lloyd-george-record',
);
},
);
});
});
Loading

0 comments on commit 259d582

Please sign in to comment.