diff --git a/.env b/.env index e3d584e6..18f70447 100644 --- a/.env +++ b/.env @@ -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 @@ -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 diff --git a/e2e/tests/erpnext-openmrs-flows.spec.ts b/e2e/tests/erpnext-openmrs-flows.spec.ts new file mode 100644 index 00000000..3386ac19 --- /dev/null +++ b/e2e/tests/erpnext-openmrs-flows.spec.ts @@ -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(); +}); diff --git a/e2e/tests/openmrs-senaite-flows.spec.ts b/e2e/tests/openmrs-senaite-flows.spec.ts index 0b7f0189..52c1859f 100644 --- a/e2e/tests/openmrs-senaite-flows.spec.ts +++ b/e2e/tests/openmrs-senaite-flows.spec.ts @@ -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'); diff --git a/e2e/utils/configs/globalSetup.ts b/e2e/utils/configs/globalSetup.ts index 0587d5a4..7aa7347a 100644 --- a/e2e/utils/configs/globalSetup.ts +++ b/e2e/utils/configs/globalSetup.ts @@ -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}`; diff --git a/e2e/utils/functions/testBase.ts b/e2e/utils/functions/testBase.ts index 39a85da2..20443053 100644 --- a/e2e/utils/functions/testBase.ts +++ b/e2e/utils/functions/testBase.ts @@ -4,7 +4,8 @@ import { ODOO_URL, SENAITE_URL, KEYCLOAK_URL, - SUPERSET_URL + SUPERSET_URL, + ERPNEXT_URL } from '../configs/globalSetup'; @@ -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')) { @@ -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}`);