Skip to content

Commit

Permalink
OZ-541: Ordering a lab test for an OpenMRS patient creates the corres…
Browse files Browse the repository at this point in the history
…ponding ERPNext customer
  • Loading branch information
kdaud committed May 6, 2024
1 parent fd4b40a commit bd003fd
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 2 deletions.
9 changes: 9 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ O3_URL_DEV=https://ozone-dev.mekomsolutions.net
O3_URL_QA=https://ozone-qa.mekomsolutions.net
O3_URL_DEMO=https://demo.ozone-his.com

# ERPNEXT
ERPNEXT_URL_DEV=https://erpnext.ozone-dev.mekomsolutions.net
ERPNEXT_URL_QA=https://erpnext.ozone-qa.mekomsolutions.net
ERPNEXT_URL_DEMO=

# Odoo
ODOO_URL_DEV=https://erp.ozone-dev.mekomsolutions.net
ODOO_URL_QA=https://erp.ozone-qa.mekomsolutions.net
Expand Down Expand Up @@ -55,6 +60,10 @@ ODOO_PASSWORD_ON_FOSS=admin
SENAITE_USERNAME_ON_FOSS=admin
SENAITE_PASSWORD_ON_FOSS=password

# (Pro only) SENAITE test user credentials
ERPNEXT_USERNAME=Administrator
ERPNEXT_PASSWORD=password

# (Pro only) Ozone test user credentials
OZONE_USERNAME=jdoe
OZONE_PASSWORD=password
Expand Down
37 changes: 37 additions & 0 deletions e2e/tests/erpnext-openmrs-flows.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { test, expect } from '@playwright/test';
import { HomePage } from '../utils/functions/testBase';
import { patientName } from '../utils/functions/testBase';
import { O3_URL, ODOO_URL } from '../utils/configs/globalSetup';

let homePage: HomePage;

test.beforeEach(async ({ page }) => {
homePage = new HomePage(page);
});

test('Ordering a lab test for an OpenMRS patient creates the corresponding ERPNext customer.', async ({ page }) => {
// setup
await homePage.initiateLogin();
await expect(page).toHaveURL(/.*home/);
await homePage.createPatient();
await homePage.startPatientVisit();

// replay
await homePage.goToLabOrderForm();
await page.getByRole('button', { name: 'Add', exact: true }).click();
await page.locator('#tab select').selectOption('857AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
await homePage.saveLabOrder();

// verify
await homePage.goToERPNext();
await expect(page).toHaveURL(/.*home/);
await homePage.searchCustomerInERPNext();

// Assert the presence of customer in ERPNext
});

test.afterEach(async ({ page }) => {
homePage = new HomePage(page);
// await homePage.deletePatient();
await page.close();
});
2 changes: 1 addition & 1 deletion e2e/tests/openmrs-senaite-flows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ test.beforeEach(async ({ page }) => {

test('Ordering a lab test for an OpenMRS patient creates the corresponding SENAITE client with an analysis request.', async ({ page }) => {
// setup
homePage = new HomePage(page);
//homePage = new HomePage(page);
await homePage.goToLabOrderForm();
await page.getByRole('button', { name: 'Add', exact: true }).click();
await page.locator('#tab select').selectOption('857AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
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 O3_URL = `${process.env.TEST_ENVIRONMENT}` == 'demo' ? `${process.env.O3_URL_DEMO}` : `${process.env.TEST_ENVIRONMENT}` == 'qa' ? `${process.env.O3_URL_QA}`: `${process.env.O3_URL_DEV}`;
export const ODOO_URL = `${process.env.TEST_ENVIRONMENT}` == 'demo' ? `${process.env.ODOO_URL_DEMO}` : `${process.env.TEST_ENVIRONMENT}` == 'qa' ? `${process.env.ODOO_URL_QA}`: `${process.env.ODOO_URL_DEV}`;
export const ERPNEXT_URL = `${process.env.TEST_ENVIRONMENT}` == 'demo' ? `${process.env.ERPNEXT_URL_DEMO}` : `${process.env.TEST_ENVIRONMENT}` == 'qa' ? `${process.env.ERPNEXT_URL_QA}`: `${process.env.ERPNEXT_URL_DEV}`;
export const SENAITE_URL = `${process.env.TEST_ENVIRONMENT}` == 'demo' ? `${process.env.SENAITE_URL_DEMO}` : `${process.env.TEST_ENVIRONMENT}` == 'qa' ? `${process.env.SENAITE_URL_QA}`: `${process.env.SENAITE_URL_DEV}`;
export const KEYCLOAK_URL = `${process.env.TEST_ENVIRONMENT}` == 'demo' ? `${process.env.KEYCLOAK_URL_DEMO}` : `${process.env.TEST_ENVIRONMENT}` == 'qa' ? `${process.env.KEYCLOAK_URL_QA}`: `${process.env.KEYCLOAK_URL_DEV}`;
export const SUPERSET_URL = `${process.env.TEST_ENVIRONMENT}` == 'demo' ? `${process.env.SUPERSET_URL_DEMO}` : `${process.env.TEST_ENVIRONMENT}` == 'qa' ? `${process.env.SUPERSET_URL_QA}`: `${process.env.SUPERSET_URL_DEV}`;
Expand Down
15 changes: 14 additions & 1 deletion e2e/utils/functions/testBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {
ODOO_URL,
SENAITE_URL,
KEYCLOAK_URL,
SUPERSET_URL
SUPERSET_URL,
ERPNEXT_URL
}
from '../configs/globalSetup';

Expand Down Expand Up @@ -90,6 +91,13 @@ export class HomePage {
}
}

async goToERPNext() {
await this.page.goto(`${ERPNEXT_URL}`);
await this.page.locator('input#login_email').fill(`${process.env.ERPNEXT_USERNAME}`);
await this.page.locator('input#login_password').fill(`${process.env.ERPNEXT_PASSWORD}`);
await this.page.locator('button.btn-login').click();
}

async goToSENAITE() {
await this.page.goto(`${SENAITE_URL}`);
if (!(`${process.env.TEST_PRO}` == 'true')) {
Expand Down Expand Up @@ -426,6 +434,11 @@ export class HomePage {
await delay(2000);
}

async searchCustomerInERPNext() {
await this.page.getByRole('link', { name: 'Selling' }).click();
await this.page.getByRole('link', { name: 'Customer', exact: true }).click();;
}

async searchClientInSENAITE() {
await this.page.getByRole('link', { name: 'Clients', exact: true }).click();
await this.page.getByRole('textbox', { name: 'Search' }).type(`${patientName.givenName}`);
Expand Down

0 comments on commit bd003fd

Please sign in to comment.