From a4b3eeacc214975bf250d398fce3e55b4abc89ee Mon Sep 17 00:00:00 2001 From: kdaud Date: Wed, 28 Feb 2024 14:49:01 +0300 Subject: [PATCH 1/2] OZ-336: Voiding an OpenMRS observation updates observations dataset in Superset --- e2e/tests/testAnalyticsIntegration.spec.ts | 46 +++++++++++++++++++++- e2e/tests/testSenaiteIntegration.spec.ts | 2 +- e2e/utils/functions/testBase.ts | 2 +- 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/e2e/tests/testAnalyticsIntegration.spec.ts b/e2e/tests/testAnalyticsIntegration.spec.ts index b8abd322..df4270a2 100644 --- a/e2e/tests/testAnalyticsIntegration.spec.ts +++ b/e2e/tests/testAnalyticsIntegration.spec.ts @@ -296,8 +296,6 @@ test('Adding an OpenMRS observation syncs observation into observations table in // setup const homePage = new HomePage(page); await homePage.createPatient(); - await homePage.searchOpenMRSPatientID(); - const patientIdentifier = await page.locator('#demographics section p:nth-child(2)').textContent(); await homePage.startPatientVisit(); const patient_uuid = await homePage.getPatientUUID(); await homePage.goToSuperset(); @@ -409,6 +407,50 @@ test('Adding an OpenMRS appointment syncs appointment into appointments table in await homePage.clearSQLEditor(); }); +test('Voiding an OpenMRS observation updates observations dataset in Superset', async ({ page }) => { + // setup + const homePage = new HomePage(page); + await homePage.createPatient(); + await homePage.startPatientVisit(); + const patient_uuid = await homePage.getPatientUUID(); + await homePage.addPatientBiometrics(); + + // replay + await homePage.goToSuperset(); + await expect(page).toHaveURL(/.*superset/); + await homePage.selectDBSchema(); + await homePage.clearSQLEditor(); + let obsVoidedQuery = `SELECT obs_voided FROM Observations WHERE patient_uuid like '${patient_uuid}';`; + + await page.getByRole('textbox').first().fill(obsVoidedQuery); + await homePage.runSQLQuery(); + + let firstObsVoidedState = await page.locator('div.virtual-table-cell:nth-child(1)'); + let secondObsVoidedState = await page.locator('div.virtual-table-cell:nth-child(2)'); + let thirdObsVoidedState = await page.locator('div.virtual-table-cell:nth-child(3)'); + await expect(firstObsVoidedState).toContainText('false'); + await expect(secondObsVoidedState).toContainText('false'); + await expect(thirdObsVoidedState).toContainText('false'); + + await page.goto(`${E2E_BASE_URL}/openmrs/spa/home`); + await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); + await homePage.discontinueAnOpenMRSEncounter(); + + // verify + await page.goto(`${E2E_ANALYTICS_URL}/superset/sqllab`); + await homePage.clearSQLEditor(); + + await page.getByRole('textbox').first().fill(obsVoidedQuery); + await homePage.runSQLQuery(); + + await expect(firstObsVoidedState).toContainText('true'); + await expect(secondObsVoidedState).toContainText('true'); + await expect(thirdObsVoidedState).toContainText('true'); + + await page.getByRole('tab', { name: 'Results' }).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 0e9253d6..116d15e4 100644 --- a/e2e/tests/testSenaiteIntegration.spec.ts +++ b/e2e/tests/testSenaiteIntegration.spec.ts @@ -114,7 +114,7 @@ test('Voiding a synced lab order cancels corresponding analysis request in SENAI // replay await page.goto(`${E2E_BASE_URL}`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); - await homePage.discontinueLabOrder(); + await homePage.discontinueAnOpenMRSEncounter(); // verify await homePage.goToSENAITE(); diff --git a/e2e/utils/functions/testBase.ts b/e2e/utils/functions/testBase.ts index cd9431f4..23975c4f 100644 --- a/e2e/utils/functions/testBase.ts +++ b/e2e/utils/functions/testBase.ts @@ -308,7 +308,7 @@ export class HomePage { await delay(5000); } - async discontinueLabOrder() { + async discontinueAnOpenMRSEncounter() { await this.page.getByRole('link', { name: 'Visits' }).click(); await this.page.getByRole('tab', { name: 'All encounters' }).click(); await this.page.getByRole('button', { name: 'Options', exact: true }).click(); From 1b1992aa34580f634241afb97abedde47ca0eb20 Mon Sep 17 00:00:00 2001 From: kdaud Date: Wed, 13 Mar 2024 14:18:07 +0300 Subject: [PATCH 2/2] Rename 'discontinueAnOpenMRSEncounter()' to 'voidEncounter()' --- e2e/tests/testAnalyticsIntegration.spec.ts | 2 +- e2e/tests/testSenaiteIntegration.spec.ts | 2 +- e2e/utils/functions/testBase.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/e2e/tests/testAnalyticsIntegration.spec.ts b/e2e/tests/testAnalyticsIntegration.spec.ts index df4270a2..d14f347d 100644 --- a/e2e/tests/testAnalyticsIntegration.spec.ts +++ b/e2e/tests/testAnalyticsIntegration.spec.ts @@ -434,7 +434,7 @@ test('Voiding an OpenMRS observation updates observations dataset in Superset', await page.goto(`${E2E_BASE_URL}/openmrs/spa/home`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); - await homePage.discontinueAnOpenMRSEncounter(); + await homePage.voidEncounter(); // verify await page.goto(`${E2E_ANALYTICS_URL}/superset/sqllab`); diff --git a/e2e/tests/testSenaiteIntegration.spec.ts b/e2e/tests/testSenaiteIntegration.spec.ts index 116d15e4..d44cbf6d 100644 --- a/e2e/tests/testSenaiteIntegration.spec.ts +++ b/e2e/tests/testSenaiteIntegration.spec.ts @@ -114,7 +114,7 @@ test('Voiding a synced lab order cancels corresponding analysis request in SENAI // replay await page.goto(`${E2E_BASE_URL}`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); - await homePage.discontinueAnOpenMRSEncounter(); + await homePage.voidEncounter(); // verify await homePage.goToSENAITE(); diff --git a/e2e/utils/functions/testBase.ts b/e2e/utils/functions/testBase.ts index 090847b9..cb220daa 100644 --- a/e2e/utils/functions/testBase.ts +++ b/e2e/utils/functions/testBase.ts @@ -308,7 +308,7 @@ export class HomePage { await delay(5000); } - async discontinueAnOpenMRSEncounter() { + async voidEncounter() { await this.page.getByRole('link', { name: 'Visits' }).click(); await this.page.getByRole('tab', { name: 'All encounters' }).click(); await this.page.getByRole('button', { name: 'Options', exact: true }).click();