Skip to content

Commit

Permalink
PRMDR-768 - Cypress test for uploading state (#333)
Browse files Browse the repository at this point in the history
* add e2e tests for view and upload after state uploading changes
  • Loading branch information
NogaNHS authored Apr 5, 2024
1 parent ad61854 commit 30139ba
Show file tree
Hide file tree
Showing 3 changed files with 80 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -604,5 +604,24 @@ describe('GP Workflow: Upload Lloyd George record when user is GP admin BSOL and
cy.url().should('eq', baseUrl + '/patient/upload/lloyd-george-record');
},
);
it(
`It navigate to error page when uploading Lloyd George record is in progress for the patient`,
{ tags: 'regression' },
() => {
const stubbedResponse = {
statusCode: 423,
data: { err_code: 'LGL_423' },
};

cy.intercept('POST', '**/DocumentReference**', stubbedResponse);

cy.getByTestId('button-input').selectFile(
uploadedFilePathNames.LG[singleFileUsecaseIndex],
{ force: true },
);
clickUploadButton();
cy.contains('Sorry, there is a problem with the service').should('be.visible');
},
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,10 @@ describe('GP Workflow: View Lloyd George record', () => {
};

gpRoles.forEach((role) => {
beforeEach(() => {
beforeEachConfiguration(role);
});
context(`View Lloyd George document for ${roleName(role)} role`, () => {
beforeEach(() => {
beforeEachConfiguration(role);
});
it(
roleName(role) + ' can view a Lloyd George document of an active patient',
{ tags: 'regression' },
Expand Down Expand Up @@ -98,22 +98,25 @@ describe('GP Workflow: View Lloyd George record', () => {
);

it(
`It displays an empty Lloyd George card when no Lloyd George record exists for the patient for a ${roleName(
`It displays an waiting message when uploading Lloyd George record is in progress for the patient for a ${roleName(
role,
)}`,
{ tags: 'regression' },
() => {
cy.intercept('GET', '/LloydGeorgeStitch*', {
statusCode: 404,
statusCode: 423,
});
cy.get('#verify-submit').click();

// Assert
assertPatientInfo();
assertEmptyLloydGeorgeCard();
cy.getByTestId('pdf-card').should('include.text', 'Lloyd George record');
cy.getByTestId('pdf-card').should(
'include.text',
'You can view this record once it’s finished uploading. This may take a few minutes.',
);
},
);

it(
`It displays an error when the Lloyd George Stitch API call fails for a ${roleName(
role,
Expand Down Expand Up @@ -147,7 +150,39 @@ describe('GP Workflow: View Lloyd George record', () => {
assertTimeoutLloydGeorgeError(true);
},
);
it(
`It displays an empty Lloyd George card when no Lloyd George record exists for the patient for a GP_CLINICAL`,
{ tags: 'regression' },
() => {
beforeEachConfiguration(Roles.GP_CLINICAL);

cy.intercept('GET', '/LloydGeorgeStitch*', {
statusCode: 404,
});
cy.get('#verify-submit').click();
// Assert
assertPatientInfo();
assertEmptyLloydGeorgeCard();
},
);
it(
`It displays an upload button when no Lloyd George record exists for the patient for a GP_ADMIN`,
{ tags: 'regression' },
() => {
beforeEachConfiguration(Roles.GP_ADMIN);

cy.intercept('GET', '/LloydGeorgeStitch*', {
statusCode: 404,
});
cy.get('#verify-submit').click();
// Assert
assertPatientInfo();
cy.getByTestId('pdf-card').should('include.text', 'Lloyd George record');
cy.getByTestId('no-records-title').should('be.visible');
cy.getByTestId('upload-patient-record-text').should('be.visible');
cy.getByTestId('upload-patient-record-button').should('be.visible');
},
);
it(
'It displays an error with download link when a Lloyd George stitching timeout occurs via the API Gateway for a GP_CLINICAL but link access is denied',
{ tags: 'regression' },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,26 @@ describe('GP Workflow: View Lloyd George record', () => {
assertEmptyLloydGeorgeCard();
},
);
it(
`It displays an waiting message when uploading Lloyd George record is in progress for the patient for a ${roleName(
role,
)}`,
{ tags: 'regression' },
() => {
cy.intercept('GET', '/LloydGeorgeStitch*', {
statusCode: 423,
});
cy.get('#verify-submit').click();

// Assert
assertPatientInfo();
cy.getByTestId('pdf-card').should('include.text', 'Lloyd George record');
cy.getByTestId('pdf-card').should(
'include.text',
'You can view this record once it’s finished uploading. This may take a few minutes.',
);
},
);
it(
`It displays an error when the Lloyd George Stitch API call fails for a ${roleName(
role,
Expand Down

0 comments on commit 30139ba

Please sign in to comment.