Skip to content

Commit

Permalink
C2C-345: E2E tests for Bahmni-Odoo flows
Browse files Browse the repository at this point in the history
  • Loading branch information
kdaud committed Aug 23, 2024
1 parent 2927dad commit b721b57
Show file tree
Hide file tree
Showing 5 changed files with 296 additions and 27 deletions.
216 changes: 211 additions & 5 deletions e2e/tests/bahmni-odoo-flows.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { test, expect } from '@playwright/test';
import { Odoo } from '../utils/functions/odoo';
import { BAHMNI_URL, ODOO_URL } from '../utils/configs/globalSetup';
import { Bahmni, patientName } from '../utils/functions/bahmni';

let bahmni: Bahmni;
Expand All @@ -15,17 +16,16 @@ test.beforeEach(async ({ page }) => {
await expect(page.getByText(/admin/i)).toBeVisible();
await expect(page.getByText(/appointment scheduling/i)).toBeVisible();
await expect(page.getByText(/patient documents/i)).toBeVisible();
await bahmni.registerPatient();
await bahmni.goToHomePage();
});

test('Ordering a lab test for a Bahmni patient creates the corresponding Odoo customer with a filled quotation.', async ({ page }) => {
// setup
await bahmni.registerPatient();
await bahmni.goToLabSamples();

// replay
await bahmni.goToLabSamples();
await page.getByText('Blood', { exact: true }).click();
await page.getByText('Malaria').click();
await bahmni.saveOrder();
await bahmni.createLabOrder();

// verify
await odoo.open();
Expand All @@ -42,6 +42,212 @@ test('Ordering a lab test for a Bahmni patient creates the corresponding Odoo cu
await expect(labTest).toContainText('Malaria');
});


test('Editing the details of a Bahmni patient with a synced lab order edits the corresponding Odoo customer details.', async ({ page }) => {
// setup
await bahmni.goToLabSamples();

// replay
await bahmni.createLabOrder();

// verify
await odoo.open();
await expect(page).toHaveURL(/.*web/);
await odoo.searchCustomer();
const customerSelector = await page.locator("tr.o_data_row:nth-child(1) td:nth-child(4)");
await expect(customerSelector).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`);

const statusSelector = await page.locator("tr.o_data_row:nth-child(1) td:nth-child(8) span");
await expect(statusSelector).toHaveText("Devis");

await page.goto(`${BAHMNI_URL}`);
await bahmni.updatePatientDetails();

// verify
await page.goto(`${ODOO_URL}`);
await odoo.searchCustomer();
const updatedCustomer = await page.locator("tr.o_data_row:nth-child(1) td:nth-child(4)");
await expect(updatedCustomer).toHaveText(`${patientName.updatedGivenName}` + ' ' + `${patientName.familyName}`);
await expect(statusSelector).toHaveText("Devis");
});

test('Revising a synced Bahmni lab order edits the corresponding Odoo quotation line.', async ({ page }) => {
// setup
await bahmni.goToLabSamples();

// replay
await bahmni.createLabOrder();

// verify
await odoo.open();
await expect(page).toHaveURL(/.*web/);
await odoo.searchCustomer();
const customerSelector = await page.locator("tr.o_data_row:nth-child(1) td:nth-child(4)");
await expect(customerSelector).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`);

const statusSelector = await page.locator("tr.o_data_row:nth-child(1) td:nth-child(8) span");
await expect(statusSelector).toHaveText("Devis");

await page.getByRole('cell', { name: `${patientName.givenName + ' ' + patientName.familyName}` }).click();
const labTest = await page.locator("td.o_data_cell.o_field_cell.o_list_many2one.o_product_configurator_cell.o_required_modifier>span");
await expect(labTest).toHaveText('Malaria');

await page.goto(`${BAHMNI_URL}`);
await bahmni.goToLabSamples();
await bahmni.reviseLabOrder();

// verify
await page.goto(`${ODOO_URL}`);
await odoo.searchCustomer();
await expect(customerSelector).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`);
await expect(statusSelector).toHaveText("Devis");
await page.getByRole('cell', { name: `${patientName.givenName + ' ' + patientName.familyName }` }).first().click();
await expect(labTest).not.toContainText('Malaria');
await expect(labTest).toHaveText('Hematocrite');
});

test('Discontinuing a synced Bahmni lab order edits the corresponding Odoo quotation line.', async ({ page }) => {
// setup
await bahmni.goToLabSamples();

// replay
await bahmni.createLabOrder();

// verify
await odoo.open();
await expect(page).toHaveURL(/.*web/);
await odoo.searchCustomer();
const customerSelector = await page.locator("tr.o_data_row:nth-child(1) td:nth-child(4)");
await expect(customerSelector).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`);

const statusSelector = await page.locator("tr.o_data_row:nth-child(1) td:nth-child(8) span");
await expect(statusSelector).toHaveText("Devis");

await page.getByRole('cell', { name: `${patientName.givenName + ' ' + patientName.familyName}` }).click();
const labTest = await page.locator("td.o_data_cell.o_field_cell.o_list_many2one.o_product_configurator_cell.o_required_modifier>span");
await expect(labTest).toHaveText('Malaria');

await page.goto(`${BAHMNI_URL}`);
await bahmni.goToLabSamples();
await bahmni.discontinueLabOrder();

// verify
await page.goto(`${ODOO_URL}`);
await odoo.searchCustomer();
await expect(customerSelector).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`);
await expect(statusSelector).toHaveText("Annulé");
await page.getByRole('cell', { name: `${patientName.givenName + ' ' + patientName.familyName }` }).first().click();
await expect(page.getByText('Malaria')).not.toBeVisible();
});

test('Ordering a drug for a Bahmni patient creates the corresponding Odoo customer with a filled quotation.', async ({ page }) => {
// setup
await bahmni.goToMedications();

// replay
await bahmni.createMedication();

// verify
await odoo.open();
await odoo.searchCustomer();
const customerSelector = await page.locator("tr.o_data_row:nth-child(1) td:nth-child(4)");
await expect(customerSelector).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`);

