diff --git a/e2e/tests/erpnext-openmrs-flows.spec.ts b/e2e/tests/erpnext-openmrs-flows.spec.ts index 39f0a8d..7eb0014 100644 --- a/e2e/tests/erpnext-openmrs-flows.spec.ts +++ b/e2e/tests/erpnext-openmrs-flows.spec.ts @@ -138,7 +138,6 @@ test('Revising details of a synced OpenMRS drug order modifies the corresponding await erpnext.searchQuotation(); await page.getByRole('link', { name: `${patientName.firstName + ' ' + patientName.givenName}` }).click(); await expect(page.locator('div.bold:nth-child(4) div:nth-child(2) div')).toHaveText('8'); - await erpnext.voidQuotation(); await openmrs.voidPatient(); await erpnext.deleteQuotation(); }); @@ -155,7 +154,7 @@ test('Ordering a drug with a free text medication dosage for an OpenMRS patient 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(); + await expect(page.locator('div.list-row-container:nth-child(3) div:nth-child(3) span:nth-child(1) span').nth(1)).toHaveText('Draft'); await openmrs.voidPatient(); await erpnext.deleteQuotation(); }); @@ -183,6 +182,29 @@ test('Discontinuing a synced OpenMRS drug order for an ERPNext customer with a s await openmrs.voidPatient(); }); +test('Discontinuing a synced OpenMRS lab order for an ERPNext customer removes the corresponding quotation.', async ({ page }) => { + // setup + await openmrs.navigateToLabOrderForm(); + await page.getByPlaceholder('Search for a test type').fill('Complete blood count'); + await openmrs.saveLabOrder(); + + await erpnext.open(); + 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.cancelLabOrder(); + + // 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(); + await openmrs.voidPatient(); +}); + test('Ordering a drug for an OpenMRS patient within a visit creates the corresponding ERPNext customer with a filled quotation linked to the visit.', async ({ page }) => { // setup await openmrs.navigateToDrugOrderForm(); diff --git a/e2e/utils/functions/erpnext.ts b/e2e/utils/functions/erpnext.ts index 53952e3..87531a3 100644 --- a/e2e/utils/functions/erpnext.ts +++ b/e2e/utils/functions/erpnext.ts @@ -16,18 +16,20 @@ export class ERPNext { async searchCustomer() { await this.page.getByRole('link', { name: /selling/i }).click(); await this.page.getByRole('link', { name: 'Customer', exact: true }).click(); + await expect(this.page.getByPlaceholder('Customer Name')).toBeVisible(); await this.page.getByPlaceholder('Customer Name').clear(); await this.page.getByPlaceholder('Customer Name').fill(`${patientName.givenName}`); - await delay(5000); + await delay(3500); } async searchQuotation() { await this.page.getByRole('link', { name: /selling/i }).click(); await this.page.getByRole('link', { name: 'Quotation', exact: true }).click(); + await expect(this.page.getByPlaceholder(/title/i)).toBeVisible(); 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(5000); + await delay(3500); } async deleteQuotation() { diff --git a/e2e/utils/functions/openmrs.ts b/e2e/utils/functions/openmrs.ts index ddf7e65..7e7aec3 100644 --- a/e2e/utils/functions/openmrs.ts +++ b/e2e/utils/functions/openmrs.ts @@ -140,7 +140,7 @@ export class OpenMRS { await this.page.locator('label').filter({ hasText: 'Facility Visit' }).locator('span').first().click(); await this.page.locator('form').getByRole('button', { name: 'Start visit' }).click(); await expect(this.page.getByText('Facility Visit started successfully')).toBeVisible(); - await delay(5000); + await delay(4000); } async endPatientVisit() { @@ -149,7 +149,7 @@ export class OpenMRS { await this.page.getByRole('menuitem', { name: 'End visit' }).click(); await this.page.getByRole('button', { name: 'danger End Visit' }).click(); await expect(this.page.getByText('Visit ended')).toBeVisible(); - await this.page.getByRole('button', { name: 'Close', exact: true }).click(); + await delay(3000); } async voidPatient() { @@ -231,12 +231,12 @@ export class OpenMRS { } async saveLabOrder() { - await delay(3000); + await delay(2500); await this.page.getByRole('button', { name: 'Order form' }).click(); await this.page.getByRole('button', { name: 'Save order' }).click(); await this.page.getByRole('button', { name: 'Sign and close' }).click(); await expect(this.page.getByText('Placed orders')).toBeVisible(); - await delay(3000); + await delay(5000); } async voidEncounter() { @@ -254,7 +254,9 @@ export class OpenMRS { await this.page.getByRole('link', { name: 'Orders' }).click(); await this.page.getByRole('button', { name: 'Options' }).nth(0).click(); await this.page.getByRole('menuitem', { name: 'Cancel Order' }).click(); + await expect(this.page.getByRole('button', { name: 'Sign and close' })).toBeEnabled(); await this.page.getByRole('button', { name: 'Sign and close' }).click(); + await delay(3000); } async viewTestResults() { diff --git a/package.json b/package.json index 95484af..bb0d9e0 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "!playwright-report/" ], "scripts": { - "ozone-pro": "npx playwright test", + "ozone-pro": "npx playwright test erpnext", "ozone-foss": "npx playwright test odoo-openmrs erpnext-openmrs openmrs-senaite", "openmrs-distro-his": "npx playwright test odoo-openmrs openmrs-senaite" }, diff --git a/playwright.config.ts b/playwright.config.ts index f7e15c9..c7326fc 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -15,7 +15,7 @@ const config: PlaywrightTestConfig = { reporter: process.env.CI ? [['junit', { outputFile: 'results.xml' }], ['html']] : [['html']], globalSetup: require.resolve('./e2e/utils/configs/globalSetup'), use: { - baseURL: `${process.env.O3_URL_DEV}/spa/`, + baseURL: `${process.env.O3_URL}/spa/`, storageState: 'e2e/storageState.json', }, projects: [ @@ -23,7 +23,7 @@ const config: PlaywrightTestConfig = { name: 'chromium', use: { ...devices['Desktop Chromium'], - viewport: { width: 1920, height: 1080 } + viewport: { width: 1920, height: 1080 }, }, },