Skip to content

Commit

Permalink
Update mark-patient-deceased.spec.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
virajwathsalag authored Dec 19, 2024
1 parent c5c0361 commit 2ec8562
Showing 1 changed file with 12 additions and 16 deletions.
28 changes: 12 additions & 16 deletions e2e/specs/mark-patient-deceased.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ 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 });
Expand All @@ -23,42 +22,39 @@ test('Mark a patient as deceased', async ({ page }) => {
const deceasedTag = () =>
page.locator('[data-extension-id="deceased-patient-tag"] span', { hasText: 'Deceased' });


await test.step('Given that I have a patient and I am on the Patient’s 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();
});

// Then I should see a form to enter the patient's death details
await test.step('Then I should see a form to enter the patient\'s 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 and the "Cause of death" to Neoplasm and click "Save and close"', async () => {

await dateOfDeathInput().fill(todayDate);
await page.keyboard.press('Enter');
await page.locator('text=Neoplasm').waitFor({ state: 'visible' });
await page.locator('text=Neoplasm').click();
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 saveAndCloseButton().click();
});
await test.step('When I set the "Cause of death" to Neoplasm', async () => {
await page.locator('text=Neoplasm').waitFor({ state: 'visible' });
await page.locator('text=Neoplasm').click();
});

await test.step('And I click "Save and close"', async () => {
await saveAndCloseButton().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({ timeout: 70000 });
});
});
Expand Down

0 comments on commit 2ec8562

Please sign in to comment.