Skip to content
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-561: 'Actions in component A → effects in component B' pattern adoption. #85

Merged
merged 6 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/foss.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ jobs:
ODOO_URL_DEV: '${{ github.event.inputs.e2e_odoo_url_input }}'
SENAITE_URL_DEV: '${{ github.event.inputs.e2e_senaite_url_input }}'
RUNNING_OZONE_ON_PRO: 'false'
run: npm run fossE2ETests
run: npm run e2e-tests-foss

- name: Upload report
uses: actions/upload-artifact@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pro.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ jobs:
KEYCLOAK_USERNAME: '${{ secrets.KEYCLOAK_USERNAME }}'
KEYCLOAK_PASSWORD: '${{ secrets.KEYCLOAK_PASSWORD }}'
run: |
npm run proE2ETests
npm run e2e-tests-pro

if: ${{ github.event_name != 'pull_request' }}
if [[ ${{ job.status }} == "success" ]]; then
Expand Down
115 changes: 46 additions & 69 deletions e2e/tests/keycloak-openmrs-flows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,23 @@ let homePage: HomePage;

test.beforeEach(async ({ page }) => {
homePage = new HomePage(page);
await homePage.initiateLogin();
await expect(page).toHaveURL(/.*home/);
});

test('Creating an OpenMRS role creates the corresponding Keycloak role.', async ({ page }) => {
// setup
homePage = new HomePage(page);
// replay
await homePage.initiateLogin();
await expect(page).toHaveURL(/.*home/);
await page.goto(`${O3_URL}/openmrs/admin/users/role.list`);
await homePage.addOpenMRSRole();

// replay
// verify
await homePage.goToKeycloak();
await expect(page).toHaveURL(/.*console/);
await homePage.goToClients();
await homePage.goToOpenMRSClient();

// verify
await homePage.selectOpenMRSId()
await expect(page.getByText(`${randomOpenMRSRoleName.roleName}`)).toBeVisible();
await expect(page.getByText('Role for e2e test').first()).toBeVisible();
await homePage.goToOpenMRSClientAttributes();
await homePage.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();
Expand All @@ -36,20 +33,18 @@ test('Creating an OpenMRS role creates the corresponding Keycloak role.', async
});

test('Updating a synced OpenMRS role updates the corresponding Keycloak role.', async ({ page }) => {
// setup
homePage = new HomePage(page);
// replay
await homePage.initiateLogin();
await expect(page).toHaveURL(/.*home/);
await page.goto(`${O3_URL}/openmrs/admin/users/role.list`);
await homePage.addOpenMRSRole();

// replay
await homePage.goToKeycloak();
await expect(page).toHaveURL(/.*console/);
await homePage.goToClients();
await homePage.goToOpenMRSClient();

await homePage.selectOpenMRSId();
await expect(page.getByText(`${randomOpenMRSRoleName.roleName}`)).toBeVisible();
await expect(page.getByText('Role for e2e test').first()).toBeVisible();
await homePage.goToOpenMRSClientAttributes();
await homePage.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();
Expand All @@ -61,8 +56,8 @@ test('Updating a synced OpenMRS role updates the corresponding Keycloak role.',
// verify
await page.goto(`${KEYCLOAK_URL}/admin/master/console`);
await homePage.goToClients();
await homePage.goToOpenMRSClient();
await homePage.goToOpenMRSClientAttributes();
await homePage.selectOpenMRSId();
await homePage.goToClientAttributes();
await expect(page.getByText('Updated role description')).toBeTruthy();
await page.getByTestId('attributesTab').click();
await expect(page.getByText('Application: Registers Patients')).toBeTruthy();
Expand All @@ -71,20 +66,18 @@ test('Updating a synced OpenMRS role updates the corresponding Keycloak role.',
});

test('Deleting a synced OpenMRS role deletes the corresponding Keycloak role.', async ({ page }) => {
// setup
homePage = new HomePage(page);
// replay
await homePage.initiateLogin();
await expect(page).toHaveURL(/.*home/);
await page.goto(`${O3_URL}/openmrs/admin/users/role.list`);
await homePage.addOpenMRSRole();

// replay
await homePage.goToKeycloak();
await expect(page).toHaveURL(/.*console/);
await homePage.goToClients();
await homePage.goToOpenMRSClient();

await homePage.selectOpenMRSId();
await expect(page.getByText(`${randomOpenMRSRoleName.roleName}`)).toBeVisible();
await expect(page.getByText('Role for e2e test').first()).toBeVisible();
await homePage.goToOpenMRSClientAttributes();
await homePage.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();
Expand All @@ -95,120 +88,104 @@ test('Deleting a synced OpenMRS role deletes the corresponding Keycloak role.',
// verify
await page.goto(`${KEYCLOAK_URL}/admin/master/console`);
await homePage.goToClients();
await homePage.goToOpenMRSClient();
await homePage.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 }) => {
// setup
homePage = new HomePage(page);
// replay
await homePage.initiateLogin();
await expect(page).toHaveURL(/.*home/);
await homePage.goToSuperset();
await homePage.addSupersetRole();

// replay
// verify
await homePage.goToKeycloak();
await homePage.goToClients();

// verify
await homePage.goToSupersetClient();

await homePage.selectSupersetId();
await expect(page.getByText(`${randomSupersetRoleName.roleName}`)).toBeVisible();

await homePage.deleteSupersetRole();
});

test('Updating a synced Superset role updates the corresponding Keycloak role.', async ({ page }) => {
// setup
homePage = new HomePage(page);
// replay
await homePage.initiateLogin();
await expect(page).toHaveURL(/.*home/);
await homePage.goToSuperset();
await homePage.addSupersetRole();

// replay
await homePage.goToKeycloak();
await homePage.goToClients();
await homePage.goToSupersetClient();

await homePage.selectSupersetId();
await expect(page.getByText(`${randomSupersetRoleName.roleName}`)).toBeVisible();
await expect(page.getByText('')).toBeTruthy();

await homePage.updateSupersetRole();

// verify
await page.goto(`${KEYCLOAK_URL}/admin/master/console`);
await homePage.goToClients();
await homePage.goToSupersetClient();
await homePage.selectSupersetId();
await expect(page.getByText(`${randomSupersetRoleName.roleName}`)).not.toBeVisible();
await expect(page.getByText(`${randomSupersetRoleName.updatedRoleName}`)).toBeVisible();

await homePage.deleteUpdatedSupersetRole();
});

test('Deleting a synced Superset role deletes the corresponding Keycloak role.', async ({ page }) => {
// setup
homePage = new HomePage(page);
// replay
await homePage.initiateLogin();
await expect(page).toHaveURL(/.*home/);
await homePage.goToSuperset();
await homePage.addSupersetRole();

// replay
await homePage.goToKeycloak();
await homePage.goToClients();
await homePage.goToSupersetClient();

await homePage.selectSupersetId();
await expect(page.getByText(`${randomSupersetRoleName.roleName}`)).toBeVisible();

await homePage.deleteSupersetRole();
await delay(30000);

// verify
await page.goto(`${KEYCLOAK_URL}/admin/master/console`);
await homePage.goToClients();
await homePage.goToSupersetClient();

await homePage.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 }) => {
// setup
homePage = new HomePage(page);
// replay
await homePage.initiateLogin();
await expect(page).toHaveURL(/.*home/);
await homePage.goToSuperset();
await homePage.addSupersetRole();

// replay
// verify
await homePage.goToKeycloak();
await homePage.goToClients();

// verify
await homePage.goToSupersetClient();

await homePage.selectSupersetId();
await expect(page.getByText(`${randomSupersetRoleName.roleName}`)).toBeVisible();
await homePage.deleteSyncedSupersetRoleInKeycloak();
await expect(page.getByText(`${randomSupersetRoleName.roleName}`)).not.toBeVisible();
await delay(30000);
await page.getByLabel('Manage').getByRole('link', { name: 'Clients' }).click();
await homePage.goToSupersetClient();
await homePage.selectSupersetId();
await expect(page.getByText(`${randomSupersetRoleName.roleName}`)).toBeVisible();

await homePage.deleteSupersetRole();
});

test('A (non-synced) role created from within Keycloak gets deleted in the subsequent polling cycle.', async ({ page }) => {
// setup
homePage = new HomePage(page);
// replay
await homePage.initiateLogin();
await expect(page).toHaveURL(/.*home/);
await homePage.goToKeycloak();
await homePage.goToClients();
await homePage.goToOpenMRSClient();
await homePage.selectOpenMRSId();
await homePage.createRoleInKeycloak();

// replay
// 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();

// verify
await homePage.goToOpenMRSClient();

await homePage.selectOpenMRSId();
await expect(page.getByText(`${randomKeycloakRoleName.roleName}`)).not.toBeVisible();
});

Expand Down
Loading