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

E2E tests for medication and lab order workflows. #11

Merged
merged 2 commits into from
Aug 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ on:
schedule:
- cron: "0 0 * * *"
push:
branches: [main]
branches: [master]
pull_request:
branches: [main]
branches: [master]

workflow_dispatch:
inputs:
Expand Down
12 changes: 6 additions & 6 deletions e2e/tests/bahmni-odoo-flows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ test.beforeEach(async ({ page }) => {
odoo = new Odoo(page);

await bahmni.login();
await expect(page.getByText('Registration')).toBeVisible();
await expect(page.getByText('Clinical')).toBeVisible();
await expect(page.getByText('Admin')).toBeVisible();
await expect(page.getByText('Appointment Scheduling')).toBeVisible();
await expect(page.getByText('Patient Documents')).toBeVisible();
await expect(page.getByText(/registration/i)).toBeVisible();
await expect(page.getByText(/linical/i)).toBeVisible();
await expect(page.getByText(/admin/i)).toBeVisible();
await expect(page.getByText(/appointment scheduling/i)).toBeVisible();
await expect(page.getByText(/patient documents/i)).toBeVisible();
});

test('Ordering a lab test for a Bahmni patient creates the corresponding Odoo customer with a filled quotation.', async ({ page }) => {
Expand All @@ -25,7 +25,7 @@ test('Ordering a lab test for a Bahmni patient creates the corresponding Odoo cu
await bahmni.goToLabSamples();
await page.getByText('Blood', { exact: true }).click();
await page.getByText('Malaria').click();
await bahmni.saveLabOrder();
await bahmni.saveOrder();

// verify
await odoo.open();
Expand Down
69 changes: 69 additions & 0 deletions e2e/tests/lab-orders.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
import { test, expect } from '@playwright/test';
import { Bahmni } from '../utils/functions/bahmni';

let bahmni: Bahmni;

test.beforeEach(async ({ page }) => {
bahmni = new Bahmni(page);

await bahmni.login();
await expect(page.getByText(/registration/i)).toBeVisible();
await expect(page.getByText(/linical/i)).toBeVisible();
await expect(page.getByText(/admin/i)).toBeVisible();
await expect(page.getByText(/appointment scheduling/i)).toBeVisible();
await expect(page.getByText(/patient documents/i)).toBeVisible();
});

test('Record, revise and discontinue lab tests.', async ({ page }) => {
// setup
await bahmni.registerPatient();

// replay
await bahmni.goToLabSamples();
await page.getByText('Blood', { exact: true }).click();
await page.getByText('Malaria').click();
await page.getByText('Urine').click();
await page.getByText('Gravindex').click();
await page.getByText('Stool').click();
await page.getByText('Stool Colour').click();
await page.getByText('Vaginal Swab').click();
await page.getByText('Bacteries').click();
await page.getByText('Sputum').click();
await page.getByText('Serial sputum bacilloscopy').click();
await bahmni.saveOrder();

// verify
kdaud marked this conversation as resolved.
Show resolved Hide resolved
await page.locator('#dashboard-link span.patient-name').click();
await expect(page.locator('#Lab-Orders').getByText('Malaria')).toBeVisible();
await expect(page.locator('#Lab-Orders').getByText('Gravindex')).toBeVisible();
await expect(page.locator('#Lab-Orders').getByText('Stool Colour')).toBeVisible();
await expect(page.locator('#Lab-Orders').getByText('Bacteria')).toBeVisible();
await expect(page.locator('#Lab-Orders').getByText('Serial sputum bacilloscopy')).toBeVisible();

await page.locator('#view-content :nth-child(1).btn--success').click();
kdaud marked this conversation as resolved.
Show resolved Hide resolved
await page.getByText('Orders', { exact: true }).click();
await page.getByText('Blood', { exact: true }).click();
await page.locator('#selected-orders li').filter({ hasText: 'Malaria' }).locator('i').nth(1).click();
await page.getByText('Blood Sugar').click();
await page.getByText('Urine').click();
await page.locator('#selected-orders li').filter({ hasText: 'Gravindex' }).locator('i').nth(1).click();
await page.getByText('Urine Colour').click();
await page.getByText('Stool', { exact: true }).click();
await page.getByText('Stool Parasites').click();
await bahmni.saveOrder();

await page.locator('#dashboard-link span.patient-name').click();
await expect(page.locator('#Lab-Orders').getByText('Malaria')).not.toBeVisible();
await expect(page.locator('#Lab-Orders').getByText('Blood Sugar')).toBeVisible();
await expect(page.locator('#Lab-Orders').getByText('Gravindex')).not.toBeVisible();
await expect(page.locator('#Lab-Orders').getByText('Urine Colour')).toBeVisible();
await expect(page.locator('#Lab-Orders').getByText('Stool Colour')).toBeVisible();
await expect(page.locator('#Lab-Orders').getByText('Stool Parasites')).toBeVisible();
await expect(page.locator('#Lab-Orders').getByText('Bacteria')).toBeVisible();
await expect(page.locator('#Lab-Orders').getByText('Serial sputum bacilloscopy')).toBeVisible();
});

test.afterEach(async ({ page }) => {
await bahmni.voidPatient();
await page.close();
});
80 changes: 80 additions & 0 deletions e2e/tests/medications.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
import { test, expect } from '@playwright/test';
import { Bahmni } from '../utils/functions/bahmni';

let bahmni: Bahmni;

test.beforeEach(async ({ page }) => {
bahmni = new Bahmni(page);

await bahmni.login();
await expect(page.getByText(/registration/i)).toBeVisible();
await expect(page.getByText(/linical/i)).toBeVisible();
await expect(page.getByText(/admin/i)).toBeVisible();
await expect(page.getByText(/appointment scheduling/i)).toBeVisible();
await expect(page.getByText(/patient documents/i)).toBeVisible();
});

test('Record, revise and discontinue a drug order.', async ({ page }) => {
kdaud marked this conversation as resolved.
Show resolved Hide resolved
// setup
await bahmni.registerPatient();

// replay
await bahmni.goToMedications();
await page.locator('#drug-name').type('Aspirine Co 81mg');
await page.getByText('Aspirine Co 81mg (Comprime)').click();
await page.locator('#uniform-dose').fill('2');
await page.locator('#uniform-dose-unit').selectOption('string:Application(s)');
await page.locator('#frequency').selectOption('string:Q3H');
await page.locator('#route').selectOption('string:Topique');
await page.locator('#start-date').fill('2024-08-16');
await page.locator('#duration').fill('5');
await page.locator('#duration-unit').selectOption('string:Semaine(s)');
await page.locator('#total-quantity-unit').selectOption('string:Ampoule(s)');
await page.locator('#instructions').selectOption('string:Estomac vide');
await page.locator('#additional-instructions').fill('Take after a meal');
await page.getByRole('button', { name: 'Add' }).click();
await bahmni.saveOrder();

// verify
kdaud marked this conversation as resolved.
Show resolved Hide resolved
await page.locator('#dashboard-link span.patient-name').click();
const drugNameSelector = await page.locator('treatment-table td.drug.active-drug span');
const medicationDetailsSelector = await page.locator('#dashboard-treatments td.dosage span:nth-child(1)');
await expect(drugNameSelector).toHaveText('Aspirine Co 81mg (Comprime)');
await expect(medicationDetailsSelector).toContainText('2 Application(s)');
await expect(medicationDetailsSelector).toContainText('Q3H');
await expect(medicationDetailsSelector).toContainText('Estomac vide');
await expect(medicationDetailsSelector).toContainText('Topique');

kdaud marked this conversation as resolved.
Show resolved Hide resolved
await page.locator('#view-content :nth-child(1).btn--success').click();
await page.getByText('Medications', { exact: true }).click();
await page.locator('#ordered-drug-orders button:nth-child(1) i').first().click();
await page.locator('#uniform-dose').clear();
await page.locator('#uniform-dose').fill('4');
await page.locator('#frequency').selectOption('string:Q4H');
await page.locator('#uniform-dose-unit').selectOption('string:Comprime(s)');
await page.locator('#route').selectOption('string:Inhalation');
await page.getByRole('button', { name: 'Add' }).click();
await bahmni.saveOrder();
await page.locator('#dashboard-link span.patient-name').click();
await expect(medicationDetailsSelector).not.toContainText('2 Application(s)');
await expect(medicationDetailsSelector).toContainText('4 Comprime(s)');
await expect(medicationDetailsSelector).not.toContainText('Q3H');
await expect(medicationDetailsSelector).toContainText('Q4H,');
await expect(medicationDetailsSelector).not.toContainText('Ampoule(s)');
await expect(medicationDetailsSelector).toContainText('Inhalation');

kdaud marked this conversation as resolved.
Show resolved Hide resolved
await page.locator('#view-content :nth-child(1).btn--success').click();
await page.getByText('Medications', { exact: true }).click();
const drugSelector = await page.locator('strong.drug-name').first();
await expect(drugSelector).toContainText('Aspirine Co 81mg (Comprime)');
await page.getByRole('button', { name: 'Stop' }).first().click();
await page.getByPlaceholder('Notes').clear();
await page.getByPlaceholder('Notes').fill('Patient allergic to medicine');
await bahmni.saveOrder();
await expect(page.getByText(/no recent treatments/i)).toBeVisible();
});

test.afterEach(async ({ page }) => {
await bahmni.voidPatient();
await page.close();
});
14 changes: 12 additions & 2 deletions e2e/utils/functions/bahmni.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,18 @@ export class Bahmni {
await expect(this.page.getByText('Lab Samples')).toBeVisible();
}

async saveLabOrder() {
async goToMedications() {
await this.page.locator('i.fa.fa-home').click();
await this.page.getByRole('link', { name: 'Clinical' }).click();
await this.searchPatient();
await this.page.locator('#view-content :nth-child(1).btn--success').click();
await this.page.getByText('Medications', { exact: true }).click();
await expect(this.page.getByText('Order Drug')).toBeVisible();
await expect(this.page.getByText('Order an Order Set')).toBeVisible();
}

async saveOrder() {
await this.page.getByRole('button', { name: 'Save' }).click();
await expect(this.page.getByText('Saved')).toBeVisible();
await expect(this.page.getByText('Saved', {exact: true})).toBeVisible();
}
}
Loading