diff --git a/.env b/.env index 3f6464f1..2e72e3fb 100644 --- a/.env +++ b/.env @@ -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 diff --git a/e2e/tests/testAnalyticsIntegration.spec.ts b/e2e/tests/testAnalyticsIntegration.spec.ts index 5d2db29a..aa07ad61 100644 --- a/e2e/tests/testAnalyticsIntegration.spec.ts +++ b/e2e/tests/testAnalyticsIntegration.spec.ts @@ -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); @@ -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(); diff --git a/e2e/tests/testKeycloakIntegration.spec.ts b/e2e/tests/testKeycloakIntegration.spec.ts new file mode 100644 index 00000000..8abfa98d --- /dev/null +++ b/e2e/tests/testKeycloakIntegration.spec.ts @@ -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(); + }); diff --git a/e2e/tests/testOdooIntegration.spec.ts b/e2e/tests/testOdooIntegration.spec.ts index 811c1be1..6c326951 100644 --- a/e2e/tests/testOdooIntegration.spec.ts +++ b/e2e/tests/testOdooIntegration.spec.ts @@ -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); @@ -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(); diff --git a/e2e/tests/testSenaiteIntegration.spec.ts b/e2e/tests/testSenaiteIntegration.spec.ts index c3507e7e..c8a21bf0 100644 --- a/e2e/tests/testSenaiteIntegration.spec.ts +++ b/e2e/tests/testSenaiteIntegration.spec.ts @@ -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); @@ -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(); diff --git a/e2e/utils/functions/testBase.ts b/e2e/utils/functions/testBase.ts index d81ec23d..aad938fa 100644 --- a/e2e/utils/functions/testBase.ts +++ b/e2e/utils/functions/testBase.ts @@ -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(); @@ -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(); + } + } diff --git a/playwright.config.ts b/playwright.config.ts index 4596c896..b8d7dcc2 100644 --- a/playwright.config.ts +++ b/playwright.config.ts @@ -24,6 +24,8 @@ const config: PlaywrightTestConfig = { use: { ...devices['Desktop Chromium'], viewport: {width: 1920, height: 1080}, + screenshot: 'only-on-failure', + video: 'on', }, }, ],