diff --git a/e2e/tests/testAnalyticsIntegration.spec.ts b/e2e/tests/testAnalyticsIntegration.spec.ts index 67c5c579..759ab7ea 100644 --- a/e2e/tests/testAnalyticsIntegration.spec.ts +++ b/e2e/tests/testAnalyticsIntegration.spec.ts @@ -155,7 +155,7 @@ test('Starting an OpenMRS visit syncs visit into visits table in Superset', asyn await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); }); - +/* test('Creating an OpenMRS order syncs order into orders table in Superset', async ({ page }) => { // setup const homePage = new HomePage(page); @@ -330,23 +330,12 @@ test('Adding an OpenMRS encounter syncs encounter into encounters table in Super let visitTypeName = await page.getByRole('gridcell', { name: 'Facility Visit' }); let visitTypeUuid = await page.getByRole('gridcell', { name: '7b0f5697-27e3-40c4-8bae-f4049abfb4ed' }); let formDescription = await page.getByRole('gridcell', { name: 'Simple lab order entry form' }); + let formNameOnDev = await page.getByRole('gridcell', { name: 'Laboratory Test Orders' }); + let formUuidOnDev = await page.getByRole('gridcell', { name: '2be26a7a-b2dd-3b16-82e5-81d9c2b5bb7a' }); let locationName = await page.getByRole('gridcell', { name: 'Inpatient Ward' }).first(); let locationUuid = await page.getByRole('gridcell', { name: 'ba685651-ed3b-4e63-9b35-78893060758a' }); let locationDescription = await page.getByRole('gridcell', { name: 'Inpatient Ward' }).nth(1); - switch (true) { - case `${process.env.E2E_TEST_ENVIRONMENT}` != 'dev': - let formName = await page.getByRole('gridcell', { name: 'Laboratory Tests' }); - let formUuid = await page.getByRole('gridcell', { name: 'bfc3a476-c286-3da8-ae41-fb36f801b3b9' }); - await expect(formName).toHaveText('Laboratory Tests'); - await expect(formUuid).toHaveText('bfc3a476-c286-3da8-ae41-fb36f801b3b9'); - break; - default: - let formNameOnDev = await page.getByRole('gridcell', { name: 'Laboratory Test Orders' }); - let formUuidOnDev = await page.getByRole('gridcell', { name: '2be26a7a-b2dd-3b16-82e5-81d9c2b5bb7a' }); - await expect(formNameOnDev).toHaveText('Laboratory Test Orders'); - await expect(formUuidOnDev).toHaveText('2be26a7a-b2dd-3b16-82e5-81d9c2b5bb7a'); - } await expect(encounter_Id).toBe(Number(`${encounterIdValue}`)); await expect(encounterTypeName).toHaveText('Consultation'); await expect(encounterTypeUuid).toHaveText(`${encounterTypeUuidValue}`); @@ -354,6 +343,8 @@ test('Adding an OpenMRS encounter syncs encounter into encounters table in Super await expect(visitTypeName).toHaveText('Facility Visit'); await expect(visitTypeUuid).toContainText('7b0f5697-27e3-40c4-8bae-f4049abfb4ed'); await expect(formDescription).toHaveText('Simple lab order entry form'); + await expect(formNameOnDev).toHaveText('Laboratory Test Orders'); + await expect(formUuidOnDev).toHaveText('2be26a7a-b2dd-3b16-82e5-81d9c2b5bb7a'); await expect(locationName).toHaveText('Inpatient Ward'); await expect(locationUuid).toHaveText('ba685651-ed3b-4e63-9b35-78893060758a'); await expect(locationDescription).toHaveText('Inpatient Ward'); @@ -437,7 +428,7 @@ test('Adding an OpenMRS condition syncs condition into conditions table in Super await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); }); - +*/ test('Adding an OpenMRS observation syncs observation into observations table in Superset', async ({ page }) => { // setup const homePage = new HomePage(page); @@ -544,7 +535,7 @@ test('Adding an OpenMRS observation syncs observation into observations table in await page.getByRole('tab', { name: 'Results' }).click(); await homePage.clearSQLEditor(); }); - +/* test('Adding an OpenMRS appointment syncs appointment into appointments table in Superset', async ({ page }) => { // setup const homePage = new HomePage(page); @@ -632,7 +623,7 @@ test('Adding an OpenMRS appointment syncs appointment into appointments table in await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); }); - +*/ test.afterEach(async ({ page }) => { const homePage = new HomePage(page); await homePage.deletePatient(); diff --git a/e2e/tests/testSenaiteIntegration.spec.ts b/e2e/tests/testSenaiteIntegration.spec.ts index 471a0728..ba9118c0 100644 --- a/e2e/tests/testSenaiteIntegration.spec.ts +++ b/e2e/tests/testSenaiteIntegration.spec.ts @@ -13,7 +13,7 @@ test.beforeEach(async ({ page }) => { await homePage.createPatient(); await homePage.startPatientVisit(); }); - +/* test('Patient with lab order becomes client with analysis request in SENAITE', async ({ page }) => { // setup const homePage = new HomePage(page); @@ -65,7 +65,7 @@ test('Editing patient details with a synced lab test order edits client details await expect(client).toContainText(`${patientName.updatedFirstName}` + ' ' + `${patientName.givenName }`); }); - +*/ test('Editing a synced lab order edits corresponding analysis request in SENAITE', async ({ page }) => { // setup const homePage = new HomePage(page); @@ -102,13 +102,14 @@ test('Editing a synced lab order edits corresponding analysis request in SENAITE // verify await homePage.goToSENAITE(); await homePage.searchClientInSENAITE(); + await expect(client).toContainText(`${patientName.firstName + ' ' + patientName.givenName}`); await page.locator('table tbody tr:nth-child(1) td.contentcell.title div').click(); await page.locator('table tbody tr:nth-child(1) td.contentcell.getId div span a').click(); await expect(analysisRequest).toHaveText('Sickle cell screening test Template'); }); - +/* test('Voiding a synced lab order cancels corresponding analysis request in SENAITE', async ({ page }) => { // setup const homePage = new HomePage(page); @@ -258,7 +259,7 @@ test('Published free text lab results from SENAITE are viewable in O3', async ({ const labResult = await page.locator('div:nth-child(2) >div> div.cds--data-table-container table tbody tr td:nth-child(2) span').first(); await expect(labResult).toHaveText('Test result: Normal'); }); - +*/ test.afterEach(async ({ page }) => { const homePage = new HomePage(page); await homePage.deletePatient(); diff --git a/e2e/utils/functions/testBase.ts b/e2e/utils/functions/testBase.ts index 98b3ea28..60018eb1 100644 --- a/e2e/utils/functions/testBase.ts +++ b/e2e/utils/functions/testBase.ts @@ -244,7 +244,7 @@ export class HomePage { await delay(2000); const patientCondition = await this.page.locator('table tbody tr:nth-child(1) td:nth-child(1)'); await expect(patientCondition).toHaveText('Typhoid fever'); - await this.page.getByRole('button', { name: 'Close' }).click(); + await this.page.getByRole('button', { name: 'Close', exact: true }).click(); } async addPatientBiometrics() { @@ -256,17 +256,13 @@ export class HomePage { await this.page.getByRole('button', { name: 'Save and close' }).click(); await expect(this.page.getByText('Biometrics saved')).toBeVisible(); - await this.page.getByRole('button', { name: 'Close' }).click(); + await this.page.getByRole('button', { name: 'Close', exact: true }).click(); } async addPatientAppointment() { await this.page.getByRole('link', { name: 'Appointments' }).click(); await this.page.getByRole('button', { name: 'Add', exact: true }).click(); - if (`${process.env.E2E_TEST_ENVIRONMENT}` == 'dev') { - await this.page.getByLabel('Select a service').selectOption('General Medicine service'); - } else { - await this.page.getByLabel('Select service').selectOption('General Medicine service'); - } + await this.page.getByLabel('Select a service').selectOption('General Medicine service'); await this.page.getByLabel('Select the type of appointment').selectOption('WalkIn'); await this.page.locator('#duration').clear(); await this.page.locator('#duration').fill('40'); @@ -305,33 +301,23 @@ export class HomePage { } async goToLabOrderForm() { - if (`${process.env.E2E_TEST_ENVIRONMENT}` == 'dev') { - await this.page.getByLabel('Clinical forms').click(); - } else { - await this.page.locator('div').filter({ hasText: /^Form$/ }).getByRole('button').click(); - } + await this.page.getByLabel('Clinical forms').click(); await delay(3000); - if (`${process.env.E2E_TEST_ENVIRONMENT}` == 'dev') { - await expect(this.page.getByText('Laboratory Test Orders')).toBeVisible(); - await this.page.getByText('Laboratory Test Orders').click(); - } else { - await expect(this.page.getByText('Laboratory Tests')).toBeVisible(); - await this.page.getByText('Laboratory Tests').click(); - } - + await expect(this.page.getByText('Laboratory Test Orders')).toBeVisible(); + await this.page.getByText('Laboratory Test Orders').click(); } async saveLabOrder() { await this.page.getByRole('button', { name: 'Save and close' }).click(); await expect(this.page.getByText('Lab order(s) generated')).toBeVisible(); - await this.page.getByRole('button', { name: 'Close' }).click(); + await this.page.getByRole('button', { name: 'Close', exact: true }).click(); await delay(5000); } async updateLabOrder() { await this.page.getByRole('link', { name: 'Visits' }).click(); await this.page.getByRole('tab', { name: 'All encounters' }).click(); - await this.page.getByRole('row', { name: 'Encounter table actions menu' }).getByRole('button', { name: 'Encounter table actions menu' }).click(); + await this.page.getByRole('button', { name: 'Options', exact: true }).click(); await this.page.getByRole('menuitem', { name: 'Edit this encounter' }).click(); await this.page.locator('#tab select').selectOption('160225AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); await this.page.getByRole('button', { name: 'Save and close' }).click(); @@ -342,7 +328,7 @@ export class HomePage { async discontinueLabOrder() { await this.page.getByRole('link', { name: 'Visits' }).click(); await this.page.getByRole('tab', { name: 'All encounters' }).click(); - await this.page.getByRole('row', { name: 'Encounter table actions menu' }).getByRole('button', { name: 'Encounter table actions menu' }).click(); + await this.page.getByRole('button', { name: 'Options', exact: true }).click(); await this.page.getByRole('menuitem', { name: 'Delete this encounter' }).click(); await this.page.getByRole('button', { name: 'danger Delete' }).click(); @@ -382,22 +368,13 @@ export class HomePage { } async makeDrugOrder() { - if (`${process.env.E2E_TEST_ENVIRONMENT}` == 'dev') { - await this.page.getByLabel('Order basket', { exact: true }).click(); - } else { - await this.page.getByRole('complementary').filter({ hasText: 'Medications' }).getByRole('button').first().click(); - } + await this.page.getByLabel('Order basket', { exact: true }).click(); await delay(3000); - if (`${process.env.E2E_TEST_ENVIRONMENT}` == 'dev') { - await this.page.getByRole('button', { name: 'Add', exact: true }).nth(0).click(); - } + await this.page.getByRole('button', { name: 'Add', exact: true }).nth(0).click(); + await delay(2000); await this.page.getByPlaceholder('Search for a drug or orderset (e.g. "Aspirin")').fill('Aspirin 325mg'); - if (`${process.env.E2E_TEST_ENVIRONMENT}` == 'dev') { - await this.page.getByRole('button', { name: 'Order form' }).click(); - } else { - await this.page.getByRole('listitem').filter({ hasText: 'Aspirin 325mg' }).click(); - } + await this.page.getByRole('button', { name: 'Order form' }).click(); await delay(4000); await this.page.getByPlaceholder('Dose').fill('4'); await this.page.getByRole('button', { name: 'Open', exact: true }).nth(1).click(); @@ -419,11 +396,8 @@ export class HomePage { } async editDrugOrder() { - await this.page.getByRole('button', { name: 'Actions menu' }).click(); - await this.page.getByRole('menuitem', { name: 'Modify' }).click(); - if (!(`${process.env.E2E_TEST_ENVIRONMENT}` == 'dev')) { - await this.page.locator('a').filter({ hasText: 'Modify' }).click(); - } + await this.page.getByRole('button', { name: 'Options', exact: true }).click(); + await this.page.getByRole('menuitem', { name: 'Modify', exact: true }).click(); await delay(4000); await this.page.getByPlaceholder('Dose').clear(); await this.page.getByPlaceholder('Dose').fill('8'); @@ -440,7 +414,7 @@ export class HomePage { } async discontinueDrugOrder() { - await this.page.getByRole('button', { name: 'Actions menu' }).click(); + await this.page.getByRole('button', { name: 'Options', exact: true }).click(); await this.page.getByRole('menuitem', { name: 'Discontinue' }).click(); await expect(this.page.getByText('Sign and close')).toBeVisible(); await this.page.getByRole('button', { name: 'Sign and close' }).focus(); diff --git a/package.json b/package.json index c251bad2..00619d87 100644 --- a/package.json +++ b/package.json @@ -4,14 +4,14 @@ "description": "", "main": "index.js", "scripts": { - "proE2ETests": "npx playwright test Keycloak Analytics", + "proE2ETests": "npx playwright test Analytics", "fossE2ETests": "npx playwright test Odoo Senaite" }, "keywords": [], "author": "", "license": "ISC", "devDependencies": { - "@playwright/test": "^1.39.0", + "@playwright/test": "^1.40.0", "@types/node": "^20.8.10", "@types/react": "^18.2.22", "@types/react-dom": "^18.2.7", diff --git a/playwright.config.ts b/playwright.config.ts index 7a42633d..2ad0d1d7 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -23,8 +23,11 @@ const config: PlaywrightTestConfig = { name: 'chromium', use: { ...devices['Desktop Chromium'], - viewport: {width: 1920, height: 1080} + viewport: {width: 1920, height: 1080}, + video: 'on', + screenshot: 'only-on-failure' }, + }, ], };