|
| 1 | +import { pdsPatients, stubPatients } from '../../../support/patients'; |
| 2 | +import { Roles } from '../../../support/roles'; |
| 3 | +import dbItem from '../../../fixtures/dynamo-db-items/active-patient.json'; |
| 4 | +import { formatNhsNumber } from '../../../../src/helpers/utils/formatNhsNumber'; |
| 5 | + |
| 6 | +const workspace = Cypress.env('WORKSPACE'); |
| 7 | +dbItem.FileLocation = dbItem.FileLocation.replace('{env}', workspace); |
| 8 | +const activePatient = |
| 9 | + workspace === 'ndr-dev' ? pdsPatients.activeUpload : stubPatients.activeUpload; |
| 10 | +const bucketName = `${workspace}-lloyd-george-store`; |
| 11 | +const tableName = `${workspace}_LloydGeorgeReferenceMetadata`; |
| 12 | +const fileName = `${activePatient}/e4a6d7f7-01f3-44be-8964-515b2c0ec180`; |
| 13 | + |
| 14 | +const patientVerifyUrl = '/patient/verify'; |
| 15 | +const lloydGeorgeRecordUrl = '/patient/lloyd-george-record'; |
| 16 | + |
| 17 | +describe('GP Workflow: View Lloyd George record', () => { |
| 18 | + context('View Lloyd George document', () => { |
| 19 | + beforeEach(() => { |
| 20 | + cy.deleteFileFromS3(bucketName, fileName); |
| 21 | + cy.deleteItemFromDynamoDb(tableName, dbItem.ID); |
| 22 | + cy.addPdfFileToS3(bucketName, fileName, 'test_patient_record.pdf'); |
| 23 | + cy.addItemToDynamoDb(tableName, dbItem); |
| 24 | + }); |
| 25 | + |
| 26 | + afterEach(() => { |
| 27 | + cy.deleteFileFromS3(bucketName, fileName); |
| 28 | + cy.deleteItemFromDynamoDb(tableName, dbItem.ID); |
| 29 | + }); |
| 30 | + |
| 31 | + it( |
| 32 | + '[Smoke] GP ADMIN user can view the Lloyd George document of an active patient', |
| 33 | + { tags: 'smoke', defaultCommandTimeout: 20000 }, |
| 34 | + () => { |
| 35 | + cy.smokeLogin(Roles.SMOKE_GP_ADMIN); |
| 36 | + cy.get('.nhsuk-navigation-container').should('exist'); |
| 37 | + cy.navigateToPatientSearchPage(); |
| 38 | + cy.get('#nhs-number-input').click(); |
| 39 | + cy.get('#nhs-number-input').type(activePatient); |
| 40 | + cy.get('#search-submit').click(); |
| 41 | + |
| 42 | + cy.url().should('contain', patientVerifyUrl); |
| 43 | + cy.get('#verify-submit').click(); |
| 44 | + |
| 45 | + cy.url().should('contain', lloydGeorgeRecordUrl); |
| 46 | + cy.contains('Loading...').should('be.visible'); |
| 47 | + |
| 48 | + cy.document({ timeout: 30000 }).should(doc => { |
| 49 | + const text = |
| 50 | + doc |
| 51 | + .querySelector('[data-testid="pdf-viewer"]') |
| 52 | + ?.shadowRoot |
| 53 | + ?.querySelector('iframe') |
| 54 | + ?.contentDocument |
| 55 | + ?.querySelector('#viewer') |
| 56 | + ?.innerText |
| 57 | + |
| 58 | + expect(text).to.include('General Practice Summary') |
| 59 | + }); |
| 60 | + }) |
| 61 | + }); |
| 62 | +}); |
0 commit comments