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 25, 2024
1 parent a50ad7c commit 3b3b93a
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 3 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!
49 changes: 49 additions & 0 deletions e2e/tests/bahmni-openelis-flows.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import { test, expect } from '@playwright/test';
import { Odoo } from '../utils/functions/odoo';
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(/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 }) => {
// setup
await bahmni.registerPatient();

// replay
await bahmni.goToHomePage();
await bahmni.goToLabSamples();
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 page.locator('#menu_labDashboard').click();
await page.locator('input[type=text]').nth(1).type(`${patientName.familyName}`);

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();
// const labTest = await page.locator('#tests_1');
//await expect(page.locator('#tests_1')).toBe('Malaria');
});

test.afterEach(async ({ page }) => {
await bahmni.voidPatient();
await page.close();
});
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
5 changes: 4 additions & 1 deletion e2e/utils/functions/bahmni.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ export var patientName = {
updatedGivenName: '',
}

export const delay = (mills) => new Promise(resolve => setTimeout(resolve, mills));

export class Bahmni {
constructor(readonly page: Page) {}

Expand Down Expand Up @@ -76,6 +78,7 @@ export class Bahmni {
await this.page.getByText('Blood', { exact: true }).click();
await this.page.getByText('Malaria').click();
await this.saveOrder();
await delay(3000);
}

async reviseLabOrder() {
Expand All @@ -92,7 +95,7 @@ export class Bahmni {
}

async goToHomePage() {
await this.page.goto(`${BAHMNI_URL}/bahmni/home/`);
await this.page.goto(`${BAHMNI_URL}/bahmni/home`);
await expect(this.page).toHaveURL(/.*home/);
}

Expand Down
21 changes: 21 additions & 0 deletions e2e/utils/functions/openelis.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Page } from '@playwright/test';
import { OPENELIS_URL } from '../configs/globalSetup';
import { patientName } from './bahmni';

export class OpenELIS {
constructor(readonly page: Page) {}

async open() {
await this.page.goto(`${OPENELIS_URL}`);
await this.page.locator("input[name='loginName']").fill(`${process.env.OPENELIS_USERNAME}`);
await this.page.locator("input[name='password']").fill(`${process.env.OPENELIS_PASSWORD}`);
await this.page.locator('#submitButton').click();
}

async searchCustomer() {
await this.page.locator("//a[contains(@class, 'full')]").click();
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 this.page.locator('input.o_searchview_input').press('Enter');
}
}

0 comments on commit 3b3b93a

Please sign in to comment.