Skip to content

Commit

Permalink
(test) O3-4070: E2E test for abnormal biometrics
Browse files Browse the repository at this point in the history
  • Loading branch information
kdaud committed Nov 6, 2024
1 parent 7122212 commit 7017c4d
Showing 1 changed file with 50 additions and 4 deletions.
54 changes: 50 additions & 4 deletions e2e/specs/biometrics.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ test('Record biometrics', async ({ page }) => {
await expect(biometricsPage.page.getByText(/record vitals and biometrics/i)).toBeVisible();
});

await test.step('When I fill `170` as the height', async () => {
await biometricsPage.page.getByRole('spinbutton', { name: /height/i }).fill('170');
await test.step('When I fill `65` as the weight', async () => {
await biometricsPage.page.getByRole('spinbutton', { name: /weight/i }).fill('65');
});

await test.step('And I fill `65` as the weight', async () => {
await biometricsPage.page.getByRole('spinbutton', { name: /weight/i }).fill('65');
await test.step('And I fill `170` as the height', async () => {
await biometricsPage.page.getByRole('spinbutton', { name: /height/i }).fill('170');
});

await test.step('Then I should see `22.51` as the auto calculated body mass index', async () => {
Expand Down Expand Up @@ -66,6 +66,52 @@ test('Record biometrics', async ({ page }) => {
});
});

test('Record abnormal biometrics', async ({ page }) => {
const biometricsPage = new BiometricsAndVitalsPage(page);

await test.step('When I visit the vitals and biometrics page', async () => {
await biometricsPage.goTo(patient.uuid);
});

await test.step('And I click on the `Record biometrics` link to launch the form', async () => {
await biometricsPage.page.getByText(/record biometrics/i).click();
});

await test.step('Then I should see the `Record Vitals and Biometrics` form launch in the workspace', async () => {
await expect(biometricsPage.page.getByText(/record vitals and biometrics/i)).toBeVisible();
});

await test.step('When I fill `255` as the weight', async () => {
await biometricsPage.page.getByRole('spinbutton', { name: /weight/i }).fill('255');
});

await test.step('And I fill `275` as the height', async () => {
await biometricsPage.page.getByRole('spinbutton', { name: /height/i }).fill('275');
});

await test.step('Then I should see `33.7` as the auto calculated body mass index', async () => {
await expect(biometricsPage.page.getByRole('spinbutton', { name: /bmi/i })).toHaveValue('33.7');
});

await test.step('When I fill `25` as the mid upper arm circumference ', async () => {
await biometricsPage.page.getByRole('spinbutton', { name: /muac/i }).fill('25');
});

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

await test.step('Then the system should not save the abnormal biometrics', async () => {
await expect(biometricsPage.page.getByText(/some of the values entered are invalid/i)).toBeVisible();
await expect(biometricsPage.page.getByText(/error saving vitals and biometrics/i)).toBeVisible();
});

await test.step(`And the abnormal vitals should be visible in the 'Biometrics' section with an indication that they exceed normal thresholds.`, async () => {
await expect(biometricsPage.page.getByText(/value must be between 0 and 250/i)).toBeVisible();
await expect(biometricsPage.page.getByText(/value must be between 10 and 272/i)).toBeVisible();
});
});

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

0 comments on commit 7017c4d

Please sign in to comment.