Skip to content

Commit

Permalink
O3-2722: Add E2E test for user returning to patient list and home pag…
Browse files Browse the repository at this point in the history
…e from the patient chart
  • Loading branch information
kdaud committed Jan 30, 2024
1 parent 422aa09 commit 4182f4e
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
2 changes: 1 addition & 1 deletion e2e/pages/registration-and-edit-page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
41 changes: 41 additions & 0 deletions e2e/specs/patient-list.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
14 changes: 14 additions & 0 deletions e2e/specs/patient-search.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});

0 comments on commit 4182f4e

Please sign in to comment.