const statusSelector = await page.locator("tr.o_data_row:nth-child(1) td:nth-child(8) span");
await expect(statusSelector).toHaveText("Devis");
await page.getByRole('cell', { name: `${patientName.givenName + ' ' + patientName.familyName}` }).click();
const drugNameSelector = await page.locator("td.o_data_cell.o_field_cell.o_list_many2one.o_product_configurator_cell.o_required_modifier>span");
await expect(drugNameSelector).toContainText('Aspirine Co 81mg');
});


test('Editing the details of a Bahmni patient with a synced drug order edits the corresponding Odoo customer details.', async ({ page }) => {
// setup
await bahmni.goToMedications();

// replay
await bahmni.createMedication();

await odoo.open();
await expect(page).toHaveURL(/.*web/);
await odoo.searchCustomer();
const customerSelector = await page.locator("tr.o_data_row:nth-child(1) td:nth-child(4)");
await expect(customerSelector).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`);

await page.goto(`${BAHMNI_URL}`);
await bahmni.updatePatientDetails();

// verify
await page.goto(`${ODOO_URL}`);
await odoo.searchCustomer();
const updatedCustomer = await page.locator("tr.o_data_row:nth-child(1) td:nth-child(4)");
await expect(updatedCustomer).toHaveText(`${patientName.updatedGivenName}` + ' ' + `${patientName.familyName}`);
});

test('Revising a synced OpenMRS drug order edits the corresponding Odoo quotation line.', async ({ page }) => {
// setup
await bahmni.goToMedications();

// replay
await bahmni.createMedication();

await odoo.open();
await expect(page).toHaveURL(/.*web/);
await odoo.searchCustomer();
const customerSelector = await page.locator("tr.o_data_row:nth-child(1) td:nth-child(4)");
await expect(customerSelector).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`);
await page.getByRole('cell', { name: `${patientName.givenName + ' ' + patientName.familyName }` }).click();
const medicationDescrptionSelector = await page.locator("td.o_data_cell.o_field_cell.o_list_text.o_section_and_note_text_cell.o_required_modifier span");
const drugNameSelector = await page.locator("td.o_data_cell.o_field_cell.o_list_many2one.o_product_configurator_cell.o_required_modifier>span");
await expect(drugNameSelector).toContainText('Aspirine Co 81mg');
await expect(medicationDescrptionSelector).toContainText('Aspirine Co 81mg | 560.0 Ampoule(s) | 2.0 Application(s) - Q3H - 5 Semaine(s)');

await page.goto(`${BAHMNI_URL}`);
await bahmni.goToMedications();
await bahmni.editMedicationDetails();

// verify
await page.goto(`${ODOO_URL}`);
await odoo.searchCustomer();
await page.getByRole('cell', { name: `${patientName.givenName + ' ' + patientName.familyName }` }).click();
await expect(drugNameSelector).toContainText('Aspirine Co 81mg');
await expect(medicationDescrptionSelector).toContainText('Aspirine Co 81mg | 120.0 Comprime(s) | 4.0 Comprime(s) - Q4H - 5 Jour(s)');
});

