Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
kdaud committed Jan 9, 2025
1 parent 39b0b08 commit 4a04449
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 7 deletions.
49 changes: 47 additions & 2 deletions e2e/tests/odoo-superset-flows.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { test, expect } from '@playwright/test';
import { O3_URL, SUPERSET_URL } from '../utils/configs/globalSetup';
import { O3_URL, ODOO_URL, SUPERSET_URL } from '../utils/configs/globalSetup';
import { Odoo } from '../utils/functions/odoo';
import { Superset } from '../utils/functions/superset';
import { OpenMRS, patientName } from '../utils/functions/openmrs';
import { delay, OpenMRS, patientName } from '../utils/functions/openmrs';

let odoo: Odoo;
let openmrs: OpenMRS;
Expand Down Expand Up @@ -62,6 +62,51 @@ test(`Creating an Odoo sale order line generates an entry in Superset's sale_ord
await expect(unitPrice).toBe(2);
});

test(`Revising an Odoo sale order line modifies the corresponding entry in Superset's sale_order_lines table.`, async ({ page }) => {
// setup
await openmrs.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`);
await openmrs.navigateToLabOrderForm();
await page.getByRole('searchbox').fill('Complete blood count');
await openmrs.saveLabOrder();

await odoo.open();
await odoo.navigateToSales();
await odoo.createSaleOrderLine();
const salesOrderId = await page.locator('.oe_title h1:nth-child(1) span').textContent();
await expect(page.locator('table tbody td.o_data_cell:nth-child(2) span:nth-child(1) span')).toHaveText('Acétaminophene Co 500mg');

await superset.open();
await superset.selectDBSchema();
await superset.clearSQLEditor();
let saleOrderLinesQuery = `SELECT sale_order_name, customer_name, product_name, quantity, unit_price FROM sale_order_lines WHERE sale_order_name like '${salesOrderId}';`;
await page.getByRole('textbox').first().fill(saleOrderLinesQuery);
await superset.runSQLQuery();
await expect(page.locator('div.virtual-table-cell:nth-child(1)')).toHaveText(`${salesOrderId}`);
await expect(page.locator('div.virtual-table-cell:nth-child(2)')).toHaveText(`${patientName.firstName + ' ' + patientName.givenName}`);
await expect(page.locator('div.virtual-table-cell:nth-child(3)')).toHaveText('Acétaminophene Co 500mg');
await expect(page.locator('div.virtual-table-cell:nth-child(4)')).toHaveText('8');
await expect(page.locator('div.virtual-table-cell:nth-child(5)')).toHaveText('2');

// replay
await page.goto(`${ODOO_URL}`);
await odoo.navigateToSales();
await odoo.searchCustomer();
await page.getByRole('cell', { name: `${patientName.firstName + ' ' + patientName.givenName}` }).nth(0).click();
await odoo.modifySaleOrderLine();

// verify
await page.goto(`${SUPERSET_URL}/sqllab`);
await superset.clearSQLEditor();
await page.getByRole('textbox').first().fill(saleOrderLinesQuery);
await superset.runSQLQuery();
await expect(page.locator('div.virtual-table-cell:nth-child(1)')).toHaveText(`${salesOrderId}`);
await expect(page.locator('div.virtual-table-cell:nth-child(2)')).toHaveText(`${patientName.firstName + ' ' + patientName.givenName}`);
await expect(page.locator('div.virtual-table-cell:nth-child(3)')).toHaveText('Acétaminophene Co 500mg');
await expect(page.locator('div.virtual-table-cell:nth-child(4)')).toHaveText('10');
await expect(page.locator('div.virtual-table-cell:nth-child(5)')).toHaveText('3');

});

test(`A (synced) sale order line in Odoo generates an entry in Superset's sale_order_lines table.`, async ({ page }) => {
// setup
await superset.open();
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/openmrs-superset-flows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ test(`Creating an OpenMRS visit creates the visit in Superset's visits table.`,
await expect(page.locator('div.virtual-table-cell:nth-child(3)')).toHaveText('Inpatient Ward');
await expect(page.locator('div.virtual-table-cell:nth-child(6)')).toHaveText('Facility Visit');
await expect(page.locator('div.virtual-table-cell:nth-child(8)')).toHaveText('M');
await expect(page.locator('div.virtual-table-cell:nth-child(10)')).toHaveText('true')
await expect(page.locator('div.virtual-table-cell:nth-child(2)')).toHaveText('false')
await page.getByRole('tab', { name: 'Query history' }).click();
await superset.clearSQLEditor();
await openmrs.voidPatient();
Expand Down
10 changes: 10 additions & 0 deletions e2e/utils/functions/odoo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,16 @@ export class Odoo {
await expect(this.page.locator('td.o_data_cell:nth-child(11)')).toHaveText('$ 16.00');
}

async modifySaleOrderLine() {
await this.page.getByRole('button', { name: 'Edit' }).click();
await this.page.getByText(/acétaminophene co 500mg/i).nth(1).click();
await this.page.locator('input[name="product_uom_qty"]').fill('10');
await this.page.locator('input[name="price_unit"]').fill('3');
await this.page.locator('td.o_field_x2many_list_row_add').click(), delay(2000);
await expect(this.page.locator('td.o_data_cell:nth-child(11)')).toHaveText('$ 30.00');
await this.page.getByRole('button', { name: 'Save' }).click(), delay(3000);
}

async activateDeveloperMode() {
await this.navigateToSettings();
await expect(this.page.locator('#devel_tool a:nth-child(1)')).toBeVisible();
Expand Down
5 changes: 2 additions & 3 deletions e2e/utils/functions/openmrs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ export class OpenMRS {

async addPatientAppointment() {
await this.page.getByRole('link', { name: /appointments/i }).click();
await this.page.getByRole('button', { name: /add/i, exact: true }).click();
await this.page.getByRole('button', { name: 'Add', exact: true }).click();
await this.page.getByLabel(/select a service/i).selectOption('General Medicine service');
await this.page.getByLabel(/select an appointment type/i).selectOption('Scheduled');
await this.page.locator('#duration').fill('40');
Expand Down Expand Up @@ -225,8 +225,7 @@ export class OpenMRS {
await this.page.getByRole('button', { name: /options/i, exact: true }).click();
await this.page.getByRole('menuitem', { name: /delete this encounter/i }).click();
await this.page.getByRole('button', { name: /danger delete/i }).click();
await expect(this.page.getByText(/encounter deleted/i)).toBeVisible();
await expect(this.page.getByText(/encounter successfully deleted/i)).toBeVisible(), delay(5000);
await expect(this.page.getByText(/encounter deleted/i)).toBeVisible(), delay(5000);
}

async cancelLabOrder() {
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 odoo-openmrs",
"ozone-pro": "npx playwright test odoo-superset",
"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 4a04449

Please sign in to comment.