Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ const workspace = Cypress.env('WORKSPACE');
const baseUrl = Cypress.config('baseUrl');

const uploadedFilePathNames = [
'cypress/fixtures/lg-files/zenia_lees/1of3_Lloyd_George_Record_[Zenia Ellisa LEES]_[9730153930]_[20-03-1929].pdf',
'cypress/fixtures/lg-files/zenia_lees/2of3_Lloyd_George_Record_[Zenia Ellisa LEES]_[9730153930]_[20-03-1929].pdf',
'cypress/fixtures/lg-files/zenia_lees/3of3_Lloyd_George_Record_[Zenia Ellisa LEES]_[9730153930]_[20-03-1929].pdf',
'cypress/fixtures/lg-files/zenia_lees/1of3_Lloyd_George_Record_[Zenia Ellisa LEES]_[9730153930]_[20-03-1929].pdf',
'cypress/fixtures/lg-files/zenia_lees/2of3_Lloyd_George_Record_[Zenia Ellisa LEES]_[9730153930]_[20-03-1929].pdf',
'cypress/fixtures/lg-files/zenia_lees/3of3_Lloyd_George_Record_[Zenia Ellisa LEES]_[9730153930]_[20-03-1929].pdf',
];
const uploadedFileNames = [
'1of3_Lloyd_George_Record_[Zenia Ellisa LEES]_[9730153930]_[20-03-1929].pdf',
'2of3_Lloyd_George_Record_[Zenia Ellisa LEES]_[9730153930]_[20-03-1929].pdf',
'3of3_Lloyd_George_Record_[Zenia Ellisa LEES]_[9730153930]_[20-03-1929].pdf',
'1of3_Lloyd_George_Record_[Zenia Ellisa LEES]_[9730153930]_[20-03-1929].pdf',
'2of3_Lloyd_George_Record_[Zenia Ellisa LEES]_[9730153930]_[20-03-1929].pdf',
'3of3_Lloyd_George_Record_[Zenia Ellisa LEES]_[9730153930]_[20-03-1929].pdf',
];

const bucketName = `${workspace}-lloyd-george-store`;
Expand All @@ -28,108 +28,111 @@ const confirmationUrl = '/patient/document-upload/confirmation';
const activePatient = pdsPatients.activeNoUpload;

