Skip to content

Commit

Permalink
OZ-681: E2E test verifying discontinuing a synced OpenMRS lab order f…
Browse files Browse the repository at this point in the history
…or an ERPNext customer removes the corresponding quotation.
  • Loading branch information
kdaud committed Nov 4, 2024
1 parent 4b63cdf commit 8827a7a
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 20 deletions.
28 changes: 25 additions & 3 deletions e2e/tests/erpnext-openmrs-flows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ test.beforeEach(async ({ page }) => {
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.navigateToLabOrderForm();
Expand Down Expand Up @@ -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();
});
Expand All @@ -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();
});
Expand Down Expand Up @@ -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();
Expand Down
9 changes: 7 additions & 2 deletions e2e/utils/functions/erpnext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -36,6 +38,7 @@ export class ERPNext {
await this.page.getByRole('checkbox', { name: 'Select All' }).check();
await delay(2000);
await this.page.getByRole('button', { name: 'Actions' }).click();
await expect(this.page.getByRole('link', { name: 'Delete' })).toBeVisible();
await this.page.getByRole('link', { name: 'Delete' }).click();
await this.page.getByRole('button', { name: 'Yes' }).click();
await expect(this.page.getByText('No Quotation found')).toBeVisible();
Expand All @@ -47,6 +50,7 @@ export class ERPNext {
await this.page.getByRole('checkbox', { name: 'Select All' }).check();
await delay(2000);
await this.page.getByRole('button', { name: 'Actions' }).click();
await expect(this.page.getByRole('link', { name: 'Cancel' })).toBeVisible();
await this.page.getByRole('link', { name: 'Cancel' }).click();
await this.page.getByRole('button', { name: 'Yes' }).click();
}
Expand All @@ -57,6 +61,7 @@ export class ERPNext {
await this.page.getByRole('checkbox', { name: 'Select All' }).check();
await delay(2000);
await this.page.getByRole('button', { name: 'Actions' }).click();
await expect(this.page.getByRole('link', { name: 'Delete' })).toBeVisible();
await this.page.getByRole('link', { name: 'Delete' }).click();
await this.page.getByRole('button', { name: 'Yes' }).click();
await expect(this.page.getByText('No Customer found')).toBeVisible();
Expand Down
20 changes: 7 additions & 13 deletions e2e/utils/functions/openmrs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,20 +71,12 @@ export class OpenMRS {
await this.page.getByLabel('Family Name').fill(`${patientName.givenName}`);
await this.page.locator('label').filter({ hasText: /^Male$/ }).locator('span').first().click();
await this.page.locator('div').filter({ hasText: /^Date of Birth Known\?YesNo$/ }).getByRole('tab', { name: 'No' }).click();
await expect(this.page.getByLabel('Estimated age in years')).toBeVisible();
await this.page.getByLabel('Estimated age in years').clear();
await this.page.getByLabel('Estimated age in years').fill(`${Math.floor(Math.random() * 99)}`);
await expect(this.page.getByText('Register Patient')).toBeVisible();
if (await this.page.getByTitle('close notification').isVisible()) {
await this.page.getByTitle('close notification').click();
}
await this.page.getByRole('button', { name: 'Register Patient' }).click();
await expect(this.page.getByText('New Patient Created')).toBeVisible();
if (await this.page.getByTitle('close notification').first().isVisible()) {
await this.page.getByTitle('close notification').first().click();
}
if (await this.page.getByTitle('close notification').isVisible()) {
await this.page.getByTitle('close notification').click();
}
await this.page.getByRole('button', { name: 'Close', exact: true }).click();
await delay(3000);
}
Expand Down Expand Up @@ -141,7 +133,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() {
Expand All @@ -150,7 +142,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() {
Expand Down Expand Up @@ -232,12 +224,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() {
Expand All @@ -255,7 +247,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() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
4 changes: 3 additions & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ const config: PlaywrightTestConfig = {
name: 'chromium',
use: {
...devices['Desktop Chromium'],
viewport: { width: 1920, height: 1080 }
viewport: { width: 1920, height: 1080 },
video: 'on',
screenshot: 'only-on-failure'
},

},
Expand Down

0 comments on commit 8827a7a

Please sign in to comment.