From a543210f2f0b15c928be641fd1c3f46f4920a7c5 Mon Sep 17 00:00:00 2001 From: Rio Knightley Date: Thu, 30 Nov 2023 17:01:14 +0000 Subject: [PATCH] Add new workflow for download lloyd george --- .../download_lloyd_george_workflow.cy.js | 118 ++++++++++++++++++ .../view_lloyd_george_ workflow.cy.js | 101 --------------- 2 files changed, 118 insertions(+), 101 deletions(-) create mode 100644 app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/download_lloyd_george_workflow.cy.js diff --git a/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/download_lloyd_george_workflow.cy.js b/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/download_lloyd_george_workflow.cy.js new file mode 100644 index 000000000..519b5f6f1 --- /dev/null +++ b/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/download_lloyd_george_workflow.cy.js @@ -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', + ); + }); + }); +}); diff --git a/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/view_lloyd_george_ workflow.cy.js b/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/view_lloyd_george_ workflow.cy.js index 483f8a084..146ab88db 100644 --- a/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/view_lloyd_george_ workflow.cy.js +++ b/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/view_lloyd_george_ workflow.cy.js @@ -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');