diff --git a/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/upload_lloyd_george_is_bsol_gp_admin.cy.js b/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/upload_lloyd_george_is_bsol_gp_admin.cy.js index e9c5df0f1..a92721fbc 100644 --- a/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/upload_lloyd_george_is_bsol_gp_admin.cy.js +++ b/app/cypress/e2e/0-ndr-core-tests/gp_user_workflows/upload_lloyd_george_is_bsol_gp_admin.cy.js @@ -3,6 +3,34 @@ import searchPatientPayload from '../../../fixtures/requests/GET_SearchPatient.j const baseUrl = Cypress.config('baseUrl'); const searchPatientUrl = '/search/patient'; +const clickUploadButton = () => { + cy.get('#upload-button').click(); + cy.wait(20); +}; + +const uploadedFilePathNames = { + LG: [ + 'cypress/fixtures/lg-files/1of1_Lloyd_George_Record_[Testy Test]_[0123456789]_[01-01-2011].pdf', + [ + 'cypress/fixtures/lg-files/1of2_Lloyd_George_Record_[Testy Test]_[0123456789]_[01-01-2011].pdf', + 'cypress/fixtures/lg-files/2of2_Lloyd_George_Record_[Testy Test]_[0123456789]_[01-01-2011].pdf', + ], + ], +}; + +const uploadedFileNames = { + LG: [ + '1of1_Lloyd_George_Record_[Testy Test]_[0123456789]_[01-01-2011].pdf', + [ + '1of2_Lloyd_George_Record_[Testy Test]_[0123456789]_[01-01-2011].pdf', + '2of2_Lloyd_George_Record_[Testy Test]_[0123456789]_[01-01-2011].pdf', + ], + ], +}; +const bucketUrlIdentifer = 'document-store.s3.amazonaws.com'; +const selectForm = () => cy.getByTestId(`upload-document-form`); +const singleFileUsecaseIndex = 0; +const multiFileUSecaseIndex = 1; describe('GP Workflow: Upload Lloyd George record when user is GP amin and patient has no record', () => { const beforeEachConfiguration = () => { @@ -34,8 +62,52 @@ describe('GP Workflow: Upload Lloyd George record when user is GP amin and patie `GP ADMIN user can upload Lloyd George files for an active patient with no existing record`, { tags: 'regression' }, () => { + const fileName = uploadedFileNames.LG[0]; + + const stubbedResponse = { + statusCode: 200, + body: { + [fileName]: { + url: 'http://' + bucketUrlIdentifer, + fields: { + key: 'test key', + 'x-amz-algorithm': 'xxxx-xxxx-SHA256', + 'x-amz-credential': + 'xxxxxxxxxxx/20230904/eu-west-2/s3/aws4_request', + 'x-amz-date': '20230904T125954Z', + 'x-amz-security-token': 'xxxxxxxxx', + 'x-amz-signature': '9xxxxxxxx', + }, + }, + }, + }; + cy.url().should('include', 'upload'); cy.url().should('eq', baseUrl + '/patient/upload/lloyd-george-record'); + cy.intercept('POST', '**/DocumentReference**', stubbedResponse); + cy.intercept('POST', '**/' + bucketUrlIdentifer + '**', { + statusCode: 204, + }); + + cy.getByTestId('button-input').selectFile( + uploadedFilePathNames.LG[singleFileUsecaseIndex], + { force: true }, + ); + clickUploadButton(); + cy.getByTestId('view-record-btn').should('be.visible'); + cy.getByTestId('search-patient-btn').should('be.visible'); + + // cy.get('#upload-summary-confirmation').should('be.visible'); + // cy.get('#upload-summary-header').should('be.visible'); + // cy.get('#successful-uploads-dropdown').should('be.visible'); + // cy.get('#successful-uploads-dropdown').click(); + // + // cy.get('#successful-uploads tbody tr').should('have.length', 1); + // + // cy.get('#successful-uploads tbody tr') + // .eq(1) + // .should('contain', uploadedFileNames.LG[singleFileUsecaseIndex]); + // cy.get('#close-page-warning').should('be.visible'); }, ); }); diff --git a/app/src/components/blocks/lloydGeorgeFileInputStage/LloydGeorgeFileInputStage.tsx b/app/src/components/blocks/lloydGeorgeFileInputStage/LloydGeorgeFileInputStage.tsx index 50e30701b..30da0d720 100644 --- a/app/src/components/blocks/lloydGeorgeFileInputStage/LloydGeorgeFileInputStage.tsx +++ b/app/src/components/blocks/lloydGeorgeFileInputStage/LloydGeorgeFileInputStage.tsx @@ -193,6 +193,7 @@ function LloydGeorgeFileInputStage({ documents, setDocuments, setStage }: Props) }} />