From c90e88275cfaaa2220e5f1b286a2261acc331c36 Mon Sep 17 00:00:00 2001 From: kdaud Date: Thu, 2 May 2024 12:42:07 +0300 Subject: [PATCH] Address review --- e2e/tests/keycloak-openmrs-flows.spec.ts | 57 +++++++++++------------- e2e/tests/odoo-openmrs-flows.spec.ts | 2 +- e2e/tests/openmrs-senaite-flows.spec.ts | 2 +- e2e/utils/functions/testBase.ts | 6 +-- 4 files changed, 31 insertions(+), 36 deletions(-) diff --git a/e2e/tests/keycloak-openmrs-flows.spec.ts b/e2e/tests/keycloak-openmrs-flows.spec.ts index c2a39069..ce29fe3e 100644 --- a/e2e/tests/keycloak-openmrs-flows.spec.ts +++ b/e2e/tests/keycloak-openmrs-flows.spec.ts @@ -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(); @@ -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(); @@ -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(); @@ -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(); @@ -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}`); }); @@ -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(); }); @@ -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(); @@ -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(); }); @@ -172,11 +167,11 @@ 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(); @@ -184,7 +179,7 @@ test('A synced role deleted from within Keycloak gets recreated in the subsequen 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(); @@ -194,10 +189,10 @@ 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 @@ -205,7 +200,7 @@ test('A (non-synced) role created from within Keycloak gets deleted in the subse 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(); }); diff --git a/e2e/tests/odoo-openmrs-flows.spec.ts b/e2e/tests/odoo-openmrs-flows.spec.ts index c72371c9..473cc76a 100644 --- a/e2e/tests/odoo-openmrs-flows.spec.ts +++ b/e2e/tests/odoo-openmrs-flows.spec.ts @@ -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(); diff --git a/e2e/tests/openmrs-senaite-flows.spec.ts b/e2e/tests/openmrs-senaite-flows.spec.ts index 6b3cc62b..f583f372 100644 --- a/e2e/tests/openmrs-senaite-flows.spec.ts +++ b/e2e/tests/openmrs-senaite-flows.spec.ts @@ -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(); diff --git a/e2e/utils/functions/testBase.ts b/e2e/utils/functions/testBase.ts index 39a85da2..c45751f7 100644 --- a/e2e/utils/functions/testBase.ts +++ b/e2e/utils/functions/testBase.ts @@ -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(); }