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 an Existing Patient as Deceased #2129

Open
wants to merge 49 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 31 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
68114ff
Add files via upload
virajwathsalag Dec 4, 2024
159ed12
Update index.ts
virajwathsalag Dec 4, 2024
dc061e7
Add files via upload
virajwathsalag Dec 4, 2024
6b4ec5b
Merge branch 'openmrs:main' into main
virajwathsalag Dec 16, 2024
2ce4ac1
Update mark-patient-deceased-page.ts
virajwathsalag Dec 16, 2024
093965c
Update mark-patient-deceased.spec.ts
virajwathsalag Dec 16, 2024
eb27823
Update mark-patient-deceased.spec.ts
virajwathsalag Dec 16, 2024
72279a3
Update mark-patient-deceased.spec.ts
virajwathsalag Dec 16, 2024
9f2b3a2
Update mark-patient-deceased.spec.ts
virajwathsalag Dec 16, 2024
6d46bbc
Update mark-patient-deceased-page.ts
virajwathsalag Dec 16, 2024
480aeee
Update mark-patient-deceased.spec.ts
virajwathsalag Dec 16, 2024
4237f7a
Update mark-patient-deceased-page.ts
virajwathsalag Dec 16, 2024
8501b93
Update mark-patient-deceased.spec.ts
virajwathsalag Dec 16, 2024
c0346dd
Update mark-patient-deceased-page.ts
virajwathsalag Dec 16, 2024
4fd05e1
Update mark-patient-deceased.spec.ts
virajwathsalag Dec 16, 2024
ad7be93
Update mark-patient-deceased-page.ts
virajwathsalag Dec 16, 2024
b60beb3
Update mark-patient-deceased-page.ts
virajwathsalag Dec 16, 2024
9702014
Update mark-patient-deceased-page.ts
virajwathsalag Dec 16, 2024
2da373a
Update mark-patient-deceased.spec.ts
virajwathsalag Dec 16, 2024
b6ef2d7
Update mark-patient-deceased-page.ts
virajwathsalag Dec 16, 2024
86a41a6
Update mark-patient-deceased-page.ts
virajwathsalag Dec 16, 2024
43b4617
Merge branch 'main' into main
virajwathsalag Dec 17, 2024
9fb15f3
Update mark-patient-deceased-page.ts
virajwathsalag Dec 17, 2024
742c34c
Update mark-patient-deceased.spec.ts
virajwathsalag Dec 17, 2024
aface66
Merge branch 'main' into main
virajwathsalag Dec 18, 2024
43729b1
Update mark-patient-deceased.spec.ts
virajwathsalag Dec 18, 2024
5a852e6
Update mark-patient-deceased.spec.ts
virajwathsalag Dec 18, 2024
029685b
Update mark-patient-deceased-page.ts
virajwathsalag Dec 18, 2024
f8f9865
Update mark-patient-deceased.spec.ts
virajwathsalag Dec 18, 2024
9492931
Update mark-patient-deceased.spec.ts
virajwathsalag Dec 18, 2024
58f4120
Update mark-patient-deceased-page.ts
virajwathsalag Dec 18, 2024
da1c408
Update mark-patient-deceased-page.ts
virajwathsalag Dec 19, 2024
a2116cc
Update mark-patient-deceased.spec.ts
virajwathsalag Dec 19, 2024
077a887
Update mark-patient-deceased-page.ts
virajwathsalag Dec 19, 2024
ee04abb
Update mark-patient-deceased.spec.ts
virajwathsalag Dec 19, 2024
ae154b1
Update mark-patient-deceased-page.ts
virajwathsalag Dec 19, 2024
9aadd8b
Update mark-patient-deceased.spec.ts
virajwathsalag Dec 19, 2024
174ae26
Update mark-patient-deceased.spec.ts
virajwathsalag Dec 19, 2024
fb2c318
Update e2e/pages/mark-patient-deceased-page.ts
virajwathsalag Dec 19, 2024
c5c0361
Update e2e/pages/mark-patient-deceased-page.ts
virajwathsalag Dec 19, 2024
2ec8562
Update mark-patient-deceased.spec.ts
virajwathsalag Dec 19, 2024
2401849
Update e2e/specs/mark-patient-deceased.spec.ts
virajwathsalag Dec 19, 2024
8bfaf6e
Update mark-patient-deceased.spec.ts
virajwathsalag Dec 19, 2024
ceedcde
Merge branch 'main' into main
virajwathsalag Dec 19, 2024
7cff878
Update e2e/specs/mark-patient-deceased.spec.ts
virajwathsalag Dec 21, 2024
6c294b0
Update e2e/specs/mark-patient-deceased.spec.ts
virajwathsalag Dec 21, 2024
0351739
Update e2e/specs/mark-patient-deceased.spec.ts
virajwathsalag Dec 21, 2024
2f26528
Update mark-patient-deceased.spec.ts
virajwathsalag Dec 21, 2024
8507574
Update mark-patient-deceased.spec.ts
virajwathsalag Dec 21, 2024
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 @@ -6,6 +6,7 @@ export * from './immunizations-page';
export * from './medications-page';
export * from './orders-page';
export * from './program-page';
export * from './mark-patient-deceased-page';
export * from './results-viewer-page';
export * from './visits-page';
export * from './vitals-and-biometrics-page';
46 changes: 46 additions & 0 deletions e2e/pages/mark-patient-deceased-page.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { expect, type Page } from '@playwright/test';

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

