-
Notifications
You must be signed in to change notification settings - Fork 249
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
dilankavishka
wants to merge
3
commits into
openmrs:main
from
dilankavishka:e2e-test-mark-patient-deceased
Closed
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 () => { | ||
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); | ||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?