Skip to content

Commit

Permalink
C2C-341: E2E test for diagnosis workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
kdaud committed Aug 30, 2024
1 parent a50ad7c commit 17789f5
Show file tree
Hide file tree
Showing 5 changed files with 129 additions and 38 deletions.
66 changes: 33 additions & 33 deletions e2e/tests/bahmni-odoo-flows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ test('Ordering a lab test for a Bahmni patient creates the corresponding Odoo cu
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)");
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");
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("tr:nth-child(1) td.o_data_cell.o_field_cell.o_list_text.o_section_and_note_text_cell.o_required_modifier");
const labTest = await page.locator('tr:nth-child(1) td.o_data_cell.o_field_cell.o_list_text.o_section_and_note_text_cell.o_required_modifier');
await expect(labTest).toContainText('Malaria');
});

Expand All @@ -50,10 +50,10 @@ test('Editing the details of a Bahmni patient with a synced lab order edits the
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)");
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");
const statusSelector = await page.locator('tr.o_data_row:nth-child(1) td:nth-child(8) span');
await expect(statusSelector).toHaveText('Devis');

// replay
await page.goto(`${BAHMNI_URL}`);
Expand All @@ -62,9 +62,9 @@ test('Editing the details of a Bahmni patient with a synced lab order edits the
// 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)");
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");
await expect(statusSelector).toHaveText('Devis');
});

test('Revising a synced Bahmni lab order edits the corresponding Odoo quotation line.', async ({ page }) => {
Expand All @@ -74,12 +74,12 @@ test('Revising a synced Bahmni lab order edits the corresponding Odoo quotation
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)");
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");
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");
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');

// replay
Expand All @@ -91,7 +91,7 @@ test('Revising a synced Bahmni lab order edits the corresponding Odoo quotation
await page.goto(`${ODOO_URL}`);
await odoo.searchCustomer();
await expect(customerSelector).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`);
await expect(statusSelector).toHaveText("Devis");
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');
Expand All @@ -104,12 +104,12 @@ test('Discontinuing a synced Bahmni lab order edits the corresponding Odoo quota
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)");
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");
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");
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');

// replay
Expand All @@ -121,7 +121,7 @@ test('Discontinuing a synced Bahmni lab order edits the corresponding Odoo quota
await page.goto(`${ODOO_URL}`);
await odoo.searchCustomer();
await expect(customerSelector).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`);
await expect(statusSelector).toHaveText("Annulé");
await expect(statusSelector).toHaveText('Annulé');
await page.getByRole('cell', { name: `${patientName.givenName + ' ' + patientName.familyName }` }).first().click();
await expect(page.getByText('Malaria')).not.toBeVisible();
});
Expand All @@ -136,13 +136,13 @@ test('Ordering a drug for a Bahmni patient creates the corresponding Odoo custom
// verify
await odoo.open();
await odoo.searchCustomer();
const customerSelector = await page.locator("tr.o_data_row:nth-child(1) td:nth-child(4)");
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");
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");
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');
});