test('Discontinuing a synced Bahmni drug order for an Odoo customer with a single quotation line removes the corresponding quotation.', async ({ page }) => {
// setup
await bahmni.goToMedications();

// replay
await bahmni.createMedication();

await odoo.open();
await expect(page).toHaveURL(/.*web/);
await odoo.searchCustomer();
const customerSelector = await page.locator("tr.o_data_row:nth-child(1) td:nth-child(4)");
await expect(customerSelector).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`);

const statusSelector = await page.locator("tr.o_data_row:nth-child(1) td:nth-child(8) span");
await expect(statusSelector).toHaveText("Devis");

await page.getByRole('cell', { name: `${patientName.givenName + ' ' + patientName.familyName }` }).click();
const medicationDescrptionSelector = await page.locator("td.o_data_cell.o_field_cell.o_list_text.o_section_and_note_text_cell.o_required_modifier span");
const drugNameSelector = await page.locator("td.o_data_cell.o_field_cell.o_list_many2one.o_product_configurator_cell.o_required_modifier>span");
await expect(drugNameSelector).toContainText('Aspirine Co 81mg');
await expect(medicationDescrptionSelector).toContainText('Aspirine Co 81mg | 560.0 Ampoule(s) | 2.0 Application(s) - Q3H - 5 Semaine(s)');
await page.goto(`${BAHMNI_URL}`);
await bahmni.goToMedications();
await bahmni.discontinueMedication();

// verify
await page.goto(`${ODOO_URL}`);
await odoo.searchCustomer();
await expect(customerSelector).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`);
await expect(statusSelector).toHaveText('Annulé');
await page.getByRole('cell', { name: `${patientName.givenName + ' ' + patientName.familyName }` }).click();
await expect(page.getByText('Aspirine Co 81mg')).not.toBeVisible();
});

test.afterEach(async ({ page }) => {
await bahmni.voidPatient();
await page.close();
Expand Down
1 change: 1 addition & 0 deletions e2e/tests/lab-orders.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ test('Create, revise and discontinue lab tests.', async ({ page }) => {
await bahmni.registerPatient();

// replay
await bahmni.goToHomePage();
await bahmni.goToLabSamples();
await page.getByText('Blood', { exact: true }).click();
await page.getByText('Malaria').click();
Expand Down
16 changes: 2 additions & 14 deletions e2e/tests/medications.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,9 @@ test('Create, revise and discontinue a drug order.', async ({ page }) => {
await bahmni.registerPatient();

// replay
await bahmni.goToHomePage();
await bahmni.goToMedications();
await page.locator('#drug-name').type('Aspirine Co 81mg');
await page.getByText('Aspirine Co 81mg (Comprime)').click();
await page.locator('#uniform-dose').fill('2');
await page.locator('#uniform-dose-unit').selectOption('string:Application(s)');
await page.locator('#frequency').selectOption('string:Q3H');
await page.locator('#route').selectOption('string:Topique');
await page.locator('#start-date').fill('2024-08-16');
await page.locator('#duration').fill('5');
await page.locator('#duration-unit').selectOption('string:Semaine(s)');
await page.locator('#total-quantity-unit').selectOption('string:Ampoule(s)');
await page.locator('#instructions').selectOption('string:Estomac vide');
await page.locator('#additional-instructions').fill('Take after a meal');
await page.getByRole('button', { name: 'Add' }).click();
await bahmni.saveOrder();
await bahmni.createMedication();

// verify creation
const drugNameSelector = await page.locator('#ordered-drug-orders strong.drug-name').first();
Expand Down
Loading

0 comments on commit b721b57

Please sign in to comment.