From fc942e7676c32fc149d9fae3cf68a0a7ae3c06a0 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 + upgraded Playwright to version 1.48.2 --- e2e/tests/bahmni-odoo-flows.spec.ts | 7 ++++--- e2e/tests/medications.spec.ts | 19 ++++--------------- e2e/tests/observation-forms.spec.ts | 26 ++++++++++++++++++++++++++ e2e/utils/functions/bahmni.ts | 25 +++++++++++-------------- package.json | 2 +- yarn.lock | 28 ++++++++++++++-------------- 6 files changed, 60 insertions(+), 47 deletions(-) diff --git a/e2e/tests/bahmni-odoo-flows.spec.ts b/e2e/tests/bahmni-odoo-flows.spec.ts index 13f9af8..a676591 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}`); @@ -151,7 +152,7 @@ test('Revising a synced OpenMRS drug order edits the corresponding Odoo quotatio 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(); 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)'); + 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 | 40.0 Comprime(s) | 1.0 Comprime(s) - Q3H - 5 Jour(s)'); // replay await bahmni.navigateToPatientDashboard(); @@ -163,7 +164,7 @@ test('Revising a synced OpenMRS drug order edits the corresponding Odoo quotatio await odoo.searchCustomer(); await page.getByRole('cell', { name: `${patientName.givenName + ' ' + patientName.familyName }` }).click(); 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)'); + 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 | 60.0 Comprime(s) | 2.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 }) => { @@ -176,7 +177,7 @@ test('Discontinuing a synced Bahmni drug order for an Odoo customer with a singl await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(8) span')).toHaveText('Quotation'); await page.getByRole('cell', { name: `${patientName.givenName + ' ' + patientName.familyName }` }).click(); 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)'); + 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 | 40.0 Comprime(s) | 1.0 Comprime(s) - Q3H - 5 Jour(s)'); // replay await bahmni.navigateToPatientDashboard(); diff --git a/e2e/tests/medications.spec.ts b/e2e/tests/medications.spec.ts index 2cfbc97..77bed33 100644 --- a/e2e/tests/medications.spec.ts +++ b/e2e/tests/medications.spec.ts @@ -26,10 +26,8 @@ test('Create, revise and discontinue a drug order.', async ({ page }) => { const drugNameSelector = await page.locator('#ordered-drug-orders strong.drug-name').first(); const medicationDetailsSelector = await page.locator('#ordered-drug-orders div.drug-details').first(); await expect(drugNameSelector).toHaveText('Aspirine Co 81mg (Comprime)'); - await expect(medicationDetailsSelector).toContainText('2 Application(s)'); await expect(medicationDetailsSelector).toContainText('Q3H'); - await expect(medicationDetailsSelector).toContainText('Estomac vide'); - await expect(medicationDetailsSelector).toContainText('Topique'); + await expect(medicationDetailsSelector).toContainText('1 Comprime(s)'); await page.locator('#dashboard-link span.patient-name').click(); const medicationSelector = await page.locator('treatment-table td.drug.active-drug span'); await expect(medicationSelector).toHaveText('Aspirine Co 81mg (Comprime)'); @@ -38,19 +36,10 @@ test('Create, revise and discontinue a drug order.', async ({ page }) => { await page.locator('#view-content :nth-child(1).btn--success').click(); await page.getByText('Medications', { exact: true }).click(); await page.locator('#ordered-drug-orders button:nth-child(1) i').first().click(); - await page.locator('#uniform-dose').clear(); - await page.locator('#uniform-dose').fill('4'); - await page.locator('#frequency').selectOption('string:Q4H'); - 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.save(); - await expect(medicationDetailsSelector).not.toContainText('2 Application(s)'); - await expect(medicationDetailsSelector).toContainText('4 Comprime(s)'); + await bahmni.editMedicationDetails(); + await expect(medicationDetailsSelector).toContainText('2 Comprime(s)'); await expect(medicationDetailsSelector).not.toContainText('Q3H'); - await expect(medicationDetailsSelector).toContainText('Q4H,'); - await expect(medicationDetailsSelector).not.toContainText('Ampoule(s)'); - await expect(medicationDetailsSelector).toContainText('Inhalation'); + await expect(medicationDetailsSelector).toContainText('Q4H'); // verify cancellation await expect(drugNameSelector).toContainText('Aspirine Co 81mg (Comprime)'); 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..38be0fc 100644 --- a/e2e/utils/functions/bahmni.ts +++ b/e2e/utils/functions/bahmni.ts @@ -127,16 +127,12 @@ 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.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').fill('1'); + await this.page.locator('#frequency').selectOption('Q3H'); 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 expect(this.page.locator('#quantity')).toHaveValue('560'); + await expect(this.page.locator('#quantity')).toHaveValue('40'); + await this.page.locator('#instructions').selectOption('Après le repas'); + await this.page.locator('#additional-instructions').fill('Take medication as directed'); await this.page.getByRole('button', { name: /add/i }).click(); await this.save(); } @@ -144,10 +140,9 @@ export class Bahmni { async editMedicationDetails() { 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('#uniform-dose').fill('2'); + await this.page.locator('#frequency').selectOption('Q4H'); + await expect(this.page.locator('#quantity')).toHaveValue('60'); await this.page.getByRole('button', { name: /add/i }).click(); await this.save(); } @@ -324,7 +319,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..e031af0 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ }, "keywords": [], "devDependencies": { - "@playwright/test": "^1.47.2", + "@playwright/test": "^1.48.2", "@types/node": "^22.2.0", "@types/react": "^18.3.3", "@types/react-dom": "^18.3.0", diff --git a/yarn.lock b/yarn.lock index 7cfe2fa..7aad674 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,12 +2,12 @@ # yarn lockfile v1 -"@playwright/test@^1.47.2": - version "1.47.2" - resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.47.2.tgz#dbe7051336bfc5cc599954214f9111181dbc7475" - integrity sha512-jTXRsoSPONAs8Za9QEQdyjFn+0ZQFjCiIztAIF6bi1HqhBzG9Ma7g1WotyiGqFSBRZjIEqMdT8RUlbk1QVhzCQ== +"@playwright/test@^1.48.2": + version "1.48.2" + resolved "https://registry.yarnpkg.com/@playwright/test/-/test-1.48.2.tgz#87dd40633f980872283404c8142a65744d3f13d6" + integrity sha512-54w1xCWfXuax7dz4W2M9uw0gDyh+ti/0K/MxcCUxChFh37kkdxPdfZDw5QBbuPUJHr1CiHJ1hXgSs+GgeQc5Zw== dependencies: - playwright "1.47.2" + playwright "1.48.2" "@types/node@^22.2.0": version "22.2.0" @@ -65,17 +65,17 @@ fsevents@2.3.2: resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== -playwright-core@1.47.2: - version "1.47.2" - resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.47.2.tgz#7858da9377fa32a08be46ba47d7523dbd9460a4e" - integrity sha512-3JvMfF+9LJfe16l7AbSmU555PaTl2tPyQsVInqm3id16pdDfvZ8TTZ/pyzmkbDrZTQefyzU7AIHlZqQnxpqHVQ== +playwright-core@1.48.2: + version "1.48.2" + resolved "https://registry.yarnpkg.com/playwright-core/-/playwright-core-1.48.2.tgz#cd76ed8af61690edef5c05c64721c26a8db2f3d7" + integrity sha512-sjjw+qrLFlriJo64du+EK0kJgZzoQPsabGF4lBvsid+3CNIZIYLgnMj9V6JY5VhM2Peh20DJWIVpVljLLnlawA== -playwright@1.47.2: - version "1.47.2" - resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.47.2.tgz#155688aa06491ee21fb3e7555b748b525f86eb20" - integrity sha512-nx1cLMmQWqmA3UsnjaaokyoUpdVaaDhJhMoxX2qj3McpjnsqFHs516QAKYhqHAgOP+oCFTEOCOAaD1RgD/RQfA== +playwright@1.48.2: + version "1.48.2" + resolved "https://registry.yarnpkg.com/playwright/-/playwright-1.48.2.tgz#fca45ae8abdc34835c715718072aaff7e305167e" + integrity sha512-NjYvYgp4BPmiwfe31j4gHLa3J7bD2WiBz8Lk2RoSsmX38SVIARZ18VYjxLjAcDsAhA+F4iSEXTSGgjua0rrlgQ== dependencies: - playwright-core "1.47.2" + playwright-core "1.48.2" optionalDependencies: fsevents "2.3.2"