-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
OZ-562: Refactored component-specific user actions #88
Merged
Changes from 9 commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
077e9df
OZ-562: Refactored component-specific user actions
kdaud f7626a4
Refined method names
kdaud c475e72
Remove comment in publishLabResults()
kdaud ad9c362
Debug openmrs-senaite flows on GitHub Actions
kdaud 62f5a2f
Debug openmrs-superset flows on GitHub Actions
kdaud e93be79
Debug openmrs - senaite flows on GitHub Actions
kdaud 1f6124b
Debug keycloak-openmrs flows on GitHub Actions
kdaud 61e381d
Run all tests on GitHub Actions
kdaud 292c9de
Address reviews
kdaud f41ec9a
Corrected typo
kdaud 1726ae0
Address reviews
kdaud File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,191 +1,183 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { HomePage, delay, randomKeycloakRoleName } from '../utils/functions/testBase'; | ||
import { randomOpenMRSRoleName, randomSupersetRoleName } from '../utils/functions/testBase'; | ||
import { Keycloack, randomKeycloakRoleName } from '../utils/functions/keycloak'; | ||
import { OpenMRS, delay, randomOpenMRSRoleName } from '../utils/functions/openmrs'; | ||
import { Superset, randomSupersetRoleName} from '../utils/functions/superset'; | ||
import { O3_URL, KEYCLOAK_URL } from '../utils/configs/globalSetup'; | ||
|
||
let homePage: HomePage; | ||
let openmrs: OpenMRS; | ||
let keycloack: Keycloack; | ||
let superset: Superset; | ||
|
||
test.beforeEach(async ({ page }) => { | ||
homePage = new HomePage(page); | ||
openmrs = new OpenMRS(page); | ||
keycloack = new Keycloack(page); | ||
superset = new Superset(page); | ||
|
||
await openmrs.initiateLogin(); | ||
await expect(page).toHaveURL(/.*home/); | ||
}); | ||
|
||
test('Creating an OpenMRS role creates the corresponding Keycloak role.', async ({ page }) => { | ||
// replay | ||
await homePage.initiateLogin(); | ||
await expect(page).toHaveURL(/.*home/); | ||
await page.goto(`${O3_URL}/openmrs/admin/users/role.list`); | ||
await homePage.addOpenMRSRole(); | ||
await openmrs.addRole(); | ||
|
||
// verify | ||
await homePage.goToKeycloak(); | ||
await keycloack.open(); | ||
await expect(page).toHaveURL(/.*console/); | ||
await homePage.goToClients(); | ||
await homePage.selectOpenMRSId() | ||
await keycloack.goToClients(); | ||
await keycloack.selectOpenMRSId() | ||
await expect(page.getByText(`${randomOpenMRSRoleName.roleName}`)).toBeVisible(); | ||
await expect(page.getByText('Role for e2e test').first()).toBeVisible(); | ||
await homePage.goToClientAttributes(); | ||
await keycloack.goToClientAttributes(); | ||
await expect(page.getByText('Organizational: Registration Clerk')).toBeTruthy(); | ||
await expect(page.getByText('Application: Edits Existing Encounters')).toBeTruthy(); | ||
await expect(page.getByText('Application: Uses Patient Summary')).toBeTruthy(); | ||
await expect(page.getByText('Application: Has Super User Privileges')).toBeTruthy(); | ||
await expect(page.getByText('Application: Administers System')).toBeTruthy(); | ||
await homePage.deleteOpenMRSRole(); | ||
await openmrs.deleteRole(); | ||
}); | ||
|
||
test('Updating a synced OpenMRS role updates the corresponding Keycloak role.', async ({ page }) => { | ||
// replay | ||
await homePage.initiateLogin(); | ||
await expect(page).toHaveURL(/.*home/); | ||
await page.goto(`${O3_URL}/openmrs/admin/users/role.list`); | ||
await homePage.addOpenMRSRole(); | ||
await homePage.goToKeycloak(); | ||
await openmrs.addRole(); | ||
await keycloack.open(); | ||
await expect(page).toHaveURL(/.*console/); | ||
await homePage.goToClients(); | ||
await homePage.selectOpenMRSId(); | ||
await keycloack.goToClients(); | ||
await keycloack.selectOpenMRSId(); | ||
await expect(page.getByText(`${randomOpenMRSRoleName.roleName}`)).toBeVisible(); | ||
await expect(page.getByText('Role for e2e test').first()).toBeVisible(); | ||
await homePage.goToClientAttributes(); | ||
await keycloack.goToClientAttributes(); | ||
await expect(page.getByText('Application: Enters Vitals')).toBeTruthy(); | ||
await expect(page.getByText('Application: Edits Existing Encounters')).toBeTruthy(); | ||
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(`${O3_URL}/openmrs/admin/users/role.list`); | ||
await homePage.updateOpenMRSRole(); | ||
await openmrs.updateRole(); | ||
|
||
// verify | ||
await page.goto(`${KEYCLOAK_URL}/admin/master/console`); | ||
await homePage.goToClients(); | ||
await homePage.selectOpenMRSId(); | ||
await homePage.goToClientAttributes(); | ||
await keycloack.goToClients(); | ||
await keycloack.selectOpenMRSId(); | ||
await keycloack.goToClientAttributes(); | ||
await expect(page.getByText('Updated role description')).toBeTruthy(); | ||
await page.getByTestId('attributesTab').click(); | ||
await expect(page.getByText('Application: Registers Patients')).toBeTruthy(); | ||
await expect(page.getByText('Application: Writes Clinical Notes')).toBeTruthy(); | ||
await homePage.deleteOpenMRSRole(); | ||
await openmrs.deleteRole(); | ||
}); | ||
|
||
test('Deleting a synced OpenMRS role deletes the corresponding Keycloak role.', async ({ page }) => { | ||
// replay | ||
await homePage.initiateLogin(); | ||
await expect(page).toHaveURL(/.*home/); | ||
await page.goto(`${O3_URL}/openmrs/admin/users/role.list`); | ||
await homePage.addOpenMRSRole(); | ||
await homePage.goToKeycloak(); | ||
await openmrs.addRole(); | ||
await keycloack.open(); | ||
await expect(page).toHaveURL(/.*console/); | ||
await homePage.goToClients(); | ||
await homePage.selectOpenMRSId(); | ||
await keycloack.goToClients(); | ||
await keycloack.selectOpenMRSId(); | ||
await expect(page.getByText(`${randomOpenMRSRoleName.roleName}`)).toBeVisible(); | ||
await expect(page.getByText('Role for e2e test').first()).toBeVisible(); | ||
await homePage.goToClientAttributes(); | ||
await keycloack.goToClientAttributes(); | ||
await expect(page.getByText('Application: Enters Vitals')).toBeTruthy(); | ||
await expect(page.getByText('Application: Edits Existing Encounters')).toBeTruthy(); | ||
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 homePage.deleteOpenMRSRole(); | ||
await openmrs.deleteRole(); | ||
|
||
// verify | ||
await page.goto(`${KEYCLOAK_URL}/admin/master/console`); | ||
await homePage.goToClients(); | ||
await homePage.selectOpenMRSId(); | ||
await keycloack.goToClients(); | ||
await keycloack.selectOpenMRSId(); | ||
const roleName = await page.locator('table tbody tr:nth-child(1) td:nth-child(1) a'); | ||
await expect(roleName).not.toHaveText(`${randomOpenMRSRoleName.roleName}`); | ||
}); | ||
|
||
test('Creating a Superset role creates the corresponding Keycloak role.', async ({ page }) => { | ||
// replay | ||
await homePage.initiateLogin(); | ||
await expect(page).toHaveURL(/.*home/); | ||
await homePage.goToSuperset(); | ||
await homePage.addSupersetRole(); | ||
await superset.open(); | ||
await superset.addRole(); | ||
|
||
// verify | ||
await homePage.goToKeycloak(); | ||
await homePage.goToClients(); | ||
await homePage.selectSupersetId(); | ||
await keycloack.open(); | ||
await keycloack.goToClients(); | ||
await keycloack.selectSupersetId(); | ||
await expect(page.getByText(`${randomSupersetRoleName.roleName}`)).toBeVisible(); | ||
await homePage.deleteSupersetRole(); | ||
await superset.deleteRole(); | ||
}); | ||
|
||
test('Updating a synced Superset role updates the corresponding Keycloak role.', async ({ page }) => { | ||
// replay | ||
await homePage.initiateLogin(); | ||
await expect(page).toHaveURL(/.*home/); | ||
await homePage.goToSuperset(); | ||
await homePage.addSupersetRole(); | ||
await homePage.goToKeycloak(); | ||
await homePage.goToClients(); | ||
await homePage.selectSupersetId(); | ||
await superset.open(); | ||
await superset.addRole(); | ||
await keycloack.open(); | ||
await keycloack.goToClients(); | ||
await keycloack.selectSupersetId(); | ||
await expect(page.getByText(`${randomSupersetRoleName.roleName}`)).toBeVisible(); | ||
await expect(page.getByText('')).toBeTruthy(); | ||
await homePage.updateSupersetRole(); | ||
await superset.updateRole(); | ||
|
||
// verify | ||
await page.goto(`${KEYCLOAK_URL}/admin/master/console`); | ||
await homePage.goToClients(); | ||
await homePage.selectSupersetId(); | ||
await keycloack.goToClients(); | ||
await keycloack.selectSupersetId(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same remark here about "id". |
||
await expect(page.getByText(`${randomSupersetRoleName.roleName}`)).not.toBeVisible(); | ||
await expect(page.getByText(`${randomSupersetRoleName.updatedRoleName}`)).toBeVisible(); | ||
await homePage.deleteUpdatedSupersetRole(); | ||
await superset.deleteUpdatedRole(); | ||
}); | ||
|
||
test('Deleting a synced Superset role deletes the corresponding Keycloak role.', async ({ page }) => { | ||
// replay | ||
await homePage.initiateLogin(); | ||
await expect(page).toHaveURL(/.*home/); | ||
await homePage.goToSuperset(); | ||
await homePage.addSupersetRole(); | ||
await homePage.goToKeycloak(); | ||
await homePage.goToClients(); | ||
await homePage.selectSupersetId(); | ||
await superset.open(); | ||
await superset.addRole(); | ||
await keycloack.open(); | ||
await keycloack.goToClients(); | ||
await keycloack.selectSupersetId(); | ||
await expect(page.getByText(`${randomSupersetRoleName.roleName}`)).toBeVisible(); | ||
await homePage.deleteSupersetRole(); | ||
await superset.deleteRole(); | ||
await delay(30000); | ||
|
||
// verify | ||
await page.goto(`${KEYCLOAK_URL}/admin/master/console`); | ||
await homePage.goToClients(); | ||
await homePage.selectSupersetId(); | ||
await keycloack.goToClients(); | ||
await keycloack.selectSupersetId(); | ||
await expect(page.getByText(`${randomSupersetRoleName.roleName}`)).not.toBeVisible(); | ||
}); | ||
|
||
test('A synced role deleted from within Keycloak gets recreated in the subsequent polling cycle.', async ({ page }) => { | ||
// replay | ||
await homePage.initiateLogin(); | ||
await expect(page).toHaveURL(/.*home/); | ||
await homePage.goToSuperset(); | ||
await homePage.addSupersetRole(); | ||
await superset.open(); | ||
await superset.addRole(); | ||
|
||
// verify | ||
await homePage.goToKeycloak(); | ||
await homePage.goToClients(); | ||
await homePage.selectSupersetId(); | ||
await keycloack.open(); | ||
await keycloack.goToClients(); | ||
await keycloack.selectSupersetId(); | ||
await expect(page.getByText(`${randomSupersetRoleName.roleName}`)).toBeVisible(); | ||
await homePage.deleteSyncedSupersetRoleInKeycloak(); | ||
await keycloack.deleteSyncedRole(); | ||
await expect(page.getByText(`${randomSupersetRoleName.roleName}`)).not.toBeVisible(); | ||
await delay(30000); | ||
await page.getByLabel('Manage').getByRole('link', { name: 'Clients' }).click(); | ||
await homePage.selectSupersetId(); | ||
await keycloack.selectSupersetId(); | ||
await expect(page.getByText(`${randomSupersetRoleName.roleName}`)).toBeVisible(); | ||
await homePage.deleteSupersetRole(); | ||
await superset.deleteRole(); | ||
}); | ||
|
||
test('A (non-synced) role created from within Keycloak gets deleted in the subsequent polling cycle.', async ({ page }) => { | ||
// replay | ||
await homePage.initiateLogin(); | ||
await expect(page).toHaveURL(/.*home/); | ||
await homePage.goToKeycloak(); | ||
await homePage.goToClients(); | ||
await homePage.selectOpenMRSId(); | ||
await homePage.createRoleInKeycloak(); | ||
await keycloack.open(); | ||
await keycloack.goToClients(); | ||
await keycloack.selectOpenMRSId(); | ||
await keycloack.createRole(); | ||
|
||
// verify | ||
await page.getByRole('link', { name: 'Client details' }).click(); | ||
await expect(page.getByText(`${randomKeycloakRoleName.roleName}`)).toBeVisible(); | ||
await delay(30000); | ||
await page.getByLabel('Manage').getByRole('link', { name: 'Clients' }).click(); | ||
await homePage.selectOpenMRSId(); | ||
await keycloack.selectOpenMRSId(); | ||
await expect(page.getByText(`${randomKeycloakRoleName.roleName}`)).not.toBeVisible(); | ||
}); | ||
|
||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't it be more something like
selectOpenMRSClient()
to remain in Keycloak's lingo? Or this is UI-driven and there is literally something called ID on the screen?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually
selectOpenMRSClient()
would imply something different however, this is UI-driven with a label called client Id on the screen.