From 7fd722490ee77add33e60945e07fc60052305500 Mon Sep 17 00:00:00 2001 From: kdaud Date: Tue, 20 Aug 2024 11:17:27 +0300 Subject: [PATCH] Address reviews --- e2e/tests/lab-orders.spec.ts | 18 ++++++++++++++++-- e2e/tests/medications.spec.ts | 24 ++++++++++++------------ 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/e2e/tests/lab-orders.spec.ts b/e2e/tests/lab-orders.spec.ts index 6b47e6d..32897d5 100644 --- a/e2e/tests/lab-orders.spec.ts +++ b/e2e/tests/lab-orders.spec.ts @@ -14,7 +14,7 @@ test.beforeEach(async ({ page }) => { await expect(page.getByText(/patient documents/i)).toBeVisible(); }); -test('Record, revise and discontinue lab tests.', async ({ page }) => { +test('Create, revise and discontinue lab tests.', async ({ page }) => { // setup await bahmni.registerPatient(); @@ -32,7 +32,7 @@ test('Record, revise and discontinue lab tests.', async ({ page }) => { await page.getByText('Serial sputum bacilloscopy').click(); await bahmni.saveOrder(); - // verify + // verify creation await page.locator('#dashboard-link span.patient-name').click(); await expect(page.locator('#Lab-Orders').getByText('Malaria')).toBeVisible(); await expect(page.locator('#Lab-Orders').getByText('Gravindex')).toBeVisible(); @@ -40,6 +40,7 @@ test('Record, revise and discontinue lab tests.', async ({ page }) => { await expect(page.locator('#Lab-Orders').getByText('Bacteria')).toBeVisible(); await expect(page.locator('#Lab-Orders').getByText('Serial sputum bacilloscopy')).toBeVisible(); + // verify revision await page.locator('#view-content :nth-child(1).btn--success').click(); await page.getByText('Orders', { exact: true }).click(); await page.getByText('Blood', { exact: true }).click(); @@ -52,6 +53,7 @@ test('Record, revise and discontinue lab tests.', async ({ page }) => { await page.getByText('Stool Parasites').click(); await bahmni.saveOrder(); + // verify revision await page.locator('#dashboard-link span.patient-name').click(); await expect(page.locator('#Lab-Orders').getByText('Malaria')).not.toBeVisible(); await expect(page.locator('#Lab-Orders').getByText('Blood Sugar')).toBeVisible(); @@ -61,6 +63,18 @@ test('Record, revise and discontinue lab tests.', async ({ page }) => { await expect(page.locator('#Lab-Orders').getByText('Stool Parasites')).toBeVisible(); await expect(page.locator('#Lab-Orders').getByText('Bacteria')).toBeVisible(); await expect(page.locator('#Lab-Orders').getByText('Serial sputum bacilloscopy')).toBeVisible(); + + // verify cancellation + await page.locator('#view-content :nth-child(1).btn--success').click(); + await page.getByText('Orders', { exact: true }).click(); + 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 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(); + await expect(page.locator('#Lab-Orders').getByText('Stool Colour')).not.toBeVisible(); }); test.afterEach(async ({ page }) => { diff --git a/e2e/tests/medications.spec.ts b/e2e/tests/medications.spec.ts index 4ba0127..b1645d0 100644 --- a/e2e/tests/medications.spec.ts +++ b/e2e/tests/medications.spec.ts @@ -14,7 +14,7 @@ test.beforeEach(async ({ page }) => { await expect(page.getByText(/patient documents/i)).toBeVisible(); }); -test('Record, revise and discontinue a drug order.', async ({ page }) => { +test('Create, revise and discontinue a drug order.', async ({ page }) => { // setup await bahmni.registerPatient(); @@ -35,16 +35,19 @@ test('Record, revise and discontinue a drug order.', async ({ page }) => { await page.getByRole('button', { name: 'Add' }).click(); await bahmni.saveOrder(); - // verify - await page.locator('#dashboard-link span.patient-name').click(); - const drugNameSelector = await page.locator('treatment-table td.drug.active-drug span'); - const medicationDetailsSelector = await page.locator('#dashboard-treatments td.dosage span:nth-child(1)'); + // verify creation + 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 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)'); + // verify revision 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(); @@ -55,7 +58,6 @@ test('Record, revise and discontinue a drug order.', async ({ page }) => { await page.locator('#route').selectOption('string:Inhalation'); await page.getByRole('button', { name: 'Add' }).click(); await bahmni.saveOrder(); - await page.locator('#dashboard-link span.patient-name').click(); await expect(medicationDetailsSelector).not.toContainText('2 Application(s)'); await expect(medicationDetailsSelector).toContainText('4 Comprime(s)'); await expect(medicationDetailsSelector).not.toContainText('Q3H'); @@ -63,15 +65,13 @@ test('Record, revise and discontinue a drug order.', async ({ page }) => { await expect(medicationDetailsSelector).not.toContainText('Ampoule(s)'); await expect(medicationDetailsSelector).toContainText('Inhalation'); - await page.locator('#view-content :nth-child(1).btn--success').click(); - await page.getByText('Medications', { exact: true }).click(); - const drugSelector = await page.locator('strong.drug-name').first(); - await expect(drugSelector).toContainText('Aspirine Co 81mg (Comprime)'); + // verify cancellation + await expect(drugNameSelector).toContainText('Aspirine Co 81mg (Comprime)'); await page.getByRole('button', { name: 'Stop' }).first().click(); - await page.getByPlaceholder('Notes').clear(); await page.getByPlaceholder('Notes').fill('Patient allergic to medicine'); await bahmni.saveOrder(); - await expect(page.getByText(/no recent treatments/i)).toBeVisible(); + await page.locator('#dashboard-link span.patient-name').click(); + //await expect(page.getByText('Aspirine Co 81mg (Comprime)')).not.toBeVisible(); }); test.afterEach(async ({ page }) => {