From f84fab2d9225bc57fe4887fdc649efb7575c9112 Mon Sep 17 00:00:00 2001 From: kdaud Date: Thu, 17 Oct 2024 21:17:36 +0300 Subject: [PATCH] C2C-355: E2E test observations for TB monitoring form --- e2e/tests/bahmni-odoo-flows.spec.ts | 1 + e2e/tests/observation-forms.spec.ts | 26 ++++++++++++++++++++++++++ e2e/utils/functions/bahmni.ts | 26 ++++++++++++++------------ package.json | 2 +- playwright.config.ts | 2 +- 5 files changed, 43 insertions(+), 14 deletions(-) diff --git a/e2e/tests/bahmni-odoo-flows.spec.ts b/e2e/tests/bahmni-odoo-flows.spec.ts index 13f9af8..725d906 100644 --- a/e2e/tests/bahmni-odoo-flows.spec.ts +++ b/e2e/tests/bahmni-odoo-flows.spec.ts @@ -128,6 +128,7 @@ test('Editing the details of a Bahmni patient with a synced drug order edits the // setup await bahmni.navigateToMedications(); await bahmni.createMedication(); + await odoo.open(); await odoo.searchCustomer(); await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(4)')).toHaveText(`${patientName.givenName + ' ' + patientName.familyName}`); diff --git a/e2e/tests/observation-forms.spec.ts b/e2e/tests/observation-forms.spec.ts index 59ab9b1..d09c7de 100644 --- a/e2e/tests/observation-forms.spec.ts +++ b/e2e/tests/observation-forms.spec.ts @@ -674,6 +674,32 @@ test('Systems review form should save observations.', async ({ page }) => { await expect(page.locator('#observationSection').getByText('Motor Skills Disorder')).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('Regular follow-up tests to check for bacterial load')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Adjustments based on response and resistance patterns')).toBeVisible(); + await expect(page.locator('#observationSection').getByText('Schedule regular check-ups for progress evaluation')).toBeVisible(); +}); + test('Health history form should save observations.', async ({ page }) => { // setup await bahmni.navigateToForms(); diff --git a/e2e/utils/functions/bahmni.ts b/e2e/utils/functions/bahmni.ts index a86b759..2acf836 100644 --- a/e2e/utils/functions/bahmni.ts +++ b/e2e/utils/functions/bahmni.ts @@ -126,16 +126,16 @@ export class Bahmni { async createMedication() { await this.page.locator('#drug-name').type('Aspirine Co 81mg'); - await this.page.getByText('Aspirine Co 81mg (Comprime)').click(); + await this.page.getByText('Aspirine Co 81mg (Tablet)').click(); await this.page.locator('#uniform-dose').fill('2'); - await this.page.locator('#uniform-dose-unit').selectOption('string:Application(s)'); - await this.page.locator('#frequency').selectOption('string:Q3H'); - await this.page.locator('#route').selectOption('string:Topique'); + await this.page.locator('#uniform-dose-unit').selectOption('Application(s)'); + await this.page.locator('#frequency').selectOption('Q3H'); + await this.page.locator('#route').selectOption('Topical'); await this.page.locator('#duration').fill('5'); - await this.page.locator('#duration-unit').selectOption('string:Semaine(s)'); - await this.page.locator('#total-quantity-unit').selectOption('string:Ampoule(s)'); - await this.page.locator('#instructions').selectOption('string:Estomac vide'); - await this.page.locator('#additional-instructions').fill('Take after a meal'); + await this.page.locator('#duration-unit').selectOption('Semaine(s)'); + await this.page.locator('#total-quantity-unit').selectOption('Ampule(s)'); + await this.page.locator('#instructions').selectOption('After meals'); + await this.page.locator('#additional-instructions').fill('Take medication as directed'); await expect(this.page.locator('#quantity')).toHaveValue('560'); await this.page.getByRole('button', { name: /add/i }).click(); await this.save(); @@ -145,9 +145,9 @@ export class Bahmni { await this.page.locator('i.fa.fa-edit').first().click(); await this.page.locator('#uniform-dose').clear(); await this.page.locator('#uniform-dose').fill('4'); - 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.locator('#frequency').selectOption('Q4H'); + await this.page.locator('#uniform-dose-unit').selectOption('Comprime(s)'); + await this.page.locator('#route').selectOption('Inhalation'); await this.page.getByRole('button', { name: /add/i }).click(); await this.save(); } @@ -324,7 +324,9 @@ export class Bahmni { 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.page.locator('div textarea').nth(0).fill('Regular follow-up tests to check for bacterial load'); + await this.page.locator('div textarea').nth(1).fill('Adjustments based on response and resistance patterns'); + await this.page.locator('div textarea').nth(2).fill('Schedule regular check-ups for progress evaluation'); await this.save(); } diff --git a/package.json b/package.json index 3f3bf38..59a9250 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "license": "MPL-2.0", "description": "These are end-to-end automated tests covering Bahmni distro C2C workflows", "scripts": { - "e2e-tests-c2c": "npx playwright test" + "e2e-tests-c2c": "npx playwright test observation" }, "keywords": [], "devDependencies": { diff --git a/playwright.config.ts b/playwright.config.ts index f9b5c40..3edfd88 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -23,7 +23,7 @@ const config: PlaywrightTestConfig = { name: 'chromium', use: { ...devices['Desktop Chromium'], - viewport: { width: 1920, height: 1080 } + viewport: { width: 1920, height: 1080 }, }, }, ],