Skip to content

Commit

Permalink
PRMDR - CIS2 Role handling added and configured (#120)
Browse files Browse the repository at this point in the history
* Configured Login request to CIS2 to prompt for role selection.
* Use selected_roleid from cis2 to determine user's role.
* General role checks as part of the token handler to return a system role as part of the request.
* Patient Active state added to Patient Search Handler as well as ODS Patient to User GP Practise ODS matching.
* GP Clinical role added to the system
* UI changes to remove role selection and use role response from token handler
* UI changes to handler workflow route based on active/inactive patient status.


---------

Co-authored-by: Richard Smith <richard.smith33@nhs.net>
Co-authored-by: AlexHerbertNHS <alexandra.herbert1@nhs.net>
Co-authored-by: Joe Fong <joe.fong1@nhs.net>
Co-authored-by: Scott Alexander <scott.alexander@madetech.com>
Co-authored-by: Rio Knightley <rio.knightley2@nhs.net>
Co-authored-by: NogaNHS <127490765+NogaNHS@users.noreply.github.com>
Co-authored-by: Richard Smith <43441481+thisusernameisnowtaken@users.noreply.github.com>
Co-authored-by: Rio Knightley <128376976+RioKnightleyNHS@users.noreply.github.com>
  • Loading branch information
9 people authored Nov 6, 2023
1 parent 731c3e4 commit 8160a95
Show file tree
Hide file tree
Showing 70 changed files with 16,636 additions and 12,068 deletions.
Empty file added app/cypress/cypress.env.json
Empty file.
4 changes: 2 additions & 2 deletions app/cypress/e2e/0-ndr-core-tests/auth.cy.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import authPayload from '../../fixtures/requests/auth/GET_TokenRequest.json';
import authPayload from '../../fixtures/requests/auth/GET_TokenRequest_GP_ADMIN.json';

describe('authentication & authorisation', () => {
const baseUrl = 'http://localhost:3000';

context('session management', () => {
it('sets session storage on login and clears session storage on logout', () => {
cy.login('gp');
cy.login('GP_ADMIN');

assertSessionStorage({
auth: authPayload,
Expand Down
45 changes: 45 additions & 0 deletions app/cypress/e2e/0-ndr-core-tests/auth_gp_admin_path.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const testPatient = '9000000009';
const patient = {
birthDate: '1970-01-01',
familyName: 'Default Surname',
givenName: ['Default Given Name'],
nhsNumber: testPatient,
postalCode: 'AA1 1AA',
superseded: false,
restricted: false,
active: true,
};

const smokeTest = Cypress.env('CYPRESS_RUN_AS_SMOKETEST') ?? false;
const baseUrl = Cypress.env('CYPRESS_BASE_URL') ?? 'http://localhost:3000/';

describe('assert GP_ADMIM workflow path', () => {
const baseUrl = 'http://localhost:3000';

context('session management', () => {
it('sets session storage on login and checks starting url route', () => {
if (!smokeTest) {
cy.intercept('GET', '/SearchPatient*', {
statusCode: 200,
body: patient,
}).as('search');
}

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

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', 'upload');
cy.url().should('eq', baseUrl + '/search/upload/result');

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

cy.url().should('include', 'lloyd-george-record');
cy.url().should('eq', baseUrl + '/search/patient/lloyd-george-record');
});
});
});
45 changes: 45 additions & 0 deletions app/cypress/e2e/0-ndr-core-tests/auth_gp_clinical_path.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
const testPatient = '9000000009';
const patient = {
birthDate: '1970-01-01',
familyName: 'Default Surname',
givenName: ['Default Given Name'],
nhsNumber: testPatient,
postalCode: 'AA1 1AA',
superseded: false,
restricted: false,
active: true,
};

const smokeTest = Cypress.env('CYPRESS_RUN_AS_SMOKETEST') ?? false;
const baseUrl = Cypress.env('CYPRESS_BASE_URL') ?? 'http://localhost:3000/';

describe('assert GP_CLINICAL workflow path', () => {
const baseUrl = 'http://localhost:3000';

context('session management', () => {
it('sets session storage on login and checks starting url route', () => {
if (!smokeTest) {
cy.intercept('GET', '/SearchPatient*', {
statusCode: 200,
body: patient,
}).as('search');
}

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

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', 'upload');
cy.url().should('eq', baseUrl + '/search/upload/result');

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

cy.url().should('include', 'lloyd-george-record');
cy.url().should('eq', baseUrl + '/search/patient/lloyd-george-record');
});
});
});
41 changes: 41 additions & 0 deletions app/cypress/e2e/0-ndr-core-tests/auth_pcse_path.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
const testPatient = '9000000009';
const patient = {
birthDate: '1970-01-01',
familyName: 'Default Surname',
givenName: ['Default Given Name'],
nhsNumber: testPatient,
postalCode: 'AA1 1AA',
superseded: false,
restricted: false,
active: false,
};

const smokeTest = Cypress.env('CYPRESS_RUN_AS_SMOKETEST') ?? false;
const baseUrl = Cypress.env('CYPRESS_BASE_URL') ?? 'http://localhost:3000/';

describe('assert PCSE workflow path', () => {
const baseUrl = 'http://localhost:3000';

context('session management', () => {
it('sets session storage on login and checks starting url route', () => {
if (!smokeTest) {
cy.intercept('GET', '/SearchPatient*', {
statusCode: 200,
body: patient,
}).as('search');
}

cy.login('PCSE');

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('#verify-submit').click();
cy.url().should('eq', baseUrl + '/search/results');
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ describe('GP Upload Workflow Step 1: Patient search and verify', () => {
postalCode: 'AA1 1AA',
superseded: false,
restricted: false,
active: false,
};

beforeEach(() => {
cy.login('gp');
cy.login('GP_ADMIN');
});

it('(Smoke test) shows patient upload screen when patient search is used by a GP and Inactive patient radio button is selected', () => {
Expand All @@ -41,7 +42,6 @@ describe('GP Upload Workflow Step 1: Patient search and verify', () => {
'have.text',
'Ensure these patient details match the records and attachments that you upload',
);
cy.get('#inactive-radio-button').click();
cy.get('#verify-submit').click();

cy.url().should('include', 'submit');
Expand Down Expand Up @@ -80,7 +80,6 @@ describe('GP Upload Workflow Step 1: Patient search and verify', () => {
cy.get('#search-submit').click();
cy.wait('@search');

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

cy.url().should('include', 'submit');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const baseUrl = Cypress.env('CYPRESS_BASE_URL') ?? 'http://localhost:3000/';
const smokeTest = Cypress.env('CYPRESS_RUN_AS_SMOKETEST') ?? false;

beforeEach(() => {
cy.login('gp');
cy.login('GP_ADMIN');
navigateToUploadPage();
});

Expand All @@ -20,6 +20,7 @@ const patient = {
postalCode: 'AA1 1AA',
superseded: false,
restricted: false,
active: false,
};

const bucketUrlIdentifer = 'document-store.s3.amazonaws.com';
Expand All @@ -40,7 +41,6 @@ const navigateToUploadPage = () => {
cy.get('#search-submit').click();
cy.wait('@search');

cy.get('#inactive-radio-button').click();
cy.get('#verify-submit').click();
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ const baseUrl = Cypress.env('CYPRESS_BASE_URL') ?? 'http://localhost:3000/';

describe('GP View Lloyd George Workflow', () => {
beforeEach(() => {
cy.login('gp');
// Arrange
cy.login('GP_ADMIN');

// search patient
cy.intercept('GET', '/SearchPatient*', {
Expand All @@ -15,9 +16,6 @@ describe('GP View Lloyd George Workflow', () => {
cy.getByTestId('nhs-number-input').type(searchPatientPayload.nhsNumber);
cy.getByTestId('search-submit-btn').click();
cy.wait('@search');

// verify patient is active
cy.get('#active-radio-button').click();
});

context('View Lloyd George document', () => {
Expand Down
2 changes: 1 addition & 1 deletion app/cypress/e2e/0-ndr-core-tests/homepage.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ describe('home page', () => {

context('logged in', () => {
beforeEach(() => {
cy.login('gp');
cy.login('GP_ADMIN');
cy.visit(baseUrl);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ describe('PCSE User all Workflows Step 1: Patient search and verify', () => {
const smokeTest = Cypress.env('CYPRESS_RUN_AS_SMOKETEST') ?? false;

const roles = Object.freeze({
GP: 'gp',
PCSE: 'pcse',
GP: 'GP_ADMIN',
PCSE: 'PCSE',
});

const noPatientError = 400;
Expand All @@ -20,6 +20,7 @@ describe('PCSE User all Workflows Step 1: Patient search and verify', () => {
superseded: false,
restricted: false,
};

beforeEach(() => {
cy.visit(baseUrl);
});
Expand All @@ -31,7 +32,7 @@ describe('PCSE User all Workflows Step 1: Patient search and verify', () => {
body: patient,
}).as('search');
}
cy.login('pcse');
cy.login('PCSE');
cy.get('#nhs-number-input').click();
cy.get('#nhs-number-input').type(testPatient);

Expand All @@ -49,7 +50,7 @@ describe('PCSE User all Workflows Step 1: Patient search and verify', () => {
});

it('shows the download documents page when download patient is verified', () => {
cy.login('pcse');
cy.login('PCSE');
cy.intercept('GET', '/SearchPatient*', {
statusCode: 200,
body: patient,
Expand All @@ -72,7 +73,7 @@ describe('PCSE User all Workflows Step 1: Patient search and verify', () => {
}).as('search');
}

cy.login('pcse');
cy.login('PCSE');
cy.get('#nhs-number-input').click();
cy.get('#nhs-number-input').type(testPatient);

Expand All @@ -93,7 +94,7 @@ describe('PCSE User all Workflows Step 1: Patient search and verify', () => {
}).as('search');
}

cy.login('pcse');
cy.login('PCSE');
cy.get('#nhs-number-input').click();
cy.get('#nhs-number-input').type(testPatient);

Expand All @@ -114,7 +115,7 @@ describe('PCSE User all Workflows Step 1: Patient search and verify', () => {
}).as('search');
}

cy.login('pcse');
cy.login('PCSE');
cy.get('#nhs-number-input').click();
cy.get('#nhs-number-input').type(testPatient);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ describe('PCSE Download Workflow: Access and download found files', () => {
const smokeTest = Cypress.env('CYPRESS_RUN_AS_SMOKETEST') ?? false;

const roles = Object.freeze({
GP: 'gp',
PCSE: 'pcse',
GP: 'GP_ADMIN',
PCSE: 'PCSE',
});

const testPatient = '9000000009';
Expand Down Expand Up @@ -35,7 +35,7 @@ describe('PCSE Download Workflow: Access and download found files', () => {
];

beforeEach(() => {
cy.login('pcse');
cy.login('PCSE');
});

const navigateToVerify = (role) => {
Expand Down
3 changes: 2 additions & 1 deletion app/cypress/fixtures/requests/GET_SearchPatient.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"nhsNumber": "9000000009",
"postalCode": "AA1 1AA",
"superseded": false,
"restricted": false
"restricted": false,
"active": true
}
10 changes: 0 additions & 10 deletions app/cypress/fixtures/requests/auth/GET_TokenRequest.json

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"role": "GP_ADMIN",
"authorisation_token": "111xxx222"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"role": "GP_CLINICAL",
"authorisation_token": "111xxx222"
}
4 changes: 4 additions & 0 deletions app/cypress/fixtures/requests/auth/GET_TokenRequest_NONE.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"role": "NONE",
"authorisation_token": "111xxx222"
}
4 changes: 4 additions & 0 deletions app/cypress/fixtures/requests/auth/GET_TokenRequest_PCSE.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"role": "PCSE",
"authorisation_token": "111xxx222"
}
7 changes: 2 additions & 5 deletions app/cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,16 @@ Cypress.Commands.add('getByTestId', (selector, ...args) => {
});

Cypress.Commands.add('login', (role) => {
if (role === 'gp' || role === 'pcse') {
if (role === 'GP_ADMIN' || role === 'GP_CLINICAL' || role === 'PCSE') {
const baseUrl = Cypress.env('CYPRESS_BASE_URL') ?? 'http://localhost:3000/';

// login and navigate to search
cy.intercept('GET', '/Auth/TokenRequest*', {
statusCode: 200,
fixture: 'requests/auth/GET_TokenRequest',
fixture: 'requests/auth/GET_TokenRequest_' + role + '.json',
}).as('auth');
cy.visit(baseUrl + 'auth-callback');
cy.wait('@auth');

cy.get(`#${role}-radio-button`).click();
cy.get('#role-submit-button').click();
} else {
throw new Error("Invalid role for login. Only 'gp' or 'pcse' are allowed.");
}
Expand Down
Loading

0 comments on commit 8160a95

Please sign in to comment.