Skip to content

Commit

Permalink
more test
Browse files Browse the repository at this point in the history
  • Loading branch information
NogaNHS committed Feb 21, 2024
1 parent 4a88e18 commit 9a708d5
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down Expand Up @@ -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');
},
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ function LloydGeorgeFileInputStage({ documents, setDocuments, setStage }: Props)
}}
/>
<Button
data-testid={`upload-button-input`}
type={'button'}
style={{ background: '#4C6272', marginBottom: 0, color: 'white' }}
onClick={() => {
Expand Down

0 comments on commit 9a708d5

Please sign in to comment.