Skip to content

Commit

Permalink
address reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
kdaud committed Dec 15, 2024
1 parent ff54875 commit 6485c76
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 10 deletions.
51 changes: 45 additions & 6 deletions e2e/tests/odoo-openmrs-flows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,21 +227,60 @@ test('Discontinuing a synced OpenMRS lab order for an Odoo customer with a singl
await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(8) span')).toHaveText('Cancelled');
});

test('Ordering a lab test for an OpenMRS patient with weight creates the corresponding Odoo customer, with a quotation that includes the weight.', async ({ page }) => {
test('Ordering a lab test for an OpenMRS patient with weight creates the weight in the corresponding Odoo customer details.', async ({ page }) => {
// setup
await openmrs.recordWeight();

// replay
await openmrs.captureBiometrics();
await openmrs.navigateToLabOrderForm();
await page.getByRole('searchbox').fill('Blood urea nitrogen');
await openmrs.saveLabOrder();
await page.getByLabel('Order basket').click();
await expect(page.getByRole('button', { name: 'Add', exact: true }).nth(1)).toBeVisible();
await page.getByRole('button', { name: 'Add', exact: true }).nth(1).click();
await page.getByRole('searchbox').fill('Aspirin 325mg');
await openmrs.fillDrugOrderForm();
await openmrs.saveDrugOrder();

// verify
await odoo.open();
await odoo.navigateToSales();
await odoo.searchCustomer();
await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(4)')).toContainText(`${patientName.firstName + ' ' + patientName.givenName}`);
await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(8) span')).toHaveText('Quotation');
await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(7) span')).toHaveText('$ 27.50');
await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(7) span')).toHaveText('$ 14.88');
await page.getByRole('cell', { name: `${patientName.firstName + ' ' + patientName.givenName}` }).click();
await expect(page.locator('.o_group :nth-child(1) tbody :nth-child(3) :nth-child(2)>span')).toContainText('75');
});

test(`Recording a patient's weight in OpenMRS on the second order creates the weight in the corresponding Odoo customer details.`, async ({ page }) => {
// setup
await openmrs.navigateToDrugOrderForm();
await page.getByRole('searchbox').fill('Aspirin 325mg');
await openmrs.fillDrugOrderForm();
await openmrs.saveDrugOrder();
await odoo.open();
await odoo.navigateToSales();
await odoo.searchCustomer();
await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(4)')).toContainText(`${patientName.firstName + ' ' + patientName.givenName}`);
await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(8) span')).toHaveText('Quotation');
await page.getByRole('cell', { name: `${patientName.firstName + ' ' + patientName.givenName}` }).click();
await expect(page.locator('.o_group :nth-child(1) tbody :nth-child(3) :nth-child(2)>span')).toBeEmpty();

// replay
await page.goto(`${O3_URL}`);
await openmrs.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`);
await openmrs.recordWeight();
await page.getByLabel('Order basket').click();
await expect(page.getByRole('button', { name: 'Add', exact: true }).nth(2)).toBeVisible();
await page.getByRole('button', { name: 'Add', exact: true }).nth(2).click();
await page.getByRole('searchbox').fill('Blood urea nitrogen');
await openmrs.saveLabOrder();

// verify
await page.goto(`${ODOO_URL}`);
await odoo.navigateToSales();
await odoo.searchCustomer();
await page.getByRole('cell', { name: `${patientName.firstName + ' ' + patientName.givenName}` }).click();
await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(2) span:nth-child(1) span')).toHaveText('Aspirin 325mg');
await expect(page.locator('tr.o_data_row:nth-child(2) td:nth-child(2) span:nth-child(1) span')).toHaveText('Blood urea nitrogen');
await expect(page.locator('.o_group :nth-child(1) tbody :nth-child(3) :nth-child(2)>span')).toContainText('75');
});

Expand Down
6 changes: 3 additions & 3 deletions e2e/utils/functions/openmrs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ export class OpenMRS {
await delay(2000);
await expect(this.page.getByRole('button', { name: 'Add', exact: true }).nth(1)).toBeVisible();
await this.page.getByRole('button', { name: 'Add', exact: true }).nth(1).click();
await delay(2000);
}

async saveLabOrder() {
Expand All @@ -232,14 +233,13 @@ export class OpenMRS {
await delay(5000);
}

async captureBiometrics() {
async recordWeight() {
await this.page.getByRole('link', { name: 'Vitals & Biometrics' }).click();
await this.page.getByRole('button', { name: 'Record biometrics' }).click();
await this.page.getByRole('spinbutton', { name: 'Weight' }).fill('75');
await this.page.getByRole('spinbutton', { name: 'Height' }).fill('168');
await this.page.getByRole('spinbutton', { name: 'MUAC' }).fill('12.5');
await this.page.getByRole('button', { name: 'Save and close' }).click();
await expect(this.page.getByText('Vitals and Biometrics saved')).toBeVisible();
await delay(2000);
}

async voidEncounter() {
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 odoo-openmrs",
"ozone-foss": "npx playwright test odoo-openmrs erpnext-openmrs openmrs-senaite",
"openmrs-distro-his": "npx playwright test odoo-openmrs openmrs-senaite"
},
Expand Down

0 comments on commit 6485c76

Please sign in to comment.