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

PRMDR-555 Patient Smoke #218

Merged
merged 29 commits into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
1436334
Add smoke logout test
RioKnightleyNHS Jan 2, 2024
460bb6a
Finish homepage smoke tests
RioKnightleyNHS Jan 2, 2024
11e9942
Add tests for GP patient search
RioKnightleyNHS Jan 2, 2024
6df364e
Add smoke tests for pcse workflow
RioKnightleyNHS Jan 3, 2024
a2177fc
Remove search stubs from pcse tests
RioKnightleyNHS Jan 3, 2024
b26e316
Remove duplicate test cases
RioKnightleyNHS Jan 3, 2024
24970fd
Add workspace environment variable
RioKnightleyNHS Jan 3, 2024
34384e0
Merge branch 'main' into prmdr-555-smoke
RioKnightleyNHS Jan 3, 2024
9ba2a08
Fix typescript errors on cypress configs
RioKnightleyNHS Jan 3, 2024
8e3447d
Add AWS config to github action
RioKnightleyNHS Jan 3, 2024
c3b5b56
Update cypress commands with cy.promise
RioKnightleyNHS Jan 3, 2024
2ecc9b5
Extend documentation for custom commands
RioKnightleyNHS Jan 3, 2024
9a446ef
Restore e2e file
RioKnightleyNHS Jan 3, 2024
524ff6a
Add cypress artefacts to smoke action
RioKnightleyNHS Jan 5, 2024
0f0543c
Update cypress artefact workflow
RioKnightleyNHS Jan 5, 2024
8b2a920
Add artifact ids
RioKnightleyNHS Jan 5, 2024
13bfffb
Add video output to env
RioKnightleyNHS Jan 5, 2024
e7f6825
Update timeout lengths on smoke tests
RioKnightleyNHS Jan 5, 2024
d483004
Change 'contain' to 'eq' on logout url
RioKnightleyNHS Jan 5, 2024
73b6406
Update patient number
RioKnightleyNHS Jan 5, 2024
94625ad
Use fake failure to test artifacts
RioKnightleyNHS Jan 5, 2024
5a231c8
Modify action for artifacts
RioKnightleyNHS Jan 5, 2024
5ac14ac
Modify artifact mv command
RioKnightleyNHS Jan 5, 2024
f488016
Add compression tag
RioKnightleyNHS Jan 5, 2024
be15e45
Edit artifact actions:
RioKnightleyNHS Jan 5, 2024
c8dae85
Update yml for only chrome artifact
RioKnightleyNHS Jan 8, 2024
38a5247
Test output of failure for artifact
RioKnightleyNHS Jan 8, 2024
cfe5dbf
Restore working test
RioKnightleyNHS Jan 8, 2024
f2e806a
Add logout stub for homepage test
RioKnightleyNHS Jan 8, 2024
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
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
Loading