-
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.
Add new workflow for download lloyd george
- Loading branch information
1 parent
0e5d65d
commit a543210
Showing
2 changed files
with
118 additions
and
101 deletions.
There are no files selected for viewing
118 changes: 118 additions & 0 deletions
118
app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/download_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,118 @@ | ||
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 Workflow: View Lloyd George record', () => { | ||
const beforeEachConfiguration = (role) => { | ||
cy.login(role); | ||
// search patient | ||
cy.intercept('GET', '/SearchPatient*', { | ||
statusCode: 200, | ||
body: searchPatientPayload, | ||
}).as('search'); | ||
cy.getByTestId('nhs-number-input').type(searchPatientPayload.nhsNumber); | ||
cy.getByTestId('search-submit-btn').click(); | ||
cy.wait('@search'); | ||
}; | ||
|
||
context('Download Lloyd George document', () => { | ||
it('GP ADMIN user can download the Lloyd George document of an active patient', () => { | ||
beforeEachConfiguration('GP_ADMIN'); | ||
|
||
cy.intercept('GET', '/LloydGeorgeStitch*', { | ||
statusCode: 200, | ||
body: viewLloydGeorgePayload, | ||
}).as('lloydGeorgeStitch'); | ||
|
||
cy.get('#verify-submit').click(); | ||
cy.wait('@lloydGeorgeStitch'); | ||
|
||
cy.intercept('GET', '/DocumentManifest*', { | ||
statusCode: 200, | ||
body: baseUrl + 'browserconfig.xml', // uses public served file in place of a ZIP file | ||
}).as('documentManifest'); | ||
|
||
cy.getByTestId('actions-menu').click(); | ||
cy.getByTestId('download-all-files-link').click(); | ||
|
||
cy.wait('@documentManifest'); | ||
|
||
// Assert contents of page when downloading | ||
cy.contains('Downloading documents').should('be.visible'); | ||
cy.contains( | ||
`Preparing download for ${viewLloydGeorgePayload.number_of_files} files`, | ||
).should('be.visible'); | ||
cy.contains('Compressing record into a zip file').should('be.visible'); | ||
cy.contains('Cancel').should('be.visible'); | ||
|
||
// Assert contents of page after download | ||
cy.contains('Download complete').should('be.visible'); | ||
cy.contains('Documents from the Lloyd George record of:').should('be.visible'); | ||
cy.contains( | ||
`${searchPatientPayload.givenName} ${searchPatientPayload.familyName}`, | ||
).should('be.visible'); | ||
cy.contains(`(NHS number: ${searchPatientPayload.nhsNumber})`).should('be.visible'); | ||
|
||
// Assert file has been downloaded | ||
cy.readFile(`${Cypress.config('downloadsFolder')}/browserconfig.xml`); | ||
|
||
cy.getByTestId('return-btn').click(); | ||
|
||
// Assert return button returns to pdf view | ||
cy.getByTestId('pdf-card').should('be.visible'); | ||
}); | ||
|
||
it('No download option or menu exists when no Lloyd George record exists for a patient as a GP ADMIN role', () => { | ||
beforeEachConfiguration('GP_ADMIN'); | ||
|
||
cy.intercept('GET', '/LloydGeorgeStitch*', { | ||
statusCode: 404, | ||
}).as('lloydGeorgeStitch'); | ||
|
||
cy.get('#verify-submit').click(); | ||
cy.wait('@lloydGeorgeStitch'); | ||
|
||
cy.getByTestId('actions-menu').should('not.exist'); | ||
}); | ||
|
||
it('No download option exists when a Lloyd George record exists for the patient as a GP CLINICAL role', () => { | ||
beforeEachConfiguration('GP_CLINICAL'); | ||
|
||
cy.intercept('GET', '/LloydGeorgeStitch*', { | ||
statusCode: 200, | ||
body: viewLloydGeorgePayload, | ||
}).as('lloydGeorgeStitch'); | ||
|
||
cy.get('#verify-submit').click(); | ||
cy.wait('@lloydGeorgeStitch'); | ||
|
||
cy.getByTestId('actions-menu').click(); | ||
cy.getByTestId('download-all-files-link').should('not.exist'); | ||
}); | ||
|
||
it.skip('It displays an error when the document manifest API call fails as a GP CLINICAL role', () => { | ||
cy.intercept('GET', '/LloydGeorgeStitch*', { | ||
statusCode: 200, | ||
body: viewLloydGeorgePayload, | ||
}).as('lloydGeorgeStitch'); | ||
|
||
cy.intercept('GET', '/DocumentManifest*', { | ||
statusCode: 500, | ||
}).as('documentManifest'); | ||
|
||
cy.get('#verify-submit').click(); | ||
cy.wait('@lloydGeorgeStitch'); | ||
|
||
cy.getByTestId('actions-menu').click(); | ||
cy.getByTestId('download-all-files-link').click(); | ||
|
||
cy.wait('@documentManifest'); | ||
|
||
// Assert | ||
cy.contains('appropriate error for when the document manifest API call fails').should( | ||
'be.visible', | ||
); | ||
}); | ||
}); | ||
}); |
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