diff --git a/e2e/tests/bahmni-odoo-flows.spec.ts b/e2e/tests/bahmni-odoo-flows.spec.ts index e70737b..790e1ef 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,34 @@ 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 +53,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 +118,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 +130,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 +140,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 +148,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 +163,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,32 +172,27 @@ 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(); }); - +*/ test.afterEach(async ({ page }) => { await bahmni.voidPatient(); await page.close(); 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..9bc9b79 --- /dev/null +++ b/e2e/tests/observation-forms.spec.ts @@ -0,0 +1,759 @@ +import { test, expect } from '@playwright/test'; +import { Bahmni, delay } 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(); + await bahmni.registerPatient(); + await bahmni.navigateToPatientDashboard(); +}); + +test('Anthropometry form should save observations.', async ({ page }) => { + // setup + await bahmni.navigateToForms(); + await expect(page.getByText('Anthropométrie')).toBeVisible(); + await page.getByRole('button', { name: 'Anthropométrie' }).click(); + await expect(page.getByText('Anthropométrie added successfully')).toBeVisible(); + + // replay + await bahmni.fillAnthropometryForm(); + + // verify + await page.locator('#dashboard-link span.patient-name').click(); + await delay(5000); + 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.navigateToForms(); + await expect(page.getByText('Echographie gynécologique')).toBeVisible(); + await page.getByRole('button', { name: 'Echographie gynécologique' }).click(); + await expect(page.getByText('Echographie gynécologique added successfully')).toBeVisible(); + + // replay + await bahmni.fillGynecologicalUltrasoundForm(); + + // verify + await page.locator('#dashboard-link span.patient-name').click(); + await delay(5000); + await expect(page.locator('a.visit')).toBeVisible(); + await page.locator('a.visit').click(); + await expect(page.getByText('Echographie gynécologique')).toBeVisible(); + 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('Obstetric ultrasound 1 form should save observations.', async ({ page }) => { + // setup + await bahmni.navigateToForms(); + await expect(page.getByText('Echographie obstétricale 1')).toBeVisible(); + await page.getByRole('button', { name: 'Echographie obstétricale 1' }).click(); + await expect(page.getByText('Echographie obstétricale 1 added successfully')).toBeVisible(); + + // replay + await bahmni.fillObstetricUltrasound1Form(); + + // verify + await page.locator('#dashboard-link span.patient-name').click(); + await delay(5000); + await expect(page.locator('a.visit')).toBeVisible(); + await page.locator('a.visit').click(); + await expect(page.getByText('Echographie obstétricale 1')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Confirmed Pregnancy')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Yes')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Confirmed Gestational Age')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Number of Weeks')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('9', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Number of Days')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('64', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Location of pregnancy')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Ovarian Pregnancy')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Number of Fetuses')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('2', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Number of Placenta')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('2', {exact: true}).nth(1)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Localisation de Placenta')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Anterior')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Fetal Heart Rate (120 - 160)')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('155 beats/min')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Risky Pregnancy')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('No').nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Identified complications')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('No').nth(1)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Other observations')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('The two fetuses are growing well.')).toBeVisible(); +}); + +test('Obstetric ultrasound 2 form should save observations.', async ({ page }) => { + // setup + await bahmni.navigateToForms(); + await expect(page.getByText('Echographie obstétricale 2')).toBeVisible(); + await page.getByRole('button', { name: 'Echographie obstétricale 2' }).click(); + await expect(page.getByText('Echographie obstétricale 2 added successfully')).toBeVisible(); + + // replay + await bahmni.fillObstetricUltrasound2Form(); + + // verify + await page.locator('#dashboard-link span.patient-name').click(); + await delay(5000); + await expect(page.locator('a.visit')).toBeVisible(); + await page.locator('a.visit').click(); + await expect(page.getByText('Echographie obstétricale 2')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Number of Fetuses')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('1', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Number of Placenta')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('1', {exact: true}).nth(1)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Fetus Details')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Localisation de Placenta')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Anterior')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Fetal Heart Rate (120 - 160)')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('150 beats/min')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Presentation')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Breech')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Arms')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Normal').nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Legs')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Normal').nth(1)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Brain')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Normal').nth(2)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Heart', {exact: true})).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Normal').nth(3)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Lungs')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Normal').nth(4)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Kidneys')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Not Seen').nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Genitals')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Not Seen').nth(1)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Fetal Sex')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Not Seen').nth(2)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Other observations')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('The fetus is about thirty two weeks.')).toBeVisible(); +}); + +test('Obstetric ultrasound 3 form should save observations.', async ({ page }) => { + // setup + await bahmni.navigateToForms(); + await expect(page.getByText('Echographie obstétricale 3')).toBeVisible(); + await page.getByRole('button', { name: 'Echographie obstétricale 3' }).click(); + await expect(page.getByText('Echographie obstétricale 3 added successfully')).toBeVisible(); + + // replay + await bahmni.fillObstetricUltrasound3Form(); + + // verify + await page.locator('#dashboard-link span.patient-name').click(); + await delay(5000); + await expect(page.locator('a.visit')).toBeVisible(); + await page.locator('a.visit').click(); + await expect(page.getByText('Echographie obstétricale 3')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Number of Fetuses')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('2', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Number of Placenta')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('2', {exact: true}).nth(1)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Localisation de Placenta')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Posterior')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Presentation')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Transverse')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Other observations')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('The two fetuses are in a good growing state.')).toBeVisible(); +}); + +test('Physical examination form should save observations.', async ({ page }) => { + // setup + await bahmni.navigateToForms(); + await expect(page.getByText('Examen physique')).toBeVisible(); + await page.getByRole('button', { name: 'Examen physique' }).click(); + await expect(page.getByText('Examen physique added successfully')).toBeVisible(); + + // replay + await bahmni.fillPhysicalExaminationForm(); + + // verify + await page.locator('#dashboard-link span.patient-name').click(); + await delay(5000); + await expect(page.locator('a.visit')).toBeVisible(); + await page.locator('a.visit').click(); + await expect(page.getByText('Examen physique')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('General Examination')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Normal').nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Cardiovascular Examination', {exact: true})).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Abnormal').nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Cardiovascular Examination Details')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('The blood vessels are very narrow.')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Respiratory Examination')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Normal').nth(1)).toBeVisible() +}); + +test('Means of transportation form should save observations.', async ({ page }) => { + // setup + await bahmni.navigateToForms(); + await expect(page.getByText('Moyen de transport')).toBeVisible(); + await page.getByRole('button', { name: 'Moyen de transport' }).click(); + await expect(page.getByText('Moyen de transport added successfully')).toBeVisible(); + + // replay + await bahmni.fillMeansOfTransportationForm(); + + // verify + await page.locator('#dashboard-link span.patient-name').click(); + await delay(5000); + await expect(page.locator('a.visit')).toBeVisible(); + await page.locator('a.visit').click(); + await expect(page.getByText('Moyen de transport')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Mode of Arrival', { exact: true })).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Minibus')).toBeVisible(); +}); + +test('Family planning form should save observations.', async ({ page }) => { + // setup + await bahmni.navigateToForms(); + await expect(page.getByText('Planification familiale')).toBeVisible(); + await page.getByRole('button', { name: 'Planification familiale' }).click(); + await expect(page.getByText('Planification familiale added successfully')).toBeVisible(); + + // replay + await bahmni.fillFamilyPlanningForm(); + + // verify + await page.locator('#dashboard-link span.patient-name').click(); + await delay(5000); + await expect(page.locator('a.visit')).toBeVisible(); + await page.locator('a.visit').click(); + await expect(page.getByText('Planification familiale')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('FP administred')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Depo Provera Injection')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Quantity Dispensed')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('3', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Type of user')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Existent')).toBeVisible(); +}); + +test('Prenatal consultation form should save observations.', async ({ page }) => { + // setup + await bahmni.navigateToForms(); + await expect(page.getByText('Consultation prénatale')).toBeVisible(); + await page.getByRole('button', { name: 'Consultation prénatale' }).click(); + await expect(page.getByText('Consultation prénatale added successfully')).toBeVisible(); + + // replay + await bahmni.fillPrenatalConsultationForm(); + + // verify + await page.locator('#dashboard-link span.patient-name').click(); + await delay(5000); + await expect(page.locator('a.visit')).toBeVisible(); + await page.locator('a.visit').click(); + await expect(page.getByText('Consultation prénatale')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Visit number')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Three')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Number of Weeks')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('18', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Risky Pregnancy')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('No')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Signs and Symptoms', {exact:true})).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Abdominal pain')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Duration')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('3', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Day(s)')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Fetal Heart Rate (120 - 160)')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('144 beats/min')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Presentation')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Cephalic')).toBeVisible(); +}); + +test('Reference form should save observations.', async ({ page }) => { + // setup + await bahmni.navigateToForms(); + await expect(page.getByText('Référence')).toBeVisible(); + await page.getByRole('button', { name: 'Référence' }).click(); + await expect(page.getByText('Référence added successfully')).toBeVisible(); + + // replay + await bahmni.fillReferenceForm(); + + // verify + await page.locator('#dashboard-link span.patient-name').click(); + await delay(5000); + await expect(page.locator('a.visit')).toBeVisible(); + await page.locator('a.visit').click(); + await expect(page.getByText('Référence')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Referred By')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Doctor Fredric Hanandez')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Health Centre')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Hopital St Jean Limbe')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Referral Notes')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('The patient needs a CT scan due to pregnancy complications.')).toBeVisible(); +}); + +test('TB monitoring form should save observations.', async ({ page }) => { + // setup + await bahmni.navigateToForms(); + await expect(page.getByText('Suivi TB')).toBeVisible(); + await page.getByRole('button', { name: 'Suivi TB' }).click(); + await expect(page.getByText('Suivi TB added successfully')).toBeVisible(); + + // replay + await bahmni.fillTBMonitoringForm(); + + // verify + await page.locator('#dashboard-link span.patient-name').click(); + await delay(5000); + await expect(page.locator('a.visit')).toBeVisible(); + await page.locator('a.visit').click(); + await expect(page.locator('#observationSection').getByText('TB Signs and symptoms')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Cough')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Evening fever')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Loss of appetite')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Weight Loss')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Response to treatment')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Conduct bacteriologic examination of patient\'s sputum or other specimens.')).toBeVisible(); +}); + +test('New case of tuberculosis form should save observations.', async ({ page }) => { + // setup + await bahmni.navigateToForms(); + await expect(page.getByText('Nouveau cas de tuberculose')).toBeVisible(); + await page.getByRole('button', { name: 'Nouveau cas de tuberculose' }).click(); + await expect(page.getByText('Nouveau cas de tuberculose added successfully')).toBeVisible(); + + // replay + await bahmni.fillNewCaseOfTuberculosisForm(); + + // verify + await page.locator('#dashboard-link span.patient-name').click(); + await delay(5000); + await expect(page.locator('a.visit')).toBeVisible(); + await page.locator('a.visit').click(); + await expect(page.getByText('Nouveau cas de tuberculose')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Number of contacts identified')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('16', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Number of contacts with symptoms')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('7', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Contact with positive TB case', {exact: true})).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Yes', {exact: true})).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Number of contact with positive TB cases')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('4', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Index case reference number')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('TB-250')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('BCG scar')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Invisible')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Anatomical site')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Pulmonary')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Treatment history')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Treatment after failure')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('TB Signs and symptoms')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Emanciation')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Cough')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Loss of Appetite')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Evening fever')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('HIV Tested')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('No', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Other observations')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Test other findings.')).toBeVisible(); +}); + +test('Triage form should save observations.', async ({ page }) => { + // setup + await bahmni.navigateToForms(); + await expect(page.getByText('Triage')).toBeVisible(); + await page.getByRole('button', { name: 'Triage' }).click(); + await expect(page.getByText('Triage added successfully')).toBeVisible(); + + // replay + await bahmni.fillTriageForm(); + + // verify + await page.locator('#dashboard-link span.patient-name').click(); + await delay(5000); + await expect(page.locator('a.visit')).toBeVisible(); + await page.locator('a.visit').click(); + await expect(page.getByText('Triage', {exact: true})).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Triage level')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Emergency')).toBeVisible(); +}); + +test('Reason for consultation form should save observations.', async ({ page }) => { + // setup + await bahmni.navigateToForms(); + await expect(page.getByText('Motif de consultation')).toBeVisible(); + await page.getByRole('button', { name: 'Motif de consultation' }).click(); + await expect(page.getByText('Motif de consultation added successfully')).toBeVisible(); + + // replay + await bahmni.fillReasonForConsultationForm(); + + // 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.getByText('Motif de consultation', {exact: true})).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Reason for Consultation', {exact: true})).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Assault by animal suspected of rabies')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Details')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Had contact with a dog that had rabies.')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Duration')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('2', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Time Units')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Day(s)')).toBeVisible(); +}); + +test('Unauthorized departure form should save observations.', async ({ page }) => { + // setup + await bahmni.navigateToForms(); + await expect(page.getByText('Départ non autorisé')).toBeVisible(); + await page.getByRole('button', { name: 'Départ non autorisé' }).click(); + await expect(page.getByText('Départ non autorisé added successfully')).toBeVisible(); + + // replay + await bahmni.fillUnauthorizedDepartureForm(); + + // verify + await page.locator('#dashboard-link span.patient-name').click(); + await delay(5000); + await expect(page.locator('a.visit')).toBeVisible(); + await page.locator('a.visit').click(); + await expect(page.getByText('Départ non autorisé', {exact: true})).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Left without permission')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('No', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Comments')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('The patient switched to using herbal medicine.')).toBeVisible(); +}); + +test('Vital signs form should save observations.', async ({ page }) => { + // setup + await bahmni.navigateToForms(); + await expect(page.getByText('Signes vitaux')).toBeVisible(); + await page.getByRole('button', { name: 'Signes vitaux' }).click(); + await expect(page.getByText('Signes vitaux added successfully')).toBeVisible(); + + // replay + await bahmni.fillVitalSignsForm(); + + // verify + await page.locator('#dashboard-link span.patient-name').click(); + await delay(5000); + await expect(page.locator('a.visit')).toBeVisible(); + await page.locator('a.visit').click(); + await expect(page.getByText('Signes vitaux', {exact: true})).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Vital Signs')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Pain Scale')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('8', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Pulse (60 - 160)')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('136 beats/min', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('T (36.7 - 37.5)')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('37.2 C', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('RR (12 - 70)')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('55 breaths/min', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('SaO2 (95 - 100)')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('97 %', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Blood Pressure')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Systolic (90 - 120)')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('115 mmHg', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Diastolic (60 - 80)')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('75 mmHg', {exact: true}).nth(0)).toBeVisible(); +}); + +test('Gynecological examination form should save observations.', async ({ page }) => { + // setup + await bahmni.navigateToForms(); + await expect(page.getByText('Examen gynécologique')).toBeVisible(); + await page.getByRole('button', { name: 'Examen gynécologique' }).click(); + await expect(page.getByText('Examen gynécologique added successfully')).toBeVisible(); + + // replay + await bahmni.fillGynecologicalExaminationForm(); + + // verify + await page.locator('#dashboard-link span.patient-name').click(); + await delay(5000); + await expect(page.locator('a.visit')).toBeVisible(); + await page.locator('a.visit').click(); + await expect(page.getByText('Examen gynécologique', {exact: true})).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Age at Menarche')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('14 Years')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Date of last period')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('15 Sep 24')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Total Number of Pregnancies (Gravidity)')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('5', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Number of abortions')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('0', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Number of Term Pregnancies')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('3', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Gyn complaint', {exact: true})).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Breast problems')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Use of contraception')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Yes', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Contraception', {exact: true})).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Microgynon (plaquette)')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Date', {exact: true})).toBeVisible(); + await expect(page.locator('#observationSection').getByText('16 Sep 23')).toBeVisible(); +}); + +test('Emergency monitoring form should save observations.', async ({ page }) => { + // setup + await bahmni.navigateToForms(); + await expect(page.getByText('Suivi d’urgences')).toBeVisible(); + await page.getByRole('button', { name: 'Suivi d’urgences' }).click(); + await expect(page.getByText('Suivi d’urgences added successfully')).toBeVisible(); + + // replay + await bahmni.fillEmergencyMonitoringForm(); + + // verify + await page.locator('#dashboard-link span.patient-name').click(); + await delay(5000); + await expect(page.locator('a.visit')).toBeVisible(); + await page.locator('a.visit').click(); + await expect(page.getByText('Suivi d’urgences')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Date/Time')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('19 Aug 24 4:30 pm')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Action taken')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Patient put on oxygen.')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Other observations')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Patient recovered from stroke.')).toBeVisible(); +}); + +test('Vaccinations form should save observations.', async ({ page }) => { + // setup + await bahmni.navigateToForms(); + await page.getByPlaceholder('Search Obs Form').type('Vaccinations'); + await expect(page.getByText('Vaccinations', {exact: true})).toBeVisible(); + await page.getByRole('button', { name: 'Vaccinations' }).click(); + await expect(page.getByText('Vaccinations added successfully')).toBeVisible(); + + // replay + await bahmni.fillVaccinationsForm(); + + // verify + await page.locator('#dashboard-link span.patient-name').click(); + await delay(5000); + await expect(page.locator('a.visit')).toBeVisible(); + await page.locator('a.visit').click(); + await expect(page.getByText('Vaccinations', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Pentavalent Vaccination')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Sequence number', {exact: true})).toBeVisible(); + await expect(page.locator('#observationSection').getByText('383', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Vaccination date')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('13 Sep 24')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Vaccine Lot Number')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('VLN-26')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Fully vaccinated')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Yes', {exact: true}).nth(0)).toBeVisible(); +}); + +test('Nutrition form should save observations.', async ({ page }) => { + // setup + await bahmni.navigateToForms(); + await expect(page.getByText('Nutrition', {exact: true})).toBeVisible(); + await page.getByRole('button', { name: 'Nutrition' }).click(); + await expect(page.getByText('Nutrition added successfully')).toBeVisible(); + + // replay + await bahmni.fillNutritionForm(); + + // verify + await page.locator('#dashboard-link span.patient-name').click(); + await delay(5000); + await expect(page.locator('a.visit')).toBeVisible(); + await page.locator('a.visit').click(); + await expect(page.getByText('Nutrition', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('First Visit')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('No', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Malnutrition Signs and symptoms', {exact: true})).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Vomiting')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Duration')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Time Units')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('4', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Hour(s)')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Grade of edema')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('++')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Chest Indrawing')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Signs of dehydration')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Moderate')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('State of consciousness')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Passive')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Extremities')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Appearance of the ears')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Ear Discharge')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Oral appearance')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Oral thrush')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Skin appearance')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Scabies')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Lymph Nodes')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Inguinal fold')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Appetite')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Good')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Other Problems')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('No', {exact: true}).nth(2)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Result of the visit')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Follow-up appointment')).toBeVisible(); +}); + +test('Systems review form should save observations.', async ({ page }) => { + // setup + await bahmni.navigateToForms(); + await expect(page.getByText('Examen des systèmes', {exact: true})).toBeVisible(); + await page.getByRole('button', { name: 'Examen des systèmes' }).click(); + await expect(page.getByText('Examen des systèmes added successfully')).toBeVisible(); + + // replay + await bahmni.fillSystemsReviewForm(); + + // verify + await page.locator('#dashboard-link span.patient-name').click(); + await delay(5000); + await expect(page.locator('a.visit')).toBeVisible(); + await page.locator('a.visit').click(); + await expect(page.getByText('Examen des systèmes', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('General Set')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Night sweats')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Fatigue')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Loss of Appetite')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Skin Set')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Rashes')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Dermatological pruritus')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Discolorations')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Head Set')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Headache')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Dizziness')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Mass')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Tongue')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Platypnea')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Ears Set')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Ear Discharge')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Deaf')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Eyes Set')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Eye itching')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Discharge from the eyes')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Conjuctivitis')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Teary eyes')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Visual disturbance')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Nose Set')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Nose Discharge')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Bleeding')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Sinus Congestion')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Mouth and Throat Set')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Missing')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Dysphagia')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Pallet')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Respiratory Set')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Cough')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Orthopnea')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Hemoptysis')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Cardiovascular Set')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Chest Pain')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Lower Extremity Edema')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Paroxysmal Nocturnal Dyspnea')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Dyspnea with Exertion')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Palpitations')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Gastrointestinal', {exact: true})).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Dyschezia')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Abdominal pain')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Hematemesis')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Constipation')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Hematochezia')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Genitourinary Set')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Hesitation')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Dysuria')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Polyuria')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Endocrine Set')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Heat Intolerance')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Hair Problem')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Dry Skin')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Musculoskeletal Set')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Joint Deformity')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Left arm')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Skin and Lymphatic Set')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Lymphadenopathy')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Under the jaw and chin')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Neuropsychiatric and Psychomotor Set')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Memory loss')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Anxiety')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Language Disorder')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Self Care Skill Deficiency')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Motor Skills Disorder')).toBeVisible(); +}); + +test('Health history form should save observations.', async ({ page }) => { + // setup + await bahmni.navigateToForms(); + await expect(page.getByText('Historique de santé', {exact: true})).toBeVisible(); + await page.getByRole('button', { name: 'Historique de santé' }).click(); + await expect(page.getByText('Historique de santé added successfully')).toBeVisible(); + + // replay + await bahmni.fillHealthHistoryForm(); + + // verify + await page.locator('#dashboard-link span.patient-name').click(); + await delay(5000); + await expect(page.locator('a.visit')).toBeVisible(); + await page.locator('a.visit').click(); + await expect(page.getByText('Historique de santé', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Insect bites and stings')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Reason', {exact: true}).first()).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Allergic to insect bites and strings')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Duration')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Time Units')).toBeVisible() + await expect(page.locator('#observationSection').getByText('6', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Month(s')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Health Centre')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Hopital Sacré Coeur Milot')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Current Medication', {exact:true})).toBeVisible(); + await expect(page.locator('#observationSection').getByText('No', {exact: true}).nth(0)).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Self Medication', {exact: true})).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Oral antihistamines')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Personal History', {exact: true})).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Asthma')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Hypertension')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Mental illness')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Cancer')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Hepatitis')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Type 1 diabetes')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Family History', {exact: true})).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Type 2 diabetes')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Tuberculosis')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Sickle-cell anemia')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('History of Trauma')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('No Trauma history')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Past Surgical History')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Colorectal surgery')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Use of alcohol')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Tobacco History Set')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Tobacco use')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Marijuana')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Other Substance')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Heterosexual')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Age at first intercourse')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('26', {exact: true}).nth(0)).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..b67ca01 100644 --- a/e2e/utils/functions/bahmni.ts +++ b/e2e/utils/functions/bahmni.ts @@ -24,25 +24,26 @@ export class Bahmni { await this.page.locator('#username').fill(`${process.env.BAHMNI_USERNAME}`); 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 this.page.getByRole('button', { name: /login/i }).click(); + await expect(this.page).toHaveURL(/.*home/); } async registerPatient() { patientName = { - givenName : `E2e_test_${Array.from({ length: 4 }, () => String.fromCharCode(Math.floor(Math.random() * 26) + 97)).join('')}`, + givenName : `e2e_test_${Array.from({ length: 4 }, () => String.fromCharCode(Math.floor(Math.random() * 26) + 97)).join('')}`, familyName : `${Array.from({ length: 8 }, () => String.fromCharCode(Math.floor(Math.random() * 26) + 97)).join('')}`, updatedGivenName : `${Array.from({ length: 8 }, () => String.fromCharCode(Math.floor(Math.random() * 26) + 97)).join('')}`, } await this.page.goto(`${BAHMNI_URL}/bahmni/registration`); - await this.page.locator('a').filter({ hasText: 'Create New' }).click(); + await this.page.locator('a').filter({ hasText: /create new/i }).click(); await this.page.locator('#givenName').fill(`${patientName.givenName}`); await this.page.locator('#familyName').fill(`${patientName.familyName}`); await this.page.locator('#gender').selectOption('F'); await this.page.locator('#ageYears').fill(`${Math.floor(Math.random() * 99)}`); await this.page.locator('#view-content div>ul>li button').click(); - await expect(this.page.getByRole('button', { name: 'Save' })).toBeEnabled(); - await this.page.getByRole('button', { name: 'Priority' }).click(); - await this.page.getByRole('button', { name: 'Save' }).click(); + await expect(this.page.getByRole('button', { name: /save/i })).toBeEnabled(); + await this.page.getByRole('button', { name: /priority/i }).click(); + await this.page.getByRole('button', { name: /save/i }).click(); await expect(this.page.getByText('error')).not.toBeVisible(); } @@ -52,76 +53,76 @@ export class Bahmni { } async updatePatientDetails() { - await this.page.getByRole('link', { name: 'Registration' }).click(); + await this.page.getByRole('link', { name: /registration/i }).click(); await this.page.locator('#name').fill(`${patientName.familyName}`); - await this.page.locator('form[name="searchByNameForm"]').getByRole('button', { name: 'Search' }).click(); + await this.page.locator('form[name="searchByNameForm"]').getByRole('button', { name: /search/i }).click(); await this.page.locator('#view-content td:nth-child(1) a').click(); await expect(this.page.locator('#givenName')).toBeVisible(); await this.page.locator('#givenName').clear(); await delay(1000); await this.page.locator('#givenName').fill(`${patientName.updatedGivenName}`); - await this.page.getByRole('button', { name: 'Save' }).click(); + await this.page.getByRole('button', { name: /save/i }).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'); - await this.page.getByRole('button', { name: 'Delete Patient', exact: true }).click(); - const message = await this.page.locator('//*[@id="patientFormVoided"]').textContent(); - await expect(message?.includes('This patient has been deleted')).toBeTruthy(); + await this.page.getByRole('button', { name: /delete patient/i, exact: true }).click(); + await expect(this.page.locator('//*[@id="patientFormVoided"]')).toHaveText(/this patient has been deleted/i); } - 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(); + await this.page.locator('#opd-tabs').getByText(/orders/i).click(); + await expect(this.page.getByText(/lab samples/i)).toBeVisible(); } async createLabOrder() { - await this.page.getByText('Blood', { exact: true }).click(); - await this.page.getByText('Malaria').click(); - await this.saveOrder(); + await this.page.getByText(/blood/i, { exact: true }).click(); + await this.page.getByText(/malaria/i).click(); + 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.page.getByText(/blood/i, { exact: true }).click(); + await this.page.locator('#selected-orders li').filter({ hasText: /malaria/i }).locator('i').nth(1).click(); + await this.page.getByText(/hematocrit/i).click(); + 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.page.getByText(/blood/i, { exact: true }).click(); + await this.page.locator('#selected-orders li').filter({ hasText: /malaria/i }).locator('i').nth(1).click(); + 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/i })).toBeVisible(); + await this.page.getByRole('button', { name: /add new obs form/i }).click(); } 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(); + await this.page.locator('#opd-tabs').getByText(/diagnosis/i).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(); - await expect(this.page.getByText('Order an Order Set')).toBeVisible(); + await this.page.locator('#opd-tabs').getByText(/medications/i).click(); + await expect(this.page.getByText(/order drug/i)).toBeVisible(); + await expect(this.page.getByText(/order an order set/i)).toBeVisible(); } async createMedication() { @@ -138,8 +139,8 @@ export class Bahmni { await this.page.locator('#instructions').selectOption('string:Estomac vide'); 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.page.getByRole('button', { name: /add/i }).click(); + await this.save(); } async editMedicationDetails() { @@ -149,22 +150,340 @@ export class Bahmni { await this.page.locator('#frequency').selectOption('string:Q4H'); 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.page.getByRole('button', { name: /add/i }).click(); + await this.save(); } async discontinueMedication() { - await this.page.getByRole('button', { name: 'Stop' }).first().click(); + await this.page.getByRole('button', { name: /stop/i }).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'); + await expect(this.page.locator('#dashboard-treatments span.discontinued-text').first()).toContainText('Stopped'); + } + + + 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 fillObstetricUltrasound1Form() { + await expect(this.page.locator('span.section-label')).toHaveText('Echographie obstétricale 1'); + await this.page.getByRole('button', { name: 'Yes' }).first().click(); + await this.page.locator('.fl input').nth(0).fill('9'); + await this.page.locator('.fl input').nth(1).fill('64'); + await this.page.getByRole('button', { name: 'Ovarian Pregnancy' }).click(); + await this.page.locator('.fl input').nth(2).fill('2'); + await this.page.locator('.fl input').nth(3).fill('2'); + await this.page.locator('.fl input').nth(4).fill('155'); + await this.page.getByRole('button', { name: 'Anterior' }).click(); + await this.page.getByRole('button', { name: 'No' }).nth(1).click(); + await this.page.getByRole('button', { name: 'No' }).nth(2).click(); + await this.page.locator('div textarea').fill('The two fetuses are growing well.'); + await this.save(); + } + + async fillObstetricUltrasound2Form() { + await this.page.locator('.fl input').nth(0).fill('1'); + await this.page.locator('.fl input').nth(1).fill('1'); + await this.page.getByRole('button', { name: 'Anterior' }).click(); + await this.page.locator('.fl input').nth(2).fill('150'); + await this.page.getByRole('button', { name: 'Breech' }).click(); + await this.page.locator(':nth-child(4)>.form-builder-column-wrapper>.form-builder-column>.form-field-wrap>.form-field-content-wrap button:nth-child(1)').first().click(); + await this.page.locator(':nth-child(5)>.form-builder-column-wrapper>.form-builder-column>.form-field-wrap>.form-field-content-wrap button:nth-child(1)').first().click(); + await this.page.locator(':nth-child(6)>.form-builder-column-wrapper>.form-builder-column>.form-field-wrap>.form-field-content-wrap button:nth-child(1)').first().click(); + await this.page.locator(':nth-child(7)>.form-builder-column-wrapper>.form-builder-column>.form-field-wrap>.form-field-content-wrap button:nth-child(1)').first().click(); + await this.page.locator(':nth-child(8)>.form-builder-column-wrapper>.form-builder-column>.form-field-wrap>.form-field-content-wrap button:nth-child(1)').first().click(); + await this.page.locator(':nth-child(9)>.form-builder-column-wrapper>.form-builder-column>.form-field-wrap>.form-field-content-wrap button:nth-child(3)').first().click(); + await this.page.locator(':nth-child(10)>.form-builder-column-wrapper>.form-builder-column>.form-field-wrap>.form-field-content-wrap button:nth-child(3)').first().click(); + await this.page.locator(':nth-child(11)>.form-builder-column-wrapper>.form-builder-column>.form-field-wrap>.form-field-content-wrap button:nth-child(3)').first().click(); + await this.page.locator('div textarea').fill('The fetus is about thirty two weeks.'); + await this.save(); + } + + async fillObstetricUltrasound3Form() { + await expect(this.page.locator('div.obs-control-field textarea')).toBeVisible(); + await this.page.locator('.fl input').nth(0).fill('2'); + await this.page.locator('.fl input').nth(1).fill('2'); + await this.page.getByRole('button', { name: 'Posterior' }).click(); + await this.page.getByRole('button', { name: 'Transverse' }).click(); + await this.page.getByRole('textbox').fill('The two fetuses are in a good growing state.'); + await this.save(); + } + + async fillPhysicalExaminationForm() { + await expect(this.page.locator('span.section-label')).toHaveText('Examen physique'); + await this.page.locator(':nth-child(3)>.form-builder-column-wrapper button').first().click(); + await this.page.locator(':nth-child(7)>.form-builder-column-wrapper :nth-child(2)').nth(1).click(); + await expect(this.page.getByText('Cardiovascular Examination Details')).toBeVisible(); + await expect(this.page.locator('div textarea')).toBeVisible(); + await this.page.locator('div textarea').fill('The blood vessels are very narrow.'); + await this.page.locator(':nth-child(9)>.form-builder-column-wrapper button').first().click(); + await this.save(); + } + + async fillMeansOfTransportationForm() { + await expect(this.page.locator('span.section-label')).toHaveText('Moyen de transport'); + await this.page.getByRole('button', { name: 'Minibus' }).click(); + await this.save(); + } + + async fillFamilyPlanningForm() { + await expect(this.page.locator('span.section-label')).toHaveText('Planification familiale'); + await this.page.getByRole('button', { name: 'Depo Provera Injection' }).click(); + await this.page.locator('input[type=number]').fill('3'); + await this.page.getByRole('button', { name: 'Existent' }).click(); + await this.save(); + } + + async fillPrenatalConsultationForm() { + await expect(this.page.locator('span.section-label')).toHaveText('Consultation prénatale'); + await this.page.getByRole('button', { name: 'Three' }).click(); + await this.page.locator('input[type=number]').nth(0).fill('18'); + await this.page.getByRole('button', { name: 'No' }).click(); + await this.page.getByRole('group', { name: 'Signs and Symptoms' }).locator('span').nth(1).click(); + await this.page.getByRole('option', { name: 'Abdominal pain' }).click(); + await this.page.getByRole('group', { name: 'Signs and Symptoms' }).getByRole('spinbutton').fill('3'); + await this.page.getByRole('button', { name: 'Day(s)' }).click(); + await this.page.getByRole('group', { name: 'Fetus Details' }).getByRole('spinbutton').fill('144'); + await this.page.getByRole('button', { name: 'Cephalic' }).click(); + await this.save(); + } + + async fillReferenceForm() { + await expect(this.page.locator('span.section-label')).toHaveText('Référence'); + await this.page.locator('div textarea').nth(0).fill('Doctor Fredric Hanandez'); + await this.page.getByRole('button', { name: 'Hopital St Jean Limbe' }).click(); + await this.page.locator('div textarea').nth(1).fill('The patient needs a CT scan due to pregnancy complications.'); + await this.save(); + } + + async fillTriageForm() { + await expect(this.page.locator('span.section-label')).toHaveText('Triage'); + await this.page.getByRole('button', { name: 'Emergency' }).click(); + await this.save(); + } + + async fillReasonForConsultationForm() { + await expect(this.page.locator('span.section-label')).toHaveText('Motif de consultation'); + await this.page.getByRole('combobox').type('Assault by animal suspected of rabies'); + await this.page.getByRole('option', { name: 'Assault by animal suspected of rabies' }).click(); + await this.page.getByRole('textbox').fill('Had contact with a dog that had rabies.'); + await this.page.locator('input[type=number]').fill('2'); + await this.page.getByRole('button', { name: 'Day(s)' }).click(); + await this.save(); + } + + async fillUnauthorizedDepartureForm() { + await expect(this.page.locator('span.section-label')).toHaveText('Départ non autorisé'); + await this.page.getByRole('button', { name: 'No' }).click(); + await this.page.locator('div textarea').fill('The patient switched to using herbal medicine.'); + await this.save(); + } + + async fillVitalSignsForm() { + await expect(this.page.locator('span.section-label')).toHaveText('Signes vitaux'); + await this.page.locator('input[type=number]').nth(0).fill('8'); + await this.page.locator('input[type=number]').nth(1).fill('136'); + await this.page.locator('input[type=number]').nth(2).fill('37.2'); + await this.page.locator('input[type=number]').nth(3).fill('55'); + await this.page.locator('input[type=number]').nth(4).fill('97'); + await this.page.locator('input[type=number]').nth(5).fill('115'); + await this.page.locator('input[type=number]').nth(6).fill('75'); + await this.save(); + } + + async fillGynecologicalExaminationForm() { + await expect(this.page.locator('span.section-label')).toHaveText('Examen gynécologique'); + await this.page.locator('input[type=number]').nth(0).fill('14'); + await this.page.locator('input[type=date]:nth-child(1)').type('09-15-2024'); + await this.page.locator('input[type=number]').nth(1).fill('5'); + await this.page.locator('input[type=number]').nth(2).fill('0'); + await this.page.locator('input[type=number]').nth(3).fill('3'); + await this.page.getByRole('button', { name: 'Breast problems' }).click(); + await this.page.getByRole('button', { name: 'Yes' }).click(); + await expect(this.page.getByText('Contraception', { exact: true })).toBeVisible(); + await expect(this.page.getByText('Date', { exact: true })).toBeVisible(); + await this.page.getByRole('button', { name: 'Microgynon (plaquette)' }).click(); + await this.page.locator('input[type=date]:nth-child(1)').nth(1).type('09-16-2023'); + await this.save(); + } + + async fillTBMonitoringForm() { + await expect(this.page.locator('span.section-label')).toHaveText('Suivi TB'); + await this.page.getByRole('button', { name: 'Cough' }).click(); + await this.page.getByRole('button', { name: 'Evening fever' }).click(); + await this.page.getByRole('button', { name: 'Loss of appetite' }).click(); + await this.page.getByRole('button', { name: 'Weight Loss' }).click(); + await this.page.locator('div textarea').nth(0).fill('Conduct bacteriologic examination of patient\'s sputum or other specimens.'); + await this.save(); + } + + async fillNewCaseOfTuberculosisForm() { + await expect(this.page.locator('span.section-label')).toHaveText('Nouveau cas de tuberculose'); + await this.page.locator('input[type=number]').nth(0).fill('16'); + await this.page.locator('input[type=number]').nth(1).fill('7'); + await this.page.getByRole('button', { name: 'Yes' }).first().click(); + await this.page.locator('input[type=number]').nth(2).fill('4'); + await this.page.getByRole('textbox').first().fill('TB-250'); + await this.page.getByRole('button', { name: 'Invisible' }).click(); + await this.page.getByRole('button', { name: 'Pulmonary', exact: true }).click(); + await this.page.getByRole('button', { name: 'Treatment after failure' }).click(); + await this.page.getByRole('button', { name: 'Cough' }).click(); + await this.page.getByRole('button', { name: 'Evening fever' }).click(); + await this.page.getByRole('button', { name: 'Loss of appetite' }).click(); + await this.page.getByRole('button', { name: 'Hemoptysis' }).click(); + await this.page.getByRole('button', { name: 'Emanciation' }).click(); + await this.page.getByRole('button', { name: 'No' }).nth(3).click(); + await this.page.locator('div textarea').nth(1).fill('Test other findings.'); + await this.save(); + } + + async fillEmergencyMonitoringForm() { + await expect(this.page.locator('span.section-label')).toHaveText('Suivi d’urgences'); + await this.page.locator('input[type=date]:nth-child(1)').type('08-19-2024'); + await this.page.locator('input[type=time]:nth-child(2)').fill('16:30'); + await this.page.locator('div textarea').nth(0).fill('Patient put on oxygen.'); + await this.page.locator('div textarea').nth(1).fill('Patient recovered from stroke.'); + await this.save(); + } + + async fillVaccinationsForm() { + await expect(this.page.locator('span.section-label')).toHaveText('Vaccinations'); + await this.page.getByRole('button', { name: 'Pentavalent Vaccination' }).click(); + await this.page.locator('input[type=number]').fill('383'); + await this.page.getByRole('button', { name: 'True' }).first().click(); + await this.page.locator('input[type=date]:nth-child(1)').type('09-13-2024'); + await this.page.locator('div textarea').fill('VLN-26'); + await this.page.getByRole('button', { name: 'True' }).nth(1).click(); + await this.save(); + } + + async fillNutritionForm() { + await expect(this.page.locator('span.section-label')).toHaveText('Nutrition'); + await this.page.getByRole('button', { name: 'No' }).first().click(); + await this.page.getByRole('button', { name: 'Vomiting' }).click(); + await this.page.locator('input[type=number]').nth(0).fill('4'); + await this.page.getByRole('button', { name: 'Hour(s)' }).click(); + await this.page.getByRole('button', { name: '++' }).click(); + await this.page.getByRole('button', { name: 'Yes', exact: true }).nth(1).click(); + await this.page.getByRole('button', { name: 'Moderate' }).click(); + await this.page.getByRole('button', { name: 'No', exact: true }).nth(0).click(); + await this.page.getByRole('button', { name: 'Yes', exact: true }).nth(2).click(); + await this.page.getByRole('button', { name: 'No', exact: true }).nth(1).click(); + await this.page.getByRole('button', { name: 'Passive' }).click(); + await this.page.getByRole('button', { name: 'Cold' }).click(); + await this.page.getByRole('button', { name: 'Ear Discharge' }).click(); + await this.page.getByRole('button', { name: 'Oral thrush' }).click(); + await this.page.getByRole('button', { name: 'Scabies' }).click(); + await this.page.getByRole('button', { name: 'Inguinal fold' }).click(); + await this.page.getByRole('button', { name: 'Good' }).click(); + await this.page.getByRole('button', { name: 'No', exact: true }).nth(2).click(); + await this.page.getByRole('button', { name: 'Follow-up appointment' }).click(); + await this.save(); + } + + async fillSystemsReviewForm() { + await expect(this.page.locator('span.section-label')).toHaveText('Examen des systèmes'); + await this.page.getByRole('button', { name: 'Loss of Appetite' }).click(); + await this.page.getByRole('button', { name: 'Night sweats' }).click(); + await this.page.getByRole('button', { name: 'Fatigue' }).click(); + await this.page.getByRole('button', { name: 'Rashes' }).click(); + await this.page.getByRole('button', { name: 'Dermatological pruritus' }).click(); + await this.page.getByRole('button', { name: 'Discolorations' }).click(); + await this.page.getByRole('button', { name: 'Headache' }).click(); + await this.page.getByRole('button', { name: 'Dizziness' }).first().click(); + await this.page.getByRole('button', { name: 'Mass' }).click(); + await this.page.getByRole('button', { name: 'Visual disturbance' }).click(); + await this.page.getByRole('button', { name: 'Eye itching' }).click(); + await this.page.getByRole('button', { name: 'Discharge from the eyes' }).click(); + await this.page.getByRole('button', { name: 'Conjuctivitis' }).click(); + await this.page.getByRole('button', { name: 'Teary eyes' }).click(); + await this.page.getByRole('button', { name: 'Ear Discharge' }).click(); + await this.page.getByRole('button', { name: 'Deaf' }).click(); + await this.page.getByRole('button', { name: 'Bleeding' }).click(); + await this.page.getByRole('button', { name: 'Nose Discharge' }).click(); + await this.page.getByRole('button', { name: 'Sinus Congestion' }).click(); + await this.page.getByRole('button', { name: 'Missing' }).click(); + await this.page.getByRole('button', { name: 'Tongue' }).click(); + await this.page.getByRole('button', { name: 'Pallet' }).click(); + await this.page.getByRole('button', { name: 'Dysphagia' }).first().click(); + await this.page.getByRole('button', { name: 'Cough', exact: true }).click(); + await this.page.getByRole('button', { name: 'Orthopnea' }).click(); + await this.page.getByRole('button', { name: 'Platypnea' }).click(); + await this.page.getByRole('button', { name: 'Hemoptysis' }).click(); + await this.page.getByRole('button', { name: 'Chest Pain' }).click(); + await this.page.getByRole('button', { name: 'Lower Extremity Edema' }).click(); + await this.page.getByRole('button', { name: 'Paroxysmal Nocturnal Dyspnea' }).click(); + await this.page.getByRole('button', { name: 'Dyspnea with Exertion' }).click(); + await this.page.getByRole('button', { name: 'Palpitations' }).click(); + await this.page.getByRole('button', { name: 'Dyschezia' }).click(); + await this.page.getByRole('button', { name: 'Abdominal pain' }).click(); + await this.page.getByRole('button', { name: 'Hematemesis' }).click(); + await this.page.getByRole('button', { name: 'Constipation' }).click(); + await this.page.getByRole('button', { name: 'Hematochezia' }).click(); + await this.page.getByRole('button', { name: 'Dysuria' }).click(); + await this.page.getByRole('button', { name: 'Polyuria' }).first().click(); + await this.page.getByRole('button', { name: 'Hesitation' }).click(); + await this.page.getByRole('button', { name: 'Heat Intolerance' }).click(); + await this.page.getByRole('button', { name: 'Hair Problem' }).click(); + await this.page.getByRole('button', { name: 'Dry Skin' }).click(); + await this.page.getByRole('button', { name: 'Joint Deformity' }).click(); + await this.page.locator('div.obs-control-field textarea').fill('Left arm'); + await this.page.getByRole('button', { name: 'Lymphadenopathy' }).click(); + await this.page.locator('div.obs-control-field textarea').nth(1).fill('Under the jaw and chin'); + await this.page.getByRole('button', { name: 'Memory loss' }).click(); + await this.page.getByRole('button', { name: 'Anxiety' }).click(); + await this.page.getByRole('button', { name: 'Language Disorder' }).click(); + await this.page.getByRole('button', { name: 'Self Care Skill Deficiency' }).click(); + await this.page.getByRole('button', { name: 'Motor Skills Disorder' }).click(); + await this.save(); + } + + async fillHealthHistoryForm() { + await expect(this.page.locator('span.section-label')).toHaveText('Historique de santé'); + await this.page.locator('div textarea').nth(0).fill('Insect bites and stings'); + await this.page.locator('input[type=date]:nth-child(1)').type('08-19-2024'); + await this.page.locator('input[type=number]').nth(0).fill('6'); + await this.page.getByRole('button', { name: 'Month(s)' }).click(); + await this.page.locator('div textarea').nth(1).fill('Allergic to insect bites and strings'); + await this.page.getByRole('button', { name: 'Hopital Sacré Coeur Milot' }).click(); + await this.page.getByRole('group', { name: 'Self Medication Set' }).getByRole('button').first().click(); + await this.page.getByRole('group', { name: 'Self Medication Set' }).getByRole('textbox').fill('Oral antihistamines'); + await this.page.getByRole('group', { name: 'Current Medication Set' }).getByRole('button').nth(1).click(); + await this.page.getByRole('button', { name: 'Asthma' }).first().click(); + await this.page.getByRole('button', { name: 'Hypertension' }).first().click(); + await this.page.getByRole('button', { name: 'Cancer' }).first().click(); + await this.page.getByRole('button', { name: 'Hepatitis' }).click(); + await this.page.getByRole('button', { name: 'Type 1 diabetes' }).first().click(); + await this.page.getByRole('button', { name: 'Tuberculosis' }).click(); + await this.page.getByRole('button', { name: 'Type 2 diabetes' }).nth(1).click(); + await this.page.getByRole('button', { name: 'Sickle-cell anemia' }).nth(1).click(); + await this.page.getByRole('button', { name: 'Mental illness' }).nth(1).click(); + await this.page.locator('div textarea').nth(3).fill('No Trauma history'); + await this.page.locator('div textarea').nth(4).fill('Colorectal surgery'); + await this.page.getByRole('group', { name: 'Alcohol Use Set' }).getByRole('button').nth(1).click(); + await this.page.getByRole('group', { name: 'Tobacco History Set' }).getByRole('button').nth(1).click(); + await this.page.locator('div:nth-child(10) div fieldset div:nth-child(3) .form-builder-column-wrapper .form-field-wrap .form-field-content-wrap button').nth(1).click(); + await this.page.getByRole('button', { name: 'Yes', exact: true }).nth(4).click(); + await this.page.getByRole('button', { name: 'Heterosexual' }).click(); + await this.page.locator('input[type=number]').nth(1).fill('26'); + await this.save(); } - async saveOrder() { - await this.page.getByRole('button', { name: 'Save' }).click(); - await expect(this.page.getByText('Saved', {exact: true})).toBeVisible(); + async save() { + await this.page.getByRole('button', { name: /save/i }).click(); await delay(5000); } } diff --git a/e2e/utils/functions/odoo.ts b/e2e/utils/functions/odoo.ts index 93485e0..f15fd1a 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 { @@ -7,15 +7,19 @@ export class Odoo { async open() { await this.page.goto(`${ODOO_URL}`); - await this.page.getByPlaceholder('Email').fill(`${process.env.ODOO_USERNAME}`); - await this.page.getByPlaceholder('Password').fill(`${process.env.ODOO_PASSWORD}`); + await this.page.getByPlaceholder(/email/i).fill(`${process.env.ODOO_USERNAME}`); + await this.page.getByPlaceholder(/password/i).fill(`${process.env.ODOO_PASSWORD}`); await this.page.locator('button[type="submit"]').click(); + await expect(this.page).toHaveURL(/.*web/); + await delay(5000); } async searchCustomer() { await this.page.locator("//a[contains(@class, 'full')]").click(); + await expect(this.page.locator('ul.o_menu_apps a:nth-child(2)')).toBeVisible(); 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/i); + 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..07c96db 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 bahmni-odoo" }, "keywords": [], "devDependencies": { diff --git a/playwright.config.ts b/playwright.config.ts index 2a7aa43..91069cd 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -4,7 +4,7 @@ dotenv.config(); const config: PlaywrightTestConfig = { testDir: './e2e/tests', - timeout: 3 * 60 * 1000, + timeout: 4 * 60 * 1000, expect: { timeout: 40 * 1000, }, @@ -23,6 +23,9 @@ const config: PlaywrightTestConfig = { name: 'chromium', use: { ...devices['Desktop Chromium'], + viewport: { width: 1920, height: 1080 }, + screenshot: 'only-on-failure', + video: 'on', }, }, ],