diff --git a/e2e/tests/bahmni-odoo-flows.spec.ts b/e2e/tests/bahmni-odoo-flows.spec.ts index d7e547f..f998ad9 100644 --- a/e2e/tests/bahmni-odoo-flows.spec.ts +++ b/e2e/tests/bahmni-odoo-flows.spec.ts @@ -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'); }); @@ -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}`); @@ -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 }) => { @@ -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 @@ -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'); @@ -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 @@ -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(); }); @@ -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'); }); @@ -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 @@ -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}`); }); @@ -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)'); @@ -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)'); diff --git a/e2e/tests/diagnosis.spec.ts b/e2e/tests/diagnosis.spec.ts new file mode 100644 index 0000000..f4662f9 --- /dev/null +++ b/e2e/tests/diagnosis.spec.ts @@ -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(); +}); \ No newline at end of file diff --git a/e2e/utils/functions/bahmni.ts b/e2e/utils/functions/bahmni.ts index 9b39f4e..468f8d0 100644 --- a/e2e/utils/functions/bahmni.ts +++ b/e2e/utils/functions/bahmni.ts @@ -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(); diff --git a/package.json b/package.json index c52ced8..419c3c0 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/playwright.config.ts b/playwright.config.ts index 23720b1..34657c2 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -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' }, }, ],