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
@@ -0,0 +1,80 @@
import { Roles } from '../../../support/roles';
import dbItem from '../../../fixtures/dynamo-db-items/example-review-h81109.json';

const workspace = Cypress.env('WORKSPACE');
const tableName = `${workspace}_DocumentUploadReview`;
const path = `9730155348/e3e4f62e-6f95-4d8c-8870-5212b6353ae9/test_patient_record.pdf`;
const bucketName = `${workspace}-document-pending-review-store`;

describe('GP Workflow: Review and Reassign', () => {
context('Review and Reassign', () => {
beforeEach(() => {
cy.addItemToDynamoDb(tableName, dbItem);
cy.addPdfFileToS3(bucketName, path, 'test_patient_record.pdf');
});

afterEach(() => {
cy.deleteItemFromDynamoDb(tableName, dbItem.ID, 1);
cy.deleteItemFromDynamoDb(tableName, dbItem.ID, 2);
cy.deleteFileFromS3(bucketName, path);
});

it(
'[Smoke] GP ADMIN user can review and reassign a document to the correct patient',
{ tags: 'smoke', defaultCommandTimeout: 20000 },
() => {
cy.smokeLogin(Roles.SMOKE_GP_ADMIN);

// click admin console
cy.navigateToHomePage();
cy.getByTestId('admin-hub-btn').should('exist').click();

// click review docs
cy.getByTestId('admin-reviews-btn').should('exist').click();

// find the example review item by nhs number and view it
cy.getByTestId('view-record-link-e3e4f62e-6f95-4d8c-8870-5212b6353ae9')
.should('exist')
.click();

// click "dont accept the record" and continue
cy.getByTestId('reject-record-option').should('exist').check();
cy.getByTestId('reject-record-option').should('be.checked');
cy.getByTestId('continue-btn').should('exist').click();

// find the textbox and search for the correct nhs number to reassign to
cy.getByTestId('nhs-number-input').should('exist').click();
cy.getByTestId('nhs-number-input').type('9730788197');
cy.getByTestId('continue-button').should('exist').click();

// confirm demographics of the new patient and continue
cy.getByTestId('confirm-patient-details-btn').should('exist').click();

// assert reassignment success message and path
cy.contains('This document has been matched to the correct patient').should(
'be.visible',
);
cy.url().should('contain', '/admin/reviews/:reviewId/complete/patient-matched');

// assert the review is no longer in our review queue
cy.getByTestId('review-another-btn').should('exist').click();
cy.getByTestId('view-record-link-e3e4f62e-6f95-4d8c-8870-5212b6353ae9').should(
'not.exist',
);

// logout
cy.getByTestId('logout-btn').click();

// login as new ods code to verify the document is now in their review queue
cy.getByTestId('start-btn').should('exist'); // wait for login button to appear after logout
cy.smokeLogin(Roles.SMOKE_GP_ADMIN, 'M85143');
cy.navigateToHomePage();
cy.getByTestId('admin-hub-btn').should('exist').click();
cy.getByTestId('admin-reviews-btn').should('exist').click();
cy.getByTestId('view-record-link-e3e4f62e-6f95-4d8c-8870-5212b6353ae9').should(
'exist',
);
},
);
});
});
17 changes: 17 additions & 0 deletions app/cypress/fixtures/dynamo-db-items/example-review-h81109.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"ID": "e3e4f62e-6f95-4d8c-8870-5212b6353ae9",
"Version": 1,
"Author": "H81109",
"Custodian": "H81109",
"DocumentSnomedCodeType": "16521000000101",
"Files": [
{
"FileLocation": "s3://ndrk-document-pending-review-store/9730155348/e3e4f62e-6f95-4d8c-8870-5212b6353ae9/test_patient_record.pdf",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this probably needs to be ndr-dev or "workspace" variable somehow

"FileName": "test_patient_record.pdf"
}
],
"NhsNumber": "9730155348",
"ReviewReason": "Unsuccessful upload",
"ReviewStatus": "PENDING_REVIEW",
"UploadDate": 1768728372
}
45 changes: 27 additions & 18 deletions app/cypress/support/aws.commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,26 +91,35 @@ Cypress.Commands.add('deleteFileFromS3', (bucketName: string, fileName: string)
);
});

Cypress.Commands.add('deleteItemFromDynamoDb', (tableName: string, itemId: string) => {
const params: DeleteItemCommandInput = {
TableName: tableName,
Key: {
Cypress.Commands.add(
'deleteItemFromDynamoDb',
(tableName: string, itemId: string, version?: number) => {
const key: DeleteItemCommandInput['Key'] = {
ID: { S: itemId },
},
};
};

return cy.wrap(
dynamo
.send(new DeleteItemCommand(params))
.then((data) => data)
.catch((err) => {
const message = 'Error deleting item from Dynamo: ' + tableName;
// eslint-disable-next-line no-console
console.error(message, err);
throw new Error(message);
}),
);
});
if (version !== undefined) {
key.Version = { N: version.toString() };
}

const params: DeleteItemCommandInput = {
TableName: tableName,
Key: key,
};

return cy.wrap(
dynamo
.send(new DeleteItemCommand(params))
.then((data) => data)
.catch((err) => {
const message = 'Error deleting item from Dynamo: ' + tableName;
// eslint-disable-next-line no-console
console.error(message, err);
throw new Error(message);
}),
);
},
);

Cypress.Commands.add(
'deleteItemsBySecondaryKeyFromDynamoDb',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -357,12 +357,17 @@ const ReviewsDetailsStage = ({
<Radios.Radio value="yes" {...radioProps} inputRef={radioRef}>
Yes, the details match and I want to accept this document
</Radios.Radio>
<Radios.Radio value="no" {...radioProps} inputRef={radioRef}>
<Radios.Radio
value="no"
{...radioProps}
inputRef={radioRef}
data-testid="reject-record-option"
>
No, I don't want to accept this document. None of the details match the
demographics shown
</Radios.Radio>
</Radios>
<Button className="mt-4" type="submit">
<Button className="mt-4" type="submit" data-testid="continue-btn">
Continue
</Button>
</Fieldset>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,12 @@ const PatientVerifyPage = ({
This page displays the current data recorded in the Personal Demographics
Service for this patient.
</p>
<Button type="submit" id="verify-submit" className="nhsuk-u-margin-top-6">
<Button
type="submit"
id="verify-submit"
className="nhsuk-u-margin-top-6"
data-testid="confirm-patient-details-btn"
>
Confirm patient details and continue
</Button>
</form>
Expand Down
Loading