From 5f3c15fdcf4c670c9426c86fefe7874d7ef1d260 Mon Sep 17 00:00:00 2001 From: kdaud Date: Wed, 1 May 2024 15:13:44 +0300 Subject: [PATCH 1/5] OZ-561: Updated test cases to follow the structure of Given-When-Then --- e2e/tests/keycloak-openmrs-flows.spec.ts | 30 +++++++++++------------- e2e/tests/odoo-openmrs-flows.spec.ts | 18 +++++++------- e2e/tests/openmrs-senaite-flows.spec.ts | 6 ++--- e2e/tests/openmrs-superset-flows.spec.ts | 3 +-- 4 files changed, 27 insertions(+), 30 deletions(-) diff --git a/e2e/tests/keycloak-openmrs-flows.spec.ts b/e2e/tests/keycloak-openmrs-flows.spec.ts index 6a309856..c2a39069 100644 --- a/e2e/tests/keycloak-openmrs-flows.spec.ts +++ b/e2e/tests/keycloak-openmrs-flows.spec.ts @@ -15,15 +15,15 @@ test('Creating an OpenMRS role creates the corresponding Keycloak role.', async // setup homePage = new HomePage(page); await page.goto(`${O3_URL}/openmrs/admin/users/role.list`); - await homePage.addOpenMRSRole(); // replay + await homePage.addOpenMRSRole(); + + // verify await homePage.goToKeycloak(); await expect(page).toHaveURL(/.*console/); await homePage.goToClients(); await homePage.goToOpenMRSClient(); - - // verify await expect(page.getByText(`${randomOpenMRSRoleName.roleName}`)).toBeVisible(); await expect(page.getByText('Role for e2e test').first()).toBeVisible(); await homePage.goToOpenMRSClientAttributes(); @@ -39,9 +39,9 @@ test('Updating a synced OpenMRS role updates the corresponding Keycloak role.', // setup homePage = new HomePage(page); await page.goto(`${O3_URL}/openmrs/admin/users/role.list`); - await homePage.addOpenMRSRole(); // replay + await homePage.addOpenMRSRole(); await homePage.goToKeycloak(); await expect(page).toHaveURL(/.*console/); await homePage.goToClients(); @@ -74,9 +74,9 @@ test('Deleting a synced OpenMRS role deletes the corresponding Keycloak role.', // setup homePage = new HomePage(page); await page.goto(`${O3_URL}/openmrs/admin/users/role.list`); - await homePage.addOpenMRSRole(); // replay + await homePage.addOpenMRSRole(); await homePage.goToKeycloak(); await expect(page).toHaveURL(/.*console/); await homePage.goToClients(); @@ -104,9 +104,9 @@ test('Creating a Superset role creates the corresponding Keycloak role.', async // setup homePage = new HomePage(page); await homePage.goToSuperset(); - await homePage.addSupersetRole(); // replay + await homePage.addSupersetRole(); await homePage.goToKeycloak(); await homePage.goToClients(); @@ -123,8 +123,6 @@ 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(); @@ -132,6 +130,7 @@ test('Updating a synced Superset role updates the corresponding Keycloak role.', await expect(page.getByText(`${randomSupersetRoleName.roleName}`)).toBeVisible(); await expect(page.getByText('')).toBeTruthy(); + // replay await homePage.updateSupersetRole(); // verify @@ -150,13 +149,13 @@ 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 expect(page.getByText(`${randomSupersetRoleName.roleName}`)).toBeVisible(); + // replay await homePage.deleteSupersetRole(); await delay(30000); @@ -173,16 +172,15 @@ test('A synced role deleted from within Keycloak gets recreated in the subsequen homePage = new HomePage(page); await homePage.goToSuperset(); await homePage.addSupersetRole(); - - // replay await homePage.goToKeycloak(); await homePage.goToClients(); - // verify + // replay await homePage.goToSupersetClient(); - 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(); @@ -198,15 +196,15 @@ test('A (non-synced) role created from within Keycloak gets deleted in the subse await homePage.goToKeycloak(); await homePage.goToClients(); await homePage.goToOpenMRSClient(); - await homePage.createRoleInKeycloak(); // replay + 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(); - - // verify await homePage.goToOpenMRSClient(); 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 7d34a5f5..c72371c9 100644 --- a/e2e/tests/odoo-openmrs-flows.spec.ts +++ b/e2e/tests/odoo-openmrs-flows.spec.ts @@ -17,15 +17,15 @@ test('Ordering a lab test for an OpenMRS patient creates the corresponding Odoo // setup homePage = new HomePage(page); await homePage.goToLabOrderForm(); + + // replay await page.getByRole('button', { name: 'Add', exact: true }).click(); await page.locator('#tab select').selectOption('857AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); await homePage.saveLabOrder(); - // replay + // verify await homePage.goToOdoo(); await expect(page).toHaveURL(/.*web/); - - // verify await homePage.searchCustomerInOdoo(); const customer = await page.locator("table tbody td.o_data_cell:nth-child(4)").textContent(); await expect(customer?.includes(`${patientName.firstName + ' ' + patientName.givenName}`)).toBeTruthy(); @@ -66,13 +66,13 @@ test('Editing the details of an OpenMRS patient with a synced lab order edits th test('Ordering a drug for an OpenMRS patient creates the corresponding Odoo customer with a filled quotation.', async ({ page }) => { // setup homePage = new HomePage(page); - await homePage.makeDrugOrder(); // replay - await homePage.goToOdoo(); - await expect(page).toHaveURL(/.*web/); + await homePage.makeDrugOrder(); // verify + await homePage.goToOdoo(); + await expect(page).toHaveURL(/.*web/); await homePage.searchCustomerInOdoo(); const customer = await page.locator("table tbody td.o_data_cell:nth-child(4)").textContent(); await expect(customer?.includes(`${patientName.firstName + ' ' + patientName.givenName}`)).toBeTruthy(); @@ -174,14 +174,14 @@ test('Discontinuing a synced OpenMRS drug order removes the corresponding Odoo q test('Ordering a drug with a free text medication dosage for an OpenMRS patient creates the corresponding Odoo customer with a filled quotation.', async ({ page }) => { // setup homePage = new HomePage(page); - await homePage.prescribeFreeTextMedicationDosage(); // replay + await homePage.prescribeFreeTextMedicationDosage(); + + // verify await homePage.goToOdoo(); await expect(page).toHaveURL(/.*web/); await homePage.searchCustomerInOdoo(); - - // verify const customer = await page.locator("table tbody td.o_data_cell:nth-child(4)").textContent(); await expect(customer?.includes(`${patientName.firstName + ' ' + patientName.givenName}`)).toBeTruthy(); diff --git a/e2e/tests/openmrs-senaite-flows.spec.ts b/e2e/tests/openmrs-senaite-flows.spec.ts index 0b7f0189..6b3cc62b 100644 --- a/e2e/tests/openmrs-senaite-flows.spec.ts +++ b/e2e/tests/openmrs-senaite-flows.spec.ts @@ -17,15 +17,15 @@ test('Ordering a lab test for an OpenMRS patient creates the corresponding SENAI // setup homePage = new HomePage(page); await homePage.goToLabOrderForm(); + + // replay await page.getByRole('button', { name: 'Add', exact: true }).click(); await page.locator('#tab select').selectOption('857AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); await homePage.saveLabOrder(); - // replay + // verify await homePage.goToSENAITE(); await expect(page).toHaveURL(/.*senaite/); - - // verify await homePage.searchClientInSENAITE(); const client = await page.locator('table tbody tr:nth-child(1) td.contentcell.title div span a'); await expect(client).toContainText(`${patientName.firstName + ' ' + patientName.givenName}`); diff --git a/e2e/tests/openmrs-superset-flows.spec.ts b/e2e/tests/openmrs-superset-flows.spec.ts index 1159a65f..852357ec 100644 --- a/e2e/tests/openmrs-superset-flows.spec.ts +++ b/e2e/tests/openmrs-superset-flows.spec.ts @@ -407,8 +407,6 @@ test('Voiding an OpenMRS obs updates the observation in Superset observations ta await homePage.startPatientVisit(); const patient_uuid = await homePage.getPatientUUID(); await homePage.addPatientBiometrics(); - - // replay await homePage.goToSuperset(); await expect(page).toHaveURL(/.*superset/); await homePage.selectDBSchema(); @@ -424,6 +422,7 @@ test('Voiding an OpenMRS obs updates the observation in Superset observations ta await expect(secondObsVoidedState).toContainText('false'); await expect(thirdObsVoidedState).toContainText('false'); + // replay await page.goto(`${O3_URL}/openmrs/spa/home`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); await homePage.voidEncounter(); From c90e88275cfaaa2220e5f1b286a2261acc331c36 Mon Sep 17 00:00:00 2001 From: kdaud Date: Thu, 2 May 2024 12:42:07 +0300 Subject: [PATCH 2/5] 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(); } From 8f7213ea28fbbdf1da33445953e27eeac6a90825 Mon Sep 17 00:00:00 2001 From: kdaud Date: Mon, 6 May 2024 11:29:32 +0300 Subject: [PATCH 3/5] Address reviews --- e2e/tests/keycloak-openmrs-flows.spec.ts | 66 +++++++++------------- e2e/tests/odoo-openmrs-flows.spec.ts | 70 +++++++++++------------- e2e/tests/openmrs-senaite-flows.spec.ts | 70 ++++++++++++------------ e2e/tests/openmrs-superset-flows.spec.ts | 58 ++++++++------------ 4 files changed, 115 insertions(+), 149 deletions(-) diff --git a/e2e/tests/keycloak-openmrs-flows.spec.ts b/e2e/tests/keycloak-openmrs-flows.spec.ts index ce29fe3e..a86b3ef3 100644 --- a/e2e/tests/keycloak-openmrs-flows.spec.ts +++ b/e2e/tests/keycloak-openmrs-flows.spec.ts @@ -7,16 +7,13 @@ 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); - await page.goto(`${O3_URL}/openmrs/admin/users/role.list`); - // replay + await homePage.initiateLogin(); + await expect(page).toHaveURL(/.*home/); + await page.goto(`${O3_URL}/openmrs/admin/users/role.list`); await homePage.addOpenMRSRole(); // verify @@ -36,17 +33,15 @@ 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); - await page.goto(`${O3_URL}/openmrs/admin/users/role.list`); - // replay + await homePage.initiateLogin(); + await expect(page).toHaveURL(/.*home/); + await page.goto(`${O3_URL}/openmrs/admin/users/role.list`); await homePage.addOpenMRSRole(); await homePage.goToKeycloak(); await expect(page).toHaveURL(/.*console/); await homePage.goToClients(); await homePage.selectOpenMRSId(); - await expect(page.getByText(`${randomOpenMRSRoleName.roleName}`)).toBeVisible(); await expect(page.getByText('Role for e2e test').first()).toBeVisible(); await homePage.goToClientAttributes(); @@ -71,17 +66,15 @@ 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); - await page.goto(`${O3_URL}/openmrs/admin/users/role.list`); - // replay + await homePage.initiateLogin(); + await expect(page).toHaveURL(/.*home/); + await page.goto(`${O3_URL}/openmrs/admin/users/role.list`); await homePage.addOpenMRSRole(); await homePage.goToKeycloak(); await expect(page).toHaveURL(/.*console/); await homePage.goToClients(); await homePage.selectOpenMRSId(); - await expect(page.getByText(`${randomOpenMRSRoleName.roleName}`)).toBeVisible(); await expect(page.getByText('Role for e2e test').first()).toBeVisible(); await homePage.goToClientAttributes(); @@ -101,11 +94,10 @@ test('Deleting a synced OpenMRS role deletes the corresponding Keycloak role.', }); test('Creating a Superset role creates the corresponding Keycloak role.', async ({ page }) => { - // setup - homePage = new HomePage(page); - await homePage.goToSuperset(); - // replay + await homePage.initiateLogin(); + await expect(page).toHaveURL(/.*home/); + await homePage.goToSuperset(); await homePage.addSupersetRole(); // verify @@ -117,12 +109,11 @@ test('Creating a Superset role creates the corresponding Keycloak role.', async }); 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.selectSupersetId(); @@ -136,17 +127,15 @@ test('Updating a synced Superset role updates the corresponding Keycloak role.', 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.selectSupersetId(); @@ -158,39 +147,35 @@ test('Deleting a synced Superset role deletes the corresponding Keycloak role.', await page.goto(`${KEYCLOAK_URL}/admin/master/console`); await homePage.goToClients(); 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(); 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.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); - await homePage.goToKeycloak(); - // replay + await homePage.initiateLogin(); + await expect(page).toHaveURL(/.*home/); + await homePage.goToKeycloak(); await homePage.goToClients(); await homePage.selectOpenMRSId(); await homePage.createRoleInKeycloak(); @@ -201,7 +186,6 @@ test('A (non-synced) role created from within Keycloak gets deleted in the subse await delay(30000); await page.getByLabel('Manage').getByRole('link', { name: 'Clients' }).click(); 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 473cc76a..4059847d 100644 --- a/e2e/tests/odoo-openmrs-flows.spec.ts +++ b/e2e/tests/odoo-openmrs-flows.spec.ts @@ -7,17 +7,14 @@ let homePage: HomePage; test.beforeEach(async ({ page }) => { homePage = new HomePage(page); - await homePage.initiateLogin(); - await expect(page).toHaveURL(/.*home/); - await homePage.createPatient(); - await homePage.startPatientVisit(); }); 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); - // replay + await homePage.initiateLogin(); + await expect(page).toHaveURL(/.*home/); + await homePage.createPatient(); + await homePage.startPatientVisit(); await homePage.goToLabOrderForm(); await page.getByRole('button', { name: 'Add', exact: true }).click(); await page.locator('#tab select').selectOption('857AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); @@ -35,8 +32,11 @@ test('Ordering a lab test for an OpenMRS patient creates the corresponding Odoo }); test('Editing the details of an OpenMRS patient with a synced lab order edits the corresponding Odoo customer details.', async ({ page }) => { - // setup - homePage = new HomePage(page); + // replay + await homePage.initiateLogin(); + await expect(page).toHaveURL(/.*home/); + await homePage.createPatient(); + await homePage.startPatientVisit(); await homePage.goToLabOrderForm(); await page.getByRole('button', { name: 'Add', exact: true }).click(); await page.locator('#tab select').selectOption('857AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); @@ -46,11 +46,8 @@ test('Editing the details of an OpenMRS patient with a synced lab order edits th await homePage.searchCustomerInOdoo(); const customer = await page.locator("table tbody td.o_data_cell:nth-child(4)").textContent(); await expect(customer?.includes(`${patientName.firstName + ' ' + patientName.givenName}`)).toBeTruthy(); - const quotation = await page.locator("table tbody td.o_data_cell:nth-child(8)").textContent(); await expect(quotation?.includes("Quotation")).toBeTruthy(); - - // replay await page.goto(`${O3_URL}`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); await homePage.updatePatientDetails(); @@ -64,10 +61,11 @@ test('Editing the details of an OpenMRS patient with a synced lab order edits th }); test('Ordering a drug for an OpenMRS patient creates the corresponding Odoo customer with a filled quotation.', async ({ page }) => { - // setup - homePage = new HomePage(page); - // replay + await homePage.initiateLogin(); + await expect(page).toHaveURL(/.*home/); + await homePage.createPatient(); + await homePage.startPatientVisit(); await homePage.makeDrugOrder(); // verify @@ -82,20 +80,19 @@ test('Ordering a drug for an OpenMRS patient creates the corresponding Odoo cust }); test('Editing the details of an OpenMRS patient with a synced drug order edits the corresponding Odoo customer details.', async ({ page }) => { - // setup - homePage = new HomePage(page); + // replay + await homePage.initiateLogin(); + await expect(page).toHaveURL(/.*home/); + await homePage.createPatient(); + await homePage.startPatientVisit(); await homePage.makeDrugOrder(); await homePage.goToOdoo(); await expect(page).toHaveURL(/.*web/); await homePage.searchCustomerInOdoo(); - const customer = await page.locator("table tbody td.o_data_cell:nth-child(4)").textContent(); await expect(customer?.includes(`${patientName.firstName + ' ' + patientName.givenName}`)).toBeTruthy(); - const quotation = await page.locator("table tbody td.o_data_cell:nth-child(8)").textContent(); await expect(quotation?.includes("Quotation")).toBeTruthy(); - - // replay await page.goto(`${O3_URL}`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); await homePage.updatePatientDetails(); @@ -110,23 +107,21 @@ test('Editing the details of an OpenMRS patient with a synced drug order edits t }); test('Revising a synced OpenMRS drug order edits the corresponding Odoo quotation line.', async ({ page }) => { - // setup - homePage = new HomePage(page); + // replay + await homePage.initiateLogin(); + await expect(page).toHaveURL(/.*home/); + await homePage.createPatient(); + await homePage.startPatientVisit(); await homePage.makeDrugOrder(); await homePage.goToOdoo(); await expect(page).toHaveURL(/.*web/); await homePage.searchCustomerInOdoo(); - const customer = await page.locator("table tbody td.o_data_cell:nth-child(4)").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 td.o_data_cell:nth-child(3) span"); - await expect(drugOrderItem).toContainText('4.0 Tablet'); await expect(drugOrderItem).toContainText('Twice daily - 5 Days'); - - // replay await page.goto(`${O3_URL}`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); await homePage.editDrugOrder(); @@ -140,23 +135,22 @@ test('Revising a synced OpenMRS drug order edits the corresponding Odoo quotatio }); test('Discontinuing a synced OpenMRS drug order removes the corresponding Odoo quotation line.', async ({ page }) => { - // setup - homePage = new HomePage(page); + // replay + await homePage.initiateLogin(); + await expect(page).toHaveURL(/.*home/); + await homePage.createPatient(); + await homePage.startPatientVisit(); await homePage.makeDrugOrder(); await homePage.goToOdoo(); await expect(page).toHaveURL(/.*web/); await homePage.searchCustomerInOdoo(); - const customer = await page.locator("table tbody td.o_data_cell:nth-child(4)").textContent(); await expect(customer?.includes(`${patientName.firstName + ' ' + patientName.givenName}`)).toBeTruthy(); - const quotation = await page.locator("table tbody td.o_data_cell:nth-child(8)"); await expect(quotation).toHaveText('Quotation'); await page.getByRole('cell', { name: `${patientName.firstName + ' ' + patientName.givenName}` }).click(); const drugOrderItem = await page.locator("table tbody td.o_data_cell:nth-child(2) span:nth-child(1) span"); await expect(drugOrderItem).toHaveText('Aspirin 325mg'); - - // replay await page.goto(`${O3_URL}`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); await homePage.discontinueDrugOrder(); @@ -172,10 +166,11 @@ test('Discontinuing a synced OpenMRS drug order removes the corresponding Odoo q }); test('Ordering a drug with a free text medication dosage for an OpenMRS patient creates the corresponding Odoo customer with a filled quotation.', async ({ page }) => { - // setup - homePage = new HomePage(page); - // replay + await homePage.initiateLogin(); + await expect(page).toHaveURL(/.*home/); + await homePage.createPatient(); + await homePage.startPatientVisit(); await homePage.prescribeFreeTextMedicationDosage(); // verify @@ -190,7 +185,6 @@ test('Ordering a drug with a free text medication dosage for an OpenMRS patient }); test.afterEach(async ({ page }) => { - homePage = new HomePage(page); await homePage.deletePatient(); await page.close(); }); diff --git a/e2e/tests/openmrs-senaite-flows.spec.ts b/e2e/tests/openmrs-senaite-flows.spec.ts index f583f372..011eebc2 100644 --- a/e2e/tests/openmrs-senaite-flows.spec.ts +++ b/e2e/tests/openmrs-senaite-flows.spec.ts @@ -7,17 +7,14 @@ let homePage: HomePage; test.beforeEach(async ({ page }) => { homePage = new HomePage(page); - await homePage.initiateLogin(); - await expect(page).toHaveURL(/.*home/); - await homePage.createPatient(); - await homePage.startPatientVisit(); }); 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); - // replay + await homePage.initiateLogin(); + await expect(page).toHaveURL(/.*home/); + await homePage.createPatient(); + await homePage.startPatientVisit(); await homePage.goToLabOrderForm(); await page.getByRole('button', { name: 'Add', exact: true }).click(); await page.locator('#tab select').selectOption('857AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); @@ -32,8 +29,11 @@ test('Ordering a lab test for an OpenMRS patient creates the corresponding SENAI }); test('Editing the details of an OpenMRS patient with a synced lab order edits the corresponding SENAITE client details.', async ({ page }) => { - // setup - homePage = new HomePage(page); + // replay + await homePage.initiateLogin(); + await expect(page).toHaveURL(/.*home/); + await homePage.createPatient(); + await homePage.startPatientVisit(); await homePage.goToLabOrderForm(); await page.getByRole('button', { name: 'Add', exact: true }).click(); await page.locator('#tab select').selectOption('857AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); @@ -43,8 +43,6 @@ test('Editing the details of an OpenMRS patient with a synced lab order edits th await homePage.searchClientInSENAITE(); const client = await page.locator('table tbody tr:nth-child(1) td.contentcell.title div span a'); await expect(client).toContainText(`${patientName.firstName + ' ' + patientName.givenName}`); - - // replay await page.goto(`${O3_URL}`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); await homePage.updatePatientDetails(); @@ -57,25 +55,24 @@ test('Editing the details of an OpenMRS patient with a synced lab order edits th }); test('Editing a synced OpenMRS lab order edits the corresponding SENAITE analysis request.', async ({ page }) => { - // setup - homePage = new HomePage(page); + // replay + await homePage.initiateLogin(); + await expect(page).toHaveURL(/.*home/); + await homePage.createPatient(); + await homePage.startPatientVisit(); await homePage.goToLabOrderForm(); await page.getByRole('button', { name: 'Add', exact: true }).click(); await page.locator('#tab select').selectOption('857AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); await homePage.saveLabOrder(); await homePage.goToSENAITE(); await expect(page).toHaveURL(/.*senaite/); - await homePage.searchClientInSENAITE(); const client = await page.locator('table tbody tr:nth-child(1) td.contentcell.title div'); await expect(client).toContainText(`${patientName.firstName + ' ' + patientName.givenName}`); - await page.locator('table tbody tr:nth-child(1) td.contentcell.title div').click(); await page.locator('table tbody tr:nth-child(1) td.contentcell.getId div span a').click(); const analysisRequest = await page.locator('#sampleheader-standard-fields tr:nth-child(1) td:nth-child(6)'); await expect(analysisRequest).toHaveText('Blood urea nitrogen Template'); - - // replay await page.goto(`${O3_URL}`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); await homePage.updateLabOrder(); @@ -91,25 +88,24 @@ test('Editing a synced OpenMRS lab order edits the corresponding SENAITE analysi }); test('Voiding a synced OpenMRS lab order cancels the corresponding SENAITE analysis request.', async ({ page }) => { - // setup - homePage = new HomePage(page); + // replay + await homePage.initiateLogin(); + await expect(page).toHaveURL(/.*home/); + await homePage.createPatient(); + await homePage.startPatientVisit(); await homePage.goToLabOrderForm(); await page.getByRole('button', { name: 'Add', exact: true }).click(); await page.locator('#tab select').selectOption('857AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); await homePage.saveLabOrder(); await homePage.goToSENAITE(); await expect(page).toHaveURL(/.*senaite/); - await homePage.searchClientInSENAITE(); const client = await page.locator('table tbody tr:nth-child(1) td.contentcell.title div'); await expect(client).toContainText(`${patientName.firstName + ' ' + patientName.givenName}`); - await page.locator('table tbody tr:nth-child(1) td.contentcell.title div').click(); await page.locator('table tbody tr:nth-child(1) td.contentcell.getId div span a').click(); const analysisRequest = await page.locator('#sampleheader-standard-fields tr:nth-child(1) td:nth-child(6)'); await expect(analysisRequest).toHaveText('Blood urea nitrogen Template'); - - // replay await page.goto(`${O3_URL}`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); await homePage.voidEncounter(); @@ -121,14 +117,15 @@ test('Voiding a synced OpenMRS lab order cancels the corresponding SENAITE analy }); test('Published coded lab results from SENAITE are viewable in the OpenMRS lab results viewer.', async ({ page }) => { - // setup - homePage = new HomePage(page); + // replay + await homePage.initiateLogin(); + await expect(page).toHaveURL(/.*home/); + await homePage.createPatient(); + await homePage.startPatientVisit(); await homePage.goToLabOrderForm(); await page.getByRole('button', { name: 'Add', exact: true }).click(); await page.locator('#tab select').selectOption('1325AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); await homePage.saveLabOrder(); - - // replay await homePage.goToSENAITE(); await expect(page).toHaveURL(/.*senaite/); await homePage.searchClientInSENAITE(); @@ -149,14 +146,15 @@ test('Published coded lab results from SENAITE are viewable in the OpenMRS lab r }); test('Published numeric lab results from SENAITE are viewable in the OpenMRS lab results viewer.', async ({ page }) => { - // setup - homePage = new HomePage(page); + // replay + await homePage.initiateLogin(); + await expect(page).toHaveURL(/.*home/); + await homePage.createPatient(); + await homePage.startPatientVisit(); await homePage.goToLabOrderForm(); await page.getByRole('button', { name: 'Add', exact: true }).click(); await page.locator('#tab select').selectOption('655AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); await homePage.saveLabOrder(); - - // replay await homePage.goToSENAITE(); await expect(page).toHaveURL(/.*senaite/); await homePage.searchClientInSENAITE(); @@ -177,14 +175,15 @@ test('Published numeric lab results from SENAITE are viewable in the OpenMRS lab }); test('Published free text lab results from SENAITE are viewable in the OpenMRS lab results viewer.', async ({ page }) => { - // setup - homePage = new HomePage(page); + // replay + await homePage.initiateLogin(); + await expect(page).toHaveURL(/.*home/); + await homePage.createPatient(); + await homePage.startPatientVisit(); await homePage.goToLabOrderForm(); await page.getByRole('button', { name: 'Add', exact: true }).click(); await page.locator('#tab select').selectOption('161447AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'); await homePage.saveLabOrder(); - - // replay await homePage.goToSENAITE(); await expect(page).toHaveURL(/.*senaite/); await homePage.searchClientInSENAITE(); @@ -205,7 +204,6 @@ test('Published free text lab results from SENAITE are viewable in the OpenMRS l }); test.afterEach(async ({ page }) => { - homePage = new HomePage(page); await homePage.deletePatient(); await page.close(); }); diff --git a/e2e/tests/openmrs-superset-flows.spec.ts b/e2e/tests/openmrs-superset-flows.spec.ts index 852357ec..d9aebb87 100644 --- a/e2e/tests/openmrs-superset-flows.spec.ts +++ b/e2e/tests/openmrs-superset-flows.spec.ts @@ -7,13 +7,12 @@ let homePage: HomePage; test.beforeEach(async ({ page }) => { homePage = new HomePage(page); - await homePage.initiateLogin(); - await expect(page).toHaveURL(/.*home/); }); test('Creating an OpenMRS patient creates the patient in Superset patients table.', async ({ page }) => { - // setup - homePage = new HomePage(page); + // replay + await homePage.initiateLogin(); + await expect(page).toHaveURL(/.*home/); await homePage.goToSuperset(); await expect(page).toHaveURL(/.*superset/); await homePage.selectDBSchema(); @@ -25,8 +24,6 @@ test('Creating an OpenMRS patient creates the patient in Superset patients table let initialPatientsCount = Number(initialNumberOfPatients); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); - - // replay await page.goto(`${O3_URL}`); await homePage.createPatient(); await homePage.searchOpenMRSPatientID(); @@ -59,8 +56,9 @@ test('Creating an OpenMRS patient creates the patient in Superset patients table }); test('Creating an OpenMRS visit creates the visit in Superset visits table.', async ({ page }) => { - // setup - homePage = new HomePage(page); + // replay + await homePage.initiateLogin(); + await expect(page).toHaveURL(/.*home/); await homePage.createPatient(); await homePage.goToSuperset(); await expect(page).toHaveURL(/.*superset/); @@ -73,8 +71,6 @@ test('Creating an OpenMRS visit creates the visit in Superset visits table.', as let initialVisitsCount = Number(initialNumberOfVisits); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); - - // replay await page.goto(`${O3_URL}`); await homePage.startPatientVisit(); const patient_uuid = await homePage.getPatientUUID(); @@ -106,8 +102,9 @@ test('Creating an OpenMRS visit creates the visit in Superset visits table.', as }); test('Creating an OpenMRS order creates the order in Superset orders table.', async ({ page }) => { - // setup - homePage = new HomePage(page); + // replay + await homePage.initiateLogin(); + await expect(page).toHaveURL(/.*home/); await homePage.createPatient(); await homePage.searchOpenMRSPatientID(); const patientIdentifier = await page.locator('#demographics section p:nth-child(2)').textContent(); @@ -123,8 +120,6 @@ test('Creating an OpenMRS order creates the order in Superset orders table.', as let initialOrdersCount = Number(initialNumberOfOrders); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); - - // replay await page.goto(`${O3_URL}`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); await homePage.goToLabOrderForm(); @@ -164,8 +159,9 @@ test('Creating an OpenMRS order creates the order in Superset orders table.', as }); test('Creating an OpenMRS encounter creates the encounter in Superset encounters table.', async ({ page }) => { - // setup - homePage = new HomePage(page); + // replay + await homePage.initiateLogin(); + await expect(page).toHaveURL(/.*home/); await homePage.createPatient(); await homePage.searchOpenMRSPatientID(); const patientIdentifier = await page.locator('#demographics section p:nth-child(2)').textContent(); @@ -181,8 +177,6 @@ test('Creating an OpenMRS encounter creates the encounter in Superset encounters let initialEncountersCount = Number(initialNumberOfEncounters); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); - - // replay await page.goto(`${O3_URL}`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); await homePage.goToLabOrderForm(); @@ -235,8 +229,9 @@ test('Creating an OpenMRS encounter creates the encounter in Superset encounters }); test('Creating an OpenMRS condition creates the condition in Superset conditions table.', async ({ page }) => { - // setup - homePage = new HomePage(page); + // replay + await homePage.initiateLogin(); + await expect(page).toHaveURL(/.*home/); await homePage.createPatient(); await homePage.searchOpenMRSPatientID(); const patientIdentifier = await page.locator('#demographics section p:nth-child(2)').textContent(); @@ -252,8 +247,6 @@ test('Creating an OpenMRS condition creates the condition in Superset conditions let initialConditionsCount = Number(initialNumberOfConditions); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); - - // replay await page.goto(`${O3_URL}`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); await homePage.addPatientCondition(); @@ -290,8 +283,9 @@ test('Creating an OpenMRS condition creates the condition in Superset conditions }); test('Creating an OpenMRS obs creates the observation in Superset observations table.', async ({ page }) => { - // setup - homePage = new HomePage(page); + // replay + await homePage.initiateLogin(); + await expect(page).toHaveURL(/.*home/); await homePage.createPatient(); await homePage.startPatientVisit(); const patient_uuid = await homePage.getPatientUUID(); @@ -306,8 +300,6 @@ test('Creating an OpenMRS obs creates the observation in Superset observations t let initialObservationsCount = Number(initialNumberOfObservations); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); - - // replay await page.goto(`${O3_URL}`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); await homePage.addPatientBiometrics(); @@ -348,8 +340,9 @@ test('Creating an OpenMRS obs creates the observation in Superset observations t }); test('Creating an OpenMRS appointment creates the appointment in Superset appointments table.', async ({ page }) => { - // setup - homePage = new HomePage(page); + // replay + await homePage.initiateLogin(); + await expect(page).toHaveURL(/.*home/); await homePage.createPatient(); await homePage.searchOpenMRSPatientID(); const patientIdentifier = await page.locator('#demographics section p:nth-child(2)').textContent(); @@ -365,8 +358,6 @@ test('Creating an OpenMRS appointment creates the appointment in Superset appoin let initialAppointmentsCount = Number(initialNumberOfAppointments); await page.getByRole('tab', { name: 'Query history' }).click(); await homePage.clearSQLEditor(); - - // replay await page.goto(`${O3_URL}`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); await homePage.addPatientAppointment(); @@ -401,8 +392,9 @@ test('Creating an OpenMRS appointment creates the appointment in Superset appoin }); test('Voiding an OpenMRS obs updates the observation in Superset observations table.', async ({ page }) => { - // setup - homePage = new HomePage(page); + // replay + await homePage.initiateLogin(); + await expect(page).toHaveURL(/.*home/); await homePage.createPatient(); await homePage.startPatientVisit(); const patient_uuid = await homePage.getPatientUUID(); @@ -422,7 +414,6 @@ test('Voiding an OpenMRS obs updates the observation in Superset observations ta await expect(secondObsVoidedState).toContainText('false'); await expect(thirdObsVoidedState).toContainText('false'); - // replay await page.goto(`${O3_URL}/openmrs/spa/home`); await homePage.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`); await homePage.voidEncounter(); @@ -442,7 +433,6 @@ test('Voiding an OpenMRS obs updates the observation in Superset observations ta }); test.afterEach(async ({ page }) => { - homePage = new HomePage(page); await homePage.deletePatient(); await page.close(); }); From e355a206077d4926eb6a4369ad18c5de1a3c8134 Mon Sep 17 00:00:00 2001 From: kdaud Date: Mon, 6 May 2024 15:42:37 +0300 Subject: [PATCH 4/5] Rename 'proE2ETests' to 'e2eTests' + Renanmed files for FOSS --- .github/workflows/pro.yml | 2 +- package.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pro.yml b/.github/workflows/pro.yml index 524c8b86..92b708ad 100644 --- a/.github/workflows/pro.yml +++ b/.github/workflows/pro.yml @@ -53,7 +53,7 @@ jobs: KEYCLOAK_USERNAME: '${{ secrets.KEYCLOAK_USERNAME }}' KEYCLOAK_PASSWORD: '${{ secrets.KEYCLOAK_PASSWORD }}' run: | - npm run proE2ETests + npm run e2eTests if: ${{ github.event_name != 'pull_request' }} if [[ ${{ job.status }} == "success" ]]; then diff --git a/package.json b/package.json index 510a5b19..86a071c5 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,8 @@ "!playwright-report/" ], "scripts": { - "proE2ETests": "npx playwright test", - "fossE2ETests": "npx playwright test Odoo Senaite" + "e2eTests": "npx playwright test", + "fossE2ETests": "npx playwright test odoo-openmrs senaite-openmrs" }, "publishConfig": { "registry": "https://nexus.mekomsolutions.net/repository/npm-public/" From ba710af844a03243fc64adb3d4aa6b7b7796d022 Mon Sep 17 00:00:00 2001 From: kdaud Date: Mon, 6 May 2024 16:31:03 +0300 Subject: [PATCH 5/5] Update reviews --- .github/workflows/foss.yml | 2 +- .github/workflows/pro.yml | 2 +- e2e/tests/odoo-openmrs-flows.spec.ts | 16 ++++++++-------- package.json | 4 ++-- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/foss.yml b/.github/workflows/foss.yml index 21367294..4e6bb2e2 100644 --- a/.github/workflows/foss.yml +++ b/.github/workflows/foss.yml @@ -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 diff --git a/.github/workflows/pro.yml b/.github/workflows/pro.yml index 92b708ad..1465efe1 100644 --- a/.github/workflows/pro.yml +++ b/.github/workflows/pro.yml @@ -53,7 +53,7 @@ jobs: KEYCLOAK_USERNAME: '${{ secrets.KEYCLOAK_USERNAME }}' KEYCLOAK_PASSWORD: '${{ secrets.KEYCLOAK_PASSWORD }}' run: | - npm run e2eTests + npm run e2e-tests-pro if: ${{ github.event_name != 'pull_request' }} if [[ ${{ job.status }} == "success" ]]; then diff --git a/e2e/tests/odoo-openmrs-flows.spec.ts b/e2e/tests/odoo-openmrs-flows.spec.ts index 4059847d..b098bb40 100644 --- a/e2e/tests/odoo-openmrs-flows.spec.ts +++ b/e2e/tests/odoo-openmrs-flows.spec.ts @@ -24,7 +24,7 @@ test('Ordering a lab test for an OpenMRS patient creates the corresponding Odoo await homePage.goToOdoo(); await expect(page).toHaveURL(/.*web/); await homePage.searchCustomerInOdoo(); - const customer = await page.locator("table tbody td.o_data_cell:nth-child(4)").textContent(); + const customer = await page.locator("tr.o_data_row:nth-child(1) td:nth-child(4)").textContent(); await expect(customer?.includes(`${patientName.firstName + ' ' + patientName.givenName}`)).toBeTruthy(); const quotation = await page.locator("table tbody td.o_data_cell:nth-child(8)").textContent(); @@ -44,7 +44,7 @@ test('Editing the details of an OpenMRS patient with a synced lab order edits th await homePage.goToOdoo(); await expect(page).toHaveURL(/.*web/); await homePage.searchCustomerInOdoo(); - const customer = await page.locator("table tbody td.o_data_cell:nth-child(4)").textContent(); + const customer = await page.locator("tr.o_data_row:nth-child(1) td:nth-child(4)").textContent(); await expect(customer?.includes(`${patientName.firstName + ' ' + patientName.givenName}`)).toBeTruthy(); const quotation = await page.locator("table tbody td.o_data_cell:nth-child(8)").textContent(); await expect(quotation?.includes("Quotation")).toBeTruthy(); @@ -55,7 +55,7 @@ test('Editing the details of an OpenMRS patient with a synced lab order edits th // verify await page.goto(`${ODOO_URL}`); await homePage.searchCustomerInOdoo(); - const updatedCustomer = await page.locator("table tbody td.o_data_cell:nth-child(4)"); + const updatedCustomer = await page.locator("tr.o_data_row:nth-child(1) td:nth-child(4)"); await expect(updatedCustomer).toHaveText(`${patientName.updatedFirstName}` + ' ' + `${patientName.givenName}`); await expect(quotation?.includes("Quotation")).toBeTruthy(); }); @@ -72,7 +72,7 @@ test('Ordering a drug for an OpenMRS patient creates the corresponding Odoo cust await homePage.goToOdoo(); await expect(page).toHaveURL(/.*web/); await homePage.searchCustomerInOdoo(); - const customer = await page.locator("table tbody td.o_data_cell:nth-child(4)").textContent(); + const customer = await page.locator("tr.o_data_row:nth-child(1) td:nth-child(4)").textContent(); await expect(customer?.includes(`${patientName.firstName + ' ' + patientName.givenName}`)).toBeTruthy(); const quotation = await page.locator("table tbody td.o_data_cell:nth-child(8)").textContent(); @@ -89,7 +89,7 @@ test('Editing the details of an OpenMRS patient with a synced drug order edits t await homePage.goToOdoo(); await expect(page).toHaveURL(/.*web/); await homePage.searchCustomerInOdoo(); - const customer = await page.locator("table tbody td.o_data_cell:nth-child(4)").textContent(); + const customer = await page.locator("tr.o_data_row:nth-child(1) td:nth-child(4)").textContent(); await expect(customer?.includes(`${patientName.firstName + ' ' + patientName.givenName}`)).toBeTruthy(); const quotation = await page.locator("table tbody td.o_data_cell:nth-child(8)").textContent(); await expect(quotation?.includes("Quotation")).toBeTruthy(); @@ -116,7 +116,7 @@ test('Revising a synced OpenMRS drug order edits the corresponding Odoo quotatio await homePage.goToOdoo(); await expect(page).toHaveURL(/.*web/); await homePage.searchCustomerInOdoo(); - const customer = await page.locator("table tbody td.o_data_cell:nth-child(4)").textContent(); + const customer = await page.locator("tr.o_data_row:nth-child(1) td:nth-child(4)").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 td.o_data_cell:nth-child(3) span"); @@ -144,7 +144,7 @@ test('Discontinuing a synced OpenMRS drug order removes the corresponding Odoo q await homePage.goToOdoo(); await expect(page).toHaveURL(/.*web/); await homePage.searchCustomerInOdoo(); - const customer = await page.locator("table tbody td.o_data_cell:nth-child(4)").textContent(); + const customer = await page.locator("tr.o_data_row:nth-child(1) td:nth-child(4)").textContent(); await expect(customer?.includes(`${patientName.firstName + ' ' + patientName.givenName}`)).toBeTruthy(); const quotation = await page.locator("table tbody td.o_data_cell:nth-child(8)"); await expect(quotation).toHaveText('Quotation'); @@ -177,7 +177,7 @@ test('Ordering a drug with a free text medication dosage for an OpenMRS patient await homePage.goToOdoo(); await expect(page).toHaveURL(/.*web/); await homePage.searchCustomerInOdoo(); - const customer = await page.locator("table tbody td.o_data_cell:nth-child(4)").textContent(); + const customer = await page.locator("tr.o_data_row:nth-child(1) td:nth-child(4)").textContent(); await expect(customer?.includes(`${patientName.firstName + ' ' + patientName.givenName}`)).toBeTruthy(); const quotation = await page.locator("table tbody td.o_data_cell:nth-child(8)").textContent(); diff --git a/package.json b/package.json index 86a071c5..fed2a293 100644 --- a/package.json +++ b/package.json @@ -13,8 +13,8 @@ "!playwright-report/" ], "scripts": { - "e2eTests": "npx playwright test", - "fossE2ETests": "npx playwright test odoo-openmrs senaite-openmrs" + "e2e-tests-pro": "npx playwright test", + "e2e-tests-foss": "npx playwright test odoo-openmrs openmrs-senaite" }, "publishConfig": { "registry": "https://nexus.mekomsolutions.net/repository/npm-public/"