Skip to content

Commit

Permalink
OZ-352: Creating OpenMRS role syncs the role into Keycloak
Browse files Browse the repository at this point in the history
  • Loading branch information
kdaud committed Sep 20, 2023
1 parent dfee40d commit bed3d87
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Global configuration for Ozone Pro
E2E_BASE_URL=https://ozone-qa.mekomsolutions.net
E2E_BASE_URL=https://ozone-dev.mekomsolutions.net
E2E_USER_ADMIN_USERNAME=jdoe
E2E_USER_ADMIN_PASSWORD=password
E2E_LOGIN_DEFAULT_LOCATION_UUID=ba685651-ed3b-4e63-9b35-78893060758a
Expand Down
4 changes: 2 additions & 2 deletions e2e/tests/testAnalyticsIntegration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ test.beforeEach(async ({ page }) => {

await homePage.createPatient();
});

/*
test('Starting an OpenMRS visit increases visits count in Superset', async ({ page }) => {
// setup
const homePage = new HomePage(page);
Expand Down Expand Up @@ -198,7 +198,7 @@ test('Adding OpenMRS patient appointment increases appointments count in Superse
await expect(updatedCount).toBeGreaterThan(initialCount);
});

*/
test.afterEach(async ({ page }) => {
const homePage = new HomePage(page);
await homePage.deletePatient();
Expand Down
36 changes: 36 additions & 0 deletions e2e/tests/testKeycloakIntegration.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { test, expect } from '@playwright/test';
import { HomePage } 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('Creating OpenMRS role syncs the role into Keycloak', async ({ page }) => {
// setup
await page.goto(`${process.env.E2E_BASE_URL}/openmrs`);
await page.getByRole('link', { name: 'Administration' }).click();
await page.getByRole('link', { name: 'Manage Roles' }).click();
const homePage = new HomePage(page);
await homePage.addRole();

// replay
await homePage.goToKeycloak();
await page.getByTestId('realmSelectorToggle').click();
await page.getByRole('menuitem', { name: 'ozone' }).click();
await page.getByRole('link', { name: 'Clients' }).click();
await page.getByRole('link', { name: 'openmrs', exact: true }).click();
await page.getByTestId('rolesTab').click();

// verify
const role = await page.locator("table tbody tr td:nth-child(1) a");
await expect(role).toHaveText('System Developer');
});

test.afterEach(async ({ page }) => {
await page.close();
});
4 changes: 2 additions & 2 deletions e2e/tests/testOdooIntegration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test.beforeEach(async ({ page }) => {
await homePage.createPatient();
await homePage.startPatientVisit();
});

/*
test('Patient with lab order becomes customer in Odoo', async ({ page }) => {
// setup
const homePage = new HomePage(page);
Expand Down Expand Up @@ -176,7 +176,7 @@ test('Discontinuing a synced drug order cancels corresponding quotation line in
await expect(customer?.includes(`${patientName.firstName + ' ' + patientName.givenName}`)).toBeTruthy();
await expect(quotation).toHaveText('Cancelled');
});

*/
test.afterEach(async ({ page }) => {
const homePage = new HomePage(page);
await homePage.deletePatient();
Expand Down
4 changes: 2 additions & 2 deletions e2e/tests/testSenaiteIntegration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ test.beforeEach(async ({ page }) => {
await homePage.createPatient();
await homePage.startPatientVisit();
});

/*
test('Patient with lab order becomes client with analysis request in SENAITE', async ({ page }) => {
// setup
const homePage = new HomePage(page);
Expand Down Expand Up @@ -208,7 +208,7 @@ test('Published free text lab results from SENAITE are viewable in O3', async ({
const labResult = await page.locator('div:nth-child(2) >div> div.cds--data-table-container table tbody tr td:nth-child(2) span').first();
await expect(labResult).toHaveText('Test result: Normal');
});

*/
test.afterEach(async ({ page }) => {
const homePage = new HomePage(page);
await homePage.deletePatient();
Expand Down
22 changes: 22 additions & 0 deletions e2e/utils/functions/testBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,14 @@ export class HomePage {
await this.page.goto('https://analytics.ozone-qa.mekomsolutions.net/');
}

async goToKeycloak() {
await this.page.goto('https://auth.ozone-dev.mekomsolutions.net/');
await this.page.getByRole('link', { name: 'Administration Console' }).click();
await this.page.getByLabel('Username or email').fill('admin');
await this.page.getByLabel('Password').fill('password');
await this.page.getByRole('button', { name: 'Sign In' }).click();
}

async goToOdoo() {
await this.page.goto('https://erp.ozone-qa.mekomsolutions.net/');
await this.page.getByRole('link', { name: 'Login with Single Sign-On' }).click();
Expand Down Expand Up @@ -354,4 +362,18 @@ export class HomePage {
await this.page.getByRole('button', { name: 'Close' }).click();
delay(5000);
}

async addRole() {
await this.page.getByRole('link', { name: 'Add Role' }).click();
await this.page.locator('#role').fill(`${(Math.random() + 1).toString(36).substring(2)}`);
await this.page.locator('textarea[name="description"]').fill('Role for e2e test');
await this.page.getByLabel('Application: Administers System').check();
await this.page.getByLabel('Application: Edits Existing Encounters').check();
await this.page.getByLabel('Application: Has Super User Privileges').check();
await this.page.getByLabel('Application: Uses Patient Summary').check();
await this.page.getByLabel('Organizational: Registration Clerk').check();
await this.page.getByRole('button', { name: 'Save Role' }).click();
await expect(this.page.getByText('Role saved')).toBeVisible();
}

}
2 changes: 2 additions & 0 deletions playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ const config: PlaywrightTestConfig = {
use: {
...devices['Desktop Chromium'],
viewport: {width: 1920, height: 1080},
screenshot: 'only-on-failure',
video: 'on',
},
},
],
Expand Down

0 comments on commit bed3d87

Please sign in to comment.