Skip to content

Commit

Permalink
Globalise server urls
Browse files Browse the repository at this point in the history
  • Loading branch information
kdaud committed Dec 6, 2023
1 parent 7f252dc commit 6665df9
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 442 deletions.
155 changes: 15 additions & 140 deletions e2e/tests/testAnalyticsIntegration.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
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';

let homePage: HomePage;

Expand All @@ -27,31 +28,13 @@ test('Adding an OpenMRS patient syncs patient into patients table in Superset',
await homePage.clearSQLEditor();

// replay
switch (true) {
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'demo':
await page.goto(`${process.env.E2E_BASE_URL_DEMO}/openmrs/spa/home`);
break;
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'qa':
await page.goto(`${process.env.E2E_BASE_URL_QA}/openmrs/spa/home`);
break;
default:
await page.goto(`${process.env.E2E_BASE_URL_DEV}/openmrs/spa/home`);
}
await page.goto(`${E2E_BASE_URL}`);
await homePage.createPatient();
await homePage.searchOpenMRSPatientID();
const patientIdentifier = await page.locator('#demographics section p:nth-child(2)').textContent();

// verify
switch (true) {
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'demo':
await page.goto(`${process.env.E2E_ANALYTICS_URL_DEMO}/superset/sqllab`);
break;
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'qa':
await page.goto(`${process.env.E2E_ANALYTICS_URL_QA}/superset/sqllab`);
break;
default:
await page.goto(`${process.env.E2E_ANALYTICS_URL_DEV}/superset/sqllab`);
}
await page.goto(`${E2E_ANALYTICS_URL}/superset/sqllab`);
await homePage.clearSQLEditor();
await page.getByRole('textbox').first().fill(patientsCountQuery);
await homePage.runSQLQuery();
Expand Down Expand Up @@ -96,29 +79,11 @@ test('Starting an OpenMRS visit syncs visit into visits table in Superset', asyn
await homePage.clearSQLEditor();

// replay
switch (true) {
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'demo':
await page.goto(`${process.env.E2E_BASE_URL_DEMO}/openmrs/spa/home`);
break;
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'qa':
await page.goto(`${process.env.E2E_BASE_URL_QA}/openmrs/spa/home`);
break;
default:
await page.goto(`${process.env.E2E_BASE_URL_DEV}/openmrs/spa/home`);
}
await page.goto(`${E2E_BASE_URL}`);
await homePage.startPatientVisit();

// verify
switch (true) {
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'demo':
await page.goto(`${process.env.E2E_ANALYTICS_URL_DEMO}/superset/sqllab`);
break;
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'qa':
await page.goto(`${process.env.E2E_ANALYTICS_URL_URL}/superset/sqllab`);
break;
default:
await page.goto(`${process.env.E2E_ANALYTICS_URL_DEV}/superset/sqllab`);
}
await page.goto(`${E2E_ANALYTICS_URL}/superset/sqllab`);
await homePage.clearSQLEditor();
await page.getByRole('textbox').first().fill(visitsCountQuery);
await homePage.runSQLQuery();
Expand Down Expand Up @@ -176,33 +141,15 @@ test('Creating an OpenMRS order syncs order into orders table in Superset', asyn
await homePage.clearSQLEditor();

// replay
switch (true) {
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'demo':
await page.goto(`${process.env.E2E_BASE_URL_DEMO}/openmrs/spa/home`);
break;
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'qa':
await page.goto(`${process.env.E2E_BASE_URL_QA}/openmrs/spa/home`);
break;
default:
await page.goto(`${process.env.E2E_BASE_URL_DEV}/openmrs/spa/home`);
}
await page.goto(`${E2E_BASE_URL}`);
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
switch (true) {
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'demo':
await page.goto(`${process.env.E2E_ANALYTICS_URL_DEMO}/superset/sqllab`);
break;
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'qa':
await page.goto(`${process.env.E2E_ANALYTICS_URL_QA}/superset/sqllab`);
break;
default:
await page.goto(`${process.env.E2E_ANALYTICS_URL_DEV}/superset/sqllab`);
}
await page.goto(`${E2E_ANALYTICS_URL}/superset/sqllab`);
await homePage.clearSQLEditor();
await page.getByRole('textbox').first().fill(ordersCountQuery);
await homePage.runSQLQuery();
Expand Down Expand Up @@ -260,33 +207,15 @@ test('Adding an OpenMRS encounter syncs encounter into encounters table in Super
await homePage.clearSQLEditor();

// replay
switch (true) {
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'demo':
await page.goto(`${process.env.E2E_BASE_URL_DEMO}/openmrs/spa/home`);
break;
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'qa':
await page.goto(`${process.env.E2E_BASE_URL_QA}/openmrs/spa/home`);
break;
default:
await page.goto(`${process.env.E2E_BASE_URL_DEV}/openmrs/spa/home`);
}
await page.goto(`${E2E_BASE_URL}`);
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
switch (true) {
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'demo':
await page.goto(`${process.env.E2E_ANALYTICS_URL_DEMO}/superset/sqllab`);
break;
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'qa':
await page.goto(`${process.env.E2E_ANALYTICS_URL_QA}/superset/sqllab`);
break;
default:
await page.goto(`${process.env.E2E_ANALYTICS_URL_DEV}/superset/sqllab`);
}
await page.goto(`${E2E_ANALYTICS_URL}/superset/sqllab`);
await homePage.clearSQLEditor();
await page.getByRole('textbox').first().fill(encountersCountQuery);
await homePage.runSQLQuery();
Expand Down Expand Up @@ -372,30 +301,12 @@ test('Adding an OpenMRS condition syncs condition into conditions table in Super
await homePage.clearSQLEditor();

// replay
switch (true) {
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'demo':
await page.goto(`${process.env.E2E_BASE_URL_DEMO}/openmrs/spa/home`);
break;
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'qa':
await page.goto(`${process.env.E2E_BASE_URL_QA}/openmrs/spa/home`);
break;
default:
await page.goto(`${process.env.E2E_BASE_URL_DEV}/openmrs/spa/home`);
}
await page.goto(`${E2E_BASE_URL}`);
await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`);
await homePage.addPatientCondition();

// verify
switch (true) {
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'demo':
await page.goto(`${process.env.E2E_ANALYTICS_URL_DEMO}/superset/sqllab`);
break;
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'qa':
await page.goto(`${process.env.E2E_ANALYTICS_URL_QA}/superset/sqllab`);
break;
default:
await page.goto(`${process.env.E2E_ANALYTICS_URL_DEV}/superset/sqllab`);
}
await page.goto(`${E2E_ANALYTICS_URL}/superset/sqllab`);
await homePage.clearSQLEditor();
await page.getByRole('textbox').first().fill(conditionsCountQuery);
await homePage.runSQLQuery();
Expand Down Expand Up @@ -449,30 +360,12 @@ test('Adding an OpenMRS observation syncs observation into observations table in
await homePage.clearSQLEditor();

// replay
switch (true) {
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'demo':
await page.goto(`${process.env.E2E_BASE_URL_DEMO}/openmrs/spa/home`);
break;
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'qa':
await page.goto(`${process.env.E2E_BASE_URL_QA}/openmrs/spa/home`);
break;
default:
await page.goto(`${process.env.E2E_BASE_URL_DEV}/openmrs/spa/home`);
}
await page.goto(`${E2E_BASE_URL}`);
await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`);
await homePage.addPatientBiometrics();

// verify
switch (true) {
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'demo':
await page.goto(`${process.env.E2E_ANALYTICS_URL_DEMO}/superset/sqllab`);
break;
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'qa':
await page.goto(`${process.env.E2E_ANALYTICS_URL_QA}/superset/sqllab`);
break;
default:
await page.goto(`${process.env.E2E_ANALYTICS_URL_DEV}/superset/sqllab`);
}
await page.goto(`${E2E_ANALYTICS_URL}/superset/sqllab`);
await homePage.clearSQLEditor();
await page.getByRole('textbox').first().fill(observationsCountQuery);
await homePage.runSQLQuery();
Expand Down Expand Up @@ -557,30 +450,12 @@ test('Adding an OpenMRS appointment syncs appointment into appointments table in
await homePage.clearSQLEditor();

// replay
switch (true) {
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'demo':
await page.goto(`${process.env.E2E_BASE_URL_DEMO}/openmrs/spa/home`);
break;
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'qa':
await page.goto(`${process.env.E2E_BASE_URL_QA}/openmrs/spa/home`);
break;
default:
await page.goto(`${process.env.E2E_BASE_URL_DEV}/openmrs/spa/home`);
}
await page.goto(`${E2E_BASE_URL}`);
await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`);
await homePage.addPatientAppointment();

// verify
switch (true) {
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'demo':
await page.goto(`${process.env.E2E_ANALYTICS_URL_DEMO}/superset/sqllab`);
break;
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'qa':
await page.goto(`${process.env.E2E_ANALYTICS_URL_QA}/superset/sqllab`);
break;
default:
await page.goto(`${process.env.E2E_ANALYTICS_URL_DEV}/superset/sqllab`);
}
await page.goto(`${E2E_ANALYTICS_URL}/superset/sqllab`);
await homePage.clearSQLEditor();
await page.getByRole('textbox').first().fill(appointmentsCountQuery);
await homePage.runSQLQuery();
Expand Down
78 changes: 8 additions & 70 deletions e2e/tests/testKeycloakIntegration.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { test, expect } from '@playwright/test';
import { HomePage } from '../utils/functions/testBase';
import { randomOpenMRSRoleName } from '../utils/functions/testBase';
import { E2E_BASE_URL, E2E_KEYCLOAK_URL } from '../utils/configs/globalSetup';

let homePage: HomePage;

Expand All @@ -13,16 +14,7 @@ test.beforeEach(async ({ page }) => {

test('Adding an OpenMRS role syncs the role into Keycloak', async ({ page }) => {
// setup
switch (true) {
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'demo':
await page.goto(`${process.env.E2E_BASE_URL_DEMO}/openmrs/admin/users/role.list`);
break;
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'qa':
await page.goto(`${process.env.E2E_BASE_URL_QA}/openmrs/admin/users/role.list`);
break;
default:
await page.goto(`${process.env.E2E_BASE_URL_DEV}/openmrs/admin/users/role.list`);
}
await page.goto(`${E2E_BASE_URL}/openmrs/admin/users/role.list`);
const homePage = new HomePage(page);
await homePage.addOpenMRSRole();

Expand All @@ -47,16 +39,7 @@ 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
switch (true) {
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'demo':
await page.goto(`${process.env.E2E_BASE_URL_DEMO}/openmrs/admin/users/role.list`);
break;
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'qa':
await page.goto(`${process.env.E2E_BASE_URL_QA}/openmrs/admin/users/role.list`);
break;
default:
await page.goto(`${process.env.E2E_BASE_URL_DEV}/openmrs/admin/users/role.list`);
}
await page.goto(`${E2E_BASE_URL}/openmrs/admin/users/role.list`);
const homePage = new HomePage(page);
await homePage.addOpenMRSRole();

Expand All @@ -75,29 +58,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();
switch (true) {
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'demo':
await page.goto(`${process.env.E2E_BASE_URL_DEMO}/openmrs/admin/users/role.list`);
break;
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'qa':
await page.goto(`${process.env.E2E_BASE_URL_QA}/openmrs/admin/users/role.list`);
break;
default:
await page.goto(`${process.env.E2E_BASE_URL_DEV}/openmrs/admin/users/role.list`);
}
await page.goto(`${E2E_BASE_URL}/openmrs/admin/users/role.list`);
await homePage.updateOpenMRSRole();

// verify
switch (true) {
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'demo':
await page.goto(`${process.env.E2E_KEYCLOAK_DEMO_URL}/admin/master/console`);
break;
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'qa':
await page.goto(`${process.env.E2E_KEYCLOAK_QA_URL}/admin/master/console`);
break;
default:
await page.goto(`${process.env.E2E_KEYCLOAK_URL_DEV}/admin/master/console`);
}
await page.goto(`${E2E_KEYCLOAK_URL}/admin/master/console`);
await homePage.goToClients();
await page.getByRole('link', { name: 'openmrs', exact: true }).click();
await page.getByTestId('rolesTab').click();
Expand All @@ -111,16 +76,7 @@ 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
switch (true) {
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'demo':
await page.goto(`${process.env.E2E_BASE_URL_DEMO}/openmrs/admin/users/role.list`);
break;
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'qa':
await page.goto(`${process.env.E2E_BASE_URL_QA}/openmrs/admin/users/role.list`);
break;
default:
await page.goto(`${process.env.E2E_BASE_URL_DEV}/openmrs/admin/users/role.list`);
}
await page.goto(`${E2E_BASE_URL}/openmrs/admin/users/role.list`);
const homePage = new HomePage(page);
await homePage.addOpenMRSRole();

Expand All @@ -142,31 +98,13 @@ test('Deleting a synced OpenMRS role deletes the corresponding role in Keycloak'
await homePage.deleteOpenMRSRole();

// verify
switch (true) {
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'demo':
await page.goto(`${process.env.E2E_KEYCLOAK_URL_DEMO}/admin/master/console`);
break;
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'qa':
await page.goto(`${process.env.E2E_KEYCLOAK_URL_QA}/admin/master/console`);
break;
default:
await page.goto(`${process.env.E2E_KEYCLOAK_URL_DEV}/admin/master/console`);
}
await page.goto(`${E2E_KEYCLOAK_URL}/admin/master/console`);
await homePage.goToClients();
await page.getByRole('link', { name: 'openmrs', exact: true }).click();
await page.getByTestId('rolesTab').click();
const roleName = await page.locator('table tbody tr:nth-child(1) td:nth-child(1) a');
await expect(roleName).not.toHaveText(`${randomOpenMRSRoleName.roleName}`);
switch (true) {
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'demo':
await page.goto(`${process.env.E2E_BASE_URL_DEMO}/openmrs/admin/users/role.list`);
break;
case `${process.env.E2E_TEST_ENVIRONMENT}` == 'qa':
await page.goto(`${process.env.E2E_BASE_URL_QA}/openmrs/admin/users/role.list`);
break;
default:
await page.goto(`${process.env.E2E_BASE_URL_DEV}/openmrs/admin/users/role.list`);
}
await page.goto(`${E2E_BASE_URL}/openmrs/admin/users/role.list`);
await homePage.addOpenMRSRole();
});

Expand Down
Loading

0 comments on commit 6665df9

Please sign in to comment.