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 1, 2024
1 parent 56dd2e4 commit 583dad6
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 11 deletions.
26 changes: 24 additions & 2 deletions e2e/tests/erpnext-openmrs-flows.spec.ts
Original file line number Diff line number Diff line change
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
6 changes: 4 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 Down
10 changes: 6 additions & 4 deletions e2e/utils/functions/openmrs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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() {
Expand Down Expand Up @@ -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() {
Expand All @@ -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() {
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: 2 additions & 2 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ 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: [
{
name: 'chromium',
use: {
...devices['Desktop Chromium'],
viewport: { width: 1920, height: 1080 }
viewport: { width: 1920, height: 1080 },
},

},
Expand Down

0 comments on commit 583dad6

Please sign in to comment.