readonly actionsButton = () => this.page.getByRole('button', { name: /actions/i });
readonly markDeceasedMenuItem = () => this.page.getByRole('menuitem', { name: /mark patient deceased/i });
readonly deathDetailsForm = () => this.page.locator('form');
readonly dateOfDeathInput = () => this.page.getByPlaceholder(/dd\/mm\/yyyy/i);
readonly causeOfDeathRadio = (cause: string) => this.page.getByRole('radio', { name: cause });
readonly saveAndCloseButton = () => this.page.getByRole('button', { name: /save and close/i });

virajwathsalag marked this conversation as resolved.
Show resolved Hide resolved

readonly deceasedTag = () =>
this.page.locator('[data-extension-id="deceased-patient-tag"] span', { hasText: 'Deceased' });

async goToPatientChart(patientUuid: string) {
await this.page.goto(`/openmrs/spa/patient/${patientUuid}/chart/Patient%20Summary`);
}

async openMarkDeceasedForm() {
await this.actionsButton().click();
await this.markDeceasedMenuItem().click();
}
virajwathsalag marked this conversation as resolved.
Show resolved Hide resolved

async fillDeathDetails(date: string, causeOfDeath: string) {
await this.dateOfDeathInput().fill(date);
await this.causeOfDeathRadio(causeOfDeath).click();
}

async saveAndClose() {
await this.saveAndCloseButton().click();
}

async verifyDeceasedTag() {

const deceasedTagLocator = this.page.locator(
'[data-extension-id="deceased-patient-tag"] span[title="Deceased"]'
);


await expect(deceasedTagLocator).toBeVisible({ timeout: 70000 });
}

virajwathsalag marked this conversation as resolved.
Show resolved Hide resolved

}
53 changes: 53 additions & 0 deletions e2e/specs/mark-patient-deceased.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { expect } from '@playwright/test';
import { generateRandomPatient, deletePatient, type Patient } from '../commands';
import { test } from '../core';
import { MarkPatientDeceasedPage } from '../pages';

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/cancer';

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

await test.step('When I click on the "Actions" button and select "Mark patient deceased"', async () => {
await markPatientDeceasedPage.openMarkDeceasedForm();
});

await test.step('Then I should see a form to enter the patient\'s death details', async () => {
await expect(markPatientDeceasedPage.deathDetailsForm()).toBeVisible();
await expect(markPatientDeceasedPage.dateOfDeathInput()).toBeVisible();
await expect(markPatientDeceasedPage.causeOfDeathRadio(causeOfDeath)).toBeVisible();
});

await test.step('When I add all the death details and save', async () => {
virajwathsalag marked this conversation as resolved.
Show resolved Hide resolved

await markPatientDeceasedPage.dateOfDeathInput().fill(todayDate);


await page.keyboard.press('Enter');


await page.locator('text=Neoplasm/cancer').waitFor({ state: 'visible' });
await page.locator('text=Neoplasm/cancer').click();


await markPatientDeceasedPage.saveAndCloseButton().click();
});

await test.step('Then I should see a “deceased” patient tag in the patient banner', async () => {
await markPatientDeceasedPage.verifyDeceasedTag();
});
});

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