Skip to content

Commit

Permalink
C2C-346: E2e tests for the flows Bahmni and OpenELIS
Browse files Browse the repository at this point in the history
  • Loading branch information
kdaud committed Aug 28, 2024
1 parent a50ad7c commit 5f959be
Show file tree
Hide file tree
Showing 9 changed files with 316 additions and 18 deletions.
4 changes: 2 additions & 2 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@ ODOO_USERNAME=admin
ODOO_PASSWORD=admin

# OpenELIS test user credentials
OpenELIS_USERNAME=admin
OpenELIS_PASSWORD=adminADMIN!
OPENELIS_USERNAME=admin
OPENELIS_PASSWORD=adminADMIN!
10 changes: 5 additions & 5 deletions e2e/tests/bahmni-odoo-flows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ test.beforeEach(async ({ page }) => {
await expect(page.getByText(/appointment scheduling/i)).toBeVisible();
await expect(page.getByText(/patient documents/i)).toBeVisible();
await bahmni.registerPatient();
await bahmni.goToHomePage();
await bahmni.goToPatientDashboard();
});

test('Ordering a lab test for a Bahmni patient creates the corresponding Odoo customer with a filled quotation.', async ({ page }) => {
Expand Down Expand Up @@ -83,7 +83,7 @@ test('Revising a synced Bahmni lab order edits the corresponding Odoo quotation
await expect(labTest).toHaveText('Malaria');

// replay
await page.goto(`${BAHMNI_URL}`);
await bahmni.goToPatientDashboard();
await bahmni.goToLabSamples();
await bahmni.reviseLabOrder();

Expand Down Expand Up @@ -113,7 +113,7 @@ test('Discontinuing a synced Bahmni lab order edits the corresponding Odoo quota
await expect(labTest).toHaveText('Malaria');

// replay
await page.goto(`${BAHMNI_URL}`);
await bahmni.goToPatientDashboard();
await bahmni.goToLabSamples();
await bahmni.discontinueLabOrder();

Expand Down Expand Up @@ -184,7 +184,7 @@ test('Revising a synced OpenMRS drug order edits the corresponding Odoo quotatio
await expect(medicationDescrptionSelector).toContainText('Aspirine Co 81mg | 560.0 Ampoule(s) | 2.0 Application(s) - Q3H - 5 Semaine(s)');

// replay
await page.goto(`${BAHMNI_URL}`);
await bahmni.goToPatientDashboard();
await bahmni.goToMedications();
await bahmni.editMedicationDetails();

Expand Down Expand Up @@ -214,7 +214,7 @@ test('Discontinuing a synced Bahmni drug order for an Odoo customer with a singl
await expect(medicationDescrptionSelector).toContainText('Aspirine Co 81mg | 560.0 Ampoule(s) | 2.0 Application(s) - Q3H - 5 Semaine(s)');

// replay
await page.goto(`${BAHMNI_URL}`);
await bahmni.goToPatientDashboard();
await bahmni.goToMedications();
await bahmni.discontinueMedication();

Expand Down
227 changes: 227 additions & 0 deletions e2e/tests/bahmni-openelis-flows.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
import { test, expect } from '@playwright/test';
import { Bahmni, patientName } from '../utils/functions/bahmni';
import { OpenELIS } from '../utils/functions/openelis';
import { BAHMNI_URL } from '../utils/configs/globalSetup';

let bahmni: Bahmni;
let openelis: OpenELIS;

test.beforeEach(async ({ page }) => {
bahmni = new Bahmni(page);
openelis = new OpenELIS(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();
await bahmni.registerPatient();
await bahmni.goToPatientDashboard();
});

test('Ordering a lab test for a Bahmni patient creates the corresponding OpenElis client with an analysis request.', async ({ page }) => {
// setup
await bahmni.goToLabSamples();

// replay
await bahmni.createLabOrder();
await page.locator('#dashboard-link span.patient-name').click();
await expect(page.locator('#Lab-Orders').getByText('Malaria')) .toBeVisible();

// verify
await openelis.open();
await expect(page).toHaveURL(/.*openelis/);
await openelis.searchClient();

const clientSelector = await page.locator("#todaySamplesToCollectListContainer-slick-grid div.slick-cell.l1.r1");
await expect(clientSelector).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`);

await page.locator('#todaySamplesToCollectListContainer-slick-grid div.slick-viewport div.slick-cell.l6.r6.cell-title a').click();
await expect(page.locator('#tests_1')).toHaveValue('Malaria')
});


test('Editing the details of a Bahmni patient with a synced lab order edits the corresponding OpenELIS client details.', async ({ page }) => {
// setup
await bahmni.goToLabSamples();
await bahmni.createLabOrder();
await page.locator('#dashboard-link span.patient-name').click();
await expect(page.locator('#Lab-Orders').getByText('Malaria')) .toBeVisible();
await openelis.open();
await expect(page).toHaveURL(/.*openelis/);
await openelis.searchClient();
const clientSelector = await page.locator("#todaySamplesToCollectListContainer-slick-grid div.slick-cell.l1.r1");
await expect(clientSelector).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`);

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

// verify
await openelis.open();
await openelis.searchClient();
await expect(clientSelector).toHaveText(`${patientName.updatedGivenName}` + ' ' + `${patientName.familyName}`);
});


test('Revising a synced Bahmni lab order edits the corresponding OpenELIS client analysis request.', async ({ page }) => {
// setup
await bahmni.goToLabSamples();
await bahmni.createLabOrder();
await page.locator('#dashboard-link span.patient-name').click();
await expect(page.locator('#Lab-Orders').getByText('Malaria')) .toBeVisible();
await openelis.open();
await expect(page).toHaveURL(/.*openelis/);
await openelis.searchClient();
const clientSelector = await page.locator("#todaySamplesToCollectListContainer-slick-grid div.slick-cell.l1.r1");
await expect(clientSelector).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`);
await page.locator('#todaySamplesToCollectListContainer-slick-grid div.slick-viewport div.slick-cell.l6.r6.cell-title a').click();
await expect(page.locator('#tests_1')).toHaveValue('Malaria')

// replay
await bahmni.goToPatientDashboard();
await bahmni.goToLabSamples();
await bahmni.reviseLabOrder();
await page.locator('#dashboard-link span.patient-name').click();
await expect(page.locator('#Lab-Orders').getByText('Hematocrit')).toBeVisible();

// verify
await openelis.open();
await openelis.searchClient();
await expect(clientSelector).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`);

await page.locator('#todaySamplesToCollectListContainer-slick-grid div.slick-viewport div.slick-cell.l6.r6.cell-title a').click();
await expect(page.locator('#tests_1')).toHaveValue('Hematocrite');
});

test('Voiding a synced OpenMRS lab order cancels the corresponding OpenElis analysis request.', async ({ page }) => {
// setup
await bahmni.goToLabSamples();
await bahmni.createLabOrder();
await page.locator('#dashboard-link span.patient-name').click();
await expect(page.locator('#Lab-Orders').getByText('Malaria')) .toBeVisible();
await openelis.open();
await expect(page).toHaveURL(/.*openelis/);
await openelis.searchClient();
const clientSelector = await page.locator("#todaySamplesToCollectListContainer-slick-grid div.slick-cell.l1.r1");
await expect(clientSelector).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`);
await page.locator('#todaySamplesToCollectListContainer-slick-grid div.slick-viewport div.slick-cell.l6.r6.cell-title a').click();
await expect(page.locator('#tests_1')).toHaveValue('Malaria')

// replay
await bahmni.goToPatientDashboard();
await bahmni.goToLabSamples();
await bahmni.discontinueLabOrder();

// verify
await openelis.open();
await openelis.searchClient();
await expect(page.getByText(`${patientName.givenName + ' ' + patientName.familyName}`)).not.toBeVisible();
});

test('Published coded lab results from OpenELIS are viewable in the Bahmni lab results viewer.', async ({ page }) => {
// setup
await bahmni.goToLabSamples();
await bahmni.createLabOrder();
await page.locator('#dashboard-link span.patient-name').click();
await expect(page.locator('#Lab-Orders').getByText('Malaria')) .toBeVisible();

// replay
await openelis.open();
await expect(page).toHaveURL(/.*openelis/);
await openelis.searchClient();

const clientSelector = await page.locator("#todaySamplesToCollectListContainer-slick-grid div.slick-cell.l1.r1");
await expect(clientSelector).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`);
await openelis.collectSample();
await page.locator('a#todaySamplesCollectedListContainerId').click();
await page.locator('#todaySamplesCollectedListContainer-slick-grid div.ui-state-default.slick-headerrow-column.l2.r2 input[type=text]').type(`${patientName.familyName}`);

await openelis.enterLabResults();
await page.locator('a#todaySamplesCollectedListContainerId').click();
await page.locator('#todaySamplesCollectedListContainer-slick-grid div.ui-state-default.slick-headerrow-column.l2.r2 input[type=text]').type(`${patientName.familyName}`);
await openelis.validateLabResults();
await page.locator('#todaySamplesCollectedListContainer-slick-grid div.ui-state-default.slick-headerrow-column.l2.r2 input[type=text]').type(`${patientName.familyName}`);
const status = await page.locator('#todaySamplesCollectedListContainer-slick-grid div.slick-viewport div div:nth-child(1) div.slick-cell.l8.r8.cell-title');
await expect(status).toHaveText('Yes');

// verify
await bahmni.goToPatientDashboard();
await expect(page.locator('#Lab-Results').getByText('Malaria')).toBeVisible();
await expect(page.locator('#Lab-Results span.value')).toHaveText('Negatif');
});

test('Published numerical lab results from OpenELIS are viewable in the Bahmni lab results viewer.', async ({ page }) => {
// setup
await bahmni.goToLabSamples();
await page.getByText('Blood', { exact: true }).click();
await page.getByText('Lymphocites').click();
await bahmni.saveOrder();
await page.locator('#dashboard-link span.patient-name').click();
await expect(page.locator('#Lab-Orders').getByText('Lymphocytes')) .toBeVisible();

// replay
await openelis.open();
await expect(page).toHaveURL(/.*openelis/);
await openelis.searchClient();

const clientSelector = await page.locator("#todaySamplesToCollectListContainer-slick-grid div.slick-cell.l1.r1");
await expect(clientSelector).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`);
await openelis.collectSample();
await page.locator('a#todaySamplesCollectedListContainerId').click();
await page.locator('#todaySamplesCollectedListContainer-slick-grid div.ui-state-default.slick-headerrow-column.l2.r2 input[type=text]').type(`${patientName.familyName}`);

await openelis.enterNumericalResults();
await page.locator('a#todaySamplesCollectedListContainerId').click();
await page.locator('#todaySamplesCollectedListContainer-slick-grid div.ui-state-default.slick-headerrow-column.l2.r2 input[type=text]').type(`${patientName.familyName}`);
await openelis.validateLabResults();
await page.locator('#todaySamplesCollectedListContainer-slick-grid div.ui-state-default.slick-headerrow-column.l2.r2 input[type=text]').type(`${patientName.familyName}`);
const status = await page.locator('#todaySamplesCollectedListContainer-slick-grid div.slick-viewport div div:nth-child(1) div.slick-cell.l8.r8.cell-title');
await expect(status).toHaveText('Yes');

// verify
await bahmni.goToPatientDashboard();
await expect(page.locator('#Lab-Results').getByText('Lymphocytes')).toBeVisible();
await expect(page.locator('#Lab-Results span.value')).toHaveText('13.7');
});

test('Published free text lab results from OpenELIS are viewable in the Bahmni lab results viewer.', async ({ page }) => {
// setup
await bahmni.goToLabSamples();
await page.getByText('Urine', { exact: true }).click();
await page.getByText('Urobilinogen').click();
await bahmni.saveOrder();
await page.locator('#dashboard-link span.patient-name').click();
await expect(page.locator('#Lab-Orders').getByText('Urobilinogen')) .toBeVisible();

// replay
await openelis.open();
await expect(page).toHaveURL(/.*openelis/);
await openelis.searchClient();

const clientSelector = await page.locator("#todaySamplesToCollectListContainer-slick-grid div.slick-cell.l1.r1");
await expect(clientSelector).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`);
await openelis.collectSample();
await page.locator('a#todaySamplesCollectedListContainerId').click();
await page.locator('#todaySamplesCollectedListContainer-slick-grid div.ui-state-default.slick-headerrow-column.l2.r2 input[type=text]').type(`${patientName.familyName}`);

await openelis.enterFreeTextResults();
await page.locator('a#todaySamplesCollectedListContainerId').click();
await page.locator('#todaySamplesCollectedListContainer-slick-grid div.ui-state-default.slick-headerrow-column.l2.r2 input[type=text]').type(`${patientName.familyName}`);
await openelis.validateLabResults();
await page.locator('#todaySamplesCollectedListContainer-slick-grid div.ui-state-default.slick-headerrow-column.l2.r2 input[type=text]').type(`${patientName.familyName}`);
const status = await page.locator('#todaySamplesCollectedListContainer-slick-grid div.slick-viewport div div:nth-child(1) div.slick-cell.l8.r8.cell-title');
await expect(status).toHaveText('Yes');

// verify
await bahmni.goToPatientDashboard();
await expect(page.locator('#Lab-Results').getByText('Urobilinogen')).toBeVisible();
await expect(page.locator('#Lab-Results span.value')).toHaveText('Abnormal level');
});

test.afterEach(async ({ page }) => {
await bahmni.voidPatient();
await page.close();
});

2 changes: 1 addition & 1 deletion e2e/tests/lab-orders.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ test.beforeEach(async ({ page }) => {
test('Create, revise and discontinue lab tests.', async ({ page }) => {
// setup
await bahmni.registerPatient();
await bahmni.goToPatientDashboard();

// replay
await bahmni.goToHomePage();
await bahmni.goToLabSamples();
await page.getByText('Blood', { exact: true }).click();
await page.getByText('Malaria').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 @@ -17,9 +17,9 @@ test.beforeEach(async ({ page }) => {
test('Create, revise and discontinue a drug order.', async ({ page }) => {
// setup
await bahmni.registerPatient();
await bahmni.goToPatientDashboard();

// replay
await bahmni.goToHomePage();
await bahmni.goToMedications();
await bahmni.createMedication();

Expand Down
1 change: 1 addition & 0 deletions e2e/utils/configs/globalSetup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ dotenv.config();

export const BAHMNI_URL = `${process.env.TEST_ENVIRONMENT}` == 'uat' ? `${process.env.BAHMNI_URL_UAT}` : `${process.env.BAHMNI_URL_DEV}`;
export const ODOO_URL = `${process.env.TEST_ENVIRONMENT}` == 'uat' ? `${process.env.ODOO_URL_UAT}` : `${process.env.ODOO_URL_DEV}`;
export const OPENELIS_URL = `${process.env.TEST_ENVIRONMENT}` == 'uat' ? `${process.env.OPENELIS_URL_UAT}` : `${process.env.OPENELIS_URL_DEV}`;

async function globalSetup() {
const requestContext = await request.newContext();
Expand Down
29 changes: 22 additions & 7 deletions e2e/utils/functions/bahmni.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@ export var patientName = {
familyName : '',
updatedGivenName: '',
}
/*
export const delay = (mills) => {
const end = Date.now() + mills;
while (Date.now() < end) {}
};
*/
export const delay = (mills) => {
let datetime1 = new Date().getTime();
let datetime2 = datetime1 + mills;
while(datetime1 < datetime2) {
datetime1 = new Date().getTime();
}
}

export class Bahmni {
constructor(readonly page: Page) {}
Expand Down Expand Up @@ -50,8 +63,10 @@ export class Bahmni {
await this.page.locator('#view-content td:nth-child(1) a').click();
await this.page.locator('#givenName').clear();
await this.page.locator('#givenName').fill(`${patientName.updatedGivenName}`);
await delay(2000);
await this.page.getByRole('button', { name: 'Save' }).click();
patientName.givenName = `${patientName.updatedGivenName}`;
await delay(5000);
};

async voidPatient() {
Expand All @@ -65,8 +80,6 @@ export class Bahmni {
}

async goToLabSamples() {
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('Orders').click();
await expect(this.page.getByText('Lab Samples')).toBeVisible();
Expand All @@ -76,29 +89,31 @@ export class Bahmni {
await this.page.getByText('Blood', { exact: true }).click();
await this.page.getByText('Malaria').click();
await this.saveOrder();
await delay(10000);
}

async reviseLabOrder() {
await this.page.getByText('Blood', { exact: true }).click();
await this.page.locator('#selected-orders li').filter({ hasText: 'Malaria' }).locator('i').nth(1).click();
await this.page.getByText('Hematocrit').click();
await this.saveOrder();
await delay(10000);
}

async discontinueLabOrder() {
await this.page.getByText('Blood', { exact: true }).click();
await this.page.locator('#selected-orders li').filter({ hasText: 'Malaria' }).locator('i').nth(1).click();
await this.saveOrder();
await delay(10000);
}

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

async goToMedications() {
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
Loading

0 comments on commit 5f959be

Please sign in to comment.