diff --git a/e2e/tests/bahmni-odoo-flows.spec.ts b/e2e/tests/bahmni-odoo-flows.spec.ts index e70737b..fcbb507 100644 --- a/e2e/tests/bahmni-odoo-flows.spec.ts +++ b/e2e/tests/bahmni-odoo-flows.spec.ts @@ -1,10 +1,10 @@ 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'; +import { BAHMNI_URL, ODOO_URL } from '../utils/configs/globalSetup'; -let bahmni: Bahmni; let odoo: Odoo; +let bahmni: Bahmni; test.beforeEach(async ({ page }) => { bahmni = new Bahmni(page); @@ -17,43 +17,35 @@ test.beforeEach(async ({ page }) => { await expect(page.getByText(/appointment scheduling/i)).toBeVisible(); await expect(page.getByText(/patient documents/i)).toBeVisible(); await bahmni.registerPatient(); - await bahmni.goToHomePage(); + await bahmni.navigateToPatientDashboard(); }); test('Ordering a lab test for a Bahmni patient creates the corresponding Odoo customer with a filled quotation.', async ({ page }) => { // setup - await bahmni.goToLabSamples(); + await bahmni.navigateToLabSamples(); // 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 expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(4)')).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`); + await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(8) span')).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'); - await expect(labTest).toContainText('Malaria'); + await expect(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')).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(); + await bahmni.navigateToLabSamples(); await bahmni.createLabOrder(); 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 expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(4)')).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`); + await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(8) span')).toHaveText('Devis'); // replay await page.goto(`${BAHMNI_URL}`); @@ -62,66 +54,57 @@ 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)'); - await expect(updatedCustomer).toHaveText(`${patientName.updatedGivenName}` + ' ' + `${patientName.familyName}`); - await expect(statusSelector).toHaveText('Devis'); + await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(4)')).toHaveText(`${patientName.updatedGivenName}` + ' ' + `${patientName.familyName}`); + await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(8) span')).toHaveText('Devis'); }); test('Revising a synced Bahmni lab order edits the corresponding Odoo quotation line.', async ({ page }) => { // setup - await bahmni.goToLabSamples(); + await bahmni.navigateToLabSamples(); await bahmni.createLabOrder(); 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 expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(4)')).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`); + await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(8) span')).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 expect(page.locator('td.o_data_cell.o_field_cell.o_list_many2one.o_product_configurator_cell.o_required_modifier>span')).toHaveText('Malaria'); // replay - await page.goto(`${BAHMNI_URL}`); - await bahmni.goToLabSamples(); + await bahmni.navigateToPatientDashboard(); + await bahmni.navigateToLabSamples(); 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 expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(4)')).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`); + await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(8) span')).toHaveText('Devis'); await page.getByRole('cell', { name: `${patientName.givenName + ' ' + patientName.familyName }` }).first().click(); - await expect(labTest).not.toContainText('Malaria'); - await expect(labTest).toHaveText('Hematocrite'); + await expect(page.locator('td.o_data_cell.o_field_cell.o_list_many2one.o_product_configurator_cell.o_required_modifier>span')).not.toHaveText('Malaria'); + await expect(page.locator('td.o_data_cell.o_field_cell.o_list_many2one.o_product_configurator_cell.o_required_modifier>span')).toHaveText('Hematocrite'); }); test('Discontinuing a synced Bahmni lab order edits the corresponding Odoo quotation line.', async ({ page }) => { // setup - await bahmni.goToLabSamples(); + await bahmni.navigateToLabSamples(); await bahmni.createLabOrder(); 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 expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(4)')).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`); + await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(8) span')).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 expect(page.locator('td.o_data_cell.o_field_cell.o_list_many2one.o_product_configurator_cell.o_required_modifier>span')).toHaveText('Malaria'); // replay - await page.goto(`${BAHMNI_URL}`); - await bahmni.goToLabSamples(); + await bahmni.navigateToPatientDashboard(); + await bahmni.navigateToLabSamples(); 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 expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(4)')).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`); + await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(8) span')).toHaveText('Annulé'); await page.getByRole('cell', { name: `${patientName.givenName + ' ' + patientName.familyName }` }).first().click(); await expect(page.getByText('Malaria')).not.toBeVisible(); }); @@ -136,14 +119,10 @@ 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)'); - 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 expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(4)')).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`); + await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(8) span')).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'); + await expect(page.locator('td.o_data_cell.o_field_cell.o_list_many2one.o_product_configurator_cell.o_required_modifier>span')).toContainText('Aspirine Co 81mg'); }); @@ -152,10 +131,8 @@ test('Editing the details of a Bahmni patient with a synced drug order edits the await bahmni.navigateToMedications(); 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 expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(4)')).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`); // replay await page.goto(`${BAHMNI_URL}`); @@ -164,8 +141,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)'); - await expect(updatedCustomer).toHaveText(`${patientName.updatedGivenName}` + ' ' + `${patientName.familyName}`); + await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(4)')).toHaveText(`${patientName.updatedGivenName}` + ' ' + `${patientName.familyName}`); }); test('Revising a synced OpenMRS drug order edits the corresponding Odoo quotation line.', async ({ page }) => { @@ -173,18 +149,14 @@ test('Revising a synced OpenMRS drug order edits the corresponding Odoo quotatio await bahmni.navigateToMedications(); 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 expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(4)')).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 expect(page.locator('td.o_data_cell.o_field_cell.o_list_many2one.o_product_configurator_cell.o_required_modifier>span')).toContainText('Aspirine Co 81mg'); + await expect(page.locator('td.o_data_cell.o_field_cell.o_list_text.o_section_and_note_text_cell.o_required_modifier span')).toContainText('Aspirine Co 81mg | 560.0 Ampoule(s) | 2.0 Application(s) - Q3H - 5 Semaine(s)'); // replay - await page.goto(`${BAHMNI_URL}`); + await bahmni.navigateToPatientDashboard(); await bahmni.navigateToMedications(); await bahmni.editMedicationDetails(); @@ -192,8 +164,8 @@ test('Revising a synced OpenMRS drug order edits the corresponding Odoo quotatio 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)'); + await expect(page.locator('td.o_data_cell.o_field_cell.o_list_many2one.o_product_configurator_cell.o_required_modifier>span')).toContainText('Aspirine Co 81mg'); + await expect(page.locator('td.o_data_cell.o_field_cell.o_list_text.o_section_and_note_text_cell.o_required_modifier span')).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 }) => { @@ -201,28 +173,23 @@ test('Discontinuing a synced Bahmni drug order for an Odoo customer with a singl await bahmni.navigateToMedications(); 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 expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(4)')).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`); + await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(8) span')).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 expect(page.locator('td.o_data_cell.o_field_cell.o_list_many2one.o_product_configurator_cell.o_required_modifier>span')).toContainText('Aspirine Co 81mg'); + await expect(page.locator('td.o_data_cell.o_field_cell.o_list_text.o_section_and_note_text_cell.o_required_modifier span')).toContainText('Aspirine Co 81mg | 560.0 Ampoule(s) | 2.0 Application(s) - Q3H - 5 Semaine(s)'); // replay - await page.goto(`${BAHMNI_URL}`); + await bahmni.navigateToPatientDashboard(); await bahmni.navigateToMedications(); 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 expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(4)')).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`); + await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(8) span')).toHaveText('Annulé'); await page.getByRole('cell', { name: `${patientName.givenName + ' ' + patientName.familyName }` }).click(); await expect(page.getByText('Aspirine Co 81mg')).not.toBeVisible(); }); diff --git a/e2e/tests/diagnosis.spec.ts b/e2e/tests/diagnosis.spec.ts index 5d0f14d..20ef198 100644 --- a/e2e/tests/diagnosis.spec.ts +++ b/e2e/tests/diagnosis.spec.ts @@ -20,12 +20,13 @@ test('Create and revise a diagnosis.', async ({ page }) => { await bahmni.registerPatient(); // replay + await bahmni.navigateToPatientDashboard(); await bahmni.navigateToDiagnosis(); 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 bahmni.saveOrder(); + await bahmni.save(); // verify creation await page.locator('#dashboard-link span.patient-name').click(); @@ -41,7 +42,7 @@ test('Create and revise a diagnosis.', async ({ page }) => { await diagnosisOrderButton.waitFor({ state: 'visible' }); await diagnosisOrderButton.focus(); await diagnosisOrderButton.click(); - await bahmni.saveOrder(); + await bahmni.save(); 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); diff --git a/e2e/tests/lab-orders.spec.ts b/e2e/tests/lab-orders.spec.ts index 9de941e..9d23d94 100644 --- a/e2e/tests/lab-orders.spec.ts +++ b/e2e/tests/lab-orders.spec.ts @@ -19,8 +19,8 @@ test('Create, revise and discontinue lab tests.', async ({ page }) => { await bahmni.registerPatient(); // replay - await bahmni.goToHomePage(); - await bahmni.goToLabSamples(); + await bahmni.navigateToPatientDashboard(); + await bahmni.navigateToLabSamples(); await page.getByText('Blood', { exact: true }).click(); await page.getByText('Malaria').click(); await page.getByText('Urine').click(); @@ -31,7 +31,7 @@ test('Create, revise and discontinue lab tests.', async ({ page }) => { await page.getByText('Bacteries').click(); await page.getByText('Sputum').click(); await page.getByText('Serial sputum bacilloscopy').click(); - await bahmni.saveOrder(); + await bahmni.save(); // verify creation await page.locator('#dashboard-link span.patient-name').click(); @@ -52,7 +52,7 @@ test('Create, revise and discontinue lab tests.', async ({ page }) => { await page.getByText('Urine Colour').click(); await page.getByText('Stool', { exact: true }).click(); await page.getByText('Stool Parasites').click(); - await bahmni.saveOrder(); + await bahmni.save(); // verify revision await page.locator('#dashboard-link span.patient-name').click(); @@ -71,7 +71,7 @@ test('Create, revise and discontinue lab tests.', async ({ page }) => { await page.locator('#selected-orders li').filter({ hasText: 'Blood Sugar' }).locator('i').nth(1).click(); await page.locator('#selected-orders li').filter({ hasText: 'Urine Colour' }).locator('i').nth(1).click(); await page.locator('#selected-orders li').filter({ hasText: 'Stool Colour' }).locator('i').nth(1).click(); - await bahmni.saveOrder(); + await bahmni.save(); await page.locator('#dashboard-link span.patient-name').click(); await expect(page.locator('#Lab-Orders').getByText('Blood Sugar')).not.toBeVisible(); await expect(page.locator('#Lab-Orders').getByText('Urine Colour')).not.toBeVisible(); diff --git a/e2e/tests/medications.spec.ts b/e2e/tests/medications.spec.ts index b89af2b..9f4ccea 100644 --- a/e2e/tests/medications.spec.ts +++ b/e2e/tests/medications.spec.ts @@ -19,7 +19,7 @@ test('Create, revise and discontinue a drug order.', async ({ page }) => { await bahmni.registerPatient(); // replay - await bahmni.goToHomePage(); + await bahmni.navigateToPatientDashboard(); await bahmni.navigateToMedications(); await bahmni.createMedication(); @@ -45,7 +45,7 @@ test('Create, revise and discontinue a drug order.', async ({ page }) => { await page.locator('#uniform-dose-unit').selectOption('string:Comprime(s)'); await page.locator('#route').selectOption('string:Inhalation'); await page.getByRole('button', { name: 'Add' }).click(); - await bahmni.saveOrder(); + await bahmni.save(); await expect(medicationDetailsSelector).not.toContainText('2 Application(s)'); await expect(medicationDetailsSelector).toContainText('4 Comprime(s)'); await expect(medicationDetailsSelector).not.toContainText('Q3H'); @@ -57,7 +57,7 @@ test('Create, revise and discontinue a drug order.', async ({ page }) => { await expect(drugNameSelector).toContainText('Aspirine Co 81mg (Comprime)'); await page.getByRole('button', { name: 'Stop' }).first().click(); await page.getByPlaceholder('Notes').fill('Patient allergic to medicine'); - await bahmni.saveOrder(); + await bahmni.save(); await page.locator('#dashboard-link span.patient-name').click(); const medicationStatus = await page.locator('#dashboard-treatments span.discontinued-text').first(); await expect(medicationStatus).toContainText('Stopped'); diff --git a/e2e/tests/observation-forms.spec.ts b/e2e/tests/observation-forms.spec.ts new file mode 100644 index 0000000..c281dc7 --- /dev/null +++ b/e2e/tests/observation-forms.spec.ts @@ -0,0 +1,70 @@ +import { test, expect } from '@playwright/test'; +import { Bahmni } from '../utils/functions/bahmni'; + +let bahmni: Bahmni; + +test.beforeEach(async ({ page }) => { + bahmni = new Bahmni(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('Anthropometry form should save observations.', async ({ page }) => { + // setup + await bahmni.registerPatient(); + + // replay + await bahmni.navigateToPatientDashboard(); + await bahmni.navigateToForms(); + await page.getByRole('button', { name: 'Anthropométrie' }).click(); + await expect(page.getByText('Anthropométrie added successfully')).toBeVisible(); + await bahmni.fillAnthropometryForm(); + + // verify + await page.locator('#dashboard-link span.patient-name').click(); + await expect(page.locator('a.visit')).toBeVisible(); + await page.locator('a.visit').click(); + await expect(page.locator('#observationSection h2')).toHaveText('Observations'); + await expect(page.locator('#observationSection').getByText('BMI Data')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('22.49')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('BMI Status Data')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Normal')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Height')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('170')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Weight')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('65')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Head Circumference')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('23')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Abdominal Diameter')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('25.5')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Mid-Upper Arm Circumference')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('24', {exact: true})).toBeVisible(); +}); + +test('Gynecological ultrasound form should save observations.', async ({ page }) => { + // setup + await bahmni.registerPatient(); + + // replay + await bahmni.navigateToPatientDashboard(); + await bahmni.navigateToForms(); + await page.getByRole('button', { name: 'Echographie gynécologique' }).click(); + await expect(page.getByText('Echographie gynécologique added successfully')).toBeVisible(); + await bahmni.fillGynecologicalUltrasoundForm(); + + // verify + await page.locator('#dashboard-link span.patient-name').click(); + await expect(page.locator('a.visit')).toBeVisible(); + await page.locator('a.visit').click(); + await expect(page.locator('div:nth-child(2) span.value-text-only').getByText('Normal left ovary. The right ovary contains a complex mass. No free fluid in the pelvis.')).toBeVisible(); +}); + +test.afterEach(async ({ page }) => { + await bahmni.voidPatient(); + await page.close(); +}); diff --git a/e2e/utils/functions/bahmni.ts b/e2e/utils/functions/bahmni.ts index fe757fc..552b477 100644 --- a/e2e/utils/functions/bahmni.ts +++ b/e2e/utils/functions/bahmni.ts @@ -25,6 +25,7 @@ export class Bahmni { await this.page.locator('#password').fill(`${process.env.BAHMNI_PASSWORD}`); await this.page.locator('#location').selectOption('object:7'); await this.page.getByRole('button', { name: 'Login' }).click(); + await expect(this.page).toHaveURL(/.*home/); } async registerPatient() { @@ -62,11 +63,12 @@ export class Bahmni { await this.page.locator('#givenName').fill(`${patientName.updatedGivenName}`); await this.page.getByRole('button', { name: 'Save' }).click(); patientName.givenName = `${patientName.updatedGivenName}`; - await delay(3000); + await delay(6000); }; async voidPatient() { await this.page.goto(`${BAHMNI_URL}/openmrs/admin/patients/index.htm`); + await expect(this.page.getByPlaceholder(' ')).toBeVisible(); await this.page.getByPlaceholder(' ').type(`${patientName.familyName}`); await this.page.locator('#openmrsSearchTable tbody tr.odd td:nth-child(1)').click(); await this.page.locator('input[name="voidReason"]').fill('Void patient created by smoke test'); @@ -75,9 +77,7 @@ export class Bahmni { await expect(message?.includes('This patient has been deleted')).toBeTruthy(); } - async goToLabSamples() { - await this.page.getByRole('link', { name: 'Clinical' }).click(); - await this.searchPatient(); + async navigateToLabSamples() { await this.page.locator('#view-content :nth-child(1).btn--success').click(); await this.page.locator('#opd-tabs').getByText('Orders').click(); await expect(this.page.getByText('Lab Samples')).toBeVisible(); @@ -86,38 +86,55 @@ export class Bahmni { async createLabOrder() { await this.page.getByText('Blood', { exact: true }).click(); await this.page.getByText('Malaria').click(); - await this.saveOrder(); + await this.save(); } async reviseLabOrder() { await this.page.getByText('Blood', { exact: true }).click(); await this.page.locator('#selected-orders li').filter({ hasText: 'Malaria' }).locator('i').nth(1).click(); await this.page.getByText('Hematocrit').click(); - await this.saveOrder(); + await this.save(); } async discontinueLabOrder() { await this.page.getByText('Blood', { exact: true }).click(); await this.page.locator('#selected-orders li').filter({ hasText: 'Malaria' }).locator('i').nth(1).click(); - await this.saveOrder(); + await this.save(); } - async goToHomePage() { + async navigateToPatientDashboard() { await this.page.goto(`${BAHMNI_URL}/bahmni/home`); - await expect(this.page).toHaveURL(/.*home/); + await this.page.getByRole('link', { name: 'Clinical' }).click(); + await this.searchPatient(); + } + + async navigateToForms() { + await this.page.locator('#view-content :nth-child(1).btn--success').click(); + await expect(this.page.getByRole('button', { name: 'Add New Obs Form' })).toBeVisible(); + await this.page.getByRole('button', { name: 'Add New Obs Form' }).click(); + } + + async fillAnthropometryForm() { + await this.page.locator('input[type=number]').nth(0).fill('170'); + await this.page.locator('input[type=number]').nth(1).fill('65'); + await this.page.locator('input[type=number]').nth(2).fill('23'); + await this.page.locator('input[type=number]').nth(3).fill('25.5'); + await this.page.locator('input[type=number]').nth(4).fill('24'); + await this.save(); + } + + async fillGynecologicalUltrasoundForm() { + await expect(this.page.locator('div.obs-control-field textarea')).toBeVisible(); + await this.page.locator('div.obs-control-field textarea').fill('Normal left ovary. The right ovary contains a complex mass. No free fluid in the pelvis.'); + await this.save(); } async navigateToDiagnosis() { - 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 navigateToMedications() { - 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('Medications').click(); await expect(this.page.getByText('Order Drug')).toBeVisible(); @@ -139,7 +156,7 @@ export class Bahmni { await this.page.locator('#additional-instructions').fill('Take after a meal'); await expect(this.page.locator('#quantity')).toHaveValue('560'); await this.page.getByRole('button', { name: 'Add' }).click(); - await this.saveOrder(); + await this.save(); } async editMedicationDetails() { @@ -150,19 +167,19 @@ export class Bahmni { await this.page.locator('#uniform-dose-unit').selectOption('string:Comprime(s)'); await this.page.locator('#route').selectOption('string:Inhalation'); await this.page.getByRole('button', { name: 'Add' }).click(); - await this.saveOrder(); + await this.save(); } async discontinueMedication() { await this.page.getByRole('button', { name: 'Stop' }).first().click(); await this.page.getByPlaceholder('Notes').fill('Patient allergic to medicine'); - await this.saveOrder(); + await this.save(); await this.page.locator('#dashboard-link span.patient-name').click(); const medicationStatus = await this.page.locator('#dashboard-treatments span.discontinued-text').first(); await expect(medicationStatus).toContainText('Stopped'); } - async saveOrder() { + async save() { await this.page.getByRole('button', { name: 'Save' }).click(); await expect(this.page.getByText('Saved', {exact: true})).toBeVisible(); await delay(5000); diff --git a/e2e/utils/functions/odoo.ts b/e2e/utils/functions/odoo.ts index 93485e0..01f33c8 100644 --- a/e2e/utils/functions/odoo.ts +++ b/e2e/utils/functions/odoo.ts @@ -1,5 +1,5 @@ -import { Page } from '@playwright/test'; -import { patientName } from './bahmni'; +import { expect, Page } from '@playwright/test'; +import { delay, patientName } from './bahmni'; import { ODOO_URL } from '../configs/globalSetup'; export class Odoo { @@ -10,12 +10,15 @@ export class Odoo { await this.page.getByPlaceholder('Email').fill(`${process.env.ODOO_USERNAME}`); await this.page.getByPlaceholder('Password').fill(`${process.env.ODOO_PASSWORD}`); await this.page.locator('button[type="submit"]').click(); + await expect(this.page).toHaveURL(/.*web/); } async searchCustomer() { await this.page.locator("//a[contains(@class, 'full')]").click(); + await delay(2000); await this.page.locator('ul.o_menu_apps a:nth-child(2)').click(); - await this.page.locator('input.o_searchview_input').fill(`${patientName.givenName + ' ' + patientName.familyName}`); + await expect(this.page.locator('.breadcrumb-item')).toHaveText('Devis'); + await this.page.locator('input.o_searchview_input').type(`${patientName.givenName + ' ' + patientName.familyName}`); await this.page.locator('input.o_searchview_input').press('Enter'); } } diff --git a/package.json b/package.json index c52ced8..73fb0d0 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 observation-forms" }, "keywords": [], "devDependencies": { diff --git a/playwright.config.ts b/playwright.config.ts index 2a7aa43..5e52603 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -23,6 +23,9 @@ const config: PlaywrightTestConfig = { name: 'chromium', use: { ...devices['Desktop Chromium'], + viewport: { width: 1920, height: 1080 }, + screenshot: 'only-on-failure', + video: 'on' }, }, ],