-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
PRMDR-264 View a Lloyd George Document e2e tests (#87)
* [PRMDR-264] create set up for LG view e2e tests and test it navigates successfully to the page * [PRMDR-264] add test for patient info and lg card * add remaining view lloyd george doc tests * add full screen checks, force GMT time on local cypress * update following PR comments --------- Co-authored-by: RachelHowellNHS <rachel.howell6@nhs.net>
- Loading branch information
1 parent
56075b7
commit 78edf3f
Showing
14 changed files
with
297 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
115 changes: 115 additions & 0 deletions
115
app/cypress/e2e/0-ndr-core-tests/gp_view_lloyd_george_workflow.cy.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
import viewLloydGeorgePayload from '../../fixtures/requests/GET_LloydGeorgeStitch.json'; | ||
import searchPatientPayload from '../../fixtures/requests/GET_SearchPatient.json'; | ||
|
||
const baseUrl = Cypress.env('CYPRESS_BASE_URL') ?? 'http://localhost:3000/'; | ||
|
||
describe('GP View Lloyd George Workflow', () => { | ||
beforeEach(() => { | ||
// Arrange | ||
navigateToLgPage(); | ||
}); | ||
|
||
it('allows a GP user to view the Lloyd George document of an active patient', () => { | ||
// Act | ||
cy.intercept('GET', '/LloydGeorgeStitch*', { | ||
statusCode: 200, | ||
body: viewLloydGeorgePayload, | ||
}); | ||
cy.get('#verify-submit').click(); | ||
|
||
// Assert | ||
assertPatientInfo(); | ||
cy.getCy('pdf-card') | ||
.should('include.text', 'Lloyd George record') | ||
.should('include.text', 'Last updated: 09 October 2023 at 15:41:38') | ||
.should('include.text', '12 files | File size: 502 KB | File format: PDF'); | ||
cy.getCy('pdf-viewer').should('be.visible'); | ||
|
||
// Act - open full screen view | ||
cy.getCy('full-screen-btn').click(); | ||
|
||
// Assert | ||
assertPatientInfo(); | ||
cy.getCy('pdf-card').should('not.exist'); | ||
cy.getCy('pdf-viewer').should('be.visible'); | ||
|
||
// Act - close full screen view | ||
cy.getCy('back-link').click(); | ||
|
||
// Assert | ||
cy.getCy('pdf-card').should('be.visible'); | ||
cy.getCy('pdf-viewer').should('be.visible'); | ||
}); | ||
|
||
it('displays an empty Lloyd George card when no Lloyd George record exists for the patient', () => { | ||
// Act | ||
cy.intercept('GET', '/LloydGeorgeStitch*', { | ||
statusCode: 404, | ||
}); | ||
cy.get('#verify-submit').click(); | ||
|
||
// Assert | ||
assertPatientInfo(); | ||
assertEmptyLloydGeorgeCard(); | ||
}); | ||
|
||
it('displays an empty Lloyd George card when the backend API call fails', () => { | ||
// Act | ||
cy.intercept('GET', '/LloydGeorgeStitch*', { | ||
statusCode: 500, | ||
}); | ||
cy.get('#verify-submit').click(); | ||
|
||
//Assert | ||
assertPatientInfo(); | ||
assertEmptyLloydGeorgeCard(); | ||
}); | ||
|
||
const navigateToLgPage = () => { | ||
// login and navigate to search | ||
cy.intercept('GET', '/Auth/TokenRequest*', { | ||
statusCode: 200, | ||
body: { | ||
organisations: [ | ||
{ | ||
org_name: 'PORTWAY LIFESTYLE CENTRE', | ||
ods_code: 'A470', | ||
role: 'DEV', | ||
}, | ||
], | ||
authorisation_token: '111xxx222', | ||
}, | ||
}).as('auth'); | ||
cy.visit(baseUrl + 'auth-callback'); | ||
cy.wait('@auth'); | ||
|
||
cy.get(`#gp-radio-button`).click(); | ||
cy.get('#role-submit-button').click(); | ||
|
||
// search patient | ||
cy.intercept('GET', '/SearchPatient*', { | ||
statusCode: 200, | ||
body: searchPatientPayload, | ||
}).as('search'); | ||
cy.get('#nhs-number-input').type(searchPatientPayload.nhsNumber); | ||
cy.get('#search-submit').click(); | ||
cy.wait('@search'); | ||
|
||
// verify patient is active | ||
cy.get('#active-radio-button').click(); | ||
}; | ||
|
||
const assertPatientInfo = () => { | ||
cy.getCy('patient-name').should( | ||
'have.text', | ||
`${searchPatientPayload.givenName} ${searchPatientPayload.familyName}`, | ||
); | ||
cy.getCy('patient-nhs-number').should('have.text', `NHS number: 900 000 0009`); | ||
cy.getCy('patient-dob').should('have.text', `Date of birth: 01 January 1970`); | ||
}; | ||
|
||
const assertEmptyLloydGeorgeCard = () => { | ||
cy.getCy('pdf-card').should('include.text', 'Lloyd George record'); | ||
cy.getCy('pdf-card').should('include.text', 'No documents are available'); | ||
}; | ||
}); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"number_of_files": 12, | ||
"last_updated": "2023-10-09T15:41:38.319508Z", | ||
"presign_url": "https://google.com", | ||
"total_file_size_in_byte": 514495 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
{ | ||
"birthDate": "1970-01-01", | ||
"familyName": "Surname", | ||
"givenName": ["GivenName"], | ||
"nhsNumber": "9000000009", | ||
"postalCode": "AA1 1AA", | ||
"superseded": false, | ||
"restricted": false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.