-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OZ-541: E2E tests for O3 and ERPNext flows.
- Loading branch information
Showing
7 changed files
with
191 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,131 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { ERPNext } from '../utils/functions/erpnext'; | ||
import { O3_URL, ERPNEXT_URL } from '../utils/configs/globalSetup'; | ||
import { OpenMRS, patientName } from '../utils/functions/openmrs'; | ||
|
||
let openmrs: OpenMRS; | ||
let erpnext: ERPNext; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
openmrs = new OpenMRS(page); | ||
erpnext = new ERPNext(page); | ||
|
||
await openmrs.login(); | ||
await expect(page).toHaveURL(/.*home/); | ||
await openmrs.createPatient(); | ||
await openmrs.startPatientVisit(); | ||
}); | ||
|
||
test('Ordering a lab test for an OpenMRS patient creates the corresponding ERPNext customer.', async ({ page }) => { | ||
// replay | ||
await openmrs.createLabOrder(); | ||
|
||
// verify | ||
await erpnext.open(); | ||
await expect(page).toHaveURL(/.*home/); | ||
await erpnext.searchCustomer(); | ||
const customer = await page.locator(".bold a:nth-child(1)"); | ||
await expect(customer).toContainText(`${patientName.firstName + ' ' + patientName.givenName}`); | ||
}); | ||
|
||
test('Ordering a drug for an OpenMRS patient creates the corresponding ERPNext customer with a filled quotation.', async ({ page }) => { | ||
// replay | ||
await openmrs.createDrugOrder(); | ||
|
||
// verify | ||
await erpnext.open(); | ||
await expect(page).toHaveURL(/.*home/); | ||
await erpnext.searchCustomer(); | ||
const customer = await page.locator(".bold a:nth-child(1)"); | ||
await expect(customer).toContainText(`${patientName.firstName + ' ' + patientName.givenName}`); | ||
await page.getByRole('link', { name: `${patientName.firstName + ' ' + patientName.givenName}` }).click(); | ||
await page.locator('#customer-dashboard_tab-tab').click(); | ||
await page.getByLabel('Dashboard').getByText('Quotation').click(); | ||
await erpnext.searchQuotation(); | ||
await expect(page.getByText('Draft').nth(0)).toBeVisible(); | ||
}); | ||
|
||
test('Ending an OpenMRS patient visit with a synced drug order updates the corresponding ERPNext draft quotation to an open state.', async ({ page }) => { | ||
// setup | ||
await openmrs.createDrugOrder(); | ||
await erpnext.open(); | ||
await expect(page).toHaveURL(/.*home/); | ||
await erpnext.searchQuotation(); | ||
|
||
const quotationStatus = await page.locator('div.level-left.ellipsis div:nth-child(3) span span'); | ||
await expect(quotationStatus).toHaveText('Draft'); | ||
|
||
// replay | ||
await page.goto(`${O3_URL}`); | ||
await openmrs.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); | ||
await openmrs.endPatientVisit(); | ||
|
||
// verify | ||
await page.goto(`${ERPNEXT_URL}/app/home`); | ||
await erpnext.searchQuotation(); | ||
await expect(quotationStatus).toHaveText('Open'); | ||
}); | ||
|
||
test('Revising a synced OpenMRS drug order edits the corresponding ERPNext quotation line.', async ({ page }) => { | ||
// setup | ||
await openmrs.createDrugOrder(); | ||
await erpnext.open(); | ||
await expect(page).toHaveURL(/.*home/); | ||
await erpnext.searchQuotation(); | ||
await page.getByRole('link', { name: `${patientName.firstName + ' ' + patientName.givenName}` }).click(); | ||
const quantity = await page.locator("div.bold:nth-child(4) div:nth-child(2) div"); | ||
await expect(quantity).toHaveText('12'); | ||
|
||
// replay | ||
await page.goto(`${O3_URL}`); | ||
await openmrs.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); | ||
await openmrs.editDrugOrder(); | ||
|
||
// verify | ||
await page.goto(`${ERPNEXT_URL}/app/home`); | ||
await erpnext.searchQuotation(); | ||
await page.getByRole('link', { name: `${patientName.firstName + ' ' + patientName.givenName}` }).click(); | ||
await expect(quantity).toHaveText('8'); | ||
}); | ||
|
||
test('Ordering a drug with a free text medication dosage for an OpenMRS patient creates the corresponding ERPNext customer with a filled quotation.', async ({ page }) => { | ||
// replay | ||
await openmrs.createDrugOrderWithFreeTextDosage(); | ||
|
||
// verify | ||
await erpnext.open(); | ||
await expect(page).toHaveURL(/.*home/); | ||
await erpnext.searchCustomer(); | ||
const customer = await page.locator(".bold a:nth-child(1)"); | ||
await expect(customer).toContainText(`${patientName.firstName + ' ' + patientName.givenName}`); | ||
await page.getByRole('link', { name: `${patientName.firstName + ' ' + patientName.givenName}` }).click(); | ||
await page.locator('#customer-dashboard_tab-tab').click(); | ||
await page.getByLabel('Dashboard').getByText('Quotation').click(); | ||
await erpnext.searchQuotation(); | ||
await expect(page.getByText('Draft').nth(0)).toBeVisible(); | ||
}); | ||
|
||
test('Discontinuing a synced OpenMRS drug order for an ERPNext customer with a single quotation line removes the corresponding quotation.', async ({ page }) => { | ||
// setup | ||
await openmrs.createDrugOrder(); | ||
await erpnext.open(); | ||
await expect(page).toHaveURL(/.*home/); | ||
await erpnext.searchQuotation(); | ||
await expect(page.getByText(`${patientName.firstName + ' ' + patientName.givenName}`)).toBeVisible(); | ||
|
||
// replay | ||
await page.goto(`${O3_URL}`); | ||
await openmrs.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); | ||
await openmrs.discontinueDrugOrder(); | ||
|
||
// verify | ||
await page.goto(`${ERPNEXT_URL}/app/home`); | ||
await erpnext.searchQuotation(); | ||
await expect(page.getByText(`${patientName.firstName + ' ' + patientName.givenName}`)).not.toBeVisible(); | ||
await expect(page.getByText('No Quotation found')).toBeVisible(); | ||
}); | ||
|
||
test.afterEach(async ({ page }) => { | ||
await openmrs.deletePatient(); | ||
await page.close(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { Page } from '@playwright/test'; | ||
import { delay, patientName } from './openmrs'; | ||
import { ERPNEXT_URL } from '../configs/globalSetup'; | ||
|
||
export class ERPNext { | ||
constructor(readonly page: Page) {} | ||
|
||
async open() { | ||
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 searchCustomer() { | ||
await this.page.getByRole('link', { name: /selling/i }).click(); | ||
await this.page.getByRole('link', { name: 'Customer', exact: true }).click(); | ||
await this.page.getByPlaceholder('Customer Name').clear(); | ||
await this.page.getByPlaceholder(/customer name/i).fill(`${patientName.givenName}`); | ||
await delay(3000); | ||
} | ||
|
||
async searchQuotation() { | ||
await this.page.getByRole('link', { name: /selling/i }).click(); | ||
await this.page.getByRole('link', { name: 'Quotation', exact: true }).click(); | ||
await this.page.getByPlaceholder(/title/i).clear(); | ||
await this.page.getByPlaceholder(/party/i).clear(); | ||
await this.page.getByPlaceholder(/title/i).fill(`${patientName.givenName}`); | ||
await delay(3000); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters