Skip to content

Commit

Permalink
Updated editing test patient + Fixed O3 → ERPNext flows
Browse files Browse the repository at this point in the history
  • Loading branch information
kdaud committed Jan 17, 2025
1 parent eaf496d commit dfe3062
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 56 deletions.
22 changes: 1 addition & 21 deletions e2e/tests/erpnext-openmrs-flows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ test('Ordering a lab test for an OpenMRS patient creates the corresponding ERPNe
await erpnext.open();
await erpnext.searchCustomer();
await expect(page.locator('div.list-row-container:nth-child(3) span:nth-child(2) a')).toContainText(`${patientName.firstName + ' ' + patientName.givenName}`);
await openmrs.voidPatient();
await erpnext.deleteQuotation();
});

test('Ordering a drug for an OpenMRS patient creates the corresponding ERPNext customer with a filled quotation.', async ({ page }) => {
Expand All @@ -44,8 +42,6 @@ test('Ordering a drug for an OpenMRS patient creates the corresponding ERPNext c
await page.locator('#customer-dashboard_tab-tab').click();
await page.getByLabel('Dashboard').getByText('Quotation').click();
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();
});

test('Editing the details of an OpenMRS patient with a synced lab order edits the corresponding ERPNext customer details.', async ({ page }) => {
Expand All @@ -66,8 +62,6 @@ test('Editing the details of an OpenMRS patient with a synced lab order edits th
await page.goto(`${ERPNEXT_URL}/app/home`);
await erpnext.searchCustomer();
await expect(page.locator('div.list-row-container:nth-child(3) span:nth-child(2) a')).toContainText(`${patientName.updatedFirstName}` + ' ' + `${patientName.givenName}`);
await openmrs.voidPatient();
await erpnext.deleteQuotation();
});

test('Editing the details of an OpenMRS patient with a synced drug order edits the corresponding ERPNext customer details.', async ({ page }) => {
Expand All @@ -89,8 +83,6 @@ test('Editing the details of an OpenMRS patient with a synced drug order edits t
await page.goto(`${ERPNEXT_URL}/app/home`);
await erpnext.searchCustomer();
await expect(page.locator('div.list-row-container:nth-child(3) span:nth-child(2) a')).toContainText(`${patientName.updatedFirstName}` + ' ' + `${patientName.givenName}`);
await openmrs.voidPatient();
await erpnext.deleteQuotation();
});

test('Ending an OpenMRS patient visit with a synced drug order updates the corresponding ERPNext draft quotation to an open state.', async ({ page }) => {
Expand All @@ -112,9 +104,6 @@ test('Ending an OpenMRS patient visit with a synced drug order updates the corre
await page.goto(`${ERPNEXT_URL}/app/home`);
await erpnext.searchQuotation();
await expect(page.locator('div.list-row-container:nth-child(3) div:nth-child(3) span:nth-child(1) span')).toHaveText('Open');
await erpnext.voidQuotation();
await openmrs.voidPatient();
await erpnext.deleteQuotation();
});

test('Revising details of a synced OpenMRS drug order modifies the corresponding ERPNext quotation item.', async ({ page }) => {
Expand All @@ -138,8 +127,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 openmrs.voidPatient();
await erpnext.deleteQuotation();
});

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 }) => {
Expand All @@ -155,8 +142,6 @@ test('Ordering a drug with a free text medication dosage for an OpenMRS patient
await page.getByLabel('Dashboard').getByText('Quotation').click();
await erpnext.searchQuotation();
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();
});

test('Discontinuing a synced OpenMRS drug order for an ERPNext customer with a single quotation line removes the corresponding quotation.', async ({ page }) => {
Expand All @@ -179,7 +164,6 @@ test('Discontinuing a synced OpenMRS drug order for an ERPNext customer with a s
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('Discontinuing a synced OpenMRS lab order for an ERPNext customer removes the corresponding quotation.', async ({ page }) => {
Expand All @@ -202,7 +186,6 @@ test('Discontinuing a synced OpenMRS lab order for an ERPNext customer removes t
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 }) => {
Expand Down Expand Up @@ -230,13 +213,10 @@ test('Ordering a drug for an OpenMRS patient within a visit creates the correspo
await erpnext.searchQuotation();
await expect(page.locator('div.list-row-container:nth-child(3) div:nth-child(3) span:nth-child(1) span')).toHaveText('Draft');
await expect(page.locator('div.list-row-container:nth-child(4) div:nth-child(3) span:nth-child(1) span')).toHaveText('Open');
await erpnext.voidQuotation();
await openmrs.voidPatient();
await erpnext.deleteQuotation();
});

test.afterEach(async ({ page }) => {
await erpnext.deleteCustomer();
await openmrs.voidPatient();
await openmrs.logout();
await page.close();
});
32 changes: 0 additions & 32 deletions e2e/utils/functions/erpnext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,36 +28,4 @@ export class ERPNext {
await this.page.getByPlaceholder(/party/i).clear();
await this.page.getByPlaceholder(/title/i).fill(`${patientName.givenName}`), delay(3500);
}

async deleteQuotation() {
await this.page.goto(`${ERPNEXT_URL}/app/quotation`);
await this.searchQuotation();
await this.page.getByRole('checkbox', { name: 'Select All' }).check(), 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/i)).toBeVisible();
}

async voidQuotation() {
await this.page.goto(`${ERPNEXT_URL}/app/quotation`);
await this.searchQuotation();
await this.page.getByRole('checkbox', { name: 'Select All' }).check(), 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();
}

async deleteCustomer() {
await this.page.goto(`${ERPNEXT_URL}/app/customer`);
await this.searchCustomer();
await this.page.getByRole('checkbox', { name: 'Select All' }).check(), 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/i)).toBeVisible();
}
}
3 changes: 1 addition & 2 deletions e2e/utils/functions/openmrs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ export class OpenMRS {
await this.page.getByRole('button', { name: /actions/i, exact: true }).click();
await this.page.getByRole('menuitem', { name: /edit patient details/i }).click(), delay(4000);
await expect(this.page.locator('#givenName')).toBeVisible();
await this.page.locator('#givenName').type(`${patientName.updatedFirstName}`), delay(2000);
await this.page.locator('#givenName').fill(`${patientName.updatedFirstName}`), delay(2000);
await this.page.locator('label').filter({ hasText: /female/i }).locator('span').first().click();
await this.page.locator('div[aria-label="day, "]').fill('18');
await this.page.locator('div[aria-label="month, "]').fill('08');
Expand All @@ -346,7 +346,6 @@ export class OpenMRS {

async updateRole() {
await this.page.getByRole('link', { name: `${randomOpenMRSRoleName.roleName}` }).click();
await this.page.locator('textarea[name="description"]').clear();
await this.page.locator('textarea[name="description"]').fill('Updated role description');
await this.page.getByLabel('Application: Registers Patients').check();
await this.page.getByLabel('Application: Writes Clinical Notes').check();
Expand Down
2 changes: 1 addition & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const config: PlaywrightTestConfig = {
name: 'chromium',
use: {
...devices['Desktop Chromium'],
viewport: { width: 1920, height: 1080 }
viewport: { width: 1920, height: 1080 },
},

},
Expand Down

0 comments on commit dfe3062

Please sign in to comment.