Skip to content

Commit

Permalink
C2C-341: E2E test for patient registration form (#21)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdaud authored Dec 9, 2024
1 parent efd966c commit 5965637
Show file tree
Hide file tree
Showing 4 changed files with 52 additions and 1 deletion.
2 changes: 2 additions & 0 deletions e2e/tests/bahmni-odoo-flows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ test('Editing the details of a Bahmni patient with a synced lab order edits the

// replay
await page.goto(`${BAHMNI_URL}`);
await bahmni.navigateToPatientRegistationForm();
await bahmni.updatePatientDetails();

// verify
Expand Down Expand Up @@ -135,6 +136,7 @@ test('Editing the details of a Bahmni patient with a synced drug order edits the

// replay
await page.goto(`${BAHMNI_URL}`);
await bahmni.navigateToPatientRegistationForm();
await bahmni.updatePatientDetails();

// verify
Expand Down
1 change: 1 addition & 0 deletions e2e/tests/bahmni-openelis-flows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ test('Editing the details of a Bahmni patient with a synced lab order edits the

// replay
await page.goto(`${BAHMNI_URL}`);
await bahmni.navigateToPatientRegistationForm();
await bahmni.updatePatientDetails();

// verify
Expand Down
38 changes: 38 additions & 0 deletions e2e/tests/patient-registration-form.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@

import { test, expect } from '@playwright/test';
import { Bahmni, patientName } from '../utils/functions/bahmni';
import { BAHMNI_URL } from '../utils/configs/globalSetup';

let bahmni: Bahmni;

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

test('Register and edit a patient.', async ({ page }) => {
// setup
await bahmni.login();
await expect(page.getByText(/registration/i)).toBeVisible();
await expect(page.getByText(/clinical/i)).toBeVisible();
await expect(page.getByText(/admin/i)).toBeVisible();
await expect(page.getByText(/patient documents/i)).toBeVisible();

// replay
await bahmni.registerPatient();

// verify creation
await bahmni.navigateToPatientDashboard();
await expect(page.locator('#patientContext span:nth-child(2)')).toContainText(`${patientName.givenName + ' ' + patientName.familyName}`)

// verify revision
await page.goto(`${BAHMNI_URL}`);
await bahmni.navigateToPatientRegistationForm();
await bahmni.updatePatientDetails();
await bahmni.navigateToPatientDashboard();
await expect(page.locator('#patientContext span:nth-child(2)')).toContainText(`${patientName.updatedGivenName}` + ' ' + `${patientName.familyName}`)
});

test.afterEach(async ({ page }) => {
await bahmni.voidPatient();
await page.close();
});
12 changes: 11 additions & 1 deletion e2e/utils/functions/bahmni.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ export class Bahmni {
}
await this.page.goto(`${BAHMNI_URL}/bahmni/registration`);
await this.page.locator('a').filter({ hasText: /create new/i }).click();
await expect(this.page.getByText('Address Information')).toBeVisible();
await expect(this.page.getByText('Additional Identifiers')).toBeVisible();
await expect(this.page.getByText('Other Information')).toBeVisible();
await expect(this.page.getByText('Additional Patient Information')).toBeVisible();
await expect(this.page.getByText('Relationships')).toBeVisible();
await expect(this.page.getByText('Death information')).toBeVisible();
await this.page.locator('#givenName').fill(`${patientName.givenName}`);
await this.page.locator('#familyName').fill(`${patientName.familyName}`);
await this.page.locator('#gender').selectOption('F');
Expand All @@ -52,9 +58,9 @@ export class Bahmni {
}

async updatePatientDetails() {
await this.page.getByRole('link', { name: /registration/i }).click();
await this.page.locator('#name').fill(`${patientName.familyName}`);
await this.page.locator('form[name="searchByNameForm"]').getByRole('button', { name: /search/i }).click();
await expect(this.page.locator('tbody tr td:nth-child(5)')).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`);
await this.page.locator('#view-content td:nth-child(1) a').click();
await expect(this.page.locator('#givenName')).toBeVisible();
await this.page.locator('#givenName').clear();
Expand Down Expand Up @@ -122,6 +128,10 @@ export class Bahmni {
await this.page.getByRole('button', { name: /add new obs form/i }).click();
}

async navigateToPatientRegistationForm() {
await this.page.getByRole('link', { name: /registration/i }).click();
}

async navigateToDiagnosis() {
await this.page.locator('#view-content :nth-child(1).btn--success').click();
await this.page.locator('#opd-tabs').getByText(/diagnosis/i).click();
Expand Down

0 comments on commit 5965637

Please sign in to comment.