Skip to content

Commit

Permalink
Add new workflow for download lloyd george
Browse files Browse the repository at this point in the history
  • Loading branch information
RioKnightleyNHS committed Nov 30, 2023
1 parent 0e5d65d commit a543210
Show file tree
Hide file tree
Showing 2 changed files with 118 additions and 101 deletions.
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',
);
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -101,107 +101,6 @@ describe('GP Workflow: View Lloyd George record', () => {
);
});
});

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',
);
});
});

context('Delete Lloyd George document', () => {
it('A GP ADMIN user can delete the Lloyd George document of an active patient', () => {
beforeEachConfiguration('GP_ADMIN');
Expand Down

0 comments on commit a543210

Please sign in to comment.