Expand All @@ -154,7 +154,7 @@ test('Editing the details of a Bahmni patient with a synced drug order edits the
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)");
const customerSelector = await page.locator('tr.o_data_row:nth-child(1) td:nth-child(4)');
await expect(customerSelector).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`);

// replay
Expand All @@ -164,7 +164,7 @@ test('Editing the details of a Bahmni patient with a synced drug order edits the
// 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)");
const updatedCustomer = await page.locator('tr.o_data_row:nth-child(1) td:nth-child(4)');
await expect(updatedCustomer).toHaveText(`${patientName.updatedGivenName}` + ' ' + `${patientName.familyName}`);
});

Expand All @@ -175,11 +175,11 @@ test('Revising a synced OpenMRS drug order edits the corresponding Odoo quotatio
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)");
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");
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)');

Expand All @@ -203,13 +203,13 @@ test('Discontinuing a synced Bahmni drug order for an Odoo customer with a singl
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)");
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");
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");
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)');

Expand Down
81 changes: 81 additions & 0 deletions e2e/tests/diagnosis.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@

import { test, expect } from '@playwright/test';
import { Odoo } from '../utils/functions/odoo';
import { Bahmni } from '../utils/functions/bahmni';

let bahmni: Bahmni;
let odoo: Odoo;

test.beforeEach(async ({ page }) => {
bahmni = new Bahmni(page);
odoo = new Odoo(page);

await bahmni.login();
await expect(page.getByText(/registration/i)).toBeVisible();
await expect(page.getByText(/linical/i)).toBeVisible();
await expect(page.getByText(/admin/i)).toBeVisible();
await expect(page.getByText(/appointment scheduling/i)).toBeVisible();
await expect(page.getByText(/patient documents/i)).toBeVisible();
});

test('Create, revise and discontinue diagnosis.', async ({ page }) => {
// setup
await bahmni.registerPatient();

// replay
await bahmni.goToDiagnosis();
await page.locator('#name-0').fill('Candidiasis (B37.9)');
await page.getByText('Candidiasis (B37.9)').click();
await page.locator('#order-0').getByRole('button', { name: /primary/i }).click();
await page.locator('#certainty-0').getByRole('button', { name: /confirmed/i }).click();

// await page.locator('#name-1').fill('Diphtheria (A36.9)');
// await page.getByText('Diphtheria (A36.9)').click();
// await page.locator('#order-1').getByRole('button', { name: /secondary/i }).click();
// await page.locator('#certainty-1').getByRole('button', { name: /presumed/i }).click();
await bahmni.saveOrder();

// verify creation
await page.locator('#dashboard-link span.patient-name').click();

await expect(page.locator('#diagnosisName')).toContainText(/candidiasis/i);
await expect(page.locator('#order')).toContainText(/primary/i);
await expect(page.locator('#certainty')).toContainText(/confirmed/i);

// verify revision
await page.locator('#view-content :nth-child(1).btn--success').click();
await page.locator('#opd-tabs').getByText('Diagnosis').click();
await page.locator('i.fa.fa-edit').first().click();
const diagnosisOrder = await page.getByRole('button', { name: 'SECONDARY' }).nth(1);
await diagnosisOrder.waitFor({ state: 'visible' }); // Wait for button to be visible
await diagnosisOrder.focus();
await diagnosisOrder.click();
await bahmni.saveOrder();
// await page.locator('i.fa.fa-edit').nth(1).click();
// const button2 = await page.getByRole('button', { name: 'PRIMARY' }).nth(1);
// await button2.waitFor({ state: 'visible' }); // Wait for button to be visible
// await button2.focus();
// await button2.click();
// await bahmni.saveOrder();
await page.locator('#dashboard-link span.patient-name').click();
await expect(page.locator('#diagnosisName')).toContainText(/candidiasis/i);
await expect(page.locator('#order')).toContainText(/secondary/i);
await expect(page.locator('#certainty')).toContainText(/confirmed/i);
/*
// verify cancellation
await page.locator('#view-content :nth-child(1).btn--success').click();
await page.locator('#opd-tabs').getByText('Diagnosis').click();
await page.locator('#deleteDiagnosis-0').click();
page.once('dialog', dialog => {
console.log(`Dialog message: ${dialog.message()}`);
dialog.dismiss().catch(() => {});
});
await page.locator('#dashboard-link span.patient-name').click();
await expect(page.getByText(/no diagnosis for this patient/i)).toBeVisible();
*/
});

test.afterEach(async ({ page }) => {
await bahmni.voidPatient();
await page.close();
});
10 changes: 9 additions & 1 deletion e2e/utils/functions/bahmni.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,18 @@ export class Bahmni {
}

async goToHomePage() {
await this.page.goto(`${BAHMNI_URL}/bahmni/home/`);
await this.page.goto(`${BAHMNI_URL}/bahmni/home`);
await expect(this.page).toHaveURL(/.*home/);
}

async goToDiagnosis() {
await this.page.locator('i.fa.fa-home').click();
await this.page.getByRole('link', { name: 'Clinical' }).click();
await this.searchPatient();
await this.page.locator('#view-content :nth-child(1).btn--success').click();
await this.page.locator('#opd-tabs').getByText('Diagnosis').click();
}

async goToMedications() {
await this.page.getByRole('link', { name: 'Clinical' }).click();
await this.searchPatient();
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"license": "MPL-2.0",
"description": "These are end-to-end automated tests covering Bahmni distro C2C workflows",
"scripts": {
"e2e-tests-c2c": "npx playwright test"
"e2e-tests-c2c": "npx playwright test diagnosis"
},
"keywords": [],
"devDependencies": {
Expand Down
8 changes: 5 additions & 3 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ const config: PlaywrightTestConfig = {
name: 'chromium',
use: {
...devices['Desktop Chromium'],
launchOptions: {
slowMo: 500
}
// launchOptions: {
// slowMo: 500
// },
video: 'on',
screenshot: 'only-on-failure'
},
},
],
Expand Down

0 comments on commit 17789f5

Please sign in to comment.