Skip to content

Commit

Permalink
(test) Enhance "Start Visit" E2E Test (#1663)
Browse files Browse the repository at this point in the history
* Delete the patient after the Start Visit E2E test

* Update steps
  • Loading branch information
jayasanka-sack authored Feb 14, 2024
1 parent 4a9a90e commit 1d74c02
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions e2e/specs/start-visit.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from '@playwright/test';
import { test } from '../core';
import { type Patient, generateRandomPatient } from '../commands';
import { type Patient, generateRandomPatient, deletePatient } from '../commands';
import { ChartPage } from '../pages';

let patient: Patient;
Expand Down Expand Up @@ -36,8 +36,11 @@ test('Start a visit', async ({ page, api }) => {
await expect(chartPage.page.locator('form').getByRole('button', { name: /start a visit/i })).toBeVisible();
});

await test.step('And if I select a visit type and then I click the `Start a visit` button', async () => {
await test.step('When I select the visit type: `OPD Visit`', async () => {
await chartPage.page.getByText(/opd visit/i).click();
});

await test.step('And I click the `Start Visit` button', async () => {
await chartPage.page
.locator('form')
.getByRole('button', { name: /start a visit/i })
Expand All @@ -50,6 +53,25 @@ test('Start a visit', async ({ page, api }) => {

await test.step('And I should see the Active Visit tag on the patient header', async () => {
await expect(chartPage.page.getByLabel(/active visit/i)).toBeVisible();
});

await test.step('When I click the `End Visit` button', async () => {
await chartPage.page.getByRole('button', { name: /end visit/i }).click();
});

await test.step('Then I should see a confirmation modal', async () => {
await expect(chartPage.page.getByText(/are you sure you want to end this active visit?/i)).toBeVisible();
});

await test.step('When I click the `End Visit` button to confirm', async () => {
await chartPage.page.getByRole('button', { name: 'danger End Visit' }).click();
});

await test.step('Then I should see a success notification', async () => {
await expect(chartPage.page.getByText(/ended current visit successfully/i)).toBeVisible();
});
});

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

0 comments on commit 1d74c02

Please sign in to comment.