Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

(test) O3-4227: Add e2e test for marking a patient as deceased #2156

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions e2e/pages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ export * from './program-page';
export * from './results-viewer-page';
export * from './visits-page';
export * from './vitals-and-biometrics-page';
export * from './mark-patient-deceased-page';
9 changes: 9 additions & 0 deletions e2e/pages/mark-patient-deceased-page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { type Page } from '@playwright/test';

export class MarkPatientDeceasedPage {
constructor(readonly page: Page) {}

async goTo(patientUuid: string) {
await this.page.goto('/openmrs/spa/patient/' + patientUuid + '/chart/Patient%20Summary');
}
}
57 changes: 57 additions & 0 deletions e2e/specs/mark-patient-deceased.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { expect } from '@playwright/test';
import { generateRandomPatient, deletePatient, type Patient } from '../commands';
import { test } from '../core';
import { MarkPatientDeceasedPage } from '../pages/mark-patient-deceased-page';

let patient: Patient;

test.beforeEach(async ({ api }) => {
patient = await generateRandomPatient(api);
});

test('Mark a patient as deceased', async ({ page }) => {
const markPatientDeceasedPage = new MarkPatientDeceasedPage(page);
const todayDate = new Date().toLocaleDateString('en-GB').replace(/\//g, '-');
const causeOfDeath = 'Neoplasm';
const actionsButton = () => page.getByRole('button', { name: /actions/i });
const markDeceasedMenuItem = () => page.getByRole('menuitem', { name: /mark patient deceased/i });
const deathDetailsForm = () => page.locator('form');
const dateOfDeathInput = () => page.getByPlaceholder(/dd\/mm\/yyyy/i);

await test.step('Given that I have a patient and I am on the Patients chart page', async () => {
await markPatientDeceasedPage.goTo(patient.uuid);
});

await test.step('When I click on the "Actions" button and select "Mark patient deceased"', async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be two separate steps?

await actionsButton().click();
await markDeceasedMenuItem().click();
});

await test.step('Then I should see a form to enter the patients death details', async () => {
await expect(deathDetailsForm()).toBeVisible();
await expect(dateOfDeathInput()).toBeVisible();
await expect(page.getByRole('radio', { name: causeOfDeath })).toBeVisible();
});

await test.step('When I enter the "Date of death" to today’s date', async () => {
await dateOfDeathInput().fill(todayDate);
await page.keyboard.press('Enter');
});

await test.step('And the "Cause of death" to Neoplasm', async () => {
await page.locator('text=Neoplasm').click();
});

await test.step('And I click "Save and close"', async () => {
await page.getByRole('button', { name: /save and close/i }).click();
});

await test.step('Then I should see a “deceased” patient tag in the patient banner', async () => {
const deceasedTagLocator = page.locator('[data-extension-id="deceased-patient-tag"] span[title="Deceased"]');
await expect(deceasedTagLocator).toBeVisible();
});
});

test.afterEach(async ({ api }) => {
await deletePatient(api, patient.uuid);
});
Loading