From 670cd0f85c562d4ad97379e2ab96c6f274dd4387 Mon Sep 17 00:00:00 2001 From: Daud Kakumirizi Date: Thu, 5 Oct 2023 17:09:30 +0300 Subject: [PATCH] OZ-365: Corrected drug order form link + Added formatting changes. (#51) --- e2e/tests/testAnalyticsIntegration.spec.ts | 20 +-- e2e/tests/testKeycloakIntegration.spec.ts | 168 ++++++++++----------- e2e/tests/testOdooIntegration.spec.ts | 4 +- e2e/utils/functions/testBase.ts | 2 +- 4 files changed, 97 insertions(+), 97 deletions(-) diff --git a/e2e/tests/testAnalyticsIntegration.spec.ts b/e2e/tests/testAnalyticsIntegration.spec.ts index 317fcf65..a9b315d1 100644 --- a/e2e/tests/testAnalyticsIntegration.spec.ts +++ b/e2e/tests/testAnalyticsIntegration.spec.ts @@ -4,13 +4,13 @@ import { patientName } from '../utils/functions/testBase'; let homePage: HomePage; -test.beforeEach(async ({ page }) => { - const homePage = new HomePage(page); - await homePage.initiateLogin(); +test.beforeEach(async ({ page }) => { + const homePage = new HomePage(page); + await homePage.initiateLogin(); - await expect(page).toHaveURL(/.*home/); + await expect(page).toHaveURL(/.*home/); - await homePage.createPatient(); + await homePage.createPatient(); }); test('Starting an OpenMRS visit increases visits count in Superset', async ({ page }) => { @@ -199,8 +199,8 @@ test('Adding an OpenMRS patient appointment increases appointments count in Supe await expect(updatedCount).toBeGreaterThan(initialCount); }); -test.afterEach(async ({ page }) => { - const homePage = new HomePage(page); - await homePage.deletePatient(); - await page.close(); - }); +test.afterEach(async ({ page }) => { + const homePage = new HomePage(page); + await homePage.deletePatient(); + await page.close(); +}); diff --git a/e2e/tests/testKeycloakIntegration.spec.ts b/e2e/tests/testKeycloakIntegration.spec.ts index 34fc66a1..b703f087 100644 --- a/e2e/tests/testKeycloakIntegration.spec.ts +++ b/e2e/tests/testKeycloakIntegration.spec.ts @@ -4,105 +4,105 @@ import { randomRoleName } from '../utils/functions/testBase'; let homePage: HomePage; -test.beforeEach(async ({ page }) => { - const homePage = new HomePage(page); - await homePage.initiateLogin(); +test.beforeEach(async ({ page }) => { + const homePage = new HomePage(page); + await homePage.initiateLogin(); - await expect(page).toHaveURL(/.*home/); + 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(); + // 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(); + // 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(); - await page.goto(`${process.env.E2E_BASE_URL}/openmrs/admin/users/role.list`); - await homePage.unlinkInheritedRoles(); - }); + // 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(); + await page.goto(`${process.env.E2E_BASE_URL}/openmrs/admin/users/role.list`); + await homePage.unlinkInheritedRoles(); +}); - test('Updating a synced OpenMRS role updates the corresponding 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(); +test('Updating a synced OpenMRS role updates the corresponding 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(); + // 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(); - await page.goto(`${process.env.E2E_BASE_URL}/openmrs/admin/users/role.list`); - await homePage.unlinkUpdatedInheritedRoles(); - }); + // 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(); + await page.goto(`${process.env.E2E_BASE_URL}/openmrs/admin/users/role.list`); + await homePage.unlinkUpdatedInheritedRoles(); +}); - test('Deleting a synced OpenMRS role deletes the corresponding 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(); +test('Deleting a synced OpenMRS role deletes the corresponding 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.unlinkInheritedRoles(); - await homePage.deleteRole(); + // 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.unlinkInheritedRoles(); + await homePage.deleteRole(); - // verify - await page.goto(`${process.env.E2E_KEYCLOAK_URL}/admin/master/console/`); - await homePage.goToRoles(); - const roleName = await page.locator('table tbody tr:nth-child(1) td:nth-child(1) a'); - await expect(roleName).not.toHaveText(`${randomRoleName.roleName}`); - await page.goto(`${process.env.E2E_BASE_URL}/openmrs/admin/users/role.list`); - await homePage.addRole(); - }); + // verify + await page.goto(`${process.env.E2E_KEYCLOAK_URL}/admin/master/console/`); + await homePage.goToRoles(); + const roleName = await page.locator('table tbody tr:nth-child(1) td:nth-child(1) a'); + await expect(roleName).not.toHaveText(`${randomRoleName.roleName}`); + 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(); - }); +}); diff --git a/e2e/tests/testOdooIntegration.spec.ts b/e2e/tests/testOdooIntegration.spec.ts index 91879113..844a429d 100644 --- a/e2e/tests/testOdooIntegration.spec.ts +++ b/e2e/tests/testOdooIntegration.spec.ts @@ -130,7 +130,7 @@ test('Revising a synced drug order edits corresponding quotation line in Odoo', await page.locator("table tbody tr:nth-child(1) td.o_data_cell.o_field_cell.o_list_many2one.o_readonly_modifier.o_required_modifier").textContent(); await expect(customer?.includes(`${patientName.firstName + ' ' + patientName.givenName}`)).toBeTruthy(); await page.getByRole('cell', { name: `${patientName.firstName + ' ' + patientName.givenName}` }).click(); - const drugOrderItem = await page.locator("table tbody tr:nth-child(1) td.o_data_cell.o_field_cell.o_list_text.o_section_and_note_text_cell.o_required_modifier span"); + const drugOrderItem = await page.locator("table tbody tr:nth-child(1) td.o_data_cell.o_field_cell.o_list_text.o_section_and_note_text_cell.o_required_modifier span"); await expect(drugOrderItem).toContainText('4.0 Tablet'); await expect(drugOrderItem).toContainText('Twice daily - 5 Days'); @@ -162,7 +162,7 @@ test('Discontinuing a synced drug order cancels corresponding quotation line in await page.locator("table tbody tr:nth-child(1) td.o_data_cell.o_field_cell.o_badge_cell.o_readonly_modifier span"); await expect(quotation).toHaveText('Quotation'); await page.getByRole('cell', { name: `${patientName.firstName + ' ' + patientName.givenName}` }).click(); - const drugOrderItem = await page.locator("table tbody tr:nth-child(1) td.o_data_cell.o_field_cell.o_list_many2one.o_product_configurator_cell.o_required_modifier span span"); + const drugOrderItem = await page.locator("table tbody tr:nth-child(1) td.o_data_cell.o_field_cell.o_list_many2one.o_product_configurator_cell.o_required_modifier span span"); await expect(drugOrderItem).toHaveText('Aspirin 325mg'); // replay diff --git a/e2e/utils/functions/testBase.ts b/e2e/utils/functions/testBase.ts index 3213d8c2..3db57cec 100644 --- a/e2e/utils/functions/testBase.ts +++ b/e2e/utils/functions/testBase.ts @@ -276,7 +276,7 @@ export class HomePage { await this.page.getByRole('button', { name: 'Add', exact: true }).nth(0).click(); await delay(2000); await this.page.getByPlaceholder('Search for a drug or orderset (e.g. "Aspirin")').fill('Aspirin 325mg'); - await this.page.getByRole('listitem').filter({ hasText: 'Aspirin 325mg — 325mg — tabletImmediately add to basket' }).click(); + await this.page.getByRole('button', { name: 'Order form' }).click(); await delay(4000); await this.page.getByPlaceholder('Dose').fill('4'); await this.page.getByRole('button', { name: 'Open', exact: true }).nth(1).click();