Skip to content

Commit

Permalink
Fix tests for erpnext-openmrs flows
Browse files Browse the repository at this point in the history
  • Loading branch information
kdaud committed Nov 6, 2024
1 parent 166db7a commit e805271
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 52 deletions.
2 changes: 1 addition & 1 deletion e2e/tests/keycloak-odoo-flows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ test('Logging out from Odoo logs out the user from Keycloak.', async ({ page })
// verify
await page.goto(`${KEYCLOAK_URL}/admin/master/console`);
await keycloak.navigateToClients();
await keycloak.selectOpenMRSId();
await keycloak.selectOdooId();
await keycloak.selectSessions();
await expect(page.locator('h1.pf-c-title:nth-child(2)')).toHaveText(/no sessions/i);
await expect(page.locator('.pf-c-empty-state__body')).toHaveText(/there are currently no active sessions for this client/i);
Expand Down
42 changes: 21 additions & 21 deletions e2e/tests/keycloak-openmrs-flows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,27 @@ test.beforeEach(async ({ page }) => {
await expect(page.locator('div:nth-child(1)>a')).toHaveText(/home/i);
});

test('Logging out from OpenMRS logs out the user from Keycloak.', async ({ page }) => {
// setup
await keycloak.open();
await keycloak.navigateToClients();
await keycloak.selectOpenMRSId();
await keycloak.selectSessions();
await expect(page.locator('td:nth-child(1) a').nth(0)).toHaveText(/jdoe/i);

// replay
await openmrs.logout();

// verify
await page.goto(`${KEYCLOAK_URL}/admin/master/console`);
await keycloak.navigateToClients();
await keycloak.selectOpenMRSId();
await keycloak.selectSessions();
await expect(page.locator('h1.pf-c-title:nth-child(2)')).toHaveText(/no sessions/i);
await expect(page.locator('.pf-c-empty-state__body')).toHaveText(/there are currently no active sessions for this client/i);
await page.goto(`${O3_URL}/openmrs/spa/home/`);
await expect(page).toHaveURL(/.*login/);
});
test('Creating an OpenMRS role creates the corresponding Keycloak role.', async ({ page }) => {
// setup
await page.goto(`${O3_URL}/openmrs/admin/users/role.list`);
Expand Down Expand Up @@ -131,27 +152,6 @@ test('A (non-synced) role created from within Keycloak gets deleted in the subse
await openmrs.logout();
});

test('Logging out from OpenMRS logs out the user from Keycloak.', async ({ page }) => {
// setup
await keycloak.open();
await keycloak.navigateToClients();
await keycloak.selectOpenMRSId();
await keycloak.selectSessions();
await expect(page.locator('td:nth-child(1) a').nth(0)).toHaveText(/jdoe/i);

// replay
await openmrs.logout();

// verify
await page.goto(`${KEYCLOAK_URL}/admin/master/console`);
await keycloak.navigateToClients();
await keycloak.selectOpenMRSId();
await keycloak.selectSessions();
await expect(page.locator('h1.pf-c-title:nth-child(2)')).toHaveText(/no sessions/i);
await expect(page.locator('.pf-c-empty-state__body')).toHaveText(/there are currently no active sessions for this client/i);
await page.goto(`${O3_URL}/openmrs/spa/home/`);
await expect(page).toHaveURL(/.*login/);
});

test.afterEach(async ({ page }) => {
await page.close();
Expand Down
56 changes: 28 additions & 28 deletions e2e/tests/keycloak-superset-flows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,34 @@ test.beforeEach(async ({ page }) => {
superset = new Superset(page);
});

test('Logging out from Superset logs out the user from Keycloak.', async ({ page }) => {
// setup
await superset.open();
await openmrs.enterLoginCredentials();
await expect(page).toHaveURL(/.*superset/);
await expect(page.locator('#app div.header')).toHaveText(/home/i);
await keycloak.open();
await keycloak.navigateToClients();
await keycloak.selectSupersetId();
await keycloak.selectSessions();
await expect(page.locator('td:nth-child(1) a').nth(0)).toHaveText(/jdoe/i);

// replay
await superset.logout();
await keycloak.confirmLogout();
await expect(page).toHaveURL(/.*login/);

// verify
await page.goto(`${KEYCLOAK_URL}/admin/master/console`);
await keycloak.navigateToClients();
await keycloak.selectSupersetId();
await keycloak.selectSessions();
await expect(page.locator('h1.pf-c-title:nth-child(2)')).toHaveText(/no sessions/i);
await expect(page.locator('.pf-c-empty-state__body')).toHaveText(/there are currently no active sessions for this client/i);
await page.goto(`${SUPERSET_URL}/superset/welcome`);
await expect(page).toHaveURL(/.*login/);
});

test('Creating a Superset role creates the corresponding Keycloak role.', async ({ page }) => {
// setup
await openmrs.login();
Expand Down Expand Up @@ -111,34 +139,6 @@ test('A synced role deleted from within Keycloak gets recreated in the subsequen
await superset.logout();
});

test('Logging out from Superset logs out the user from Keycloak.', async ({ page }) => {
// setup
await superset.open();
await openmrs.enterLoginCredentials();
await expect(page).toHaveURL(/.*superset/);
await expect(page.locator('#app div.header')).toHaveText(/home/i);
await keycloak.open();
await keycloak.navigateToClients();
await keycloak.selectSupersetId();
await keycloak.selectSessions();
await expect(page.locator('td:nth-child(1) a').nth(0)).toHaveText(/jdoe/i);

// replay
await superset.logout();
await keycloak.confirmLogout();
await expect(page).toHaveURL(/.*login/);

// verify
await page.goto(`${KEYCLOAK_URL}/admin/master/console`);
await keycloak.navigateToClients();
await keycloak.selectSupersetId();
await keycloak.selectSessions();
await expect(page.locator('h1.pf-c-title:nth-child(2)')).toHaveText(/no sessions/i);
await expect(page.locator('.pf-c-empty-state__body')).toHaveText(/there are currently no active sessions for this client/i);
await page.goto(`${SUPERSET_URL}/superset/welcome`);
await expect(page).toHaveURL(/.*login/);
});

test.afterEach(async ({ page }) => {
await page.close();
});
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"!playwright-report/"
],
"scripts": {
"ozone-pro": "npx playwright test",
"ozone-pro": "npx playwright test erpnext",
"ozone-foss": "npx playwright test odoo-openmrs erpnext-openmrs openmrs-senaite",
"openmrs-distro-his": "npx playwright test odoo-openmrs openmrs-senaite"
},
Expand Down
4 changes: 3 additions & 1 deletion playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ const config: PlaywrightTestConfig = {
name: 'chromium',
use: {
...devices['Desktop Chromium'],
viewport: { width: 1920, height: 1080 }
viewport: { width: 1920, height: 1080 },
video: 'retain-on-failure',
screenshot: 'only-on-failure'
},

},
Expand Down

0 comments on commit e805271

Please sign in to comment.