diff --git a/.env b/.env index 0f0f2211..bece2071 100644 --- a/.env +++ b/.env @@ -1,24 +1,28 @@ # Global configuration for Ozone HIS -E2E_BASE_URL_DEMO=https://demo.ozone-his.com -E2E_BASE_URL_DEV=https://ozone-dev.mekomsolutions.net -E2E_BASE_URL_QA=https://ozone-qa.mekomsolutions.net -E2E_ODOO_URL_DEMO=https://erp.demo.ozone-his.com -E2E_ODOO_URL_DEV=https://erp.ozone-dev.mekomsolutions.net -E2E_ODOO_URL_QA=https://erp.ozone-qa.mekomsolutions.net -E2E_SENAITE_URL_DEMO=https://lims.demo.ozone-his.com -E2E_SENAITE_URL_DEV=https://lims.ozone-dev.mekomsolutions.net -E2E_SENAITE_URL_QA=https://lims.ozone-qa.mekomsolutions.net -E2E_KEYCLOAK_URL_DEMO=https://auth.demo.ozone-his.com -E2E_KEYCLOAK_URL_DEV=https://auth.ozone-dev.mekomsolutions.net -E2E_KEYCLOAK_URL_QA=https://auth.ozone-qa.mekomsolutions.net -E2E_ANALYTICS_URL_DEMO=https://analytics.demo.ozone-his.com -E2E_ANALYTICS_URL_DEV=https://analytics.ozone-dev.mekomsolutions.net -E2E_ANALYTICS_URL_QA=https://analytics.ozone-qa.mekomsolutions.net -E2E_USER_ADMIN_USERNAME=jdoe -E2E_USER_ADMIN_PASSWORD=password -FOSS_E2E_USER_ADMIN_USERNAME=admin -FOSS_E2E_USER_ADMIN_PASSWORD=Admin123 -E2E_KEYCLOAK_USERNAME= -E2E_KEYCLOAK_PASSWORD= -E2E_RUNNING_ON_OZONE_PRO=true -E2E_TEST_ENVIRONMENT=dev +O3_URL_DEMO=https://demo.ozone-his.com +O3_URL_DEV=https://ozone-dev.mekomsolutions.net +O3_URL_QA=https://ozone-qa.mekomsolutions.net +ODOO_URL_DEMO=https://erp.demo.ozone-his.com +ODOO_URL_DEV=https://erp.ozone-dev.mekomsolutions.net +ODOO_URL_QA=https://erp.ozone-qa.mekomsolutions.net +SENAITE_URL_DEMO=https://lims.demo.ozone-his.com +SENAITE_URL_DEV=https://lims.ozone-dev.mekomsolutions.net +SENAITE_URL_QA=https://lims.ozone-qa.mekomsolutions.net +KEYCLOAK_URL_DEMO=https://auth.demo.ozone-his.com +KEYCLOAK_URL_DEV=https://auth.ozone-dev.mekomsolutions.net +KEYCLOAK_URL_QA=https://auth.ozone-qa.mekomsolutions.net +ANALYTICS_URL_DEMO=https://analytics.demo.ozone-his.com +ANALYTICS_URL_DEV=https://analytics.ozone-dev.mekomsolutions.net +ANALYTICS_URL_QA=https://analytics.ozone-qa.mekomsolutions.net +O3_USERNAME=jdoe +O3_PASSWORD=password +O3_USERNAME_ON_FOSS=admin +O3_PASSWORD_ON_FOSS=Admin123 +ODOO_USERNAME_ON_FOSS=admin +ODOO_PASSWORD_ON_FOSS=admin +SENAITE_USERNAME_ON_FOSS=admin +SENAITE_PASSWORD_ON_FOSS=password +KEYCLOAK_USERNAME= +KEYCLOAK_PASSWORD= +RUNNING_OZONE_ON_PRO=true +TEST_ENVIRONMENT=dev diff --git a/.github/workflows/foss.yml b/.github/workflows/foss.yml index 9b428a30..0c56b345 100644 --- a/.github/workflows/foss.yml +++ b/.github/workflows/foss.yml @@ -42,10 +42,10 @@ jobs: - name: Run E2E tests env: - E2E_BASE_URL_DEV: '${{ github.event.inputs.e2e_base_url_input }}' - E2E_ODOO_URL_DEV: '${{ github.event.inputs.e2e_odoo_url_input }}' - E2E_SENAITE_URL_DEV: '${{ github.event.inputs.e2e_senaite_url_input }}' - E2E_RUNNING_ON_OZONE_PRO: 'false' + O3_DEV: '${{ github.event.inputs.e2e_base_url_input }}' + ODOO_URL_DEV: '${{ github.event.inputs.e2e_odoo_url_input }}' + SENAITE_URL_DEV: '${{ github.event.inputs.e2e_senaite_url_input }}' + RUNNING_OZONE_ON_PRO: 'false' run: npm run fossE2ETests - name: Upload report diff --git a/.github/workflows/pro.yml b/.github/workflows/pro.yml index 28ef2296..ec0ce035 100644 --- a/.github/workflows/pro.yml +++ b/.github/workflows/pro.yml @@ -49,9 +49,9 @@ jobs: - name: Run E2E tests id: jobStatusPretty env: - E2E_TEST_ENVIRONMENT: '${{ github.event.inputs.environment }}' - E2E_KEYCLOAK_USERNAME: '${{ secrets.KEYCLOAK_USERNAME }}' - E2E_KEYCLOAK_PASSWORD: '${{ secrets.KEYCLOAK_PASSWORD }}' + TEST_ENVIRONMENT: '${{ github.event.inputs.environment }}' + KEYCLOAK_USERNAME: '${{ secrets.KEYCLOAK_USERNAME }}' + KEYCLOAK_PASSWORD: '${{ secrets.KEYCLOAK_PASSWORD }}' run: | npm run proE2ETests diff --git a/e2e/tests/testAnalyticsIntegration.spec.ts b/e2e/tests/testAnalyticsIntegration.spec.ts index d14f347d..27178ef8 100644 --- a/e2e/tests/testAnalyticsIntegration.spec.ts +++ b/e2e/tests/testAnalyticsIntegration.spec.ts @@ -1,19 +1,19 @@ import { test, expect } from '@playwright/test'; import { HomePage } from '../utils/functions/testBase'; import { patientName } from '../utils/functions/testBase'; -import { E2E_BASE_URL, E2E_ANALYTICS_URL } from '../utils/configs/globalSetup'; +import { O3_URL, ANALYTICS_URL } from '../utils/configs/globalSetup'; let homePage: HomePage; test.beforeEach(async ({ page }) => { - const homePage = new HomePage(page); + 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 }) => { - const homePage = new HomePage(page); + // setup + homePage = new HomePage(page); await homePage.goToSuperset(); await expect(page).toHaveURL(/.*superset/); await homePage.selectDBSchema(); @@ -27,13 +27,13 @@ test('Adding an OpenMRS patient syncs patient into patients table in Superset', await homePage.clearSQLEditor(); // replay - await page.goto(`${E2E_BASE_URL}`); + await page.goto(`${O3_URL}`); await homePage.createPatient(); await homePage.searchOpenMRSPatientID(); const patientIdentifier = await page.locator('#demographics section p:nth-child(2)').textContent(); // verify - await page.goto(`${E2E_ANALYTICS_URL}/superset/sqllab`); + await page.goto(`${ANALYTICS_URL}/superset/sqllab`); await homePage.clearSQLEditor(); await page.getByRole('textbox').first().fill(patientsCountQuery); await homePage.runSQLQuery(); @@ -47,7 +47,6 @@ test('Adding an OpenMRS patient syncs patient into patients table in Superset', let patientQuery = `SELECT * FROM patients WHERE identifiers like 'OpenMRS ID: ${patientIdentifier}';`; await page.getByRole('textbox').fill(patientQuery); await homePage.runSQLQuery(); - let patientGivenName = await page.getByText(`${patientName.firstName}`); let patientFamilyName = await page.getByText(`${patientName.givenName}`); let patientGender = await page.getByText('M', { exact: true }); @@ -60,7 +59,8 @@ test('Adding an OpenMRS patient syncs patient into patients table in Superset', }); test('Starting an OpenMRS visit syncs visit into visits table in Superset', async ({ page }) => { - const homePage = new HomePage(page); + // setup + homePage = new HomePage(page); await homePage.createPatient(); await homePage.goToSuperset(); await expect(page).toHaveURL(/.*superset/); @@ -75,12 +75,12 @@ test('Starting an OpenMRS visit syncs visit into visits table in Superset', asyn await homePage.clearSQLEditor(); // replay - await page.goto(`${E2E_BASE_URL}`); + await page.goto(`${O3_URL}`); await homePage.startPatientVisit(); const patient_uuid = await homePage.getPatientUUID(); // verify - await page.goto(`${E2E_ANALYTICS_URL}/superset/sqllab`); + await page.goto(`${ANALYTICS_URL}/superset/sqllab`); await homePage.clearSQLEditor(); await page.getByRole('textbox').first().fill(visitsCountQuery); await homePage.runSQLQuery(); @@ -91,11 +91,9 @@ 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 patientVisitQuery = `SELECT * FROM visits WHERE patient_uuid like '${patient_uuid}';`; await page.getByRole('textbox').first().fill(patientVisitQuery); await homePage.runSQLQuery(); - let patientVisitType = await page.getByText('Facility Visit'); const patientGender = await page.getByText('M', {exact: true }); let patientAgeAtVisit = Number(await page.getByText('24', {exact: true }).nth(0).textContent()); @@ -108,7 +106,8 @@ test('Starting an OpenMRS visit syncs visit into visits table in Superset', asyn }); test('Creating an OpenMRS order syncs order into orders table in Superset', async ({ page }) => { - const homePage = new HomePage(page); + // setup + homePage = new HomePage(page); await homePage.createPatient(); await homePage.searchOpenMRSPatientID(); const patientIdentifier = await page.locator('#demographics section p:nth-child(2)').textContent(); @@ -126,7 +125,7 @@ test('Creating an OpenMRS order syncs order into orders table in Superset', asyn await homePage.clearSQLEditor(); // replay - await page.goto(`${E2E_BASE_URL}`); + await page.goto(`${O3_URL}`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); await homePage.goToLabOrderForm(); await page.getByRole('button', { name: 'Add', exact: true }).click(); @@ -134,7 +133,7 @@ test('Creating an OpenMRS order syncs order into orders table in Superset', asyn await homePage.saveLabOrder(); // verify - await page.goto(`${E2E_ANALYTICS_URL}/superset/sqllab`); + await page.goto(`${ANALYTICS_URL}/superset/sqllab`); await homePage.clearSQLEditor(); await page.getByRole('textbox').first().fill(ordersCountQuery); await homePage.runSQLQuery(); @@ -155,7 +154,6 @@ test('Creating an OpenMRS order syncs order into orders table in Superset', asyn let orderQuery = `SELECT * FROM orders WHERE patient_id=${patientIdValue};`; await page.getByRole('textbox').first().fill(orderQuery); await homePage.runSQLQuery(); - let orderTypeName = await page.getByText('Test Order' ); let encounterTypeName = await page.getByText('Consultation', { exact: true }); @@ -166,7 +164,8 @@ test('Creating an OpenMRS order syncs order into orders table in Superset', asyn }); test('Adding an OpenMRS encounter syncs encounter into encounters table in Superset', async ({ page }) => { - const homePage = new HomePage(page); + // setup + homePage = new HomePage(page); await homePage.createPatient(); await homePage.searchOpenMRSPatientID(); const patientIdentifier = await page.locator('#demographics section p:nth-child(2)').textContent(); @@ -184,7 +183,7 @@ test('Adding an OpenMRS encounter syncs encounter into encounters table in Super await homePage.clearSQLEditor(); // replay - await page.goto(`${E2E_BASE_URL}`); + await page.goto(`${O3_URL}`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); await homePage.goToLabOrderForm(); await page.getByRole('button', { name: 'Add', exact: true }).click(); @@ -192,7 +191,7 @@ test('Adding an OpenMRS encounter syncs encounter into encounters table in Super await homePage.saveLabOrder(); // verify - await page.goto(`${E2E_ANALYTICS_URL}/superset/sqllab`); + await page.goto(`${ANALYTICS_URL}/superset/sqllab`); await homePage.clearSQLEditor(); await page.getByRole('textbox').first().fill(encountersCountQuery); await homePage.runSQLQuery(); @@ -221,13 +220,11 @@ test('Adding an OpenMRS encounter syncs encounter into encounters table in Super await page.getByRole('textbox').fill(encounterTypeUuidQuery); await homePage.runSQLQuery(); let encounterTypeUuidValue = await page.locator('div.virtual-table-cell').textContent(); - await page.getByRole('tab', { name: 'Results' }).click(); await homePage.clearSQLEditor(); 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(); - let encounterTypeName = await page.getByText('Consultation', { exact: true }); let visitTypeName = await page.getByText('Facility Visit'); @@ -238,7 +235,8 @@ test('Adding an OpenMRS encounter syncs encounter into encounters table in Super }); test('Adding an OpenMRS condition syncs condition into conditions table in Superset', async ({ page }) => { - const homePage = new HomePage(page); + // setup + homePage = new HomePage(page); await homePage.createPatient(); await homePage.searchOpenMRSPatientID(); const patientIdentifier = await page.locator('#demographics section p:nth-child(2)').textContent(); @@ -256,12 +254,12 @@ test('Adding an OpenMRS condition syncs condition into conditions table in Super await homePage.clearSQLEditor(); // replay - await page.goto(`${E2E_BASE_URL}`); + await page.goto(`${O3_URL}`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); await homePage.addPatientCondition(); // verify - await page.goto(`${E2E_ANALYTICS_URL}/superset/sqllab`); + await page.goto(`${ANALYTICS_URL}/superset/sqllab`); await homePage.clearSQLEditor(); await page.getByRole('textbox').first().fill(conditionsCountQuery); await homePage.runSQLQuery(); @@ -282,7 +280,6 @@ test('Adding an OpenMRS condition syncs condition into conditions table in Super let conditionQuery = `SELECT * FROM conditions WHERE patient_id=${patientIdValue};`; await page.getByRole('textbox').first().fill(conditionQuery); await homePage.runSQLQuery(); - let clinicalStatus = await page.getByText('ACTIVE'); let onSetDate = await page.getByText('2023-07-27'); @@ -294,7 +291,7 @@ test('Adding an OpenMRS condition syncs condition into conditions table in Super test('Adding an OpenMRS observation syncs observation into observations table in Superset', async ({ page }) => { // setup - const homePage = new HomePage(page); + homePage = new HomePage(page); await homePage.createPatient(); await homePage.startPatientVisit(); const patient_uuid = await homePage.getPatientUUID(); @@ -311,12 +308,12 @@ test('Adding an OpenMRS observation syncs observation into observations table in await homePage.clearSQLEditor(); // replay - await page.goto(`${E2E_BASE_URL}`); + await page.goto(`${O3_URL}`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); await homePage.addPatientBiometrics(); // verify - await page.goto(`${E2E_ANALYTICS_URL}/superset/sqllab`); + await page.goto(`${ANALYTICS_URL}/superset/sqllab`); await homePage.clearSQLEditor(); await page.getByRole('textbox').first().fill(observationsCountQuery); await homePage.runSQLQuery(); @@ -330,7 +327,6 @@ test('Adding an OpenMRS observation syncs observation into observations table in let observationsQuery = `SELECT * FROM observations WHERE patient_uuid like '${patient_uuid}';`; await page.getByRole('textbox').fill(observationsQuery); await homePage.runSQLQuery(); - let firstConceptName = await page.getByText('Circonférence du haut du bras').first(); let secondConceptName = await page.getByText('Taille (cm)').first(); let thirdConceptName = await page.getByText('Weight (kg)').first(); @@ -353,8 +349,7 @@ test('Adding an OpenMRS observation syncs observation into observations table in test('Adding an OpenMRS appointment syncs appointment into appointments table in Superset', async ({ page }) => { // setup - const homePage = new HomePage(page); - + homePage = new HomePage(page); await homePage.createPatient(); await homePage.searchOpenMRSPatientID(); const patientIdentifier = await page.locator('#demographics section p:nth-child(2)').textContent(); @@ -366,19 +361,18 @@ test('Adding an OpenMRS appointment syncs appointment into appointments table in let appointmentsCountQuery = `SELECT COUNT(*) FROM appointments;` await page.getByRole('textbox').first().fill(appointmentsCountQuery); await homePage.runSQLQuery(); - const initialNumberOfAppointments = await page.locator('div.virtual-table-cell').textContent(); let initialAppointmentsCount = Number(initialNumberOfAppointments); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); // replay - await page.goto(`${E2E_BASE_URL}`); + await page.goto(`${O3_URL}`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); await homePage.addPatientAppointment(); // verify - await page.goto(`${E2E_ANALYTICS_URL}/superset/sqllab`); + await page.goto(`${ANALYTICS_URL}/superset/sqllab`); await homePage.clearSQLEditor(); await page.getByRole('textbox').first().fill(appointmentsCountQuery); await homePage.runSQLQuery(); @@ -399,7 +393,6 @@ test('Adding an OpenMRS appointment syncs appointment into appointments table in let appointmentQuery = `SELECT * FROM appointments WHERE patient_id=${patientIdValue};`; await page.getByRole('textbox').first().fill(appointmentQuery); await homePage.runSQLQuery(); - let appointmentStatus = await page.getByText('Scheduled').first(); await expect(appointmentStatus).toContainText('Scheduled'); @@ -409,7 +402,7 @@ test('Adding an OpenMRS appointment syncs appointment into appointments table in test('Voiding an OpenMRS observation updates observations dataset in Superset', async ({ page }) => { // setup - const homePage = new HomePage(page); + homePage = new HomePage(page); await homePage.createPatient(); await homePage.startPatientVisit(); const patient_uuid = await homePage.getPatientUUID(); @@ -421,25 +414,23 @@ test('Voiding an OpenMRS observation updates observations dataset in 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 page.goto(`${O3_URL}/openmrs/spa/home`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); await homePage.voidEncounter(); // verify - await page.goto(`${E2E_ANALYTICS_URL}/superset/sqllab`); + await page.goto(`${ANALYTICS_URL}/superset/sqllab`); await homePage.clearSQLEditor(); - await page.getByRole('textbox').first().fill(obsVoidedQuery); await homePage.runSQLQuery(); @@ -452,7 +443,7 @@ test('Voiding an OpenMRS observation updates observations dataset in Superset', }); test.afterEach(async ({ page }) => { - const homePage = new HomePage(page); + homePage = new HomePage(page); await homePage.deletePatient(); await page.close(); }); diff --git a/e2e/tests/testKeycloakIntegration.spec.ts b/e2e/tests/testKeycloakIntegration.spec.ts index d1986766..3a09173e 100644 --- a/e2e/tests/testKeycloakIntegration.spec.ts +++ b/e2e/tests/testKeycloakIntegration.spec.ts @@ -1,21 +1,20 @@ import { test, expect } from '@playwright/test'; import { HomePage, delay, randomKeycloakRoleName } from '../utils/functions/testBase'; import { randomOpenMRSRoleName, randomSupersetRoleName } from '../utils/functions/testBase'; -import { E2E_BASE_URL, E2E_KEYCLOAK_URL } from '../utils/configs/globalSetup'; +import { O3_URL, KEYCLOAK_URL } from '../utils/configs/globalSetup'; let homePage: HomePage; test.beforeEach(async ({ page }) => { - const homePage = new HomePage(page); + homePage = new HomePage(page); await homePage.initiateLogin(); - await expect(page).toHaveURL(/.*home/); }); test('Adding an OpenMRS role syncs the role into Keycloak', async ({ page }) => { // setup - await page.goto(`${E2E_BASE_URL}/openmrs/admin/users/role.list`); - const homePage = new HomePage(page); + homePage = new HomePage(page); + await page.goto(`${O3_URL}/openmrs/admin/users/role.list`); await homePage.addOpenMRSRole(); // replay @@ -38,11 +37,11 @@ test('Adding an OpenMRS role syncs the role into Keycloak', async ({ page }) => test('Updating a synced OpenMRS role updates the corresponding role in Keycloak', async ({ page }) => { // setup - await page.goto(`${E2E_BASE_URL}/openmrs/admin/users/role.list`); - const homePage = new HomePage(page); + homePage = new HomePage(page); + await page.goto(`${O3_URL}/openmrs/admin/users/role.list`); await homePage.addOpenMRSRole(); - // reply + // replay await homePage.goToKeycloak(); await expect(page).toHaveURL(/.*console/); await homePage.goToClients(); @@ -56,11 +55,11 @@ test('Updating a synced OpenMRS role updates the corresponding role in Keycloak' await expect(page.getByText('Application: Uses Patient Summary')).toBeTruthy(); await expect(page.getByText('Organizational: Registration Clerk')).toBeTruthy(); await expect(page.getByText('Application: Records Allergies')).toBeTruthy(); - await page.goto(`${E2E_BASE_URL}/openmrs/admin/users/role.list`); + await page.goto(`${O3_URL}/openmrs/admin/users/role.list`); await homePage.updateOpenMRSRole(); // verify - await page.goto(`${E2E_KEYCLOAK_URL}/admin/master/console`); + await page.goto(`${KEYCLOAK_URL}/admin/master/console`); await homePage.goToClients(); await homePage.goToOpenMRSClient(); await homePage.goToOpenMRSClientAttributes(); @@ -73,11 +72,11 @@ test('Updating a synced OpenMRS role updates the corresponding role in Keycloak' test('Deleting a synced OpenMRS role deletes the corresponding role in Keycloak', async ({ page }) => { // setup - await page.goto(`${E2E_BASE_URL}/openmrs/admin/users/role.list`); - const homePage = new HomePage(page); + homePage = new HomePage(page); + await page.goto(`${O3_URL}/openmrs/admin/users/role.list`); await homePage.addOpenMRSRole(); - // reply + // replay await homePage.goToKeycloak(); await expect(page).toHaveURL(/.*console/); await homePage.goToClients(); @@ -94,7 +93,7 @@ test('Deleting a synced OpenMRS role deletes the corresponding role in Keycloak' await homePage.deleteOpenMRSRole(); // verify - await page.goto(`${E2E_KEYCLOAK_URL}/admin/master/console`); + await page.goto(`${KEYCLOAK_URL}/admin/master/console`); await homePage.goToClients(); await homePage.goToOpenMRSClient(); const roleName = await page.locator('table tbody tr:nth-child(1) td:nth-child(1) a'); @@ -103,15 +102,15 @@ test('Deleting a synced OpenMRS role deletes the corresponding role in Keycloak' test('Adding a Superset role syncs the role into Keycloak', async ({ page }) => { // setup - const homePage = new HomePage(page); + homePage = new HomePage(page); await homePage.goToSuperset(); - - // reply await homePage.addSupersetRole(); - // verify + // replay await homePage.goToKeycloak(); await homePage.goToClients(); + + // verify await homePage.goToSupersetClient(); await expect(page.getByText(`${randomSupersetRoleName.roleName}`)).toBeVisible(); @@ -121,11 +120,11 @@ test('Adding a Superset role syncs the role into Keycloak', async ({ page }) => test('Updating a synced Superset role updates the corresponding role in Keycloak', async ({ page }) => { // setup - const homePage = new HomePage(page); + homePage = new HomePage(page); await homePage.goToSuperset(); - - // reply await homePage.addSupersetRole(); + + // replay await homePage.goToKeycloak(); await homePage.goToClients(); await homePage.goToSupersetClient(); @@ -136,7 +135,7 @@ test('Updating a synced Superset role updates the corresponding role in Keycloak await homePage.updateSupersetRole(); // verify - await page.goto(`${E2E_KEYCLOAK_URL}/admin/master/console`); + await page.goto(`${KEYCLOAK_URL}/admin/master/console`); await homePage.goToClients(); await homePage.goToSupersetClient(); await expect(page.getByText(`${randomSupersetRoleName.roleName}`)).not.toBeVisible(); @@ -147,11 +146,11 @@ test('Updating a synced Superset role updates the corresponding role in Keycloak test('Deleting a synced Superset role deletes the corresponding role in Keycloak', async ({ page }) => { // setup - const homePage = new HomePage(page); + homePage = new HomePage(page); await homePage.goToSuperset(); await homePage.addSupersetRole(); - // reply + // replay await homePage.goToKeycloak(); await homePage.goToClients(); await homePage.goToSupersetClient(); @@ -162,7 +161,7 @@ test('Deleting a synced Superset role deletes the corresponding role in Keycloak await delay(30000); // verify - await page.goto(`${E2E_KEYCLOAK_URL}/admin/master/console`); + await page.goto(`${KEYCLOAK_URL}/admin/master/console`); await homePage.goToClients(); await homePage.goToSupersetClient(); @@ -171,15 +170,15 @@ test('Deleting a synced Superset role deletes the corresponding role in Keycloak test('Deleting a synchronized role in Keycloak gets created in the subsequent polling cycle', async ({ page }) => { // setup - const homePage = new HomePage(page); + homePage = new HomePage(page); await homePage.goToSuperset(); - - // reply await homePage.addSupersetRole(); - // verify + // replay await homePage.goToKeycloak(); await homePage.goToClients(); + + // verify await homePage.goToSupersetClient(); await expect(page.getByText(`${randomSupersetRoleName.roleName}`)).toBeVisible(); @@ -195,13 +194,13 @@ test('Deleting a synchronized role in Keycloak gets created in the subsequent po test('Creating a role in Keycloak automatically gets deleted during the subsequent polling cycle', async ({ page }) => { // setup - const homePage = new HomePage(page); + homePage = new HomePage(page); await homePage.goToKeycloak(); - - // reply await homePage.goToClients(); await homePage.goToOpenMRSClient(); await homePage.createRoleInKeycloak(); + + // replay await page.getByRole('link', { name: 'Client details' }).click(); await expect(page.getByText(`${randomKeycloakRoleName.roleName}`)).toBeVisible(); await delay(30000); diff --git a/e2e/tests/testOdooIntegration.spec.ts b/e2e/tests/testOdooIntegration.spec.ts index a5c1e03b..5c816f50 100644 --- a/e2e/tests/testOdooIntegration.spec.ts +++ b/e2e/tests/testOdooIntegration.spec.ts @@ -1,34 +1,32 @@ import { test, expect } from '@playwright/test'; import { HomePage } from '../utils/functions/testBase'; import { patientName } from '../utils/functions/testBase'; -import { E2E_BASE_URL, E2E_ODOO_URL } from '../utils/configs/globalSetup'; +import { O3_URL, ODOO_URL } from '../utils/configs/globalSetup'; let homePage: HomePage; test.beforeEach(async ({ page }) => { - const homePage = new HomePage(page); + homePage = new HomePage(page); await homePage.initiateLogin(); - await expect(page).toHaveURL(/.*home/); - await homePage.createPatient(); await homePage.startPatientVisit(); }); test('Patient with lab order becomes customer in Odoo', async ({ page }) => { // setup - const homePage = new HomePage(page); + homePage = new HomePage(page); await homePage.goToLabOrderForm(); await page.getByRole('button', { name: 'Add', exact: true }).click(); await page.locator('#tab select').selectOption('857AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); await homePage.saveLabOrder(); - await homePage.goToOdoo(); - await expect(page).toHaveURL(/.*web/); // replay - await homePage.searchCustomerInOdoo(); + await homePage.goToOdoo(); + await expect(page).toHaveURL(/.*web/); // verify + await homePage.searchCustomerInOdoo(); const customer = await page.locator("table tbody td.o_data_cell:nth-child(4)").textContent(); await expect(customer?.includes(`${patientName.firstName + ' ' + patientName.givenName}`)).toBeTruthy(); @@ -38,7 +36,7 @@ test('Patient with lab order becomes customer in Odoo', async ({ page }) => { test('Editing patient details with a synced lab order edits the corresponding customer details in Odoo', async ({ page }) => { // setup - const homePage = new HomePage(page); + homePage = new HomePage(page); await homePage.goToLabOrderForm(); await page.getByRole('button', { name: 'Add', exact: true }).click(); await page.locator('#tab select').selectOption('857AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); @@ -53,12 +51,12 @@ test('Editing patient details with a synced lab order edits the corresponding cu await expect(quotation?.includes("Quotation")).toBeTruthy(); // replay - await page.goto(`${E2E_BASE_URL}`); + await page.goto(`${O3_URL}`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); await homePage.updatePatientDetails(); // verify - await page.goto(`${E2E_ODOO_URL}`); + await page.goto(`${ODOO_URL}`); await homePage.searchCustomerInOdoo(); const updatedCustomer = await page.locator("table tbody td.o_data_cell:nth-child(4)"); await expect(updatedCustomer).toHaveText(`${patientName.updatedFirstName}` + ' ' + `${patientName.givenName}`); @@ -67,15 +65,15 @@ test('Editing patient details with a synced lab order edits the corresponding cu test('Patient with drug order becomes customer in Odoo', async ({ page }) => { // setup - const homePage = new HomePage(page); + homePage = new HomePage(page); await homePage.makeDrugOrder(); - await homePage.goToOdoo(); - await expect(page).toHaveURL(/.*web/); // replay - await homePage.searchCustomerInOdoo(); + await homePage.goToOdoo(); + await expect(page).toHaveURL(/.*web/); // verify + await homePage.searchCustomerInOdoo(); const customer = await page.locator("table tbody td.o_data_cell:nth-child(4)").textContent(); await expect(customer?.includes(`${patientName.firstName + ' ' + patientName.givenName}`)).toBeTruthy(); @@ -85,7 +83,7 @@ test('Patient with drug order becomes customer in Odoo', async ({ page }) => { test('Editing patient details with a synced drug order edits corresponding customer details in Odoo', async ({ page }) => { // setup - const homePage = new HomePage(page); + homePage = new HomePage(page); await homePage.makeDrugOrder(); await homePage.goToOdoo(); await expect(page).toHaveURL(/.*web/); @@ -98,12 +96,12 @@ test('Editing patient details with a synced drug order edits corresponding custo await expect(quotation?.includes("Quotation")).toBeTruthy(); // replay - await page.goto(`${E2E_BASE_URL}`); + await page.goto(`${O3_URL}`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); await homePage.updatePatientDetails(); // verify - await page.goto(`${E2E_ODOO_URL}`); + await page.goto(`${ODOO_URL}`); await homePage.searchCustomerInOdoo(); const updatedCustomer = await page.locator("table tbody td.o_data_cell:nth-child(4)"); @@ -113,7 +111,7 @@ test('Editing patient details with a synced drug order edits corresponding custo test('Revising a synced drug order edits corresponding quotation line in Odoo', async ({ page }) => { // setup - const homePage = new HomePage(page); + homePage = new HomePage(page); await homePage.makeDrugOrder(); await homePage.goToOdoo(); await expect(page).toHaveURL(/.*web/); @@ -129,12 +127,12 @@ test('Revising a synced drug order edits corresponding quotation line in Odoo', await expect(drugOrderItem).toContainText('Twice daily - 5 Days'); // replay - await page.goto(`${E2E_BASE_URL}`); + await page.goto(`${O3_URL}`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); await homePage.editDrugOrder(); // verify - await page.goto(`${E2E_ODOO_URL}`); + await page.goto(`${ODOO_URL}`); await homePage.searchCustomerInOdoo(); await page.getByRole('cell', { name: `${patientName.firstName + ' ' + patientName.givenName}` }).click(); await expect(drugOrderItem).toContainText('8.0 Tablet'); @@ -143,7 +141,7 @@ test('Revising a synced drug order edits corresponding quotation line in Odoo', test('Discontinuing a synced drug order cancels corresponding quotation line in Odoo', async ({ page }) => { // setup - const homePage = new HomePage(page); + homePage = new HomePage(page); await homePage.makeDrugOrder(); await homePage.goToOdoo(); await expect(page).toHaveURL(/.*web/); @@ -159,12 +157,12 @@ test('Discontinuing a synced drug order cancels corresponding quotation line in await expect(drugOrderItem).toHaveText('Aspirin 325mg'); // replay - await page.goto(`${E2E_BASE_URL}`); + await page.goto(`${O3_URL}`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); await homePage.discontinueDrugOrder(); // verify - await page.goto(`${E2E_ODOO_URL}`); + await page.goto(`${ODOO_URL}`); await homePage.searchCustomerInOdoo(); await expect(customer?.includes(`${patientName.firstName + ' ' + patientName.givenName}`)).toBeTruthy(); await expect(quotation).toHaveText('Cancelled'); @@ -172,13 +170,12 @@ test('Discontinuing a synced drug order cancels corresponding quotation line in test('Patient with free text medication dosage becomes customer in Odoo', async ({ page }) => { // setup - const homePage = new HomePage(page); + homePage = new HomePage(page); await homePage.prescribeFreeTextMedicationDosage(); + // replay await homePage.goToOdoo(); await expect(page).toHaveURL(/.*web/); - - // replay await homePage.searchCustomerInOdoo(); // verify @@ -190,7 +187,7 @@ test('Patient with free text medication dosage becomes customer in Odoo', async }); test.afterEach(async ({ page }) => { - const homePage = new HomePage(page); + homePage = new HomePage(page); await homePage.deletePatient(); await page.close(); }); diff --git a/e2e/tests/testSenaiteIntegration.spec.ts b/e2e/tests/testSenaiteIntegration.spec.ts index d44cbf6d..96235fb6 100644 --- a/e2e/tests/testSenaiteIntegration.spec.ts +++ b/e2e/tests/testSenaiteIntegration.spec.ts @@ -1,41 +1,39 @@ import { test, expect } from '@playwright/test'; import { HomePage } from '../utils/functions/testBase'; import { patientName } from '../utils/functions/testBase'; -import { E2E_BASE_URL, E2E_SENAITE_URL } from '../utils/configs/globalSetup'; +import { O3_URL } from '../utils/configs/globalSetup'; let homePage: HomePage; test.beforeEach(async ({ page }) => { - const homePage = new HomePage(page); + homePage = new HomePage(page); await homePage.initiateLogin(); - await expect(page).toHaveURL(/.*home/); - 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); + homePage = new HomePage(page); await homePage.goToLabOrderForm(); await page.getByRole('button', { name: 'Add', exact: true }).click(); await page.locator('#tab select').selectOption('857AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); await homePage.saveLabOrder(); - await homePage.goToSENAITE(); - await expect(page).toHaveURL(/.*senaite/); // replay - await homePage.searchClientInSENAITE(); + await homePage.goToSENAITE(); + await expect(page).toHaveURL(/.*senaite/); // verify + await homePage.searchClientInSENAITE(); const client = await page.locator('table tbody tr:nth-child(1) td.contentcell.title div span a'); await expect(client).toContainText(`${patientName.firstName + ' ' + patientName.givenName}`); }); test('Editing patient details with a synced lab test order edits client details in SENAITE', async ({ page }) => { // setup - const homePage = new HomePage(page); + homePage = new HomePage(page); await homePage.goToLabOrderForm(); await page.getByRole('button', { name: 'Add', exact: true }).click(); await page.locator('#tab select').selectOption('857AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); @@ -47,7 +45,7 @@ test('Editing patient details with a synced lab test order edits client details await expect(client).toContainText(`${patientName.firstName + ' ' + patientName.givenName}`); // replay - await page.goto(`${E2E_BASE_URL}`); + await page.goto(`${O3_URL}`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); await homePage.updatePatientDetails(); @@ -60,7 +58,7 @@ test('Editing patient details with a synced lab test order edits client details test('Editing a synced lab order edits corresponding analysis request in SENAITE', async ({ page }) => { // setup - const homePage = new HomePage(page); + homePage = new HomePage(page); await homePage.goToLabOrderForm(); await page.getByRole('button', { name: 'Add', exact: true }).click(); await page.locator('#tab select').selectOption('857AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); @@ -78,7 +76,7 @@ test('Editing a synced lab order edits corresponding analysis request in SENAITE await expect(analysisRequest).toHaveText('Blood urea nitrogen Template'); // replay - await page.goto(`${E2E_BASE_URL}`); + await page.goto(`${O3_URL}`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); await homePage.updateLabOrder(); @@ -94,7 +92,7 @@ test('Editing a synced lab order edits corresponding analysis request in SENAITE test('Voiding a synced lab order cancels corresponding analysis request in SENAITE', async ({ page }) => { // setup - const homePage = new HomePage(page); + homePage = new HomePage(page); await homePage.goToLabOrderForm(); await page.getByRole('button', { name: 'Add', exact: true }).click(); await page.locator('#tab select').selectOption('857AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); @@ -112,7 +110,7 @@ test('Voiding a synced lab order cancels corresponding analysis request in SENAI await expect(analysisRequest).toHaveText('Blood urea nitrogen Template'); // replay - await page.goto(`${E2E_BASE_URL}`); + await page.goto(`${O3_URL}`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); await homePage.voidEncounter(); @@ -124,15 +122,15 @@ test('Voiding a synced lab order cancels corresponding analysis request in SENAI test('Published coded lab results from SENAITE are viewable in O3', async ({ page }) => { // setup - const homePage = new HomePage(page); + homePage = new HomePage(page); await homePage.goToLabOrderForm(); await page.getByRole('button', { name: 'Add', exact: true }).click(); await page.locator('#tab select').selectOption('1325AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); await homePage.saveLabOrder(); - await homePage.goToSENAITE(); - await expect(page).toHaveURL(/.*senaite/); // replay + await homePage.goToSENAITE(); + await expect(page).toHaveURL(/.*senaite/); await homePage.searchClientInSENAITE(); await homePage.createPartition(); await page.getByRole('combobox', { name: 'Result' }).selectOption('664AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); @@ -141,7 +139,7 @@ test('Published coded lab results from SENAITE are viewable in O3', async ({ pag await expect(reviewState?.includes('Published')).toBeTruthy(); // verify - await page.goto(`${E2E_BASE_URL}`); + await page.goto(`${O3_URL}`); await homePage.viewTestResults(); const testName = await page.locator('div:nth-child(2) >div> div.cds--data-table-container td:nth-child(1)').first(); await expect(testName).toContainText('Hepatitis C test - qualitative'); @@ -152,15 +150,15 @@ test('Published coded lab results from SENAITE are viewable in O3', async ({ pag test('Published numeric lab results from SENAITE are viewable in O3', async ({ page }) => { // setup - const homePage = new HomePage(page); + homePage = new HomePage(page); await homePage.goToLabOrderForm(); await page.getByRole('button', { name: 'Add', exact: true }).click(); await page.locator('#tab select').selectOption('655AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); await homePage.saveLabOrder(); - await homePage.goToSENAITE(); - await expect(page).toHaveURL(/.*senaite/); // replay + await homePage.goToSENAITE(); + await expect(page).toHaveURL(/.*senaite/); await homePage.searchClientInSENAITE(); await homePage.createPartition(); await page.locator('tr:nth-child(1) td.contentcell.Result div span input').fill('64'); @@ -169,7 +167,7 @@ test('Published numeric lab results from SENAITE are viewable in O3', async ({ p await expect(reviewState?.includes('Published')).toBeTruthy(); // verify - await page.goto(`${E2E_BASE_URL}`); + await page.goto(`${O3_URL}`); await homePage.viewTestResults(); const testName = await page.locator('div:nth-child(2) >div> div.cds--data-table-container td:nth-child(1)').first(); await expect(testName).toContainText('Total bilirubin'); @@ -180,15 +178,15 @@ test('Published numeric lab results from SENAITE are viewable in O3', async ({ p test('Published free text lab results from SENAITE are viewable in O3', async ({ page }) => { // setup - const homePage = new HomePage(page); + homePage = new HomePage(page); await homePage.goToLabOrderForm(); await page.getByRole('button', { name: 'Add', exact: true }).click(); await page.locator('#tab select').selectOption('161447AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); await homePage.saveLabOrder(); - await homePage.goToSENAITE(); - await expect(page).toHaveURL(/.*senaite/); // replay + await homePage.goToSENAITE(); + await expect(page).toHaveURL(/.*senaite/); await homePage.searchClientInSENAITE(); await homePage.createPartition(); await page.locator('div:nth-child(4) div table tbody tr td.contentcell.Result div span input').fill('Test result: Normal'); @@ -197,7 +195,7 @@ test('Published free text lab results from SENAITE are viewable in O3', async ({ await expect(reviewState?.includes('Published')).toBeTruthy(); // verify - await page.goto(`${E2E_BASE_URL}`); + await page.goto(`${O3_URL}`); await homePage.viewTestResults(); const testName = await page.locator('div:nth-child(2) >div> div.cds--data-table-container td:nth-child(1)').first(); await expect(testName).toHaveText('Stool microscopy with concentration'); @@ -207,7 +205,7 @@ test('Published free text lab results from SENAITE are viewable in O3', async ({ }); test.afterEach(async ({ page }) => { - const homePage = new HomePage(page); + homePage = new HomePage(page); await homePage.deletePatient(); await page.close(); }); diff --git a/e2e/utils/configs/globalSetup.ts b/e2e/utils/configs/globalSetup.ts index 3fb2bd89..f840d757 100644 --- a/e2e/utils/configs/globalSetup.ts +++ b/e2e/utils/configs/globalSetup.ts @@ -11,20 +11,20 @@ import { dotenv.config(); -export const E2E_BASE_URL = `${process.env.E2E_TEST_ENVIRONMENT}` == 'demo' ? `${process.env.E2E_BASE_URL_DEMO}` : `${process.env.E2E_TEST_ENVIRONMENT}` == 'qa' ? `${process.env.E2E_BASE_URL_QA}`: `${process.env.E2E_BASE_URL_DEV}`; -export const E2E_ODOO_URL = `${process.env.E2E_TEST_ENVIRONMENT}` == 'demo' ? `${process.env.E2E_ODOO_URL_DEMO}` : `${process.env.E2E_TEST_ENVIRONMENT}` == 'qa' ? `${process.env.E2E_ODOO_URL_QA}`: `${process.env.E2E_ODOO_URL_DEV}`; -export const E2E_SENAITE_URL = `${process.env.E2E_TEST_ENVIRONMENT}` == 'demo' ? `${process.env.E2E_SENAITE_URL_DEMO}` : `${process.env.E2E_TEST_ENVIRONMENT}` == 'qa' ? `${process.env.E2E_SENAITE_URL_QA}`: `${process.env.E2E_SENAITE_URL_DEV}`; -export const E2E_KEYCLOAK_URL = `${process.env.E2E_TEST_ENVIRONMENT}` == 'demo' ? `${process.env.E2E_KEYCLOAK_URL_DEMO}` : `${process.env.E2E_TEST_ENVIRONMENT}` == 'qa' ? `${process.env.E2E_KEYCLOAK_URL_QA}`: `${process.env.E2E_KEYCLOAK_URL_DEV}`; -export const E2E_ANALYTICS_URL = `${process.env.E2E_TEST_ENVIRONMENT}` == 'demo' ? `${process.env.E2E_ANALYTICS_URL_DEMO}` : `${process.env.E2E_TEST_ENVIRONMENT}` == 'qa' ? `${process.env.E2E_ANALYTICS_URL_QA}`: `${process.env.E2E_ANALYTICS_URL_DEV}`; +export const O3_URL = `${process.env.TEST_ENVIRONMENT}` == 'demo' ? `${process.env.O3_URL_DEMO}` : `${process.env.TEST_ENVIRONMENT}` == 'qa' ? `${process.env.O3_URL_QA}`: `${process.env.O3_URL_DEV}`; +export const ODOO_URL = `${process.env.TEST_ENVIRONMENT}` == 'demo' ? `${process.env.ODOO_URL_DEMO}` : `${process.env.TEST_ENVIRONMENT}` == 'qa' ? `${process.env.ODOO_URL_QA}`: `${process.env.ODOO_URL_DEV}`; +export const SENAITE_URL = `${process.env.TEST_ENVIRONMENT}` == 'demo' ? `${process.env.SENAITE_URL_DEMO}` : `${process.env.TEST_ENVIRONMENT}` == 'qa' ? `${process.env.SENAITE_URL_QA}`: `${process.env.SENAITE_URL_DEV}`; +export const KEYCLOAK_URL = `${process.env.TEST_ENVIRONMENT}` == 'demo' ? `${process.env.KEYCLOAK_URL_DEMO}` : `${process.env.TEST_ENVIRONMENT}` == 'qa' ? `${process.env.KEYCLOAK_URL_QA}`: `${process.env.KEYCLOAK_URL_DEV}`; +export const ANALYTICS_URL = `${process.env.TEST_ENVIRONMENT}` == 'demo' ? `${process.env.ANALYTICS_URL_DEMO}` : `${process.env.TEST_ENVIRONMENT}` == 'qa' ? `${process.env.ANALYTICS_URL_QA}`: `${process.env.ANALYTICS_URL_DEV}`; async function globalSetup() { const requestContext = await request.newContext(); - const token = Buffer.from(`${process.env.E2E_USER_ADMIN_USERNAME}:${process.env.E2E_USER_ADMIN_PASSWORD}`).toString( + const token = Buffer.from(`${process.env.O3_USERNAME}:${process.env.O3_PASSWORD}`).toString( 'base64', ); - await requestContext.post(`${E2E_BASE_URL}/ws/rest/v1/session`, { + await requestContext.post(`${O3_URL}/ws/rest/v1/session`, { data: { - sessionLocation: process.env.E2E_LOGIN_DEFAULT_LOCATION_UUID, + sessionLocation: '', locale: 'en', }, headers: { @@ -38,10 +38,10 @@ async function globalSetup() { export const api: WorkerFixture = async ({ playwright }, use) => { const ctx = await playwright.request.newContext({ - baseURL: `${E2E_BASE_URL}/ws/rest/v1/`, + baseURL: `${O3_URL}/ws/rest/v1/`, httpCredentials: { - username: process.env.E2E_USER_ADMIN_USERNAME ?? "", - password: process.env.E2E_USER_ADMIN_PASSWORD ?? "", + username: process.env.O3_USERNAME ?? "", + password: process.env.O3_PASSWORD ?? "", }, }); diff --git a/e2e/utils/functions/testBase.ts b/e2e/utils/functions/testBase.ts index e0ef8a5f..93c926cd 100644 --- a/e2e/utils/functions/testBase.ts +++ b/e2e/utils/functions/testBase.ts @@ -1,10 +1,10 @@ import { Page, expect } from '@playwright/test'; import { - E2E_BASE_URL, - E2E_ODOO_URL, - E2E_SENAITE_URL, - E2E_KEYCLOAK_URL, - E2E_ANALYTICS_URL + O3_URL, + ODOO_URL, + SENAITE_URL, + KEYCLOAK_URL, + ANALYTICS_URL } from '../configs/globalSetup'; @@ -44,17 +44,17 @@ export class HomePage { readonly patientSearchBar = () => this.page.locator('[data-testid="patientSearchBar"]'); async initiateLogin() { - await this.page.goto(`${E2E_BASE_URL}`); - if (`${process.env.E2E_RUNNING_ON_OZONE_PRO}` == 'true') { - await this.page.locator('#username').fill(`${process.env.E2E_USER_ADMIN_USERNAME}`); + await this.page.goto(`${O3_URL}`); + if (`${process.env.RUNNING_OZONE_ON_PRO}` == 'true') { + await this.page.locator('#username').fill(`${process.env.O3_USERNAME}`); await this.page.getByRole('button', { name: 'Continue' }).click(); - await this.page.locator('#password').fill(`${process.env.E2E_USER_ADMIN_PASSWORD}`); + await this.page.locator('#password').fill(`${process.env.O3_PASSWORD}`); await this.page.getByRole('button', { name: 'Sign In' }).click(); } else { - await this.page.locator('#username').fill(`${process.env.FOSS_E2E_USER_ADMIN_USERNAME}`); + await this.page.locator('#username').fill(`${process.env.O3_USERNAME_ON_FOSS}`); await this.page.waitForTimeout(1000); await this.page.getByRole('button', { name: 'Continue' }).click(); - await this.page.locator('#password').fill(`${process.env.FOSS_E2E_USER_ADMIN_PASSWORD}`); + await this.page.locator('#password').fill(`${process.env.O3_PASSWORD_ON_FOSS}`); await this.page.waitForTimeout(1000); await this.page.locator('button[type="submit"]').click(); } @@ -65,38 +65,38 @@ export class HomePage { } async goToSuperset() { - await this.page.goto(`${E2E_ANALYTICS_URL}`); + await this.page.goto(`${ANALYTICS_URL}`); } async goToKeycloak() { - await this.page.goto(`${E2E_KEYCLOAK_URL}/admin/master/console`); - await this.page.getByLabel('Username or email').fill(`${process.env.E2E_KEYCLOAK_USERNAME}`); - await this.page.getByLabel('Password').fill(`${process.env.E2E_KEYCLOAK_PASSWORD}`); + await this.page.goto(`${KEYCLOAK_URL}/admin/master/console`); + await this.page.getByLabel('Username or email').fill(`${process.env.KEYCLOAK_USERNAME}`); + await this.page.getByLabel('Password').fill(`${process.env.KEYCLOAK_PASSWORD}`); await this.page.getByRole('button', { name: 'Sign In' }).click(); await delay(8000); } async goToOdoo() { - await this.page.goto(`${E2E_ODOO_URL}`); - if (`${process.env.E2E_RUNNING_ON_OZONE_PRO}` == 'true') { + await this.page.goto(`${ODOO_URL}`); + if (`${process.env.RUNNING_OZONE_ON_PRO}` == 'true') { await this.page.getByRole('link', { name: 'Login with Single Sign-On' }).click(); } else { await delay(3000); - await this.page.locator('#login').fill(`${process.env.FOSS_E2E_USER_ADMIN_USERNAME}`); + await this.page.locator('#login').fill(`${process.env.ODOO_USERNAME_ON_FOSS}`); await delay(1000); - await this.page.locator('#password').fill('admin'); + await this.page.locator('#password').fill(`${process.env.ODOO_PASSWORD_ON_FOSS}`); await delay(1000); await this.page.locator('button[type="submit"]').click(); } } async goToSENAITE() { - await this.page.goto(`${E2E_SENAITE_URL}`); - if (!(`${process.env.E2E_RUNNING_ON_OZONE_PRO}` == 'true')) { + await this.page.goto(`${SENAITE_URL}`); + if (!(`${process.env.RUNNING_OZONE_ON_PRO}` == 'true')) { await delay(3000); - await this.page.locator('#__ac_name').fill(`${process.env.FOSS_E2E_USER_ADMIN_USERNAME}`); + await this.page.locator('#__ac_name').fill(`${process.env.SENAITE_USERNAME_ON_FOSS}`); await delay(1000); - await this.page.locator('#__ac_password').fill('password'); + await this.page.locator('#__ac_password').fill(`${process.env.SENAITE_PASSWORD_ON_FOSS}`); await delay(1000); await this.page.locator('#buttons-login').click(); } @@ -109,7 +109,6 @@ export class HomePage { updatedFirstName: `${(Math.random() + 1).toString(36).substring(2)}` } patientFullName = patientName.firstName + ' ' + patientName.givenName; - await this.expectAllButtonsToBePresent(); await this.page.getByRole('button', { name: 'Add Patient' }).click(); await expect(this.page.getByRole('button', { name: 'Register Patient' })).toBeEnabled(); @@ -126,7 +125,6 @@ export class HomePage { await this.page.getByTitle('close notification').click(); } await this.page.getByRole('button', { name: 'Register Patient' }).click(); - await expect(this.page.getByText('New Patient Created')).toBeVisible(); if (await this.page.getByTitle('close notification').first().isVisible()) { await this.page.getByTitle('close notification').first().click(); @@ -139,7 +137,7 @@ export class HomePage { } async goToHomePage() { - await this.page.goto(`${E2E_BASE_URL}/openmrs/spa/home`); + await this.page.goto(`${O3_URL}/openmrs/spa/home`); await expect(this.page).toHaveURL(/.*home/); } @@ -176,7 +174,7 @@ export class HomePage { } async getPatientUUID() { - await this.page.goto(`${E2E_BASE_URL}/openmrs/spa/home`); + await this.page.goto(`${O3_URL}/openmrs/spa/home`); await this.patientSearchIcon().click(); await this.patientSearchBar().type(`${patientName.firstName + ' ' + patientName.givenName}`); await this.page.getByRole('link', { name: `${patientFullName}` }).first().click(); @@ -198,18 +196,16 @@ export class HomePage { await this.page.getByRole('button', { name: 'Actions', exact: true }).click(); await this.page.getByRole('menuitem', { name: 'End visit' }).click(); await this.page.getByRole('button', { name: 'danger End Visit' }).click(); - await expect(this.page.getByText('Visit ended')).toBeVisible(); await this.page.getByRole('button', { name: 'Close' }).click(); } async deletePatient() { - await this.page.goto(`${E2E_BASE_URL}/openmrs/admin/patients/index.htm`); + await this.page.goto(`${O3_URL}/openmrs/admin/patients/index.htm`); await this.page.getByPlaceholder(' ').type(`${patientName.firstName + ' ' + patientName.givenName}`); await this.page.locator('#openmrsSearchTable tbody tr.odd td:nth-child(1)').click(); await this.page.locator('input[name="voidReason"]').fill('Delete patient created by smoke tests'); await this.page.getByRole('button', { name: 'Delete Patient', exact: true }).click(); - const message = await this.page.locator('//*[@id="patientFormVoided"]').textContent(); await expect(message?.includes('This patient has been deleted')).toBeTruthy(); await this.page.getByRole('link', { name: 'Log out' }).click(); @@ -222,7 +218,6 @@ export class HomePage { await this.page.getByRole('menuitem', { name: 'Typhoid fever' }).click(); await this.page.getByLabel('Onset date').fill('27/07/2023'); await this.page.getByRole('button', { name: 'Save & close' }).click(); - await expect(this.page.getByText('Condition saved successfully')).toBeVisible(); await delay(2000); const patientCondition = await this.page.locator('table tbody tr:nth-child(1) td:nth-child(1)'); @@ -237,7 +232,6 @@ export class HomePage { await this.page.getByRole('spinbutton', { name: 'Height' }).fill('165'); await this.page.getByRole('spinbutton', { name: 'MUAC' }).fill('34'); 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', exact: true }).click(); } @@ -253,14 +247,11 @@ export class HomePage { await this.page.getByPlaceholder('Write any additional points here').fill('This is an appointment.'); await this.page.getByRole('button', { name: 'Save and close' }).click(); await expect(this.page.getByText('Appointment scheduled')).toBeVisible(); - await this.page.getByRole('tab', { name: 'Today' }).click(); const serviceType = await this.page.locator('table tbody tr:nth-child(1) td:nth-child(3)'); await expect(serviceType).toHaveText('General Medicine service'); - const appointmentType = await this.page.locator('table tbody tr:nth-child(1) td:nth-child(5)'); await expect(appointmentType).toHaveText('Scheduled'); - const appointmentStatus = await this.page.locator('table tbody tr:nth-child(1) td:nth-child(4)'); await expect(appointmentStatus).toHaveText('Scheduled'); } @@ -314,7 +305,6 @@ export class HomePage { 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(); - await expect(this.page.getByText('Encounter deleted')).toBeVisible(); await expect(this.page.getByText('Encounter successfully deleted')).toBeVisible(); await delay(5000); @@ -505,7 +495,7 @@ export class HomePage { } async updateSupersetRole() { - await this.page.goto(`${E2E_ANALYTICS_URL}/roles/list/`); + await this.page.goto(`${ANALYTICS_URL}/roles/list/`); await this.page.getByRole('row', { name: `${randomSupersetRoleName.roleName}` }).getByRole('link').nth(1).click(); await delay(2000); await this.page.getByPlaceholder('Name').clear(); @@ -518,7 +508,7 @@ export class HomePage { } async deleteSupersetRole(){ - await this.page.goto(`${E2E_ANALYTICS_URL}/roles/list`); + await this.page.goto(`${ANALYTICS_URL}/roles/list`); await this.page.getByRole('row', { name: `${randomSupersetRoleName.roleName}` }).getByRole('checkbox').check(); await this.page.getByRole('row', { name: `${randomSupersetRoleName.roleName}` }).getByRole('link').nth(2).click(); await delay(2000); @@ -529,7 +519,7 @@ export class HomePage { } async deleteUpdatedSupersetRole(){ - await this.page.goto(`${E2E_ANALYTICS_URL}/roles/list`); + await this.page.goto(`${ANALYTICS_URL}/roles/list`); await this.page.getByRole('row', { name: `${randomSupersetRoleName.updatedRoleName}` }).getByRole('checkbox').check(); await this.page.getByRole('row', { name: `${randomSupersetRoleName.updatedRoleName}` }).getByRole('link').nth(2).click(); await delay(2000); @@ -606,7 +596,7 @@ export class HomePage { } async deleteOpenMRSRole() { - await this.page.goto(`${E2E_BASE_URL}/openmrs/admin/users/role.list`); + await this.page.goto(`${O3_URL}/openmrs/admin/users/role.list`); await this.unlinkInheritedOpenMRSRoles(); await this.page.getByRole('row', { name: `${randomOpenMRSRoleName.roleName}` }).getByRole('checkbox').check(); await this.page.getByRole('button', { name: 'Delete Selected Roles' }).click(); @@ -622,5 +612,4 @@ export class HomePage { await expect(this.page.getByRole('button', { name: 'My Account' })).toBeEnabled(); await expect(this.page.getByRole('button', { name: 'App Menu' })).toBeEnabled(); } - } diff --git a/playwright.config.ts b/playwright.config.ts index eca322c8..f7e15c96 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -15,7 +15,7 @@ const config: PlaywrightTestConfig = { reporter: process.env.CI ? [['junit', { outputFile: 'results.xml' }], ['html']] : [['html']], globalSetup: require.resolve('./e2e/utils/configs/globalSetup'), use: { - baseURL: `${process.env.E2E_BASE_URL_DEV}/spa/`, + baseURL: `${process.env.O3_URL_DEV}/spa/`, storageState: 'e2e/storageState.json', }, projects: [ @@ -23,7 +23,7 @@ const config: PlaywrightTestConfig = { name: 'chromium', use: { ...devices['Desktop Chromium'], - viewport: {width: 1920, height: 1080} + viewport: { width: 1920, height: 1080 } }, },