From 4a0444993d44b259794c8f462b96cb6598fb1e11 Mon Sep 17 00:00:00 2001 From: kdaud Date: Wed, 8 Jan 2025 10:26:56 +0300 Subject: [PATCH] fix --- e2e/tests/odoo-superset-flows.spec.ts | 49 +++++++++++++++++++++++- e2e/tests/openmrs-superset-flows.spec.ts | 2 +- e2e/utils/functions/odoo.ts | 10 +++++ e2e/utils/functions/openmrs.ts | 5 +-- package.json | 2 +- 5 files changed, 61 insertions(+), 7 deletions(-) diff --git a/e2e/tests/odoo-superset-flows.spec.ts b/e2e/tests/odoo-superset-flows.spec.ts index 6d23cc4..25b3d20 100644 --- a/e2e/tests/odoo-superset-flows.spec.ts +++ b/e2e/tests/odoo-superset-flows.spec.ts @@ -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; @@ -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(); diff --git a/e2e/tests/openmrs-superset-flows.spec.ts b/e2e/tests/openmrs-superset-flows.spec.ts index 4fb5d74..9b1a110 100644 --- a/e2e/tests/openmrs-superset-flows.spec.ts +++ b/e2e/tests/openmrs-superset-flows.spec.ts @@ -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(); diff --git a/e2e/utils/functions/odoo.ts b/e2e/utils/functions/odoo.ts index 7a24381..6b7c22d 100644 --- a/e2e/utils/functions/odoo.ts +++ b/e2e/utils/functions/odoo.ts @@ -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(); diff --git a/e2e/utils/functions/openmrs.ts b/e2e/utils/functions/openmrs.ts index d19ba62..ea00398 100644 --- a/e2e/utils/functions/openmrs.ts +++ b/e2e/utils/functions/openmrs.ts @@ -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'); @@ -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() { diff --git a/package.json b/package.json index a3c9f32..8136f08 100644 --- a/package.json +++ b/package.json @@ -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" },