From f9ed72ae3e18a4a4092ec23560f78853c41eb94c Mon Sep 17 00:00:00 2001 From: kdaud Date: Wed, 18 Oct 2023 07:25:12 +0300 Subject: [PATCH 1/4] OZ-336: Test Superset tables beyond count --- e2e/tests/testAnalyticsIntegration.spec.ts | 206 --------- e2e/tests/testSupersetIntegration.spec.ts | 476 +++++++++++++++++++++ e2e/utils/functions/testBase.ts | 16 +- 3 files changed, 483 insertions(+), 215 deletions(-) delete mode 100644 e2e/tests/testAnalyticsIntegration.spec.ts create mode 100644 e2e/tests/testSupersetIntegration.spec.ts diff --git a/e2e/tests/testAnalyticsIntegration.spec.ts b/e2e/tests/testAnalyticsIntegration.spec.ts deleted file mode 100644 index a9b315d1..00000000 --- a/e2e/tests/testAnalyticsIntegration.spec.ts +++ /dev/null @@ -1,206 +0,0 @@ -import { test, expect } from '@playwright/test'; -import { HomePage } from '../utils/functions/testBase'; -import { patientName } from '../utils/functions/testBase'; - -let homePage: HomePage; - -test.beforeEach(async ({ page }) => { - const homePage = new HomePage(page); - await homePage.initiateLogin(); - - await expect(page).toHaveURL(/.*home/); - - await homePage.createPatient(); -}); - -test('Starting an OpenMRS visit increases visits count in Superset', async ({ page }) => { - // setup - const homePage = new HomePage(page); - await homePage.goToSuperset(); - await expect(page).toHaveURL(/.*superset/); - await homePage.selectDBSchema(); - await page.getByRole('textbox').first().clear(); - await page.getByRole('textbox').fill('SELECT COUNT (*) FROM visits;'); - await homePage.runSQLQuery(); - const initialNumberOfItems = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); - let initialCount = Number(initialNumberOfItems); - - // replay - await page.goto(`${process.env.E2E_BASE_URL}/openmrs/spa/home`); - await homePage.startPatientVisit(); - - // verify - await homePage.goToSuperset(); - await homePage.returnToSQLEditor(); - await page.getByRole('textbox').first().clear(); - await page.getByRole('textbox').fill('SELECT COUNT (*) FROM visits;'); - await homePage.runSQLQuery(); - const updatedNumberOfItems = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); - let updatedCount = Number(updatedNumberOfItems); - - await expect(updatedCount).toBeGreaterThan(initialCount); -}); - -test('Creating an OpenMRS order increases orders count in Superset', async ({ page }) => { - // setup - const homePage = new HomePage(page); - await homePage.startPatientVisit(); - await homePage.goToSuperset(); - await expect(page).toHaveURL(/.*superset/); - await homePage.selectDBSchema(); - await page.getByRole('textbox').first().clear(); - await page.getByRole('textbox').fill('SELECT COUNT(*) FROM _orders;'); - await homePage.runSQLQuery(); - const initialNumberOfItems = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); - let initialCount = Number(initialNumberOfItems); - - // replay - await page.goto(`${process.env.E2E_BASE_URL}/openmrs/spa/home`); - await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); - await homePage.goToLabOrderForm(); - await page.getByRole('button', { name: 'Add', exact: true }).click(); - await page.locator('#tab select').selectOption('857AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); - await homePage.saveLabOrder(); - - // verify - await homePage.goToSuperset(); - await homePage.returnToSQLEditor(); - await page.getByRole('textbox').first().clear(); - await page.getByRole('textbox').fill('SELECT COUNT(*) FROM _orders;'); - await homePage.runSQLQuery(); - const updatedNumberOfItems = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); - let updatedCount = Number(updatedNumberOfItems); - - await expect(updatedCount).toBeGreaterThan(initialCount); -}); - -test('Creating an OpenMRS order increases encounters count in Superset', async ({ page }) => { - // setup - const homePage = new HomePage(page); - await homePage.startPatientVisit(); - await homePage.goToSuperset(); - await expect(page).toHaveURL(/.*superset/); - await homePage.selectDBSchema(); - await page.getByRole('textbox').first().clear(); - await page.getByRole('textbox').fill('SELECT COUNT(*) FROM encounters;'); - await homePage.runSQLQuery(); - const initialNumberOfItems = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); - let initialCount = Number(initialNumberOfItems); - - // replay - await page.goto(`${process.env.E2E_BASE_URL}/openmrs/spa/home`); - await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); - await homePage.goToLabOrderForm(); - await page.getByRole('button', { name: 'Add', exact: true }).click(); - await page.locator('#tab select').selectOption('857AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); - await homePage.saveLabOrder(); - - // verify - await homePage.goToSuperset(); - await homePage.returnToSQLEditor(); - await page.getByRole('textbox').first().clear(); - await page.getByRole('textbox').fill('SELECT COUNT(*) FROM encounters;'); - await homePage.runSQLQuery(); - const updatedNumberOfItems = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); - let updatedCount = Number(updatedNumberOfItems); - - await expect(updatedCount).toBeGreaterThan(initialCount); -}); - -test('Adding an OpenMRS patient condition increases conditions count in Superset', async ({ page }) => { - // setup - const homePage = new HomePage(page); - await homePage.startPatientVisit(); - await homePage.goToSuperset(); - await expect(page).toHaveURL(/.*superset/); - await homePage.selectDBSchema(); - await page.getByRole('textbox').first().clear(); - await page.getByRole('textbox').fill('SELECT COUNT (*) FROM _conditions;'); - await homePage.runSQLQuery(); - const initialNumberOfItems = await page.getByRole('gridcell', { name: ' ' }).textContent(); - let initialCount = Number(initialNumberOfItems); - - // replay - await page.goto(`${process.env.E2E_BASE_URL}/openmrs/spa/home`); - await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); - await homePage.addPatientCondition(); - - // verify - await homePage.goToSuperset(); - await homePage.returnToSQLEditor(); - await page.getByRole('textbox').first().clear(); - await page.getByRole('textbox').fill('SELECT COUNT (*) FROM _conditions;'); - await homePage.runSQLQuery(); - const updatedNumberOfItems = await page.getByRole('gridcell', { name: ' ' }).textContent(); - let updatedCount = Number(updatedNumberOfItems); - - await expect(updatedCount).toBeGreaterThan(initialCount); -}); - -test('Adding an OpenMRS patient biometrics increases observations count in Superset', async ({ page }) => { - // setup - const homePage = new HomePage(page); - await homePage.startPatientVisit(); - await homePage.goToSuperset(); - await expect(page).toHaveURL(/.*superset/); - await homePage.selectDBSchema(); - await page.getByRole('textbox').first().clear(); - await page.getByRole('textbox').fill('SELECT COUNT (*) FROM observations;'); - await homePage.runSQLQuery(); - const initialNumberOfItems = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); - let initialCount = Number(initialNumberOfItems); - - // replay - await page.goto(`${process.env.E2E_BASE_URL}/openmrs/spa/home`); - await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); - await homePage.addPatientBiometrics(); - - // verify - await homePage.goToSuperset(); - await homePage.returnToSQLEditor(); - await page.getByRole('textbox').first().clear(); - await page.getByRole('textbox').fill('SELECT COUNT (*) FROM observations;'); - await homePage.runSQLQuery(); - const updatedNumberOfItems = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); - let updatedCount = Number(updatedNumberOfItems); - - await expect(updatedCount).toBeGreaterThan(initialCount); -}); - -test('Adding an OpenMRS patient appointment increases appointments count in Superset', async ({ page }) => { - // setup - const homePage = new HomePage(page); - await homePage.startPatientVisit(); - await homePage.goToSuperset(); - await expect(page).toHaveURL(/.*superset/); - await homePage.selectDBSchema(); - await page.getByRole('textbox').first().clear(); - await page.getByRole('textbox').fill('SELECT COUNT(*) FROM appointments;'); - await homePage.runSQLQuery(); - - const initialNumberOfItems = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); - let initialCount = Number(initialNumberOfItems); - - // replay - await page.goto(`${process.env.E2E_BASE_URL}/openmrs/spa/home`); - await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); - await homePage.addPatientAppointment(); - - // verify - await homePage.goToSuperset() - await homePage.returnToSQLEditor(); - await page.getByRole('textbox').first().clear(); - await page.getByRole('textbox').fill('SELECT COUNT(*) FROM appointments;'); - await homePage.runSQLQuery(); - - const updatedNumberOfItems = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); - let updatedCount = Number(updatedNumberOfItems); - - await expect(updatedCount).toBeGreaterThan(initialCount); -}); - -test.afterEach(async ({ page }) => { - const homePage = new HomePage(page); - await homePage.deletePatient(); - await page.close(); -}); diff --git a/e2e/tests/testSupersetIntegration.spec.ts b/e2e/tests/testSupersetIntegration.spec.ts new file mode 100644 index 00000000..34f46414 --- /dev/null +++ b/e2e/tests/testSupersetIntegration.spec.ts @@ -0,0 +1,476 @@ +import { test, expect } from '@playwright/test'; +import { HomePage } from '../utils/functions/testBase'; +import { patientName } from '../utils/functions/testBase'; + +let homePage: HomePage; + +test.beforeEach(async ({ page }) => { + const homePage = new HomePage(page); + await homePage.initiateLogin(); + + await expect(page).toHaveURL(/.*home/); +}); + +test('Adding an OpenMRS patient syncs patient into patients table in Superset', async ({ page }) => { + // setup + const homePage = new HomePage(page); + await homePage.goToSuperset(); + await expect(page).toHaveURL(/.*superset/); + await homePage.selectDBSchema(); + await homePage.clearSQLEditor(); + let sqlQuerry1 = `SELECT COUNT (*) FROM patients;` + await page.getByRole('textbox').fill(sqlQuerry1); + await homePage.runSQLQuery(); + const initialNumberOfPatients = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); + let initialPatientCount = Number(initialNumberOfPatients); + await page.getByRole('tab', { name: 'Query history' }).click(); + await homePage.clearSQLEditor(); + + // replay + await page.goto(`${process.env.E2E_BASE_URL}/openmrs/spa/home`); + await homePage.createPatient(); + + // verify + await page.goto(`${process.env.E2E_SUPERSET_URL}/superset/sqllab`); + await homePage.clearSQLEditor(); + await page.getByRole('textbox').first().fill(sqlQuerry1); + await homePage.runSQLQuery(); + const updatedNumberOfPatients = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); + let updatedPatientCount = Number(updatedNumberOfPatients); + + await expect(updatedPatientCount).toBeGreaterThan(initialPatientCount); + + await page.getByRole('tab', { name: 'Query history' }).click(); + await homePage.clearSQLEditor(); + let sqlQuerry2 = `SELECT * FROM patients WHERE given_name like '${patientName.firstName}' AND family_name like '${patientName.givenName}';`; + await page.getByRole('textbox').fill(sqlQuerry2); + await homePage.runSQLQuery(); + + let patientGivenName = await page.getByRole('gridcell', { name: `${patientName.firstName}` }); + let patientFamilyName = await page.getByRole('gridcell', { name: `${patientName.givenName}` }); + let patientGender = await page.getByRole('gridcell', { name: 'M', exact: true }); + + await expect(patientGivenName).toHaveText(`${patientName.firstName}`); + await expect(patientFamilyName).toHaveText(`${patientName.givenName}`); + await expect(patientGender).toHaveText('M'); +}); + +test('Starting an OpenMRS visit syncs visit into visits table in Superset', async ({ page }) => { + // setup + const homePage = new HomePage(page); + await homePage.createPatient(); + await homePage.goToSuperset(); + await expect(page).toHaveURL(/.*superset/); + await homePage.selectDBSchema(); + await homePage.clearSQLEditor(); + let sqlQuery1 = `SELECT COUNT (*) FROM visits;` + await page.getByRole('textbox').fill(sqlQuery1); + await homePage.runSQLQuery(); + const initialNumberOfVisits = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); + let initialVisitCount = Number(initialNumberOfVisits); + await page.getByRole('tab', { name: 'Query history' }).click(); + await homePage.clearSQLEditor(); + + // replay + await page.goto(`${process.env.E2E_BASE_URL}/openmrs/spa/home`); + await homePage.startPatientVisit(); + + // verify + await page.goto(`${process.env.E2E_SUPERSET_URL}/superset/sqllab`); + await homePage.clearSQLEditor(); + await page.getByRole('textbox').first().fill(sqlQuery1); + await homePage.runSQLQuery(); + const updatedNumberOfVisits = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); + let updatedVisitCount = Number(updatedNumberOfVisits); + + await expect(updatedVisitCount).toBeGreaterThan(initialVisitCount); + + await page.getByRole('tab', { name: 'Query history' }).click(); + await homePage.clearSQLEditor(); + let sqlQuery2 = `SELECT patient_id FROM patients WHERE given_name like '${patientName.firstName}' AND family_name like '${patientName.givenName}';`; + await page.getByRole('textbox').fill(sqlQuery2); + await homePage.runSQLQuery(); + let patientId = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); + const patientIdValue = Number(patientId); + await page.getByRole('tab', { name: 'Results' }).click(); + await homePage.clearSQLEditor(); + let sqlQuery3 = `SELECT * FROM visits WHERE patient_id=${patientIdValue};`; + await page.getByRole('textbox').first().fill(sqlQuery3); + await homePage.runSQLQuery(); + + patientId = await page.getByRole('gridcell', { name: `${patientIdValue}` }).first().textContent(); + let patient_Id = Number(patientId); + let patientVisitType = await page.getByRole('gridcell', { name: 'Facility Visit' }); + let patientAgeGroupAtVisit = await page.getByRole('gridcell', { name: '20 - 24' }); + const patientGender = await page.getByRole('gridcell', { name: 'M', exact: true }); + let patientAgeAtVisit = Number(await page.getByRole('gridcell', { name: '24', exact: true }).nth(0).textContent()); + + await expect(patient_Id).toBe(Number(`${patientIdValue}`)); + await expect(patientVisitType).toHaveText('Facility Visit'); + await expect(patientGender).toHaveText('M'); + await expect(patientAgeAtVisit).toBe(24); + await expect(patientAgeGroupAtVisit).toHaveText('20 - 24'); +}); + +test('Creating an OpenMRS order syncs order into orders table in Superset', async ({ page }) => { + // setup + const homePage = new HomePage(page); + await homePage.createPatient(); + await homePage.startPatientVisit(); + await homePage.goToSuperset(); + await expect(page).toHaveURL(/.*superset/); + await homePage.selectDBSchema(); + await homePage.clearSQLEditor(); + let sqlQuery1 = `SELECT COUNT(*) FROM _orders;` + await page.getByRole('textbox').fill(sqlQuery1); + await homePage.runSQLQuery(); + const initialNumberOfOrders = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); + let initialOrderCount = Number(initialNumberOfOrders); + await page.getByRole('tab', { name: 'Query history' }).click(); + await homePage.clearSQLEditor(); + + // replay + await page.goto(`${process.env.E2E_BASE_URL}/openmrs/spa/home`); + await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); + await homePage.goToLabOrderForm(); + await page.getByRole('button', { name: 'Add', exact: true }).click(); + await page.locator('#tab select').selectOption('857AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); + await homePage.saveLabOrder(); + + // verify + await page.goto(`${process.env.E2E_SUPERSET_URL}/superset/sqllab`); + await homePage.clearSQLEditor(); + await page.getByRole('textbox').first().fill(sqlQuery1); + await homePage.runSQLQuery(); + const updatedNumberOfOrders = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); + let updatedOrderCount = Number(updatedNumberOfOrders); + + await expect(updatedOrderCount).toBeGreaterThan(initialOrderCount); + + await page.getByRole('tab', { name: 'Query history' }).click(); + await homePage.clearSQLEditor(); + let sqlQuery2 = `SELECT patient_id FROM patients WHERE given_name like '${patientName.firstName}' AND family_name like '${patientName.givenName}';`; + await page.getByRole('textbox').fill(sqlQuery2); + await homePage.runSQLQuery(); + let patientId = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); + const patientIdValue = Number(patientId); + await page.getByRole('tab', { name: 'Results' }).click(); + await homePage.clearSQLEditor(); + let sqlQuery3 = `SELECT * FROM _orders WHERE patient_id=${patientIdValue};`; + await page.getByRole('textbox').first().fill(sqlQuery3); + await homePage.runSQLQuery(); + + patientId = await page.getByRole('gridcell', { name: `${patientIdValue}` }).first().textContent(); + const patient_Id = Number(patientId); + let orderTypeName = await page.getByRole('gridcell', { name: 'Test Order' }); + let encounterTypeName = await page.getByRole('gridcell', { name: 'Consultation', exact: true }); + let careSettingName = await page.getByRole('gridcell', { name: 'Inpatient', exact: true }); + let careSettingType = await page.getByRole('gridcell', { name: 'INPATIENT', exact: true }); + + await expect(patient_Id).toBe(Number(`${patientIdValue}`)); + await expect(orderTypeName).toHaveText('Test Order'); + await expect(encounterTypeName).toHaveText('Consultation'); + await expect(careSettingName).toHaveText('Inpatient'); + await expect(careSettingType).toHaveText('INPATIENT'); +}); + +test('Adding an OpenMRS encounter syncs encounter into encounters table in Superset', async ({ page }) => { + // setup + const homePage = new HomePage(page); + await homePage.createPatient(); + await homePage.startPatientVisit(); + await homePage.goToSuperset(); + await expect(page).toHaveURL(/.*superset/); + await homePage.selectDBSchema(); + await homePage.clearSQLEditor(); + let sqlQuery1 = `SELECT COUNT(*) FROM encounters;` + await page.getByRole('textbox').fill(sqlQuery1); + await homePage.runSQLQuery(); + const initialNumberOfEncounters = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); + let initialEncounterCount = Number(initialNumberOfEncounters); + await page.getByRole('tab', { name: 'Query history' }).click(); + await homePage.clearSQLEditor(); + + // replay + await page.goto(`${process.env.E2E_BASE_URL}/openmrs/spa/home`); + await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); + await homePage.goToLabOrderForm(); + await page.getByRole('button', { name: 'Add', exact: true }).click(); + await page.locator('#tab select').selectOption('857AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); + await homePage.saveLabOrder(); + + // verify + await page.goto(`${process.env.E2E_SUPERSET_URL}/superset/sqllab`); + await homePage.clearSQLEditor(); + await page.getByRole('textbox').first().fill(sqlQuery1); + await homePage.runSQLQuery(); + const updatedNumberOfEncounters = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); + let updatedEncounterCount = Number(updatedNumberOfEncounters); + + await expect(updatedEncounterCount).toBeGreaterThan(initialEncounterCount); + + await page.getByRole('tab', { name: 'Query history' }).click(); + await homePage.clearSQLEditor(); + let sqlQuery2 = `SELECT patient_id FROM patients WHERE given_name like '${patientName.firstName}' AND family_name like '${patientName.givenName}';`; + await page.getByRole('textbox').fill(sqlQuery2); + await homePage.runSQLQuery(); + let patientId = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); + const patientIdValue = Number(patientId); + await page.getByRole('tab', { name: 'Results' }).click(); + await homePage.clearSQLEditor(); + let sqlQuery3 = `SELECT encounter_id FROM _orders WHERE patient_id=${patientIdValue};`; + await page.getByRole('textbox').first().fill(sqlQuery3); + await homePage.runSQLQuery(); + let encounterId = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); + const encounterIdValue = Number(encounterId); + await page.getByRole('tab', { name: 'Query history' }).click(); + await homePage.clearSQLEditor(); + let sqlQuery4 = `SELECT encounter_type_uuid FROM _orders WHERE patient_id=${patientIdValue};`; + await page.getByRole('textbox').fill(sqlQuery4); + await homePage.runSQLQuery(); + let encounterTypeUuidValue = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); + await page.getByRole('tab', { name: 'Results' }).click(); + await homePage.clearSQLEditor(); + let sqlQuery5 = `SELECT * FROM encounters WHERE encounter_id=${encounterIdValue} AND encounter_type_uuid like '${encounterTypeUuidValue}';`; + await page.getByRole('textbox').first().fill(sqlQuery5); + await homePage.runSQLQuery(); + + encounterId = await page.getByRole('gridcell', { name: `${encounterIdValue}` }).first().textContent(); + const encounter_Id = Number(encounterId); + let encounterTypeName = await page.getByRole('gridcell', { name: 'Consultation', exact: true }); + let encounterTypeUuid = await page.getByRole('gridcell', { name: 'dd528487-82a5-4082-9c72-ed246bd49591' }); + let encounterTypeDescription = await page.getByRole('gridcell', { name: 'Consultation encounter' }); + let visitTypeName = await page.getByRole('gridcell', { name: 'Facility Visit' }); + let visitTypeUuid = await page.getByRole('gridcell', { name: '7b0f5697-27e3-40c4-8bae-f4049abfb4ed' }); + let formName = await page.getByRole('gridcell', { name: 'Laboratory Tests' }); + let formUuid = await page.getByRole('gridcell', { name: 'bfc3a476-c286-3da8-ae41-fb36f801b3b9' }); + let formDescription = await page.getByRole('gridcell', { name: 'Simple lab order entry form' }); + 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); + + await expect(encounter_Id).toBe(Number(`${encounterIdValue}`)); + await expect(encounterTypeName).toHaveText('Consultation'); + await expect(encounterTypeUuid).toHaveText(`${encounterTypeUuidValue}`); + await expect(encounterTypeDescription).toHaveText('Consultation encounter'); + await expect(visitTypeName).toHaveText('Facility Visit'); + await expect(visitTypeUuid).toContainText('7b0f5697-27e3-40c4-8bae-f4049abfb4ed'); + await expect(formName).toHaveText('Laboratory Tests'); + await expect(formUuid).toHaveText('bfc3a476-c286-3da8-ae41-fb36f801b3b9'); + await expect(formDescription).toHaveText('Simple lab order entry form'); + await expect(locationName).toHaveText('Inpatient Ward'); + await expect(locationUuid).toHaveText('ba685651-ed3b-4e63-9b35-78893060758a'); + await expect(locationDescription).toHaveText('Inpatient Ward'); +}); + +test('Adding an OpenMRS patient condition syncs condition into conditions table in Superset', async ({ page }) => { + // setup + const homePage = new HomePage(page); + await homePage.createPatient(); + await homePage.startPatientVisit(); + await homePage.goToSuperset(); + await expect(page).toHaveURL(/.*superset/); + await homePage.selectDBSchema(); + await homePage.clearSQLEditor(); + let sqlQuery1 = `SELECT COUNT (*) FROM _conditions;` + await page.getByRole('textbox').fill(sqlQuery1); + await homePage.runSQLQuery(); + const initialNumberOfConditions = await page.getByRole('gridcell', { name: ' ' }).textContent(); + let initialConditionCount = Number(initialNumberOfConditions); + await page.getByRole('tab', { name: 'Query history' }).click(); + await homePage.clearSQLEditor(); + + // replay + await page.goto(`${process.env.E2E_BASE_URL}/openmrs/spa/home`); + await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); + await homePage.addPatientCondition(); + + // verify + await page.goto(`${process.env.E2E_SUPERSET_URL}/superset/sqllab`); + await homePage.clearSQLEditor(); + await page.getByRole('textbox').first().fill(sqlQuery1); + await homePage.runSQLQuery(); + const updatedNumberOfConditions = await page.getByRole('gridcell', { name: ' ' }).textContent(); + let updatedConditionCount = Number(updatedNumberOfConditions); + + await expect(updatedConditionCount).toBeGreaterThan(initialConditionCount); + + await page.getByRole('tab', { name: 'Query history' }).click(); + await homePage.clearSQLEditor(); + let sqlQuery2 = `SELECT patient_id FROM patients WHERE given_name like '${patientName.firstName}' AND family_name like '${patientName.givenName}';`; + await page.getByRole('textbox').fill(sqlQuery2); + await homePage.runSQLQuery(); + let patientId = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); + const patientIdValue = Number(patientId); + await page.getByRole('tab', { name: 'Results' }).click(); + await homePage.clearSQLEditor(); + let sqlQuery3 = `SELECT * FROM _conditions WHERE patient_id=${patientIdValue};`; + await page.getByRole('textbox').first().fill(sqlQuery3); + await homePage.runSQLQuery(); + + patientId = await page.getByRole('gridcell', { name: `${patientIdValue}` }).first().textContent(); + const patient_Id = Number(patientId); + let clinicalStatus = await page.getByRole('gridcell', { name: 'ACTIVE' }); + let onSetDate = await page.getByRole('gridcell', { name: '2023-07-27' }); + + await expect(patient_Id).toBe(Number(`${patientIdValue}`)); + await expect(clinicalStatus).toHaveText('ACTIVE'); + await expect(onSetDate).toContainText('2023-07-27T00:00:00'); +}); + +test('Adding an OpenMRS observation syncs observation into observations table in Superset', async ({ page }) => { + // setup + const homePage = new HomePage(page); + await homePage.createPatient(); + await homePage.startPatientVisit(); + await homePage.goToSuperset(); + await expect(page).toHaveURL(/.*superset/); + await homePage.selectDBSchema(); + await homePage.clearSQLEditor(); + let sqlQuery1 = `SELECT COUNT (*) FROM observations;` + await page.getByRole('textbox').fill(sqlQuery1); + await homePage.runSQLQuery(); + const initialNumberOfObservations = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); + let initialObservationCount = Number(initialNumberOfObservations); + await page.getByRole('tab', { name: 'Query history' }).click(); + await homePage.clearSQLEditor(); + + // replay + await page.goto(`${process.env.E2E_BASE_URL}/openmrs/spa/home`); + await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); + await homePage.addPatientBiometrics(); + + // verify + await page.goto(`${process.env.E2E_SUPERSET_URL}/superset/sqllab`); + await homePage.clearSQLEditor(); + await page.getByRole('textbox').first().fill(sqlQuery1); + await homePage.runSQLQuery(); + const updatedNumberOfObservations = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); + let updatedObservationCount = Number(updatedNumberOfObservations); + + await expect(updatedObservationCount).toBeGreaterThan(initialObservationCount); + + await page.getByRole('tab', { name: 'Query history' }).click(); + await homePage.clearSQLEditor(); + let sqlQuery2 = `SELECT patient_id FROM patients WHERE given_name like '${patientName.firstName}' AND family_name like '${patientName.givenName}';`; + await page.getByRole('textbox').fill(sqlQuery2); + await homePage.runSQLQuery(); + let patientId = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); + const patientIdValue = Number(patientId); + await page.getByRole('tab', { name: 'Results' }).click(); + await homePage.clearSQLEditor(); + let sqlQuery3 = `SELECT person_id FROM visits WHERE patient_id=${patientIdValue};`; + await page.getByRole('textbox').first().fill(sqlQuery3); + await homePage.runSQLQuery(); + let personId = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); + const personIdValue = Number(personId); + await page.getByRole('tab', { name: 'Query history' }).click(); + await homePage.clearSQLEditor(); + let sqlQuery4 = `SELECT * FROM observations WHERE person_id=${personIdValue};`; + await page.getByRole('textbox').fill(sqlQuery4); + await homePage.runSQLQuery(); + + personId = await page.getByRole('gridcell', { name: `${personIdValue}` }).first().textContent(); + let person_Id = Number(personId); + let firstConceptName = await page.getByRole('gridcell', { name: 'Circonférence du haut du bras' }); + let secondConceptName = await page.getByRole('gridcell', { name: 'Taille (cm)' }); + let thirdConceptName = await page.getByRole('gridcell', { name: 'Weight (kg)' }); + let firstConceptUuid = await page.getByRole('gridcell', { name: '9ff26a7f-b598-3e33-aff1-639fd777fc06' }); + let secondConceptUuid = await page.getByRole('gridcell', { name: 'b911bf87-a5e0-3ebf-9ffe-2bbe13e178b8' }); + let thirdConceptUuid = await page.getByRole('gridcell', { name: 'c1015fd1-729b-33c7-82e8-0b14a5a824ed' }); + let weight = await page.getByRole('gridcell', { name: '78', exact: true }).textContent(); + let patientWeight = Number(weight); + let height = await page.getByRole('gridcell', { name: '165', exact: true }).textContent(); + let patientHeight = Number(height); + let midUpperArmCircumference = await page.getByRole('gridcell', { name: '34', exact: true }).textContent(); + let patientMidUpperArmCircumference = Number(midUpperArmCircumference); + let encounterTypeUuid = await page.getByRole('row', { name: 'Weight (kg)' }).getByTitle('67a71486-1a54-468f-ac3e-7091a9a79584'); + let encounterName = await page.getByRole('row', { name: 'Weight (kg)' }).getByTitle('Vitals'); + let encounterTypeDescription = await page.getByRole('row', { name: 'Taille (cm)' }).getByTitle('For capturing vital signs'); + + await expect(person_Id).toBe(Number(`${personIdValue}`)); + await expect(firstConceptName).toHaveText('Circonférence du haut du bras'); + await expect(secondConceptName).toHaveText('Taille (cm)'); + await expect(thirdConceptName).toHaveText('Weight (kg)'); + await expect(patientWeight).toBe(78); + await expect(patientHeight).toBe(165); + await expect(patientMidUpperArmCircumference).toBe(34); + await expect(firstConceptUuid).toHaveText('9ff26a7f-b598-3e33-aff1-639fd777fc06'); + await expect(secondConceptUuid).toHaveText('b911bf87-a5e0-3ebf-9ffe-2bbe13e178b8'); + await expect(thirdConceptUuid).toHaveText('c1015fd1-729b-33c7-82e8-0b14a5a824ed'); + await expect(encounterTypeUuid).toHaveText('67a71486-1a54-468f-ac3e-7091a9a79584'); + await expect(encounterName).toHaveText('Vitals'); + await expect(encounterTypeDescription).toHaveText('For capturing vital signs'); +}); + +test('Adding an OpenMRS patient appointment syncs appointment into appointments table in Superset', async ({ page }) => { + // setup + const homePage = new HomePage(page); + await homePage.createPatient(); + await homePage.startPatientVisit(); + await homePage.goToSuperset(); + await expect(page).toHaveURL(/.*superset/); + await homePage.selectDBSchema(); + await homePage.clearSQLEditor(); + let sqlQuery1 = `SELECT COUNT(*) FROM appointments;` + await page.getByRole('textbox').fill(sqlQuery1); + await homePage.runSQLQuery(); + + const initialNumberOfAppointments = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); + let initialAppointmentCount = Number(initialNumberOfAppointments); + await page.getByRole('tab', { name: 'Query history' }).click(); + await homePage.clearSQLEditor(); + + // replay + await page.goto(`${process.env.E2E_BASE_URL}/openmrs/spa/home`); + await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); + await homePage.addPatientAppointment(); + + // verify + await page.goto(`${process.env.E2E_SUPERSET_URL}/superset/sqllab`); + await homePage.clearSQLEditor(); + await page.getByRole('textbox').first().fill(sqlQuery1); + await homePage.runSQLQuery(); + const updatedNumberOfAppointments = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); + let updatedAppointmentCount = Number(updatedNumberOfAppointments); + + await expect(updatedAppointmentCount).toBeGreaterThan(initialAppointmentCount); + + await page.getByRole('tab', { name: 'Query history' }).click(); + await homePage.clearSQLEditor(); + let sqlQuery2 = `SELECT patient_id FROM patients WHERE given_name like '${patientName.firstName}' AND family_name like '${patientName.givenName}';`; + await page.getByRole('textbox').fill(sqlQuery2); + await homePage.runSQLQuery(); + let patientId = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); + const patientIdValue = Number(patientId); + await page.getByRole('tab', { name: 'Results' }).click(); + await homePage.clearSQLEditor(); + let sqlQuery3 = `SELECT * FROM appointments WHERE patient_id=${patientIdValue};`; + await page.getByRole('textbox').first().fill(sqlQuery3); + await homePage.runSQLQuery(); + + patientId = await page.getByRole('gridcell', { name: `${patientIdValue}` }).first().textContent(); + let patient_Id = Number(patientId); + let appointmentServiceName = await page.getByRole('gridcell', { name: 'General Medicine service' }); + let appointmentServiceUuid = await page.getByRole('gridcell', { name: '7ba3aa21-cc56-47ca-bb4d-a60549f666c0' }); + let appointmentStatus = await page.getByRole('gridcell', { name: 'Scheduled' }); + let appointmentKind = await page.getByRole('gridcell', { name: 'WalkIn' }); + let appointmentServiceTypeName = await page.getByRole('gridcell', { name: 'Short follow-up' }); + let appointmentComment = await page.getByRole('gridcell', { name: 'This is an appointment.' }); + let patientAppointmentProviderResponse = await page.getByRole('gridcell', { name: 'ACCEPTED' }); + + await expect(patient_Id).toBe(Number(`${patientIdValue}`)); + await expect(appointmentServiceName).toHaveText('General Medicine service'); + await expect(appointmentServiceUuid).toHaveText('7ba3aa21-cc56-47ca-bb4d-a60549f666c0'); + await expect(appointmentStatus).toHaveText('Scheduled'); + await expect(appointmentKind).toHaveText('WalkIn'); + await expect(appointmentServiceTypeName).toHaveText('Short follow-up'); + await expect(appointmentComment).toHaveText('This is an appointment.'); + await expect(patientAppointmentProviderResponse).toHaveText('ACCEPTED'); +}); + +test.afterEach(async ({ page }) => { + const homePage = new HomePage(page); + await homePage.deletePatient(); + await page.close(); +}); diff --git a/e2e/utils/functions/testBase.ts b/e2e/utils/functions/testBase.ts index 7175ac0f..b9c124d1 100644 --- a/e2e/utils/functions/testBase.ts +++ b/e2e/utils/functions/testBase.ts @@ -187,19 +187,17 @@ export class HomePage { await this.page.locator('div').filter({ hasText: /^Select schema or type schema name$/ }).nth(1).click(); await this.page.getByTitle('public').getByText('public').click(); await this.page.getByRole('textbox').first().clear(); - await delay(5000); + await delay(4000); } - async runSQLQuery() { - await this.page.getByRole('button', { name: 'Run' }).click(); - await delay(5000); + async clearSQLEditor() { + await this.page.getByRole('textbox').first().clear(); + await this.page.getByRole('textbox').first().fill(''); + await delay(3000); } - async returnToSQLEditor() { - await this.page.getByRole('button', { name: 'triangle-down SQL Lab' }).click(); - await this.page.getByRole('link', { name: 'SQL Editor' }).click(); - await this.page.getByRole('textbox').first().clear(); - await this.page.getByRole('tab', { name: 'Query history' }).click(); + async runSQLQuery() { + await this.page.getByRole('button', { name: 'Run' }).click(); await delay(5000); } From 6cb333b54670150de7ca6907611e557960c91520 Mon Sep 17 00:00:00 2001 From: kdaud Date: Mon, 23 Oct 2023 16:51:37 +0300 Subject: [PATCH 2/4] Updated names of the queries + Updating data counts check --- .env | 2 +- ...ec.ts => testAnalyticsIntegration.spec.ts} | 120 +++++++++--------- 2 files changed, 61 insertions(+), 61 deletions(-) rename e2e/tests/{testSupersetIntegration.spec.ts => testAnalyticsIntegration.spec.ts} (81%) diff --git a/.env b/.env index 8f021a51..fc9f33a0 100644 --- a/.env +++ b/.env @@ -3,7 +3,7 @@ E2E_BASE_URL=https://ozone-dev.mekomsolutions.net E2E_ODOO_URL=https://erp.ozone-dev.mekomsolutions.net E2E_SENAITE_URL=https://lims.ozone-dev.mekomsolutions.net E2E_KEYCLOAK_URL=https://auth.ozone-dev.mekomsolutions.net -E2E_SUPERSET_URL=https://analytics.ozone-dev.mekomsolutions.net +E2E_ANALYTICS_URL=https://analytics.ozone-dev.mekomsolutions.net E2E_USER_ADMIN_USERNAME=jdoe E2E_USER_ADMIN_PASSWORD=password E2E_LOGIN_DEFAULT_LOCATION_UUID=ba685651-ed3b-4e63-9b35-78893060758a diff --git a/e2e/tests/testSupersetIntegration.spec.ts b/e2e/tests/testAnalyticsIntegration.spec.ts similarity index 81% rename from e2e/tests/testSupersetIntegration.spec.ts rename to e2e/tests/testAnalyticsIntegration.spec.ts index 34f46414..ec4dc367 100644 --- a/e2e/tests/testSupersetIntegration.spec.ts +++ b/e2e/tests/testAnalyticsIntegration.spec.ts @@ -18,8 +18,8 @@ test('Adding an OpenMRS patient syncs patient into patients table in Superset', await expect(page).toHaveURL(/.*superset/); await homePage.selectDBSchema(); await homePage.clearSQLEditor(); - let sqlQuerry1 = `SELECT COUNT (*) FROM patients;` - await page.getByRole('textbox').fill(sqlQuerry1); + let patientCountsQuery = `SELECT COUNT (*) FROM patients;` + await page.getByRole('textbox').fill(patientCountsQuery); await homePage.runSQLQuery(); const initialNumberOfPatients = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); let initialPatientCount = Number(initialNumberOfPatients); @@ -33,17 +33,17 @@ test('Adding an OpenMRS patient syncs patient into patients table in Superset', // verify await page.goto(`${process.env.E2E_SUPERSET_URL}/superset/sqllab`); await homePage.clearSQLEditor(); - await page.getByRole('textbox').first().fill(sqlQuerry1); + await page.getByRole('textbox').first().fill(patientCountsQuery); await homePage.runSQLQuery(); const updatedNumberOfPatients = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); let updatedPatientCount = Number(updatedNumberOfPatients); - await expect(updatedPatientCount).toBeGreaterThan(initialPatientCount); + await expect(updatedPatientCount).toBe(initialPatientCount + 1); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); - let sqlQuerry2 = `SELECT * FROM patients WHERE given_name like '${patientName.firstName}' AND family_name like '${patientName.givenName}';`; - await page.getByRole('textbox').fill(sqlQuerry2); + let patientQuery = `SELECT * FROM patients WHERE given_name like '${patientName.firstName}' AND family_name like '${patientName.givenName}';`; + await page.getByRole('textbox').fill(patientQuery); await homePage.runSQLQuery(); let patientGivenName = await page.getByRole('gridcell', { name: `${patientName.firstName}` }); @@ -63,8 +63,8 @@ test('Starting an OpenMRS visit syncs visit into visits table in Superset', asyn await expect(page).toHaveURL(/.*superset/); await homePage.selectDBSchema(); await homePage.clearSQLEditor(); - let sqlQuery1 = `SELECT COUNT (*) FROM visits;` - await page.getByRole('textbox').fill(sqlQuery1); + let visitCountsQuery = `SELECT COUNT (*) FROM visits;` + await page.getByRole('textbox').fill(visitCountsQuery); await homePage.runSQLQuery(); const initialNumberOfVisits = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); let initialVisitCount = Number(initialNumberOfVisits); @@ -78,24 +78,24 @@ test('Starting an OpenMRS visit syncs visit into visits table in Superset', asyn // verify await page.goto(`${process.env.E2E_SUPERSET_URL}/superset/sqllab`); await homePage.clearSQLEditor(); - await page.getByRole('textbox').first().fill(sqlQuery1); + await page.getByRole('textbox').first().fill(visitCountsQuery); await homePage.runSQLQuery(); const updatedNumberOfVisits = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); let updatedVisitCount = Number(updatedNumberOfVisits); - await expect(updatedVisitCount).toBeGreaterThan(initialVisitCount); + await expect(updatedVisitCount).toBe(initialVisitCount + 1); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); - let sqlQuery2 = `SELECT patient_id FROM patients WHERE given_name like '${patientName.firstName}' AND family_name like '${patientName.givenName}';`; - await page.getByRole('textbox').fill(sqlQuery2); + let patientIdQuery = `SELECT patient_id FROM patients WHERE given_name like '${patientName.firstName}' AND family_name like '${patientName.givenName}';`; + await page.getByRole('textbox').fill(patientIdQuery); await homePage.runSQLQuery(); let patientId = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); const patientIdValue = Number(patientId); await page.getByRole('tab', { name: 'Results' }).click(); await homePage.clearSQLEditor(); - let sqlQuery3 = `SELECT * FROM visits WHERE patient_id=${patientIdValue};`; - await page.getByRole('textbox').first().fill(sqlQuery3); + let visitQuery = `SELECT * FROM visits WHERE patient_id=${patientIdValue};`; + await page.getByRole('textbox').first().fill(visitQuery); await homePage.runSQLQuery(); patientId = await page.getByRole('gridcell', { name: `${patientIdValue}` }).first().textContent(); @@ -121,8 +121,8 @@ test('Creating an OpenMRS order syncs order into orders table in Superset', asyn await expect(page).toHaveURL(/.*superset/); await homePage.selectDBSchema(); await homePage.clearSQLEditor(); - let sqlQuery1 = `SELECT COUNT(*) FROM _orders;` - await page.getByRole('textbox').fill(sqlQuery1); + let orderCountsQuery = `SELECT COUNT(*) FROM _orders;` + await page.getByRole('textbox').fill(orderCountsQuery); await homePage.runSQLQuery(); const initialNumberOfOrders = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); let initialOrderCount = Number(initialNumberOfOrders); @@ -140,24 +140,24 @@ test('Creating an OpenMRS order syncs order into orders table in Superset', asyn // verify await page.goto(`${process.env.E2E_SUPERSET_URL}/superset/sqllab`); await homePage.clearSQLEditor(); - await page.getByRole('textbox').first().fill(sqlQuery1); + await page.getByRole('textbox').first().fill(orderCountsQuery); await homePage.runSQLQuery(); const updatedNumberOfOrders = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); let updatedOrderCount = Number(updatedNumberOfOrders); - await expect(updatedOrderCount).toBeGreaterThan(initialOrderCount); + await expect(updatedOrderCount).toBe(initialOrderCount + 1); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); - let sqlQuery2 = `SELECT patient_id FROM patients WHERE given_name like '${patientName.firstName}' AND family_name like '${patientName.givenName}';`; - await page.getByRole('textbox').fill(sqlQuery2); + let patientIdQuery = `SELECT patient_id FROM patients WHERE given_name like '${patientName.firstName}' AND family_name like '${patientName.givenName}';`; + await page.getByRole('textbox').fill(patientIdQuery); await homePage.runSQLQuery(); let patientId = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); const patientIdValue = Number(patientId); await page.getByRole('tab', { name: 'Results' }).click(); await homePage.clearSQLEditor(); - let sqlQuery3 = `SELECT * FROM _orders WHERE patient_id=${patientIdValue};`; - await page.getByRole('textbox').first().fill(sqlQuery3); + let orderQuery = `SELECT * FROM _orders WHERE patient_id=${patientIdValue};`; + await page.getByRole('textbox').first().fill(orderQuery); await homePage.runSQLQuery(); patientId = await page.getByRole('gridcell', { name: `${patientIdValue}` }).first().textContent(); @@ -183,8 +183,8 @@ test('Adding an OpenMRS encounter syncs encounter into encounters table in Super await expect(page).toHaveURL(/.*superset/); await homePage.selectDBSchema(); await homePage.clearSQLEditor(); - let sqlQuery1 = `SELECT COUNT(*) FROM encounters;` - await page.getByRole('textbox').fill(sqlQuery1); + let encounterCountsQuery = `SELECT COUNT(*) FROM encounters;` + await page.getByRole('textbox').fill(encounterCountsQuery); await homePage.runSQLQuery(); const initialNumberOfEncounters = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); let initialEncounterCount = Number(initialNumberOfEncounters); @@ -202,37 +202,37 @@ test('Adding an OpenMRS encounter syncs encounter into encounters table in Super // verify await page.goto(`${process.env.E2E_SUPERSET_URL}/superset/sqllab`); await homePage.clearSQLEditor(); - await page.getByRole('textbox').first().fill(sqlQuery1); + await page.getByRole('textbox').first().fill(encounterCountsQuery); await homePage.runSQLQuery(); const updatedNumberOfEncounters = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); let updatedEncounterCount = Number(updatedNumberOfEncounters); - await expect(updatedEncounterCount).toBeGreaterThan(initialEncounterCount); + await expect(updatedEncounterCount).toBe(initialEncounterCount + 1); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); - let sqlQuery2 = `SELECT patient_id FROM patients WHERE given_name like '${patientName.firstName}' AND family_name like '${patientName.givenName}';`; - await page.getByRole('textbox').fill(sqlQuery2); + let patientIdQuery = `SELECT patient_id FROM patients WHERE given_name like '${patientName.firstName}' AND family_name like '${patientName.givenName}';`; + await page.getByRole('textbox').fill(patientIdQuery); await homePage.runSQLQuery(); let patientId = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); const patientIdValue = Number(patientId); await page.getByRole('tab', { name: 'Results' }).click(); await homePage.clearSQLEditor(); - let sqlQuery3 = `SELECT encounter_id FROM _orders WHERE patient_id=${patientIdValue};`; - await page.getByRole('textbox').first().fill(sqlQuery3); + let encounterIdQuery = `SELECT encounter_id FROM _orders WHERE patient_id=${patientIdValue};`; + await page.getByRole('textbox').first().fill(encounterIdQuery); await homePage.runSQLQuery(); let encounterId = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); const encounterIdValue = Number(encounterId); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); - let sqlQuery4 = `SELECT encounter_type_uuid FROM _orders WHERE patient_id=${patientIdValue};`; - await page.getByRole('textbox').fill(sqlQuery4); + let encounterTypeUuidQuery = `SELECT encounter_type_uuid FROM _orders WHERE patient_id=${patientIdValue};`; + await page.getByRole('textbox').fill(encounterTypeUuidQuery); await homePage.runSQLQuery(); let encounterTypeUuidValue = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); await page.getByRole('tab', { name: 'Results' }).click(); await homePage.clearSQLEditor(); - let sqlQuery5 = `SELECT * FROM encounters WHERE encounter_id=${encounterIdValue} AND encounter_type_uuid like '${encounterTypeUuidValue}';`; - await page.getByRole('textbox').first().fill(sqlQuery5); + let encounterQuery = `SELECT * FROM encounters WHERE encounter_id=${encounterIdValue} AND encounter_type_uuid like '${encounterTypeUuidValue}';`; + await page.getByRole('textbox').first().fill(encounterQuery); await homePage.runSQLQuery(); encounterId = await page.getByRole('gridcell', { name: `${encounterIdValue}` }).first().textContent(); @@ -272,8 +272,8 @@ test('Adding an OpenMRS patient condition syncs condition into conditions table await expect(page).toHaveURL(/.*superset/); await homePage.selectDBSchema(); await homePage.clearSQLEditor(); - let sqlQuery1 = `SELECT COUNT (*) FROM _conditions;` - await page.getByRole('textbox').fill(sqlQuery1); + let conditionCountsQuery = `SELECT COUNT (*) FROM _conditions;` + await page.getByRole('textbox').fill(conditionCountsQuery); await homePage.runSQLQuery(); const initialNumberOfConditions = await page.getByRole('gridcell', { name: ' ' }).textContent(); let initialConditionCount = Number(initialNumberOfConditions); @@ -288,24 +288,24 @@ test('Adding an OpenMRS patient condition syncs condition into conditions table // verify await page.goto(`${process.env.E2E_SUPERSET_URL}/superset/sqllab`); await homePage.clearSQLEditor(); - await page.getByRole('textbox').first().fill(sqlQuery1); + await page.getByRole('textbox').first().fill(conditionCountsQuery); await homePage.runSQLQuery(); const updatedNumberOfConditions = await page.getByRole('gridcell', { name: ' ' }).textContent(); let updatedConditionCount = Number(updatedNumberOfConditions); - await expect(updatedConditionCount).toBeGreaterThan(initialConditionCount); + await expect(updatedConditionCount).toBe(initialConditionCount + 1); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); - let sqlQuery2 = `SELECT patient_id FROM patients WHERE given_name like '${patientName.firstName}' AND family_name like '${patientName.givenName}';`; - await page.getByRole('textbox').fill(sqlQuery2); + let patientIdQuery = `SELECT patient_id FROM patients WHERE given_name like '${patientName.firstName}' AND family_name like '${patientName.givenName}';`; + await page.getByRole('textbox').fill(patientIdQuery); await homePage.runSQLQuery(); let patientId = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); const patientIdValue = Number(patientId); await page.getByRole('tab', { name: 'Results' }).click(); await homePage.clearSQLEditor(); - let sqlQuery3 = `SELECT * FROM _conditions WHERE patient_id=${patientIdValue};`; - await page.getByRole('textbox').first().fill(sqlQuery3); + let conditionQuery = `SELECT * FROM _conditions WHERE patient_id=${patientIdValue};`; + await page.getByRole('textbox').first().fill(conditionQuery); await homePage.runSQLQuery(); patientId = await page.getByRole('gridcell', { name: `${patientIdValue}` }).first().textContent(); @@ -327,8 +327,8 @@ test('Adding an OpenMRS observation syncs observation into observations table in await expect(page).toHaveURL(/.*superset/); await homePage.selectDBSchema(); await homePage.clearSQLEditor(); - let sqlQuery1 = `SELECT COUNT (*) FROM observations;` - await page.getByRole('textbox').fill(sqlQuery1); + let observationCountsQuery = `SELECT COUNT (*) FROM observations;` + await page.getByRole('textbox').fill(observationCountsQuery); await homePage.runSQLQuery(); const initialNumberOfObservations = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); let initialObservationCount = Number(initialNumberOfObservations); @@ -343,31 +343,31 @@ test('Adding an OpenMRS observation syncs observation into observations table in // verify await page.goto(`${process.env.E2E_SUPERSET_URL}/superset/sqllab`); await homePage.clearSQLEditor(); - await page.getByRole('textbox').first().fill(sqlQuery1); + await page.getByRole('textbox').first().fill(observationCountsQuery); await homePage.runSQLQuery(); const updatedNumberOfObservations = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); let updatedObservationCount = Number(updatedNumberOfObservations); - await expect(updatedObservationCount).toBeGreaterThan(initialObservationCount); + await expect(updatedObservationCount).toBe(initialObservationCount + 3); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); - let sqlQuery2 = `SELECT patient_id FROM patients WHERE given_name like '${patientName.firstName}' AND family_name like '${patientName.givenName}';`; - await page.getByRole('textbox').fill(sqlQuery2); + let patientIdQuery = `SELECT patient_id FROM patients WHERE given_name like '${patientName.firstName}' AND family_name like '${patientName.givenName}';`; + await page.getByRole('textbox').fill(patientIdQuery); await homePage.runSQLQuery(); let patientId = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); const patientIdValue = Number(patientId); await page.getByRole('tab', { name: 'Results' }).click(); await homePage.clearSQLEditor(); - let sqlQuery3 = `SELECT person_id FROM visits WHERE patient_id=${patientIdValue};`; - await page.getByRole('textbox').first().fill(sqlQuery3); + let personIdQuery = `SELECT person_id FROM visits WHERE patient_id=${patientIdValue};`; + await page.getByRole('textbox').first().fill(personIdQuery); await homePage.runSQLQuery(); let personId = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); const personIdValue = Number(personId); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); - let sqlQuery4 = `SELECT * FROM observations WHERE person_id=${personIdValue};`; - await page.getByRole('textbox').fill(sqlQuery4); + let observationsQuery = `SELECT * FROM observations WHERE person_id=${personIdValue};`; + await page.getByRole('textbox').fill(observationsQuery); await homePage.runSQLQuery(); personId = await page.getByRole('gridcell', { name: `${personIdValue}` }).first().textContent(); @@ -412,8 +412,8 @@ test('Adding an OpenMRS patient appointment syncs appointment into appointments await expect(page).toHaveURL(/.*superset/); await homePage.selectDBSchema(); await homePage.clearSQLEditor(); - let sqlQuery1 = `SELECT COUNT(*) FROM appointments;` - await page.getByRole('textbox').fill(sqlQuery1); + let appointmentCountsQuery = `SELECT COUNT(*) FROM appointments;` + await page.getByRole('textbox').fill(appointmentCountsQuery); await homePage.runSQLQuery(); const initialNumberOfAppointments = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); @@ -429,24 +429,24 @@ test('Adding an OpenMRS patient appointment syncs appointment into appointments // verify await page.goto(`${process.env.E2E_SUPERSET_URL}/superset/sqllab`); await homePage.clearSQLEditor(); - await page.getByRole('textbox').first().fill(sqlQuery1); + await page.getByRole('textbox').first().fill(appointmentCountsQuery); await homePage.runSQLQuery(); const updatedNumberOfAppointments = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); let updatedAppointmentCount = Number(updatedNumberOfAppointments); - await expect(updatedAppointmentCount).toBeGreaterThan(initialAppointmentCount); + await expect(updatedAppointmentCount).toBe(initialAppointmentCount + 1); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); - let sqlQuery2 = `SELECT patient_id FROM patients WHERE given_name like '${patientName.firstName}' AND family_name like '${patientName.givenName}';`; - await page.getByRole('textbox').fill(sqlQuery2); + let patientIdQuery = `SELECT patient_id FROM patients WHERE given_name like '${patientName.firstName}' AND family_name like '${patientName.givenName}';`; + await page.getByRole('textbox').fill(patientIdQuery); await homePage.runSQLQuery(); let patientId = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); const patientIdValue = Number(patientId); await page.getByRole('tab', { name: 'Results' }).click(); await homePage.clearSQLEditor(); - let sqlQuery3 = `SELECT * FROM appointments WHERE patient_id=${patientIdValue};`; - await page.getByRole('textbox').first().fill(sqlQuery3); + let appointmentQuery = `SELECT * FROM appointments WHERE patient_id=${patientIdValue};`; + await page.getByRole('textbox').first().fill(appointmentQuery); await homePage.runSQLQuery(); patientId = await page.getByRole('gridcell', { name: `${patientIdValue}` }).first().textContent(); From 2fc69bb89830f09146e2fc30137dbb732d76b307 Mon Sep 17 00:00:00 2001 From: kdaud Date: Mon, 23 Oct 2023 19:28:18 +0300 Subject: [PATCH 3/4] Use OpenMRS ID when searching patient in Superset patients table --- e2e/tests/testAnalyticsIntegration.spec.ts | 28 ++++++++++++++++------ e2e/utils/functions/testBase.ts | 8 +++++++ 2 files changed, 29 insertions(+), 7 deletions(-) diff --git a/e2e/tests/testAnalyticsIntegration.spec.ts b/e2e/tests/testAnalyticsIntegration.spec.ts index ec4dc367..903b89f5 100644 --- a/e2e/tests/testAnalyticsIntegration.spec.ts +++ b/e2e/tests/testAnalyticsIntegration.spec.ts @@ -29,6 +29,8 @@ test('Adding an OpenMRS patient syncs patient into patients table in Superset', // replay await page.goto(`${process.env.E2E_BASE_URL}/openmrs/spa/home`); await homePage.createPatient(); + await homePage.searchPatientId(); + const patientIdentifier = await page.locator('#demographics section p:nth-child(2)').textContent(); // verify await page.goto(`${process.env.E2E_SUPERSET_URL}/superset/sqllab`); @@ -42,7 +44,7 @@ test('Adding an OpenMRS patient syncs patient into patients table in Superset', await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); - let patientQuery = `SELECT * FROM patients WHERE given_name like '${patientName.firstName}' AND family_name like '${patientName.givenName}';`; + let patientQuery = `SELECT * FROM patients WHERE identifier like '${patientIdentifier}';`; await page.getByRole('textbox').fill(patientQuery); await homePage.runSQLQuery(); @@ -59,6 +61,8 @@ test('Starting an OpenMRS visit syncs visit into visits table in Superset', asyn // setup const homePage = new HomePage(page); await homePage.createPatient(); + await homePage.searchPatientId(); + const patientIdentifier = await page.locator('#demographics section p:nth-child(2)').textContent(); await homePage.goToSuperset(); await expect(page).toHaveURL(/.*superset/); await homePage.selectDBSchema(); @@ -87,7 +91,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(); - let patientIdQuery = `SELECT patient_id FROM patients WHERE given_name like '${patientName.firstName}' AND family_name like '${patientName.givenName}';`; + let patientIdQuery = `SELECT patient_id FROM patients WHERE identifier like '${patientIdentifier}';`; await page.getByRole('textbox').fill(patientIdQuery); await homePage.runSQLQuery(); let patientId = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); @@ -116,6 +120,8 @@ test('Creating an OpenMRS order syncs order into orders table in Superset', asyn // setup const homePage = new HomePage(page); await homePage.createPatient(); + await homePage.searchPatientId(); + const patientIdentifier = await page.locator('#demographics section p:nth-child(2)').textContent(); await homePage.startPatientVisit(); await homePage.goToSuperset(); await expect(page).toHaveURL(/.*superset/); @@ -149,7 +155,7 @@ test('Creating an OpenMRS order syncs order into orders table in Superset', asyn await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); - let patientIdQuery = `SELECT patient_id FROM patients WHERE given_name like '${patientName.firstName}' AND family_name like '${patientName.givenName}';`; + let patientIdQuery = `SELECT patient_id FROM patients WHERE identifier like '${patientIdentifier}';`; await page.getByRole('textbox').fill(patientIdQuery); await homePage.runSQLQuery(); let patientId = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); @@ -178,6 +184,8 @@ test('Adding an OpenMRS encounter syncs encounter into encounters table in Super // setup const homePage = new HomePage(page); await homePage.createPatient(); + await homePage.searchPatientId(); + const patientIdentifier = await page.locator('#demographics section p:nth-child(2)').textContent(); await homePage.startPatientVisit(); await homePage.goToSuperset(); await expect(page).toHaveURL(/.*superset/); @@ -211,7 +219,7 @@ test('Adding an OpenMRS encounter syncs encounter into encounters table in Super await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); - let patientIdQuery = `SELECT patient_id FROM patients WHERE given_name like '${patientName.firstName}' AND family_name like '${patientName.givenName}';`; + let patientIdQuery = `SELECT patient_id FROM patients WHERE identifier like '${patientIdentifier}';`; await page.getByRole('textbox').fill(patientIdQuery); await homePage.runSQLQuery(); let patientId = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); @@ -267,6 +275,8 @@ test('Adding an OpenMRS patient condition syncs condition into conditions table // setup const homePage = new HomePage(page); await homePage.createPatient(); + await homePage.searchPatientId(); + const patientIdentifier = await page.locator('#demographics section p:nth-child(2)').textContent(); await homePage.startPatientVisit(); await homePage.goToSuperset(); await expect(page).toHaveURL(/.*superset/); @@ -297,7 +307,7 @@ test('Adding an OpenMRS patient condition syncs condition into conditions table await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); - let patientIdQuery = `SELECT patient_id FROM patients WHERE given_name like '${patientName.firstName}' AND family_name like '${patientName.givenName}';`; + let patientIdQuery = `SELECT patient_id FROM patients WHERE identifier like '${patientIdentifier}';`; await page.getByRole('textbox').fill(patientIdQuery); await homePage.runSQLQuery(); let patientId = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); @@ -322,6 +332,8 @@ test('Adding an OpenMRS observation syncs observation into observations table in // setup const homePage = new HomePage(page); await homePage.createPatient(); + await homePage.searchPatientId(); + const patientIdentifier = await page.locator('#demographics section p:nth-child(2)').textContent(); await homePage.startPatientVisit(); await homePage.goToSuperset(); await expect(page).toHaveURL(/.*superset/); @@ -352,7 +364,7 @@ test('Adding an OpenMRS observation syncs observation into observations table in await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); - let patientIdQuery = `SELECT patient_id FROM patients WHERE given_name like '${patientName.firstName}' AND family_name like '${patientName.givenName}';`; + let patientIdQuery = `SELECT patient_id FROM patients WHERE identifier like '${patientIdentifier}';`; await page.getByRole('textbox').fill(patientIdQuery); await homePage.runSQLQuery(); let patientId = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); @@ -407,6 +419,8 @@ test('Adding an OpenMRS patient appointment syncs appointment into appointments // setup const homePage = new HomePage(page); await homePage.createPatient(); + await homePage.searchPatientId(); + const patientIdentifier = await page.locator('#demographics section p:nth-child(2)').textContent(); await homePage.startPatientVisit(); await homePage.goToSuperset(); await expect(page).toHaveURL(/.*superset/); @@ -438,7 +452,7 @@ test('Adding an OpenMRS patient appointment syncs appointment into appointments await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); - let patientIdQuery = `SELECT patient_id FROM patients WHERE given_name like '${patientName.firstName}' AND family_name like '${patientName.givenName}';`; + let patientIdQuery = `SELECT patient_id FROM patients WHERE identifier like '${patientIdentifier}';`; await page.getByRole('textbox').fill(patientIdQuery); await homePage.runSQLQuery(); let patientId = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); diff --git a/e2e/utils/functions/testBase.ts b/e2e/utils/functions/testBase.ts index b9c124d1..47f9f8b9 100644 --- a/e2e/utils/functions/testBase.ts +++ b/e2e/utils/functions/testBase.ts @@ -92,6 +92,7 @@ export class HomePage { await this.page.getByTitle('close notification').click(); } await this.page.getByRole('button', { name: 'Close' }).click(); + await delay(3000); } async searchPatient(searchText: string) { @@ -100,6 +101,13 @@ export class HomePage { await this.page.getByRole('link', { name: `${patientFullName}` }).first().click(); } + async searchPatientId(searchText: string) { + await this.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); + await this.page.getByRole('button', { name: 'Actions', exact: true }).click(); + await this.page.getByRole('menuitem', { name: 'Edit patient details' }).click(); + await delay(4000); + } + async startPatientVisit() { await this.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); await this.page.getByRole('button', { name: 'Start a visit' }).click(); From 1db984433c67678fcb39adbbd83133a8e096992f Mon Sep 17 00:00:00 2001 From: kdaud Date: Tue, 24 Oct 2023 10:50:09 +0300 Subject: [PATCH 4/4] Updated variable names of sql queries --- e2e/tests/testAnalyticsIntegration.spec.ts | 96 +++++++++++----------- e2e/utils/functions/testBase.ts | 2 +- 2 files changed, 49 insertions(+), 49 deletions(-) diff --git a/e2e/tests/testAnalyticsIntegration.spec.ts b/e2e/tests/testAnalyticsIntegration.spec.ts index 903b89f5..43a5674a 100644 --- a/e2e/tests/testAnalyticsIntegration.spec.ts +++ b/e2e/tests/testAnalyticsIntegration.spec.ts @@ -18,11 +18,11 @@ test('Adding an OpenMRS patient syncs patient into patients table in Superset', await expect(page).toHaveURL(/.*superset/); await homePage.selectDBSchema(); await homePage.clearSQLEditor(); - let patientCountsQuery = `SELECT COUNT (*) FROM patients;` - await page.getByRole('textbox').fill(patientCountsQuery); + let patientsCountQuery = `SELECT COUNT (*) FROM patients;` + await page.getByRole('textbox').fill(patientsCountQuery); await homePage.runSQLQuery(); const initialNumberOfPatients = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); - let initialPatientCount = Number(initialNumberOfPatients); + let initialPatientsCount = Number(initialNumberOfPatients); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); @@ -35,12 +35,12 @@ test('Adding an OpenMRS patient syncs patient into patients table in Superset', // verify await page.goto(`${process.env.E2E_SUPERSET_URL}/superset/sqllab`); await homePage.clearSQLEditor(); - await page.getByRole('textbox').first().fill(patientCountsQuery); + await page.getByRole('textbox').first().fill(patientsCountQuery); await homePage.runSQLQuery(); const updatedNumberOfPatients = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); - let updatedPatientCount = Number(updatedNumberOfPatients); + let updatedPatientsCount = Number(updatedNumberOfPatients); - await expect(updatedPatientCount).toBe(initialPatientCount + 1); + await expect(updatedPatientsCount).toBe(initialPatientsCount + 1); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); @@ -67,11 +67,11 @@ test('Starting an OpenMRS visit syncs visit into visits table in Superset', asyn await expect(page).toHaveURL(/.*superset/); await homePage.selectDBSchema(); await homePage.clearSQLEditor(); - let visitCountsQuery = `SELECT COUNT (*) FROM visits;` - await page.getByRole('textbox').fill(visitCountsQuery); + let visitsCountQuery = `SELECT COUNT (*) FROM visits;` + await page.getByRole('textbox').fill(visitsCountQuery); await homePage.runSQLQuery(); const initialNumberOfVisits = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); - let initialVisitCount = Number(initialNumberOfVisits); + let initialVisitsCount = Number(initialNumberOfVisits); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); @@ -82,12 +82,12 @@ test('Starting an OpenMRS visit syncs visit into visits table in Superset', asyn // verify await page.goto(`${process.env.E2E_SUPERSET_URL}/superset/sqllab`); await homePage.clearSQLEditor(); - await page.getByRole('textbox').first().fill(visitCountsQuery); + await page.getByRole('textbox').first().fill(visitsCountQuery); await homePage.runSQLQuery(); const updatedNumberOfVisits = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); - let updatedVisitCount = Number(updatedNumberOfVisits); + let updatedVisitsCount = Number(updatedNumberOfVisits); - await expect(updatedVisitCount).toBe(initialVisitCount + 1); + await expect(updatedVisitsCount).toBe(initialVisitsCount + 1); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); @@ -98,8 +98,8 @@ test('Starting an OpenMRS visit syncs visit into visits table in Superset', asyn const patientIdValue = Number(patientId); await page.getByRole('tab', { name: 'Results' }).click(); await homePage.clearSQLEditor(); - let visitQuery = `SELECT * FROM visits WHERE patient_id=${patientIdValue};`; - await page.getByRole('textbox').first().fill(visitQuery); + let patientVisitQuery = `SELECT * FROM visits WHERE patient_id=${patientIdValue};`; + await page.getByRole('textbox').first().fill(patientVisitQuery); await homePage.runSQLQuery(); patientId = await page.getByRole('gridcell', { name: `${patientIdValue}` }).first().textContent(); @@ -127,11 +127,11 @@ test('Creating an OpenMRS order syncs order into orders table in Superset', asyn await expect(page).toHaveURL(/.*superset/); await homePage.selectDBSchema(); await homePage.clearSQLEditor(); - let orderCountsQuery = `SELECT COUNT(*) FROM _orders;` - await page.getByRole('textbox').fill(orderCountsQuery); + let ordersCountQuery = `SELECT COUNT(*) FROM _orders;` + await page.getByRole('textbox').fill(ordersCountQuery); await homePage.runSQLQuery(); const initialNumberOfOrders = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); - let initialOrderCount = Number(initialNumberOfOrders); + let initialOrdersCount = Number(initialNumberOfOrders); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); @@ -146,12 +146,12 @@ test('Creating an OpenMRS order syncs order into orders table in Superset', asyn // verify await page.goto(`${process.env.E2E_SUPERSET_URL}/superset/sqllab`); await homePage.clearSQLEditor(); - await page.getByRole('textbox').first().fill(orderCountsQuery); + await page.getByRole('textbox').first().fill(ordersCountQuery); await homePage.runSQLQuery(); const updatedNumberOfOrders = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); - let updatedOrderCount = Number(updatedNumberOfOrders); + let updatedOrdersCount = Number(updatedNumberOfOrders); - await expect(updatedOrderCount).toBe(initialOrderCount + 1); + await expect(updatedOrdersCount).toBe(initialOrdersCount + 1); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); @@ -191,11 +191,11 @@ test('Adding an OpenMRS encounter syncs encounter into encounters table in Super await expect(page).toHaveURL(/.*superset/); await homePage.selectDBSchema(); await homePage.clearSQLEditor(); - let encounterCountsQuery = `SELECT COUNT(*) FROM encounters;` - await page.getByRole('textbox').fill(encounterCountsQuery); + let encountersCountQuery = `SELECT COUNT(*) FROM encounters;` + await page.getByRole('textbox').fill(encountersCountQuery); await homePage.runSQLQuery(); const initialNumberOfEncounters = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); - let initialEncounterCount = Number(initialNumberOfEncounters); + let initialEncountersCount = Number(initialNumberOfEncounters); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); @@ -210,12 +210,12 @@ test('Adding an OpenMRS encounter syncs encounter into encounters table in Super // verify await page.goto(`${process.env.E2E_SUPERSET_URL}/superset/sqllab`); await homePage.clearSQLEditor(); - await page.getByRole('textbox').first().fill(encounterCountsQuery); + await page.getByRole('textbox').first().fill(encountersCountQuery); await homePage.runSQLQuery(); const updatedNumberOfEncounters = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); - let updatedEncounterCount = Number(updatedNumberOfEncounters); + let updatedEncountersCount = Number(updatedNumberOfEncounters); - await expect(updatedEncounterCount).toBe(initialEncounterCount + 1); + await expect(updatedEncountersCount).toBe(initialEncountersCount + 1); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); @@ -282,11 +282,11 @@ test('Adding an OpenMRS patient condition syncs condition into conditions table await expect(page).toHaveURL(/.*superset/); await homePage.selectDBSchema(); await homePage.clearSQLEditor(); - let conditionCountsQuery = `SELECT COUNT (*) FROM _conditions;` - await page.getByRole('textbox').fill(conditionCountsQuery); + let conditionsCountQuery = `SELECT COUNT (*) FROM _conditions;` + await page.getByRole('textbox').fill(conditionsCountQuery); await homePage.runSQLQuery(); const initialNumberOfConditions = await page.getByRole('gridcell', { name: ' ' }).textContent(); - let initialConditionCount = Number(initialNumberOfConditions); + let initialConditionsCount = Number(initialNumberOfConditions); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); @@ -298,12 +298,12 @@ test('Adding an OpenMRS patient condition syncs condition into conditions table // verify await page.goto(`${process.env.E2E_SUPERSET_URL}/superset/sqllab`); await homePage.clearSQLEditor(); - await page.getByRole('textbox').first().fill(conditionCountsQuery); + await page.getByRole('textbox').first().fill(conditionsCountQuery); await homePage.runSQLQuery(); const updatedNumberOfConditions = await page.getByRole('gridcell', { name: ' ' }).textContent(); - let updatedConditionCount = Number(updatedNumberOfConditions); + let updatedConditionsCount = Number(updatedNumberOfConditions); - await expect(updatedConditionCount).toBe(initialConditionCount + 1); + await expect(updatedConditionsCount).toBe(initialConditionsCount + 1); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); @@ -314,8 +314,8 @@ test('Adding an OpenMRS patient condition syncs condition into conditions table const patientIdValue = Number(patientId); await page.getByRole('tab', { name: 'Results' }).click(); await homePage.clearSQLEditor(); - let conditionQuery = `SELECT * FROM _conditions WHERE patient_id=${patientIdValue};`; - await page.getByRole('textbox').first().fill(conditionQuery); + let patientConditionQuery = `SELECT * FROM _conditions WHERE patient_id=${patientIdValue};`; + await page.getByRole('textbox').first().fill(patientConditionQuery); await homePage.runSQLQuery(); patientId = await page.getByRole('gridcell', { name: `${patientIdValue}` }).first().textContent(); @@ -339,11 +339,11 @@ test('Adding an OpenMRS observation syncs observation into observations table in await expect(page).toHaveURL(/.*superset/); await homePage.selectDBSchema(); await homePage.clearSQLEditor(); - let observationCountsQuery = `SELECT COUNT (*) FROM observations;` - await page.getByRole('textbox').fill(observationCountsQuery); + let observationsCountQuery = `SELECT COUNT (*) FROM observations;` + await page.getByRole('textbox').fill(observationsCountQuery); await homePage.runSQLQuery(); const initialNumberOfObservations = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); - let initialObservationCount = Number(initialNumberOfObservations); + let initialObservationsCount = Number(initialNumberOfObservations); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); @@ -355,12 +355,12 @@ test('Adding an OpenMRS observation syncs observation into observations table in // verify await page.goto(`${process.env.E2E_SUPERSET_URL}/superset/sqllab`); await homePage.clearSQLEditor(); - await page.getByRole('textbox').first().fill(observationCountsQuery); + await page.getByRole('textbox').first().fill(observationsCountQuery); await homePage.runSQLQuery(); const updatedNumberOfObservations = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); - let updatedObservationCount = Number(updatedNumberOfObservations); + let updatedObservationsCount = Number(updatedNumberOfObservations); - await expect(updatedObservationCount).toBe(initialObservationCount + 3); + await expect(updatedObservationsCount).toBe(initialObservationsCount + 3); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); @@ -426,12 +426,12 @@ test('Adding an OpenMRS patient appointment syncs appointment into appointments await expect(page).toHaveURL(/.*superset/); await homePage.selectDBSchema(); await homePage.clearSQLEditor(); - let appointmentCountsQuery = `SELECT COUNT(*) FROM appointments;` - await page.getByRole('textbox').fill(appointmentCountsQuery); + let appointmentsCountQuery = `SELECT COUNT(*) FROM appointments;` + await page.getByRole('textbox').fill(appointmentsCountQuery); await homePage.runSQLQuery(); const initialNumberOfAppointments = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); - let initialAppointmentCount = Number(initialNumberOfAppointments); + let initialAppointmentsCount = Number(initialNumberOfAppointments); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); @@ -443,12 +443,12 @@ test('Adding an OpenMRS patient appointment syncs appointment into appointments // verify await page.goto(`${process.env.E2E_SUPERSET_URL}/superset/sqllab`); await homePage.clearSQLEditor(); - await page.getByRole('textbox').first().fill(appointmentCountsQuery); + await page.getByRole('textbox').first().fill(appointmentsCountQuery); await homePage.runSQLQuery(); const updatedNumberOfAppointments = await page.getByRole('gridcell', { name: ' ' }).nth(0).textContent(); - let updatedAppointmentCount = Number(updatedNumberOfAppointments); + let updatedAppointmentsCount = Number(updatedNumberOfAppointments); - await expect(updatedAppointmentCount).toBe(initialAppointmentCount + 1); + await expect(updatedAppointmentsCount).toBe(initialAppointmentsCount + 1); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); @@ -459,8 +459,8 @@ test('Adding an OpenMRS patient appointment syncs appointment into appointments const patientIdValue = Number(patientId); await page.getByRole('tab', { name: 'Results' }).click(); await homePage.clearSQLEditor(); - let appointmentQuery = `SELECT * FROM appointments WHERE patient_id=${patientIdValue};`; - await page.getByRole('textbox').first().fill(appointmentQuery); + let patientAppointmentQuery = `SELECT * FROM appointments WHERE patient_id=${patientIdValue};`; + await page.getByRole('textbox').first().fill(patientAppointmentQuery); await homePage.runSQLQuery(); patientId = await page.getByRole('gridcell', { name: `${patientIdValue}` }).first().textContent(); diff --git a/e2e/utils/functions/testBase.ts b/e2e/utils/functions/testBase.ts index 47f9f8b9..fbdb731f 100644 --- a/e2e/utils/functions/testBase.ts +++ b/e2e/utils/functions/testBase.ts @@ -101,7 +101,7 @@ export class HomePage { await this.page.getByRole('link', { name: `${patientFullName}` }).first().click(); } - async searchPatientId(searchText: string) { + async searchPatientId() { await this.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); await this.page.getByRole('button', { name: 'Actions', exact: true }).click(); await this.page.getByRole('menuitem', { name: 'Edit patient details' }).click();