Skip to content

Commit

Permalink
Merge branch 'main' into PRMDR-488
Browse files Browse the repository at this point in the history
  • Loading branch information
carlsmith101 authored Jan 2, 2024
2 parents f3d894a + 5c4bf62 commit a4a5cb9
Show file tree
Hide file tree
Showing 102 changed files with 2,420 additions and 1,775 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/ui-smoketest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ on:
required: true
type: 'string'
default: 'main'
environment:
description: 'Which Environment type are we using'
required: true
type: 'string'
default: 'development'
sandbox:
description: 'Sandbox to run the smoke tests on.'
required: true
Expand All @@ -21,8 +26,10 @@ permissions:
contents: read # This is required for actions/checkout

jobs:

cypress-run-chrome:
runs-on: ubuntu-22.04
environment: ${{ github.event.inputs.environment }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -44,9 +51,12 @@ jobs:
env:
CYPRESS_BASE_URL: 'https://${{ github.event.inputs.sandbox }}.access-request-fulfilment.patient-deductions.nhs.uk'
CYPRESS_grepTags: 'smoke'
CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }}
CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }}

cypress-run-firefox:
runs-on: ubuntu-22.04
environment: ${{ github.event.inputs.environment }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -68,9 +78,12 @@ jobs:
env:
CYPRESS_BASE_URL: 'https://${{ github.event.inputs.sandbox }}.access-request-fulfilment.patient-deductions.nhs.uk'
CYPRESS_grepTags: 'smoke'
CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }}
CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }}

