Skip to content

Commit

Permalink
Address review
Browse files Browse the repository at this point in the history
  • Loading branch information
kdaud committed May 2, 2024
1 parent 5f3c15f commit c90e882
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 36 deletions.
57 changes: 26 additions & 31 deletions e2e/tests/keycloak-openmrs-flows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ test('Creating an OpenMRS role creates the corresponding Keycloak role.', async
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('Organizational: Registration Clerk')).toBeTruthy();
await expect(page.getByText('Application: Edits Existing Encounters')).toBeTruthy();
await expect(page.getByText('Application: Uses Patient Summary')).toBeTruthy();
Expand All @@ -45,11 +45,11 @@ test('Updating a synced OpenMRS role updates the corresponding Keycloak role.',
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 +61,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 @@ -80,11 +80,11 @@ test('Deleting a synced OpenMRS role deletes the corresponding Keycloak role.',
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,7 +95,7 @@ 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}`);
});
Expand All @@ -107,14 +107,12 @@ test('Creating a Superset role creates the corresponding Keycloak role.', async

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

// verify
await homePage.goToSupersetClient();

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

await homePage.deleteSupersetRole();
});

Expand All @@ -123,20 +121,19 @@ test('Updating a synced Superset role updates the corresponding Keycloak role.',
homePage = new HomePage(page);
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();

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

Expand All @@ -149,20 +146,18 @@ test('Deleting a synced Superset role deletes the corresponding Keycloak role.',
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();

// replay
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();
});
Expand All @@ -172,19 +167,19 @@ test('A synced role deleted from within Keycloak gets recreated in the subsequen
homePage = new HomePage(page);
await homePage.goToSuperset();
await homePage.addSupersetRole();
await homePage.goToKeycloak();
await homePage.goToClients();

// replay
await homePage.goToSupersetClient();
await homePage.goToKeycloak();
await homePage.goToClients();
await homePage.selectSupersetId();
await expect(page.getByText(`${randomSupersetRoleName.roleName}`)).toBeVisible();
await homePage.deleteSyncedSupersetRoleInKeycloak();

// verify
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();
Expand All @@ -194,18 +189,18 @@ test('A (non-synced) role created from within Keycloak gets deleted in the subse
// setup
homePage = new HomePage(page);
await homePage.goToKeycloak();
await homePage.goToClients();
await homePage.goToOpenMRSClient();

// replay
await homePage.goToClients();
await homePage.selectOpenMRSId();
await homePage.createRoleInKeycloak();

// 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.goToOpenMRSClient();
await homePage.selectOpenMRSId();

await expect(page.getByText(`${randomKeycloakRoleName.roleName}`)).not.toBeVisible();
});
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/odoo-openmrs-flows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ test.beforeEach(async ({ page }) => {
test('Ordering a lab test for an OpenMRS patient creates the corresponding Odoo customer with a filled quotation.', async ({ page }) => {
// setup
homePage = new HomePage(page);
await homePage.goToLabOrderForm();

// replay
await homePage.goToLabOrderForm();
await page.getByRole('button', { name: 'Add', exact: true }).click();
await page.locator('#tab select').selectOption('857AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
await homePage.saveLabOrder();
Expand Down
2 changes: 1 addition & 1 deletion e2e/tests/openmrs-senaite-flows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ test.beforeEach(async ({ page }) => {
test('Ordering a lab test for an OpenMRS patient creates the corresponding SENAITE client with an analysis request.', async ({ page }) => {
// setup
homePage = new HomePage(page);
await homePage.goToLabOrderForm();

// replay
await homePage.goToLabOrderForm();
await page.getByRole('button', { name: 'Add', exact: true }).click();
await page.locator('#tab select').selectOption('857AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
await homePage.saveLabOrder();
Expand Down
6 changes: 3 additions & 3 deletions e2e/utils/functions/testBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -543,17 +543,17 @@ export class HomePage {
await delay(2000);
}

async goToOpenMRSClient() {
async selectOpenMRSId() {
await this.page.getByRole('link', { name: 'openmrs', exact: true }).click();
await this.page.getByTestId('rolesTab').click();
}

async goToOpenMRSClientAttributes() {
async goToClientAttributes() {
await this.page.getByRole('link', { name: `${randomOpenMRSRoleName.roleName}` }).click();
await this.page.getByTestId('attributesTab').click();
}

async goToSupersetClient() {
async selectSupersetId() {
if (await this.page. getByRole('link', { name: 'superset', exact: true }).isHidden()) {
await this.page.getByLabel('Pagination top').getByLabel('Go to next page').click();
}
Expand Down

0 comments on commit c90e882

Please sign in to comment.