Skip to content

Commit

Permalink
OZ 345: E2E tests verifying creating an Odoo sale order line generate…
Browse files Browse the repository at this point in the history
…s an entry in Superset's sale_order_lines table. (#107)
  • Loading branch information
kdaud authored Sep 20, 2024
1 parent 6c8caa8 commit 0172145
Show file tree
Hide file tree
Showing 6 changed files with 182 additions and 14 deletions.
15 changes: 15 additions & 0 deletions e2e/tests/odoo-openmrs-flows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ test('Ordering a lab test for an OpenMRS patient creates the corresponding Odoo

// 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');
Expand All @@ -34,6 +35,7 @@ test('Editing the details of an OpenMRS patient with a synced lab order edits th
await page.getByPlaceholder('Search for a test type').fill('Blood urea nitrogen');
await openmrs.saveLabOrder();
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');
Expand All @@ -45,6 +47,7 @@ test('Editing the details of an OpenMRS patient with a synced lab order edits th

// verify
await page.goto(`${ODOO_URL}`);
await odoo.navigateToSales();
await odoo.searchCustomer();
await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(4)')).toHaveText(`${patientName.updatedFirstName}` + ' ' + `${patientName.givenName}`);
await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(8) span')).toHaveText('Quotation');
Expand All @@ -59,6 +62,7 @@ test('Ordering a drug for an OpenMRS patient creates the corresponding Odoo cust

// 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');
Expand All @@ -71,6 +75,7 @@ test('Editing the details of an OpenMRS patient with a synced drug order edits t
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');
Expand All @@ -82,6 +87,7 @@ test('Editing the details of an OpenMRS patient with a synced drug order edits t

// verify
await page.goto(`${ODOO_URL}`);
await odoo.navigateToSales();
await odoo.searchCustomer();
await expect(page.locator('table tbody td.o_data_cell:nth-child(4)')).toHaveText(`${patientName.updatedFirstName}` + ' ' + `${patientName.givenName }`);
await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(8) span')).toHaveText('Quotation');
Expand All @@ -94,6 +100,7 @@ test('Revising a synced OpenMRS drug order edits the corresponding Odoo quotatio
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 page.getByRole('cell', { name: `${patientName.firstName + ' ' + patientName.givenName}` }).click();
Expand All @@ -108,6 +115,7 @@ test('Revising a synced OpenMRS drug order edits the corresponding Odoo quotatio

// verify
await page.goto(`${ODOO_URL}`);
await odoo.navigateToSales();
await odoo.searchCustomer();
await page.getByRole('cell', { name: `${patientName.firstName + ' ' + patientName.givenName}` }).click();
await expect(drugOrderItem).toContainText('8.0 Tablet');
Expand All @@ -121,6 +129,7 @@ test('Discontinuing a synced OpenMRS drug order for an Odoo customer with a sing
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');
Expand All @@ -134,6 +143,7 @@ test('Discontinuing a synced OpenMRS drug order for an Odoo customer with a sing

// verify
await page.goto(`${ODOO_URL}`);
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('Cancelled');
Expand All @@ -152,6 +162,7 @@ test('Discontinuing a synced OpenMRS drug order for an Odoo customer with multip
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');
Expand All @@ -166,6 +177,7 @@ test('Discontinuing a synced OpenMRS drug order for an Odoo customer with multip

// 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('Blood urea nitrogen');
Expand All @@ -178,6 +190,7 @@ test('Ordering a drug with a free text medication dosage for an OpenMRS patient

// 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');
Expand All @@ -189,6 +202,7 @@ test('Discontinuing a synced OpenMRS lab order for an Odoo customer with a singl
await page.getByPlaceholder('Search for a test type').fill('Blood urea nitrogen');
await openmrs.saveLabOrder();
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');
Expand All @@ -201,6 +215,7 @@ test('Discontinuing a synced OpenMRS lab order for an Odoo customer with a singl

// verify
await page.goto(`${ODOO_URL}`);
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('Cancelled');
Expand Down
119 changes: 119 additions & 0 deletions e2e/tests/odoo-superset-flows.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
import { test, expect } from '@playwright/test';
import { Odoo } from '../utils/functions/odoo';
import { Superset } from '../utils/functions/superset';
import { OpenMRS, patientName } from '../utils/functions/openmrs';
import { O3_URL, SUPERSET_URL } from '../utils/configs/globalSetup';

let odoo: Odoo;
let openmrs: OpenMRS;
let superset: Superset;

test.beforeEach(async ({ page }) => {
openmrs = new OpenMRS(page);
odoo = new Odoo(page);
superset = new Superset(page);

await openmrs.login();
await openmrs.createPatient();
await openmrs.startPatientVisit();
});

test(`Creating an Odoo sale order line generates an entry in Superset's sale_order_lines table.`, async ({ page }) => {
// setup
await openmrs.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`);
await openmrs.goToLabOrderForm();
await page.getByPlaceholder('Search for a test type').fill('Complete blood count');
await openmrs.saveLabOrder();
await superset.open();
await superset.selectDBSchema();
await superset.clearSQLEditor();
let saleOrderLinesCountQuery = `SELECT COUNT (*) FROM sale_order_lines;`;
await page.getByRole('textbox').first().fill(saleOrderLinesCountQuery);
await superset.runSQLQuery();
let initialSaleOrderLinesCount = Number(await page.locator('div.virtual-table-cell').textContent());
await page.getByRole('tab', { name: 'Query history' }).click();
await superset.clearSQLEditor();

// replay
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');

// verify
await page.goto(`${SUPERSET_URL}/sqllab`);
await superset.clearSQLEditor();
await page.getByRole('textbox').first().fill(saleOrderLinesCountQuery);
await superset.runSQLQuery();
let updatedSaleOrderLinesCount = Number(await page.locator('div.virtual-table-cell').textContent());
await expect(updatedSaleOrderLinesCount).toBe(initialSaleOrderLinesCount + 1);
await page.getByRole('tab', { name: 'Query history' }).click();
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');
let quantity = Number(await page.locator('div.virtual-table-cell:nth-child(4)').textContent());
let unitPrice = Number(await page.locator('div.virtual-table-cell:nth-child(5)').textContent());
await expect(quantity).toBe(8);
await expect(unitPrice).toBe(2);
});

test(`A (synced) sale order line in Odoo generates an entry in Superset's sale_order_lines table.`, async ({ page }) => {
// setup
await superset.open();
await superset.selectDBSchema();
await superset.clearSQLEditor();
let saleOrderLinesCountQuery = `SELECT COUNT (*) FROM sale_order_lines;`;
await page.getByRole('textbox').first().fill(saleOrderLinesCountQuery);
await superset.runSQLQuery();
let initialSaleOrderLinesCount = Number(await page.locator('div.virtual-table-cell').textContent());
await page.getByRole('tab', { name: 'Query history' }).click();
await superset.clearSQLEditor();
await page.goto(`${O3_URL}`);
await openmrs.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`);
await openmrs.goToLabOrderForm();
await page.getByPlaceholder('Search for a test type').fill('Haemoglobin');
await openmrs.saveLabOrder();

// replay
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();
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('Haemoglobin');
let quantity = Number(await page.locator('td.o_data_cell:nth-child(4)').textContent());
await expect(quantity).toBe(1);
await expect(page.locator('td.o_data_cell:nth-child(7)')).toContainText('24');

// verify
await page.goto(`${SUPERSET_URL}/sqllab`);
await superset.clearSQLEditor();
await page.getByRole('textbox').first().fill(saleOrderLinesCountQuery);
await superset.runSQLQuery();
let updatedSaleOrderLinesCount = Number(await page.locator('div.virtual-table-cell').textContent());
await expect(updatedSaleOrderLinesCount).toBe(initialSaleOrderLinesCount + 1);
await page.getByRole('tab', { name: 'Query history' }).click();
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('Haemoglobin');
quantity = Number(await page.locator('div.virtual-table-cell:nth-child(4)').textContent());
let unitPrice = Number(await page.locator('div.virtual-table-cell:nth-child(5)').textContent());
await expect(quantity).toBe(1);
await expect(unitPrice).toBe(24);
});

test.afterEach(async ({ page }) => {
await openmrs.voidPatient();
await page.close();
});
24 changes: 12 additions & 12 deletions e2e/tests/openmrs-superset-flows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test.beforeEach(async ({ page }) => {
await openmrs.login();
});

test('Creating an OpenMRS patient creates the patient in Superset patients table.', async ({ page }) => {
test(`Creating an OpenMRS patient creates the patient in Superset's patients table.`, async ({ page }) => {
// setup
await superset.open();
await superset.selectDBSchema();
Expand Down Expand Up @@ -51,7 +51,7 @@ test('Creating an OpenMRS patient creates the patient in Superset patients table
await openmrs.voidPatient();
});

test('Creating an OpenMRS visit creates the visit in Superset visits table.', async ({ page }) => {
test(`Creating an OpenMRS visit creates the visit in Superset's visits table.`, async ({ page }) => {
// setup
await openmrs.createPatient();
await superset.open();
Expand Down Expand Up @@ -90,7 +90,7 @@ test('Creating an OpenMRS visit creates the visit in Superset visits table.', as
await openmrs.voidPatient();
});

test('Creating an OpenMRS order creates the order in Superset orders table.', async ({ page }) => {
test(`Creating an OpenMRS order creates the order in Superset's orders table.`, async ({ page }) => {
// setup
await openmrs.createPatient();
await openmrs.searchPatientId();
Expand Down Expand Up @@ -138,7 +138,7 @@ test('Creating an OpenMRS order creates the order in Superset orders table.', as
await openmrs.voidPatient();
});

test('Creating an OpenMRS encounter creates the encounter in Superset encounters table.', async ({ page }) => {
test(`Creating an OpenMRS encounter creates the encounter in Superset's encounters table.`, async ({ page }) => {
// setup
await openmrs.createPatient();
await openmrs.searchPatientId();
Expand Down Expand Up @@ -186,7 +186,7 @@ test('Creating an OpenMRS encounter creates the encounter in Superset encounters
await openmrs.voidPatient();
});

test('Creating an OpenMRS condition creates the condition in Superset conditions table.', async ({ page }) => {
test(`Creating an OpenMRS condition creates the condition in Superset's conditions table.`, async ({ page }) => {
// setup
await openmrs.createPatient();
await openmrs.searchPatientId();
Expand Down Expand Up @@ -232,7 +232,7 @@ test('Creating an OpenMRS condition creates the condition in Superset conditions
await openmrs.voidPatient();
});

test('Creating an OpenMRS obs creates the observation in Superset observations table.', async ({ page }) => {
test(`Creating an OpenMRS obs creates the observation in Superset's observations table.`, async ({ page }) => {
// setup
await openmrs.createPatient();
await openmrs.startPatientVisit();
Expand Down Expand Up @@ -275,7 +275,7 @@ test('Creating an OpenMRS obs creates the observation in Superset observations t
await openmrs.voidPatient();
});

test('Creating an OpenMRS appointment creates the appointment in Superset appointments table.', async ({ page }) => {
test(`Creating an OpenMRS appointment creates the appointment in Superset's appointments table.`, async ({ page }) => {
// setup
await openmrs.createPatient();
await openmrs.searchPatientId();
Expand Down Expand Up @@ -323,7 +323,7 @@ test('Creating an OpenMRS appointment creates the appointment in Superset appoin
await openmrs.voidPatient();
});

test('Voiding an OpenMRS obs updates the observation in Superset observations table.', async ({ page }) => {
test(`Voiding an OpenMRS obs updates the observation in Superset's observations table.`, async ({ page }) => {
// setup
await openmrs.createPatient();
await openmrs.startPatientVisit();
Expand Down Expand Up @@ -357,7 +357,7 @@ test('Voiding an OpenMRS obs updates the observation in Superset observations ta
await openmrs.voidPatient();
});

test('Voiding an OpenMRS patient updates the patient in Superset patients table.', async ({ page }) => {
test(`Voiding an OpenMRS patient updates the patient in Superset's patients table.`, async ({ page }) => {
// setup
await openmrs.createPatient();
await openmrs.searchPatientId();
Expand All @@ -382,7 +382,7 @@ test('Voiding an OpenMRS patient updates the patient in Superset patients table.
await superset.clearSQLEditor();
});

test('Voiding an OpenMRS condition updates the condition in Superset conditions table.', async ({ page }) => {
test(`Voiding an OpenMRS condition updates the condition in Superset's conditions table.`, async ({ page }) => {
// setup
await openmrs.createPatient();
await openmrs.searchPatientId();
Expand Down Expand Up @@ -418,7 +418,7 @@ test('Voiding an OpenMRS condition updates the condition in Superset conditions
await openmrs.voidPatient();
});

test('Voiding an OpenMRS encounter updates the encounter in Superset encounters table.', async ({ page }) => {
test(`Voiding an OpenMRS encounter updates the encounter in Superset's encounters table.`, async ({ page }) => {
// setup
await openmrs.createPatient();
await openmrs.searchPatientId();
Expand Down Expand Up @@ -457,7 +457,7 @@ test('Voiding an OpenMRS encounter updates the encounter in Superset encounters
await openmrs.voidPatient();
});

test('Cancelling an OpenMRS appointment updates the appointment in Superset appointments table.', async ({ page }) => {
test(`Cancelling an OpenMRS appointment updates the appointment in Superset's appointments table.`, async ({ page }) => {
// setup
await openmrs.createPatient();
await openmrs.searchPatientId();
Expand Down
Loading

0 comments on commit 0172145

Please sign in to comment.