cypress-run-edge:
runs-on: ubuntu-22.04
environment: ${{ github.event.inputs.environment }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand All @@ -92,3 +105,5 @@ jobs:
env:
CYPRESS_BASE_URL: 'https://${{ github.event.inputs.sandbox }}.access-request-fulfilment.patient-deductions.nhs.uk'
CYPRESS_grepTags: 'smoke'
CYPRESS_USERNAME: ${{ secrets.CYPRESS_USERNAME }}
CYPRESS_PASSWORD: ${{ secrets.CYPRESS_PASSWORD }}
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ clean-test:

format:
./lambdas/venv/bin/python3 -m isort --profile black lambdas/
./lambdas/venv/bin/python3 -m black lambdas/ &&\
ruff check lambdas/ --fix
./lambdas/venv/bin/python3 -m black lambdas/
./lambdas/venv/bin/ruff check lambdas/ --fix

sort-requirements:
sort -o lambdas/requirements.txt lambdas/requirements.txt
Expand Down
2 changes: 2 additions & 0 deletions app/.env.template
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ CONTAINER_PORT=xx # Port number within the container. Needed for building the
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_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
14 changes: 6 additions & 8 deletions app/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
import { defineConfig } from 'cypress';
import * as dotenv from 'dotenv';

function getBaseUrlFromEnv() {
dotenv.config();
return process.env.CYPRESS_BASE_URL;
}

dotenv.config();
export default defineConfig({
e2e: {
setupNodeEvents(on, config) {
// implement node event listeners here
},
downloadsFolder: 'cypress/downloads',
trashAssetsBeforeRuns: true,
baseUrl: getBaseUrlFromEnv(),
baseUrl: process.env.CYPRESS_BASE_URL,
},
env: {
USERNAME: process.env.CYPRESS_USERNAME,
PASSWORD: process.env.CYPRESS_PASSWORD,
},

component: {
devServer: {
framework: 'create-react-app',
bundler: 'webpack',
},
},

reporter: 'mochawesome',
reporterOptions: {
reportDir: 'cypress/results',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import authPayload from '../../../fixtures/requests/auth/GET_TokenRequest_GP_ADMIN.json';
import { Roles } from '../../../support/roles';

describe('Authentication & Authorisation', () => {
const baseUrl = Cypress.config('baseUrl');
Expand All @@ -8,7 +9,7 @@ describe('Authentication & Authorisation', () => {
'sets session storage on login and clears session storage on logout',
{ tags: 'regression' },
() => {
cy.login('GP_ADMIN');
cy.login(Roles.GP_ADMIN);

assertSessionStorage({
auth: authPayload,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const { Roles } = require('../../../support/roles');

const testPatient = '9000000009';
const patient = {
birthDate: '1970-01-01',
Expand All @@ -22,7 +24,7 @@ describe('GP Admin user role has access to the expected GP_ADMIM workflow paths'
body: patient,
}).as('search');

cy.login('GP_ADMIN');
cy.login(Roles.GP_ADMIN);
cy.url().should('eq', baseUrl + '/search/upload');

cy.get('#nhs-number-input').click();
Expand All @@ -48,7 +50,7 @@ describe('GP Admin user role cannot access expected forbidden routes', () => {
'GP Admin role cannot access route ' + forbiddenRoute,
{ tags: 'regression' },
() => {
cy.login('GP_ADMIN');
cy.login(Roles.GP_ADMIN);
cy.visit(forbiddenRoute);
cy.url().should('include', 'unauthorised');
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const { Roles } = require('../../../support/roles');

const testPatient = '9000000009';
const patient = {
birthDate: '1970-01-01',
Expand All @@ -22,7 +24,7 @@ describe('GP Clinical user role has access to the expected GP_CLINICAL workflow
body: patient,
}).as('search');

cy.login('GP_CLINICAL');
cy.login(Roles.GP_CLINICAL);
cy.url().should('eq', baseUrl + '/search/upload');

cy.get('#nhs-number-input').click();
Expand All @@ -48,7 +50,7 @@ describe('GP Clinical user role cannot access expected forbidden routes', () =>
'GP Clinical role cannot access route ' + forbiddenRoute,
{ tags: 'regression' },
() => {
cy.login('GP_CLINICAL');
cy.login(Roles.GP_CLINICAL);
cy.visit(forbiddenRoute);
cy.url().should('include', 'unauthorised');
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
const { Roles } = require('../../../support/roles');

const testPatient = '9000000009';
const patient = {
birthDate: '1970-01-01',
Expand Down Expand Up @@ -27,7 +29,7 @@ describe('PCSE user role has access to the expected GP_ADMIN workflow paths', ()
body: patient,
}).as('search');

cy.login('PCSE');
cy.login(Roles.PCSE);

cy.url().should('eq', baseUrl + '/search/patient');

Expand All @@ -46,7 +48,7 @@ describe('PCSE user role cannot access expected forbidden routes', () => {
context('PCSE role has no access to forbidden routes', () => {
forbiddenRoutes.forEach((forbiddenRoute) => {
it('PCSE role cannot access route' + forbiddenRoute, { tags: 'regression' }, () => {
cy.login('PCSE');
cy.login(Roles.PCSE);
cy.visit(forbiddenRoute);
cy.url().should('include', 'unauthorised');
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import viewLloydGeorgePayload from '../../../fixtures/requests/GET_LloydGeorgeStitch.json';
import searchPatientPayload from '../../../fixtures/requests/GET_SearchPatient.json';
import { Roles } from '../../../support/roles';

const baseUrl = Cypress.config('baseUrl');

Expand All @@ -21,7 +22,7 @@ describe('GP Workflow: View Lloyd George record', () => {
'GP ADMIN user can download the Lloyd George document of an active patient',
{ tags: 'regression' },
() => {
beforeEachConfiguration('GP_ADMIN');
beforeEachConfiguration(Roles.GP_ADMIN);

cy.intercept('GET', '/LloydGeorgeStitch*', {
statusCode: 200,
Expand Down Expand Up @@ -71,7 +72,7 @@ describe('GP Workflow: View Lloyd George record', () => {
'No download option or menu exists when no Lloyd George record exists for a patient as a GP ADMIN role',
{ tags: 'regression' },
() => {
beforeEachConfiguration('GP_ADMIN');
beforeEachConfiguration(Roles.GP_ADMIN);

cy.intercept('GET', '/LloydGeorgeStitch*', {
statusCode: 404,
Expand All @@ -88,7 +89,7 @@ describe('GP Workflow: View Lloyd George record', () => {
'No download option exists when a Lloyd George record exists for the patient as a GP CLINICAL role',
{ tags: 'regression' },
() => {
beforeEachConfiguration('GP_CLINICAL');
beforeEachConfiguration(Roles.GP_CLINICAL);

cy.intercept('GET', '/LloydGeorgeStitch*', {
statusCode: 200,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { Roles, roleName } from '../../../support/roles';

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

const noPatientError = 400;
const testNotFoundPatient = '1000000001';
Expand All @@ -25,11 +27,9 @@ describe('GP Workflow: Patient search and verify', () => {
afterEach(() => {
patient.active = false;
});

it(
'Shows patient upload screen when patient search is used by a ' +
role +
' role and patient response is inactive',
`Shows patient upload screen when patient search is used by as a
${roleName(role)} and patient response is inactive`,
{ tags: 'regression' },
() => {
cy.intercept('GET', '/SearchPatient*', {
Expand Down Expand Up @@ -58,9 +58,9 @@ describe('GP Workflow: Patient search and verify', () => {
);

it(
'Does not show verify patient view when the search finds no patient as a ' +
role +
' role',
`Does not show verify patient view when the search finds no patient as ${roleName(
role,
)}`,
{ tags: 'regression' },
() => {
cy.intercept('GET', '/SearchPatient*', {
Expand All @@ -84,9 +84,9 @@ describe('GP Workflow: Patient search and verify', () => {
);

it(
'Shows the upload documents page when upload patient is verified and inactive as a ' +
role +
' role',
`Shows the upload documents page when upload patient is verified and inactive as a ${roleName(
role,
)} `,
{ tags: 'regression' },
() => {
cy.intercept('GET', '/SearchPatient*', {
Expand All @@ -107,9 +107,9 @@ describe('GP Workflow: Patient search and verify', () => {
);

it(
'Shows the Lloyd george view page when upload patient is verified and active as a ' +
role +
' role',
`Shows the Lloyd george view page when upload patient is verified and active as a ${roleName(
role,
)} `,
{ tags: 'regression' },
() => {
patient.active = true;
Expand All @@ -132,9 +132,9 @@ describe('GP Workflow: Patient search and verify', () => {
);

it(
'Search validation is shown when the user does not enter an nhs number as a ' +
role +
' role',
`Search validation is shown when the user does not enter an nhs number as a ${roleName(
role,
)}`,
{ tags: 'regression' },
() => {
cy.get('#search-submit').click();
Expand All @@ -147,9 +147,9 @@ describe('GP Workflow: Patient search and verify', () => {
);

it(
'Search validation is shown when the user enters an invalid nhs number as a ' +
role +
' role',
`Search validation is shown when the user enters an invalid nhs number as a ${roleName(
role,
)} `,
{ tags: 'regression' },
() => {
cy.get('#nhs-number-input').click();
Expand Down
Loading

0 comments on commit a4a5cb9

Please sign in to comment.