Skip to content

Commit

Permalink
C2C-355: E2E tests for the observation forms
Browse files Browse the repository at this point in the history
  • Loading branch information
kdaud committed Sep 16, 2024
1 parent 0703d95 commit bc202dd
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 98 deletions.
129 changes: 48 additions & 81 deletions e2e/tests/bahmni-odoo-flows.spec.ts

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions e2e/tests/diagnosis.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ test('Create and revise a diagnosis.', async ({ page }) => {
await bahmni.registerPatient();

// replay
await bahmni.navigateToPatientDashboard();
await bahmni.navigateToDiagnosis();
await page.locator('#name-0').fill('Candidiasis (B37.9)');
await page.getByText('Candidiasis (B37.9)').click();
Expand Down
4 changes: 2 additions & 2 deletions e2e/tests/lab-orders.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ test('Create, revise and discontinue lab tests.', async ({ page }) => {
await bahmni.registerPatient();

// replay
await bahmni.goToHomePage();
await bahmni.goToLabSamples();
await bahmni.navigateToPatientDashboard();
await bahmni.navigateToLabSamples();
await page.getByText('Blood', { exact: true }).click();
await page.getByText('Malaria').click();
await page.getByText('Urine').click();
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/medications.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ test('Create, revise and discontinue a drug order.', async ({ page }) => {
await bahmni.registerPatient();

// replay
await bahmni.goToHomePage();
await bahmni.navigateToPatientDashboard();
await bahmni.navigateToMedications();
await bahmni.createMedication();

Expand Down
28 changes: 28 additions & 0 deletions e2e/tests/observation-forms.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
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('Create, revise and discontinue lab tests.', async ({ page }) => {
// setup
await bahmni.registerPatient();

// replay
await bahmni.navigateToPatientDashboard();
});

test.afterEach(async ({ page }) => {
await bahmni.voidPatient();
await page.close();
});
18 changes: 7 additions & 11 deletions e2e/utils/functions/bahmni.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class Bahmni {
await this.page.locator('#password').fill(`${process.env.BAHMNI_PASSWORD}`);
await this.page.locator('#location').selectOption('object:7');
await this.page.getByRole('button', { name: 'Login' }).click();
await expect(this.page).toHaveURL(/.*home/);
}

async registerPatient() {
Expand Down Expand Up @@ -62,11 +63,12 @@ export class Bahmni {
await this.page.locator('#givenName').fill(`${patientName.updatedGivenName}`);
await this.page.getByRole('button', { name: 'Save' }).click();
patientName.givenName = `${patientName.updatedGivenName}`;
await delay(3000);
await delay(6000);
};

async voidPatient() {
await this.page.goto(`${BAHMNI_URL}/openmrs/admin/patients/index.htm`);
await expect(this.page.getByPlaceholder(' ')).toBeVisible();
await this.page.getByPlaceholder(' ').type(`${patientName.familyName}`);
await this.page.locator('#openmrsSearchTable tbody tr.odd td:nth-child(1)').click();
await this.page.locator('input[name="voidReason"]').fill('Void patient created by smoke test');
Expand All @@ -75,9 +77,7 @@ export class Bahmni {
await expect(message?.includes('This patient has been deleted')).toBeTruthy();
}

async goToLabSamples() {
await this.page.getByRole('link', { name: 'Clinical' }).click();
await this.searchPatient();
async navigateToLabSamples() {
await this.page.locator('#view-content :nth-child(1).btn--success').click();
await this.page.locator('#opd-tabs').getByText('Orders').click();
await expect(this.page.getByText('Lab Samples')).toBeVisible();
Expand All @@ -102,22 +102,18 @@ export class Bahmni {
await this.saveOrder();
}

async goToHomePage() {
async navigateToPatientDashboard() {
await this.page.goto(`${BAHMNI_URL}/bahmni/home`);
await expect(this.page).toHaveURL(/.*home/);
await this.page.getByRole('link', { name: 'Clinical' }).click();
await this.searchPatient();
}

async navigateToDiagnosis() {
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.locator('#opd-tabs').getByText('Diagnosis').click();
}

async navigateToMedications() {
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.locator('#opd-tabs').getByText('Medications').click();
await expect(this.page.getByText('Order Drug')).toBeVisible();
Expand Down
9 changes: 6 additions & 3 deletions e2e/utils/functions/odoo.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Page } from '@playwright/test';
import { patientName } from './bahmni';
import { expect, Page } from '@playwright/test';
import { delay, patientName } from './bahmni';
import { ODOO_URL } from '../configs/globalSetup';

export class Odoo {
Expand All @@ -10,12 +10,15 @@ export class Odoo {
await this.page.getByPlaceholder('Email').fill(`${process.env.ODOO_USERNAME}`);
await this.page.getByPlaceholder('Password').fill(`${process.env.ODOO_PASSWORD}`);
await this.page.locator('button[type="submit"]').click();
await expect(this.page).toHaveURL(/.*web/);
}

async searchCustomer() {
await this.page.locator("//a[contains(@class, 'full')]").click();
await delay(2000);
await this.page.locator('ul.o_menu_apps a:nth-child(2)').click();
await this.page.locator('input.o_searchview_input').fill(`${patientName.givenName + ' ' + patientName.familyName}`);
await expect(this.page.locator('.breadcrumb-item')).toHaveText('Devis');
await this.page.locator('input.o_searchview_input').type(`${patientName.givenName + ' ' + patientName.familyName}`);
await this.page.locator('input.o_searchview_input').press('Enter');
}
}
1 change: 1 addition & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const config: PlaywrightTestConfig = {
name: 'chromium',
use: {
...devices['Desktop Chromium'],
viewport: { width: 1920, height: 1080 }
},
},
],
Expand Down

0 comments on commit bc202dd

Please sign in to comment.