Skip to content

Commit

Permalink
(test) O3-3000: Add E2E tests for editing and deleting an allergy (op…
Browse files Browse the repository at this point in the history
…enmrs#1761)

(test) O3-3OOO: Add E2E tests for editing and deleting an allergy
  • Loading branch information
kdaud authored Mar 28, 2024
1 parent d9dd7f2 commit d2a3c8a
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 73 deletions.
143 changes: 143 additions & 0 deletions e2e/specs/allergies.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
import { expect } from '@playwright/test';
import { generateRandomPatient, deletePatient, type Patient } from '../commands';
import { test } from '../core';
import { PatientAllergiesPage } from '../pages';

let patient: Patient;

test.beforeEach(async ({ api }) => {
patient = await generateRandomPatient(api);
});

test('Add, edit and delete an allergy', async ({ page }) => {
const allergiesPage = new PatientAllergiesPage(page);
const headerRow = allergiesPage.allergiesTable().locator('thead > tr');
const dataRow = allergiesPage.allergiesTable().locator('tbody > tr');

await test.step('When I visit the Allergies page', async () => {
await allergiesPage.goTo(patient.uuid);
});

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

await test.step('Then I should see the record allergy form launch in the workspace', async () => {
await expect(page.getByText(/record a new allergy/i)).toBeVisible();
});

await test.step('When I select `ACE inhibitors` as the allergy', async () => {
await page.getByPlaceholder(/select the allergen/i).click();
await page.getByText(/ace inhibitors/i).click();
});

await test.step('And I select `Mental status change` as the reaction', async () => {
await page.getByText(/mental status change/i).click();
});

await test.step('And I select `Mild` as the severity', async () => {
await page.getByText(/mild/i).click();
});

await test.step('And I add a comment for the allergy', async () => {
await page.locator('#comments').fill('Feeling faint and light-headed');
});

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

await test.step('Then I should see a success toast notification', async () => {
await expect(page.getByText(/allergy saved/i)).toBeVisible();
});

await test.step('And I should see the newly recorded drug allergen in the list', async () => {
await expect(headerRow).toContainText(/allergen/i);
await expect(headerRow).toContainText(/severity/i);
await expect(headerRow).toContainText(/reaction/i);
await expect(headerRow).toContainText(/onset date and comments/i);
await expect(dataRow).toContainText(/ace inhibitors/i);
await expect(dataRow).toContainText(/mild/i);
await expect(dataRow).toContainText(/mental status change/i);
await expect(dataRow).toContainText(/feeling faint and light-headed/i);
});

await test.step('When I click the overflow menu in the table row with the newly added allergy', async () => {
await page
.getByRole('button', { name: /options/i })
.nth(0)
.click();
});

await test.step('And I click on the `Edit` button', async () => {
await page.getByRole('menuitem', { name: /edit/i }).click();
});

await test.step('Then I should see the allergy form launch in the workspace in edit mode`', async () => {
await expect(page.getByText(/edit an allergy/i)).toBeVisible();
await expect(page.getByText(/ace inhibitors/i)).toBeVisible();
});

await test.step('When I change the allergy to `Bee stings`', async () => {
await page.getByPlaceholder(/select the allergen/i).click();
await page.getByText(/bee stings/i).click();
});

await test.step('And I change the severity to `Severe`', async () => {
await page.getByText(/severe/i).click();
});

await test.step('And I change the allergy comment to `Itching all over the body`', async () => {
await page.locator('#comments').clear();
await page.locator('#comments').fill('Itching all over the body');
});

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

await test.step('Then I should see a success toast notification', async () => {
await expect(page.getByText(/allergy updated/i)).toBeVisible();
});

await test.step('And I should see the updated allergy in the list', async () => {
await expect(headerRow).toContainText(/allergen/i);
await expect(headerRow).toContainText(/severity/i);
await expect(headerRow).toContainText(/reaction/i);
await expect(headerRow).toContainText(/onset date and comments/i);
await expect(dataRow).toContainText(/bee stings/i);
await expect(dataRow).not.toContainText(/ace inhibitors/i);
await expect(dataRow).toContainText(/severe/i);
await expect(dataRow).not.toContainText(/mild/i);
await expect(dataRow).toContainText(/itching all over the body/i);
await expect(dataRow).not.toContainText(/feeling faint and light-headed/i);
});

await test.step('When I click the overflow menu in the table row with the updated allergy', async () => {
await page
.getByRole('button', { name: /options/i })
.nth(0)
.click();
});

await test.step('And I click on the `Delete` button', async () => {
await page.getByRole('menuitem', { name: /delete/i }).click();
await page.getByRole('button', { name: /delete/i }).click();
});

await test.step('Then I should see a success toast notification', async () => {
await expect(page.getByText(/allergy deleted/i)).toBeVisible();
});

await test.step('And I should not see the deleted allergy in the list', async () => {
await expect(page.getByText(/bee stings/i)).not.toBeVisible();
});

await test.step('And the allergy table should be empty', async () => {
await expect(page.getByText(/there are no allergy intolerances to display for this patient/i)).toBeVisible();
});
});

test.afterEach(async ({ api }) => {
await deletePatient(api, patient.uuid);
});
4 changes: 2 additions & 2 deletions e2e/specs/attachments.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ test('Add and remove an attachment', async ({ page }) => {
});

await test.step('And I click on the `Add Attachment` button', async () => {
await page.getByRole('button', { name: /add Attachment/i }).click();
await page.getByRole('button', { name: /add attachment/i }).click();
});

await test.step('Then I should see a success toast notification', async () => {
Expand Down Expand Up @@ -82,7 +82,7 @@ test('Add and remove an attachment', async ({ page }) => {
});

await test.step('And the attachments table should be empty', async () => {
await expect(page.getByText(/There are no attachments to display for this patient/i)).toBeVisible();
await expect(page.getByText(/there are no attachments to display for this patient/i)).toBeVisible();
});
});

Expand Down
2 changes: 1 addition & 1 deletion e2e/specs/conditions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ test('Record, edit and delete a condition', async ({ page }) => {

await test.step('And I should not see the deleted condition in the list', async () => {
await expect(conditionsPage.page.getByText(/mental status change/i)).not.toBeVisible();
await expect(conditionsPage.page.getByText(/There are no conditions to display for this patient/i)).toBeVisible();
await expect(conditionsPage.page.getByText(/there are no conditions to display for this patient/i)).toBeVisible();
});
});

Expand Down
2 changes: 1 addition & 1 deletion e2e/specs/drug-orders.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ test('Record, edit and discontinue a drug order', async ({ page }) => {
});

await test.step('And the medications table should be empty', async () => {
await expect(page.getByText(/There are no active medications to display for this patient/i)).toBeVisible();
await expect(page.getByText(/there are no active medications to display for this patient/i)).toBeVisible();
});
});

Expand Down
2 changes: 1 addition & 1 deletion e2e/specs/lab-orders.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ test('Record, edit and discontinue a lab order', async ({ page }) => {

await test.step('And the encounters table should be empty', async () => {
await expect(
page.getByLabel(/all encounters/i).getByText(/There are no encounters to display for this patient/i),
page.getByLabel(/all encounters/i).getByText(/there are no encounters to display for this patient/i),
).toBeVisible();
});
});
Expand Down
68 changes: 0 additions & 68 deletions e2e/specs/record-allergy.spec.ts

This file was deleted.

0 comments on commit d2a3c8a

Please sign in to comment.