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,131 @@
import { pdsPatients } from '../../../support/patients';
import dbItem from '../../../fixtures/dynamo-db-items/active-patient-h81109.json';
import { Roles } from '../../../support/roles';

const workspace = Cypress.env('WORKSPACE');
const lgTableName = `${workspace}_LloydGeorgeReferenceMetadata`;
const bucketName = `${workspace}-lloyd-george-store`;
const activePatient = pdsPatients.activeUpload;
const filePath = `${activePatient}/c165a49e-71b3-4662-8494-49c6b08070ba`;

const patientVerifyUrl = '/patient/verify';
const lloydGeorgeRecordUrl = '/patient/documents';
const selectOrderUrl = '/patient/document-upload/select-order';
const confirmationUrl = '/patient/document-upload/confirmation';

dbItem.FileLocation = dbItem.FileLocation.replace('{env}', workspace);

const uploadedFilePathNames = [
'cypress/fixtures/lg-files/simple_pages/6.pdf',
'cypress/fixtures/lg-files/simple_pages/7.pdf',
];
const uploadedFileNames = ['6', '7'];

describe('GP Workflow: Add additional scanned paper notes in correct order', () => {
context('Add additional scanned paper notes in correct order', () => {
beforeEach(() => {
cy.deleteItemsBySecondaryKeyFromDynamoDb(
lgTableName,
'NhsNumberIndex',
'NhsNumber',
activePatient.toString(),
);
cy.addPdfFileToS3(bucketName, filePath, 'test_patient_record.pdf');
cy.addItemToDynamoDb(lgTableName, dbItem);
});

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

const roles = [Roles.SMOKE_GP_ADMIN, Roles.SMOKE_GP_CLINICAL];

roles.forEach((role) => {
it(
`[Smoke] ${role} can add additional scanned paper notes and order is correct`,
{ tags: 'smoke', defaultCommandTimeout: 20000 },
() => {
cy.smokeLogin(role);
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('view-0-link').should('exist');
cy.getByTestId('view-0-link').click();

cy.getByTestId('add-files-link').should('exist');
cy.getByTestId('add-files-link').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').should('exist');
cy.get('#continue-button').click();
cy.url().should('contain', selectOrderUrl);

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

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

cy.getByTestId('upload-complete-page', { timeout: 25000 }).should('exist');
cy.getByTestId('upload-complete-card').should('be.visible');

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

cy.get('#nhs-number-input').type(activePatient);
cy.get('#search-submit').click();
cy.get('.patient-results-form').should('exist');

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

cy.getByTestId('view-0-link').should('exist');
cy.getByTestId('view-0-link').click();
cy.get('#pdf-viewer', { timeout: 20000 }).should('exist');

cy.getByTestId('pdf-viewer').should('be.visible');

cy.pdfViewerPageShouldBeText(7, '6');
cy.pdfViewerPageShouldBeText(8, '7');
},
);
});
});
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"Author": "H81109",
"ContentType": "application/pdf",
"Created": "2023-12-05T16:06:48.300566Z",
"CurrentGpOds": "H81109",
Expand All @@ -7,13 +8,14 @@
"DocStatus": "final",
"DocumentScanCreation": "2023-01-01",
"DocumentSnomedCodeType": "16521000000101",
"FileLocation": "s3://{env}-lloyd-george-store/9730153817/e4a6d7f7-01f3-44be-8964-515b2c0ec180",
"FileLocation": "s3://{env}-lloyd-george-store/9730153817/c165a49e-71b3-4662-8494-49c6b08070ba",
"FileName": "1of1_Lloyd_George_Record_[Haley Glenda RUDKIN]_[9730153817]_[07-08-2023].pdf",
"FileSize": "192910",
"ID": "c165a49e-71b3-4662-8494-49c6b08070ba",
"LastUpdated": "1713800398",
"NhsNumber": "9730153817",
"S3FileKey": "9730153817/e4a6d7f7-01f3-44be-8964-515b2c0ec180",
"S3FileKey": "9730153817/c165a49e-71b3-4662-8494-49c6b08070ba",
"S3VersionID": "_Ac549L3L0WbwLXwrIqtQ6ZsLVawWgaU",
"Status": "current",
"Uploaded": true,
"Uploading": false,
Expand Down
Binary file not shown.
Binary file not shown.
27 changes: 27 additions & 0 deletions app/cypress/support/aws.commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,30 @@ Cypress.Commands.add(
});
},
);

Cypress.Commands.add('pdfViewerPageShouldBeText', (pageNumber: number, expectedText: string) => {
cy.get('pdfjs-viewer-element')
.shadow()
.find('iframe')
.its('0.contentDocument.body')
.should('not.be.empty')
.then(cy.wrap)
.find('#viewerContainer')
.then(($container) => {
cy.wrap($container)
.find(`.page[data-page-number="${pageNumber}"]`)
.should('exist')
.then(($page) => {
$page[0].scrollIntoView({ block: 'center' });
});
});

cy.get('pdfjs-viewer-element')
.shadow()
.find('iframe')
.its('0.contentDocument.body')
.then(cy.wrap)
.find(`.page[data-page-number="${pageNumber}"] .textLayer`)
.invoke('text')
.should('eq', expectedText);
});
2 changes: 2 additions & 0 deletions app/cypress/support/commands.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ declare global {
attribute: string,
value: string,
): Chainable<void>;

pdfViewerPageShouldBeText(pageNumber: number, expectedText: string): Chainable<void>;
}
}
}
Expand Down
1 change: 1 addition & 0 deletions app/cypress/support/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ declare global {
navigateToPatientSearchPage(): Chainable<void>;
navigateToDownloadReportPage(): Chainable<void>;
declineCookies(): Chainable<void>;
pdfViewerPageShouldBeText(pageNumber: number, expectedText: string): Chainable<void>;
}
}
}
Loading