describe('GP Workflow: Upload Lloyd George record', () => {
context('Upload a Lloyd George document', () => {
beforeEach(() => {
//delete any records present for the active patient
cy.deleteItemsBySecondaryKeyFromDynamoDb(
referenceTableName,
'NhsNumberIndex',
'NhsNumber',
activePatient.toString(),
);
cy.deleteItemsBySecondaryKeyFromDynamoDb(
stitchTableName,
'NhsNumberIndex',
'NhsNumber',
activePatient.toString()
);
uploadedFileNames.forEach((file) => {
cy.deleteFileFromS3(bucketName, file);
});
});

afterEach(() => {
//clean up any records present for the active patient
cy.deleteItemsBySecondaryKeyFromDynamoDb(
referenceTableName,
'NhsNumberIndex',
'NhsNumber',
activePatient.toString(),
);
cy.deleteItemsBySecondaryKeyFromDynamoDb(
stitchTableName,
'NhsNumberIndex',
'NhsNumber',
activePatient.toString()
);
uploadedFileNames.forEach((file) => {
cy.deleteFileFromS3(bucketName, file);
});
});

it(
'[Smoke] GP ADMIN can upload multiple files and then view a Lloyd George record for an active patient with no record',
{ tags: 'smoke', defaultCommandTimeout: 20000 },
() => {
cy.smokeLogin(Roles.SMOKE_GP_ADMIN);

cy.navigateToPatientSearchPage();

cy.get('#nhs-number-input').should('exist');
cy.get('#nhs-number-input').click();
cy.get('#nhs-number-input').type(activePatient);
cy.getByTestId('search-submit-btn').should('exist');
cy.getByTestId('search-submit-btn').click();

cy.url({ timeout: 15000 }).should('contain', patientVerifyUrl);

cy.get('#verify-submit').should('exist');
cy.get('#verify-submit').click();

cy.url().should('contain', lloydGeorgeRecordUrl);
cy.getByTestId('no-records-title').should(
'include.text',
'This patient does not have a Lloyd George record',
);
cy.getByTestId('upload-patient-record-button').should('exist');
cy.getByTestId('upload-patient-record-button').click();
uploadedFilePathNames.forEach((file) => {
cy.getByTestId('button-input').selectFile(file, { force: true });
var index = uploadedFilePathNames.indexOf(file);
cy.get('#selected-documents-table').should('contain', uploadedFileNames[index]);
context('Upload a Lloyd George document', () => {
beforeEach(() => {
//delete any records present for the active patient
cy.deleteItemsBySecondaryKeyFromDynamoDb(
referenceTableName,
'NhsNumberIndex',
'NhsNumber',
activePatient.toString(),
);
cy.deleteItemsBySecondaryKeyFromDynamoDb(
stitchTableName,
'NhsNumberIndex',
'NhsNumber',
activePatient.toString(),
);
uploadedFileNames.forEach((file) => {
cy.deleteFileFromS3(bucketName, file);
});
});
cy.get('#continue-button').click();

cy.url().should('contain', selectOrderUrl);
cy.get('#selected-documents-table').should('exist');
uploadedFileNames.forEach((name) => {
cy.get('#selected-documents-table').should('contain', name);
afterEach(() => {
//clean up any records present for the active patient
cy.deleteItemsBySecondaryKeyFromDynamoDb(
referenceTableName,
'NhsNumberIndex',
'NhsNumber',
activePatient.toString(),
);
cy.deleteItemsBySecondaryKeyFromDynamoDb(
stitchTableName,
'NhsNumberIndex',
'NhsNumber',
activePatient.toString(),
);
uploadedFileNames.forEach((file) => {
cy.deleteFileFromS3(bucketName, file);
});
});
cy.getByTestId('form-submit-button').click();

cy.url().should('contain', confirmationUrl);
uploadedFileNames.forEach((name) => {
cy.get('#selected-documents-table').should('contain', name);
});
cy.getByTestId('confirm-button').click();

cy.getByTestId('upload-complete-page', { timeout: 25000 }).should('exist');
cy.getByTestId('upload-complete-page')
.should('include.text', 'You have successfully uploaded a digital Lloyd George record for');

cy.getByTestId('upload-complete-card').should('be.visible');

cy.getByTestId('home-btn').eq(1).click();

cy.navigateToPatientSearchPage();

cy.get('#nhs-number-input').type(activePatient);
cy.get('#search-submit').click();
cy.wait(5000)

cy.get('.patient-results-form').submit();

cy.get("#pdf-viewer", {timeout: 20000}).should('exist');
});
});
it(
'[Smoke] GP ADMIN can upload multiple files and then view a Lloyd George record for an active patient with no record',
{ tags: 'smoke', defaultCommandTimeout: 20000 },
() => {
cy.smokeLogin(Roles.SMOKE_GP_ADMIN);

cy.navigateToPatientSearchPage();

cy.get('#nhs-number-input').should('exist');
cy.get('#nhs-number-input').click();
cy.get('#nhs-number-input').type(activePatient);
cy.getByTestId('search-submit-btn').should('exist');
cy.getByTestId('search-submit-btn').click();

cy.url({ timeout: 15000 }).should('contain', patientVerifyUrl);

cy.get('#verify-submit').should('exist');
cy.get('#verify-submit').click();

cy.url().should('contain', lloydGeorgeRecordUrl);
cy.getByTestId('no-records-title').should(
'include.text',
'This patient does not have a Lloyd George record',
);
cy.getByTestId('upload-patient-record-button').should('exist');
cy.getByTestId('upload-patient-record-button').click();
uploadedFilePathNames.forEach((file) => {
cy.getByTestId('button-input').selectFile(file, { force: true });
var index = uploadedFilePathNames.indexOf(file);
cy.get('#selected-documents-table').should('contain', uploadedFileNames[index]);
});
cy.get('#continue-button').click();

cy.url().should('contain', selectOrderUrl);
cy.get('#selected-documents-table').should('exist');
uploadedFileNames.forEach((name) => {
cy.get('#selected-documents-table').should('contain', name);
});
cy.getByTestId('form-submit-button').click();

cy.url().should('contain', confirmationUrl);
uploadedFileNames.forEach((name) => {
cy.get('#selected-documents-table').should('contain', name);
});
cy.getByTestId('confirm-button').click();

cy.getByTestId('upload-complete-page', { timeout: 25000 }).should('exist');
cy.getByTestId('upload-complete-page').should(
'include.text',
'You have successfully uploaded a digital Lloyd George record for',
);

cy.getByTestId('upload-complete-card').should('be.visible');

cy.getByTestId('home-btn').eq(1).click();

cy.navigateToPatientSearchPage();

cy.get('#nhs-number-input').type(activePatient);
cy.get('#search-submit').click();
cy.wait(5000);

cy.get('.patient-results-form').submit();

cy.get('#pdf-viewer', { timeout: 20000 }).should('exist');
},
);
});
});
8 changes: 4 additions & 4 deletions app/cypress/support/patients.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
export const pdsPatients = {
activeUpload: 9730153817,
activeNoUpload: 9730153930,
activeUpload: 9730153817,
activeNoUpload: 9730153930,
};
export const stubPatients = {
activeUpload: 9730153817,
activeNoUpload: 9000000068,
activeUpload: 9730153817,
activeNoUpload: 9000000068,
};
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ const DocumentUploadCompleteStage = ({ documents, documentConfig }: Props): Reac
]);

useEffect(() => {
if (!docsAreInFinishedState()) {
if (!docsAreInFinishedState() || patientDetails === null) {
navigate(routes.HOME);
}
}, [navigate, documents]);
}, [navigate, documents, patientDetails]);

if (!docsAreInFinishedState()) {
if (!docsAreInFinishedState() || patientDetails === null) {
return <></>;
}

Expand Down Expand Up @@ -108,7 +108,7 @@ const DocumentUploadCompleteStage = ({ documents, documentConfig }: Props): Reac

<h3>What happens next</h3>

{journey === 'update' && (
{journey === 'update' && patientDetails.canManageRecord && (
<p>
You can now view the updated {documentConfig.displayName} for this patient in
this service by{' '}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,14 +262,14 @@ const DocumentView = ({
)}
</div>

{documentReference.url
? getRecordCard()
: (
<p>
This document is currently being uploaded, please try again in a few minutes.
</p>
)
}
{documentReference.url ? (
getRecordCard()
) : (
<p>
This document is currently being uploaded, please try again in a few
minutes.
</p>
)}
</div>
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions app/src/helpers/requests/downloadReport.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('downloadReport', () => {

expect(getSpy).toHaveBeenCalledWith(args.baseUrl + report.endpoint, {
headers: args.baseHeaders,
params: { outputFileFormat: args.fileType, odsReportType: "PATIENT" },
params: { outputFileFormat: args.fileType, odsReportType: 'PATIENT' },
});

expect(mockAnchor.setAttribute).toHaveBeenCalledWith('download', '');
Expand Down Expand Up @@ -90,7 +90,7 @@ describe('downloadReport', () => {
expect(errorCode).toBe(404);
expect(getSpy).toHaveBeenCalledWith(args.baseUrl + report.endpoint, {
headers: args.baseHeaders,
params: { outputFileFormat: args.fileType, odsReportType: "PATIENT" },
params: { outputFileFormat: args.fileType, odsReportType: 'PATIENT' },
});
});
});
2 changes: 1 addition & 1 deletion app/src/helpers/requests/downloadReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const downloadReport = async ({ report, fileType, baseUrl, baseHeaders }: Args):
},
params: {
outputFileFormat: fileType,
odsReportType: "PATIENT"
odsReportType: 'PATIENT',
},
});

Expand Down
Loading
Loading