Skip to content

Commit

Permalink
Break down steps when returning to the home page and patient list page
Browse files Browse the repository at this point in the history
  • Loading branch information
kdaud committed Feb 9, 2024
1 parent 4182f4e commit d9bc61e
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 17 deletions.
69 changes: 61 additions & 8 deletions e2e/specs/patient-list.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { test } from '../core';
import { PatientListsPage } from '../pages';
import { HomePage, PatientListsPage } from '../pages';
import { expect } from '@playwright/test';
import {
type Cohort,
Expand Down Expand Up @@ -91,40 +91,93 @@ 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);
const patientListPage = new PatientListsPage(page);
const homePage = new HomePage(page);
await test.step("When I visit a specific patient list's page", async () => {
await patientListPage.goto(cohort.uuid);
});

await test.step('And adds a patient to the list', async () => {
const patientListPage = new PatientListsPage(page);
await test.step('And I add a patient to the list', async () => {
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 test.step('And I click on the patient link', async () => {
await page.locator('table tbody tr td:nth-child(1) a').click();
await page.getByLabel('Open menu').click();
});

await test.step('Then I should be redirected to the patient chart', async () => {
await expect(homePage.page).toHaveURL(
`${process.env.E2E_BASE_URL}/spa/patient/${patient.uuid}/chart/Patient Summary`,
);
});

await test.step('When I click on the `Close` button', async () => {
await page.getByRole('button', { name: 'Close' }).click();
const patientListPage = new PatientListsPage(page);
});

await test.step('Then I should be redirected to the patient list page', async () => {
await expect(page).toHaveURL(/.*patient-lists/);
await expect(patientListPage.patientListHeader()).toHaveText(/1 patients/);
await expect(patientListPage.patientsTable()).toHaveText(new RegExp(patient.person.display));
});

await test.step('When I click on the patient link', async () => {
await page.locator('table tbody tr td:nth-child(1) a').click();
});

await test.step('Then I should be redirected to the patient chart', async () => {
await expect(homePage.page).toHaveURL(
`${process.env.E2E_BASE_URL}/spa/patient/${patient.uuid}/chart/Patient Summary`,
);
});

await test.step('When I click on the `Open menu` button', async () => {
await page.getByLabel('Open menu').click();
});

await test.step('And I click on the `Visits` link', async () => {
await page.getByRole('link', { name: 'Visits' }).click();
});

await test.step('And I click on the `Close` button', async () => {
await page.getByRole('button', { name: 'Close' }).click();
});

await test.step('Then I should be redirected to the patient list page', async () => {
await expect(page).toHaveURL(/.*patient-lists/);
await expect(patientListPage.patientListHeader()).toHaveText(/1 patients/);
await expect(patientListPage.patientsTable()).toHaveText(new RegExp(patient.person.display));
});

await test.step('When I click on the patient link', async () => {
await page.locator('table tbody tr td:nth-child(1) a').click();
});

await test.step('Then I should be redirected to the patient chart', async () => {
await expect(homePage.page).toHaveURL(
`${process.env.E2E_BASE_URL}/spa/patient/${patient.uuid}/chart/Patient Summary`,
);
});

await test.step('When I click on the `Open menu` button', async () => {
await page.getByLabel('Open menu').click();
});

await test.step('And I click on the `Visits` link', async () => {
await page.getByRole('link', { name: 'Visits' }).click();
});

await test.step('And I refesh the page', async () => {
await page.reload();
});

await test.step('And I click on the `Close` button', async () => {
await page.getByRole('button', { name: 'Close' }).click();
});

await test.step('Then I should be redirected to the patient list page', async () => {
await expect(page).toHaveURL(/.*patient-lists/);
await expect(patientListPage.patientListHeader()).toHaveText(/1 patients/);
await expect(patientListPage.patientsTable()).toHaveText(new RegExp(patient.person.display));
Expand Down
12 changes: 3 additions & 9 deletions e2e/specs/patient-search.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from '@playwright/test';
import { test } from '../core';
import { HomePage } from '../pages';
import { generateRandomPatient, deletePatient, Patient } from '../commands';
import { generateRandomPatient, deletePatient, type Patient } from '../commands';

let patient: Patient;

Expand Down Expand Up @@ -74,18 +74,12 @@ test('Search patient by full name', async ({ page, api }) => {
`${process.env.E2E_BASE_URL}/spa/patient/${patient.uuid}/chart/Patient Summary`,
);
});
});

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 test.step('When I click on the `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 test.step('Then I should be redirected to the home page', async () => {
await expect(page).toHaveURL(`${process.env.E2E_BASE_URL}/spa/home`);
});
});
Expand Down

0 comments on commit d9bc61e

Please sign in to comment.