diff --git a/e2e/pages/registration-and-edit-page.ts b/e2e/pages/registration-and-edit-page.ts index bcbafe42d..46ba4f4d5 100644 --- a/e2e/pages/registration-and-edit-page.ts +++ b/e2e/pages/registration-and-edit-page.ts @@ -46,10 +46,10 @@ export class RegistrationAndEditPage { async fillPatientRegistrationForm(formValues: PatientRegistrationFormValues) { const tryFill = (locator: Locator, value?: string) => value && locator.fill(value); - formValues.sex && (await this.sexRadioButton(formValues.sex).check()); await tryFill(this.givenNameInput(), formValues.givenName); await tryFill(this.middleNameInput(), formValues.middleName); await tryFill(this.familyNameInput(), formValues.familyName); + formValues.sex && (await this.sexRadioButton(formValues.sex).check()); await tryFill(this.birthdateInput(), formValues.birthdate); await tryFill(this.phoneInput(), formValues.phone); await tryFill(this.emailInput(), formValues.email); diff --git a/e2e/specs/patient-list.spec.ts b/e2e/specs/patient-list.spec.ts index a5572c730..1d2762b6c 100644 --- a/e2e/specs/patient-list.spec.ts +++ b/e2e/specs/patient-list.spec.ts @@ -90,6 +90,47 @@ test('Manage patients in a list', async ({ api, page }) => { }); }); +test('User should return to patient list from the patient chart', async ({ api, page }) => { + await test.step("When a user visits a specific patient list's page", async () => { + const patientListPage = new PatientListsPage(page); + await patientListPage.goto(cohort.uuid); + }); + + await test.step('And adds a patient to the list', async () => { + const patientListPage = new PatientListsPage(page); + createdCohortMember = await addPatientToCohort(api, cohort.uuid, patient.uuid); + await patientListPage.goto(cohort.uuid); + await expect(patientListPage.patientsTable()).toHaveText(new RegExp(patient.person.display)); + }); + + await test.step('Then should be able to wind up back to patient list from the patient chart', async () => { + await page.locator('table tbody tr td:nth-child(1) a').click(); + await page.getByLabel('Open menu').click(); + await page.getByRole('button', { name: 'Close' }).click(); + const patientListPage = new PatientListsPage(page); + await expect(page).toHaveURL(/.*patient-lists/); + await expect(patientListPage.patientListHeader()).toHaveText(/1 patients/); + await expect(patientListPage.patientsTable()).toHaveText(new RegExp(patient.person.display)); + + await page.locator('table tbody tr td:nth-child(1) a').click(); + await page.getByLabel('Open menu').click(); + await page.getByRole('link', { name: 'Visits' }).click(); + await page.getByRole('button', { name: 'Close' }).click(); + await expect(page).toHaveURL(/.*patient-lists/); + await expect(patientListPage.patientListHeader()).toHaveText(/1 patients/); + await expect(patientListPage.patientsTable()).toHaveText(new RegExp(patient.person.display)); + + await page.locator('table tbody tr td:nth-child(1) a').click(); + await page.getByLabel('Open menu').click(); + await page.getByRole('link', { name: 'Visits' }).click(); + await page.reload(); + await page.getByRole('button', { name: 'Close' }).click(); + await expect(page).toHaveURL(/.*patient-lists/); + await expect(patientListPage.patientListHeader()).toHaveText(/1 patients/); + await expect(patientListPage.patientsTable()).toHaveText(new RegExp(patient.person.display)); + }); +}); + test.afterEach(async ({ api }) => { if (createdCohortMember) { await removePatientFromCohort(api, createdCohortMember.uuid); diff --git a/e2e/specs/patient-search.spec.ts b/e2e/specs/patient-search.spec.ts index 25e4bc55e..a23a391dc 100644 --- a/e2e/specs/patient-search.spec.ts +++ b/e2e/specs/patient-search.spec.ts @@ -76,6 +76,20 @@ test('Search patient by full name', async ({ page, api }) => { }); }); +test('User should return to home page from the patient chart', async ({ api, page }) => { + await test.step('When a user goes to patient chart using the url', async () => { + await page.goto(`${process.env.E2E_BASE_URL}/spa/patient/${patient.uuid}/chart/Patient Summary`); + }); + + await test.step('And clicks on `Close` button', async () => { + await page.getByRole('button', { name: 'Close' }).click(); + }); + + await test.step('Then should be able to wind up back to home page from the patient chart', async () => { + await expect(page).toHaveURL(`${process.env.E2E_BASE_URL}/spa/home`); + }); +}); + test.afterEach(async ({ api }) => { await deletePatient(api, patient.uuid); });