-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
162 additions
and
8 deletions.
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
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
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 |
---|---|---|
@@ -0,0 +1,102 @@ | ||
import { test, expect } from '@playwright/test'; | ||
import { HomePage } from '../utils/functions/testBase'; | ||
import { randomRoleName } 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 an OpenMRS role syncs the role into Keycloak', async ({ page }) => { | ||
// setup | ||
await page.goto(`${process.env.E2E_BASE_URL}/openmrs/admin/users/role.list`); | ||
const homePage = new HomePage(page); | ||
await homePage.addRole(); | ||
|
||
// replay | ||
await homePage.goToKeycloak(); | ||
await homePage.goToRoles(); | ||
|
||
// verify | ||
await expect(page.getByText(`${randomRoleName.roleName}`)).toBeVisible(); | ||
await expect(page.getByText('Role for e2e test').first()).toBeVisible(); | ||
await page.getByRole('link', { name: `${randomRoleName.roleName}` }).click(); | ||
await page.getByTestId('attributesTab').click(); | ||
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(); | ||
}); | ||
|
||
test('Updating a synced OpenMRS role updates the role in Keycloak', async ({ page }) => { | ||
// setup | ||
await page.goto(`${process.env.E2E_BASE_URL}/openmrs/admin/users/role.list`); | ||
const homePage = new HomePage(page); | ||
await homePage.addRole(); | ||
|
||
// reply | ||
await homePage.goToKeycloak(); | ||
await homePage.goToRoles(); | ||
await expect(page.getByText(`${randomRoleName.roleName}`)).toBeVisible(); | ||
await expect(page.getByText('Role for e2e test').first()).toBeVisible(); | ||
await page.getByRole('link', { name: `${randomRoleName.roleName}` }).click(); | ||
await page.getByTestId('attributesTab').click(); | ||
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(`${process.env.E2E_BASE_URL}/openmrs/admin/users/role.list`); | ||
await homePage.updateRole(); | ||
|
||
// verify | ||
await page.goto(`${process.env.E2E_KEYCLOAK_URL}/admin/master/console/`); | ||
await homePage.goToRoles(); | ||
await page.getByRole('link', { name: `${randomRoleName.roleName}` }).click(); | ||
await page.getByTestId('attributesTab').click(); | ||
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(); | ||
}); | ||
|
||
test('Deleting a synced OpenMRS role deletes the role in Keycloak', async ({ page }) => { | ||
// setup | ||
await page.goto(`${process.env.E2E_BASE_URL}/openmrs/admin/users/role.list`); | ||
const homePage = new HomePage(page); | ||
await homePage.addRole(); | ||
|
||
// reply | ||
await homePage.goToKeycloak(); | ||
await homePage.goToRoles(); | ||
await expect(page.getByText(`${randomRoleName.roleName}`)).toBeVisible(); | ||
await expect(page.getByText('Role for e2e test').first()).toBeVisible(); | ||
await page.getByRole('link', { name: `${randomRoleName.roleName}` }).click(); | ||
await page.getByTestId('attributesTab').click(); | ||
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(`${process.env.E2E_BASE_URL}/openmrs`); | ||
await homePage.deleteRole(); | ||
|
||
// verify | ||
await page.goto(`${process.env.E2E_KEYCLOAK_URL}/admin/master/console/`); | ||
await homePage.goToRoles(); | ||
// await expect(page.getByText(`${randomRoleName.roleName}`)).toBeFalsy(); | ||
await page.goto(`${process.env.E2E_BASE_URL}/openmrs/admin/users/role.list`); | ||
await homePage.addRole(); | ||
}); | ||
|
||
test.afterEach(async ({ page }) => { | ||
const homePage = new HomePage(page); | ||
await homePage.deleteRole(); | ||
await page.getByRole('link', { name: 'Log out' }).click(); | ||
await page.close(); | ||
}); |
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
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
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
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