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-4177: Add E2E test for adding abnormal vitals #2132

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Changes from 2 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
64 changes: 64 additions & 0 deletions e2e/specs/invalid.vitals.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
import { test } from '../core';
import { expect } from '@playwright/test';
import { type Visit } from '@openmrs/esm-framework';
import { generateRandomPatient, type Patient, startVisit, endVisit } from '../commands';
import { BiometricsAndVitalsPage } from '../pages';

let patient: Patient;
let visit: Visit;

test.beforeEach(async ({ api }) => {
patient = await generateRandomPatient(api);
visit = await startVisit(api, patient.uuid);
});

test('Flagging abnormal vitals in the Patient Chart', async ({ page }) => {
const biometricsPage = new BiometricsAndVitalsPage(page);

await test.step('Given a patient record exists and the user is on the "Patient Chart" page', async () => {
lucyjemutai marked this conversation as resolved.
Show resolved Hide resolved
await biometricsPage.goTo(patient.uuid);
});

await test.step('When the user navigates to the "Vitals & Biometrics" section', async () => {
lucyjemutai marked this conversation as resolved.
Show resolved Hide resolved
await biometricsPage.goTo(patient.uuid);
});

await test.step('And clicks on "Add New Vital/Biometric"', async () => {
await biometricsPage.page.getByText(/record biometrics/i).click();
});

await test.step('Then a form to enter vitals/biometrics details should be displayed', async () => {
await expect(biometricsPage.page.getByText(/record vitals and biometrics/i)).toBeVisible();
});

await test.step('When the user enters abnormal vitals/biometric values', async () => {
Copy link
Member

Choose a reason for hiding this comment

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

Is the test for vitals or biometrics?

Copy link
Author

Choose a reason for hiding this comment

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

vitals @kdaud

Copy link
Member

Choose a reason for hiding this comment

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

Shall we break down each value into sub steps? Generic steps can be confusing since they don't show what information was filled in the form.

Copy link
Author

Choose a reason for hiding this comment

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

Please review again @jayasanka-sack , Thank you

await biometricsPage.page.getByRole('spinbutton', { name: /temperature/i }).fill('43.0');
await biometricsPage.page.getByRole('spinbutton', { name: /systolic/i }).fill('250');
await biometricsPage.page.getByRole('spinbutton', { name: /diastolic/i }).fill('150');
await biometricsPage.page.getByRole('spinbutton', { name: /pulse/i }).fill('230');
await biometricsPage.page.getByRole('spinbutton', { name: /respiration rate/i }).fill('999');
await biometricsPage.page.getByRole('spinbutton', { name: /oxygen saturation/i }).fill('100');
});

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

await test.step('Then the system should save the vitals/biometrics', async () => {
await expect(biometricsPage.page.getByText(/vitals and biometrics saved/i)).toBeVisible();
});

await test.step('And the system should flag the abnormal values based on predefined thresholds', async () => {
await expect(biometricsPage.page.getByRole('cell', { name: '43 ↑↑' })).toBeVisible();
await expect(biometricsPage.page.getByRole('cell', { name: '/ 150 ↑↑' })).toBeVisible();
await expect(biometricsPage.page.getByRole('cell', { name: '230 ↑↑' })).toBeVisible();
await expect(biometricsPage.page.getByRole('cell', { name: '999 ↑↑' })).toBeVisible();
});

await test.step('And the abnormal vitals/biometrics should be visible in the "Vitals & Biometrics" section with indications they exceed normal thresholds', async () => {
await expect(biometricsPage.page.getByText(/temp43 deg c/i)).toBeVisible();
await expect(biometricsPage.page.getByText(/bp250 \/ 150 mmhg/i)).toBeVisible();
await expect(biometricsPage.page.getByText(/heart rate230 beats\/min/i)).toBeVisible();
await expect(biometricsPage.page.getByText(/r. rate999 breaths\/min/i)).toBeVisible();
});
});
Loading