Skip to content

Commit

Permalink
C2C-346: E2E tests for Bahmni-OpenELIS flows
Browse files Browse the repository at this point in the history
  • Loading branch information
kdaud committed Oct 8, 2024
1 parent 4414349 commit 8028343
Show file tree
Hide file tree
Showing 9 changed files with 299 additions and 88 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!
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ jobs:
with:
name: playwright-report
path: playwright-report/
retention-days: 30
retention-days: 7
2 changes: 1 addition & 1 deletion e2e/tests/bahmni-odoo-flows.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test, expect } from '@playwright/test';
import { BAHMNI_URL, ODOO_URL } from '../utils/configs/globalSetup';
import { Odoo } from '../utils/functions/odoo';
import { Bahmni, patientName } from '../utils/functions/bahmni';
import { BAHMNI_URL, ODOO_URL } from '../utils/configs/globalSetup';

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

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(/clinical/i)).toBeVisible();
await expect(page.getByText(/admin/i)).toBeVisible();
await expect(page.getByText(/patient documents/i)).toBeVisible();
await bahmni.registerPatient();
await bahmni.navigateToPatientDashboard();
});

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

// replay
await bahmni.createLabOrder();

// 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.navigateToLabSamples();
await bahmni.createLabOrder();
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.navigateToLabSamples();
await bahmni.createLabOrder();
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.navigateToPatientDashboard();
await bahmni.navigateToLabSamples();
await bahmni.reviseLabOrder();

// 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.navigateToLabSamples();
await bahmni.createLabOrder();
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.navigateToPatientDashboard();
await bahmni.navigateToLabSamples();
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.navigateToLabSamples();
await bahmni.createLabOrder();

// 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.navigateToPatientDashboard();
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.navigateToLabSamples();
await page.getByText('Blood', { exact: true }).click();
await page.getByText('Lymphocites').click();
await bahmni.save();

// 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.navigateToPatientDashboard();
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.navigateToLabSamples();
await page.getByText('Urine', { exact: true }).click();
await page.getByText('Urobilinogen').click();
await bahmni.save();

// 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.navigateToPatientDashboard();
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();
});
Loading

0 comments on commit 8028343

Please sign in to comment.