Skip to content

Commit

Permalink
OZ-767: Upgraded Playwright version to 1.49.0 (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
kdaud authored Dec 25, 2024
1 parent 1537ab8 commit 4d423e6
Show file tree
Hide file tree
Showing 11 changed files with 271 additions and 381 deletions.
6 changes: 2 additions & 4 deletions e2e/tests/keycloak-openmrs-flows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ test('Deleting a synced OpenMRS role deletes the corresponding Keycloak role.',
await expect(page.getByText('Application: Records Allergies')).toBeTruthy();

// replay
await openmrs.deleteRole();
await delay(160000);
await openmrs.deleteRole(), delay(160000);

// verify
await page.goto(`${KEYCLOAK_URL}/admin/master/console`);
Expand All @@ -142,8 +141,7 @@ test('A (non-synced) role created from within Keycloak gets deleted in the subse
await expect(page.getByPlaceholder('Search role by name')).toBeVisible();
await page.getByPlaceholder('Search role by name').fill(`${randomKeycloakRoleName.roleName}`);
await page.getByRole('button', { name: 'Search' }).press('Enter');
await expect(page.getByText(`${randomKeycloakRoleName.roleName}`)).toBeVisible();
await delay(120000);
await expect(page.getByText(`${randomKeycloakRoleName.roleName}`)).toBeVisible(), delay(120000);
await page.getByLabel('Manage').getByRole('link', { name: 'Clients' }).click();
await keycloak.selectOpenMRSId();
await expect(page.getByPlaceholder('Search role by name')).toBeVisible();
Expand Down
3 changes: 1 addition & 2 deletions e2e/tests/keycloak-superset-flows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,8 +100,7 @@ test('Deleting a synced Superset role deletes the corresponding Keycloak role.',
await expect(page.locator('tbody:nth-child(2) td:nth-child(1) a')).toHaveText(`${randomSupersetRoleName.roleName}`);

// replay
await superset.deleteRole();
await delay(60000);
await superset.deleteRole(), delay(60000);

// verify
await page.goto(`${KEYCLOAK_URL}/admin/master/console`);
Expand Down
4 changes: 2 additions & 2 deletions e2e/tests/odoo-openmrs-flows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ test('Discontinuing a synced OpenMRS lab order for an Odoo customer with a singl
await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(8) span')).toHaveText('Cancelled');
});

test('Ordering a lab test for an OpenMRS patient with weight creates the weight in the corresponding Odoo customer details.', async ({ page }) => {
test('Ordering a lab test for an OpenMRS patient with weight creates the weight on the corresponding Odoo quotation.', async ({ page }) => {
// setup
await openmrs.recordWeight();

Expand All @@ -260,7 +260,7 @@ test('Ordering a lab test for an OpenMRS patient with weight creates the weight
await expect(page.locator('.o_group :nth-child(1) tbody :nth-child(3) :nth-child(2)>span')).toContainText('75');
});

test(`Recording a patient's weight in OpenMRS on the second order creates the weight in the corresponding Odoo customer details.`, async ({ page }) => {
test(`Recording a patient's weight in OpenMRS on the second order creates the weight on the corresponding Odoo quotation.`, async ({ page }) => {
// setup
await openmrs.navigateToDrugOrderForm();
await page.getByRole('searchbox').fill('Aspirin 325mg');
Expand Down
20 changes: 7 additions & 13 deletions e2e/utils/functions/erpnext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ export class ERPNext {
await this.page.getByRole('link', { name: /selling/i }).click();
await this.page.getByRole('link', { name: 'Customer', exact: true }).click();
await expect(this.page.getByPlaceholder('Customer Name')).toBeVisible();
await this.page.getByPlaceholder('Customer Name').clear();
await this.page.getByPlaceholder('Customer Name').fill(`${patientName.givenName}`);
await delay(3500);
await this.page.getByPlaceholder('Customer Name').fill(`${patientName.givenName}`), delay(3500);
}

async searchQuotation() {
Expand All @@ -28,27 +26,24 @@ export class ERPNext {
await expect(this.page.getByPlaceholder(/title/i)).toBeVisible();
await this.page.getByPlaceholder(/title/i).clear();
await this.page.getByPlaceholder(/party/i).clear();
await this.page.getByPlaceholder(/title/i).fill(`${patientName.givenName}`);
await delay(3500);
await this.page.getByPlaceholder(/title/i).fill(`${patientName.givenName}`), delay(3500);
}

async deleteQuotation() {
await this.page.goto(`${ERPNEXT_URL}/app/quotation`);
await this.searchQuotation();
await this.page.getByRole('checkbox', { name: 'Select All' }).check();
await delay(2000);
await this.page.getByRole('checkbox', { name: 'Select All' }).check(), delay(2000);
await this.page.getByRole('button', { name: 'Actions' }).click();
await expect(this.page.getByRole('link', { name: 'Delete' })).toBeVisible();
await this.page.getByRole('link', { name: 'Delete' }).click();
await this.page.getByRole('button', { name: 'Yes' }).click();
await expect(this.page.getByText('No Quotation found')).toBeVisible();
await expect(this.page.getByText(/no quotation found/i)).toBeVisible();
}

async voidQuotation() {
await this.page.goto(`${ERPNEXT_URL}/app/quotation`);
await this.searchQuotation();
await this.page.getByRole('checkbox', { name: 'Select All' }).check();
await delay(2000);
await this.page.getByRole('checkbox', { name: 'Select All' }).check(), delay(2000);
await this.page.getByRole('button', { name: 'Actions' }).click();
await expect(this.page.getByRole('link', { name: 'Cancel' })).toBeVisible();
await this.page.getByRole('link', { name: 'Cancel' }).click();
Expand All @@ -58,12 +53,11 @@ export class ERPNext {
async deleteCustomer() {
await this.page.goto(`${ERPNEXT_URL}/app/customer`);
await this.searchCustomer();
await this.page.getByRole('checkbox', { name: 'Select All' }).check();
await delay(2000);
await this.page.getByRole('checkbox', { name: 'Select All' }).check(), delay(2000);
await this.page.getByRole('button', { name: 'Actions' }).click();
await expect(this.page.getByRole('link', { name: 'Delete' })).toBeVisible();
await this.page.getByRole('link', { name: 'Delete' }).click();
await this.page.getByRole('button', { name: 'Yes' }).click();
await expect(this.page.getByText('No Customer found')).toBeVisible();
await expect(this.page.getByText(/no customer found/i)).toBeVisible();
}
}
55 changes: 26 additions & 29 deletions e2e/utils/functions/keycloak.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ export class Keycloak {

async open() {
await this.page.goto(`${KEYCLOAK_URL}/admin/master/console`);
await this.page.getByLabel('Username or email').fill(`${process.env.KEYCLOAK_USERNAME}`);
await this.page.getByLabel('Password').fill(`${process.env.KEYCLOAK_PASSWORD}`);
await this.page.getByRole('button', { name: 'Sign In' }).click();
await this.page.getByLabel(/username or email/i).fill(`${process.env.KEYCLOAK_USERNAME}`);
await this.page.getByLabel(/password/i).fill(`${process.env.KEYCLOAK_PASSWORD}`);
await this.page.getByRole('button', { name: /sign in/i }).click();
await expect(this.page).toHaveURL(/.*console/);
await delay(6000);
}
Expand All @@ -24,68 +24,65 @@ export class Keycloak {
await this.page.getByTestId('create-role').click();
await this.page.getByLabel('Role name').fill(`${randomKeycloakRoleName.roleName}`);
await this.page.getByLabel('Description').fill('This is Keycloak test role');
await this.page.getByTestId('save').click();
await expect(this.page.getByText('Role created')).toBeVisible();
await delay(2000);
await this.page.getByTestId(/save/i).click();
await expect(this.page.getByText(/role created/i)).toBeVisible(), delay(2000);
}

async navigateToClients() {
await this.page.getByTestId('realmSelectorToggle').click();
await expect(this.page.getByRole('menuitem', { name: 'ozone' })).toBeVisible();
await this.page.getByRole('menuitem', { name: 'ozone' }).click();
await this.page.getByRole('link', { name: 'Clients' }).click();
await delay(2000);
await this.page.getByRole('link', { name: 'Clients' }).click(), delay(2000);
}

async selectOpenMRSId() {
await expect(this.page.getByPlaceholder('Search for client')).toBeVisible();
await this.page.getByPlaceholder('Search for client').fill('openmrs');
await this.page.getByRole('button', { name: 'Search' }).click();
await expect(this.page.getByPlaceholder(/search for client/i)).toBeVisible();
await this.page.getByPlaceholder(/search for client/i).fill('openmrs');
await this.page.getByRole('button', { name: /search/i }).click();
await this.page.getByRole('link', { name: 'openmrs', exact: true }).click();
}

async selectOdooId() {
await expect(this.page.getByPlaceholder('Search for client')).toBeVisible();
await this.page.getByPlaceholder('Search for client').fill('odoo');
await this.page.getByRole('button', { name: 'Search' }).click();
await expect(this.page.getByPlaceholder(/search for client/i)).toBeVisible();
await this.page.getByPlaceholder(/search for client/i).fill('odoo');
await this.page.getByRole('button', { name: /search/i }).click();
await this.page.getByRole('link', { name: 'odoo', exact: true }).click();
}

async selectSENAITEId() {
await expect(this.page.getByPlaceholder('Search for client')).toBeVisible();
await this.page.getByPlaceholder('Search for client').fill('senaite');
await this.page.getByRole('button', { name: 'Search' }).click();
await expect(this.page.getByPlaceholder(/search for client/i)).toBeVisible();
await this.page.getByPlaceholder(/search for client/i).fill('senaite');
await this.page.getByRole('button', { name: /search/i }).click();
await this.page.getByRole('link', { name: 'senaite', exact: true }).click();
}

async selectSupersetId() {
await expect(this.page.getByPlaceholder('Search for client')).toBeVisible();
await this.page.getByPlaceholder('Search for client').fill('superset');
await this.page.getByRole('button', { name: 'Search' }).click();
await expect(this.page.getByPlaceholder(/search for client/i)).toBeVisible();
await this.page.getByPlaceholder(/search for client/i).fill('superset');
await this.page.getByRole('button', { name: /search/i }).click();
await this.page.getByRole('link', { name: 'superset', exact: true }).click();
}

async selectRoles() {
await this.page.getByTestId('rolesTab').click();
await delay(4000);
await this.page.getByTestId('rolesTab').click(), delay(4000);
await this.page.reload();
}

async searchOpenMRSRole() {
await expect(this.page.getByPlaceholder('Search role by name')).toBeVisible();
await this.page.getByPlaceholder('Search role by name').fill(`${randomOpenMRSRoleName.roleName}`);
await expect(this.page.getByPlaceholder(/search role by name/i)).toBeVisible();
await this.page.getByPlaceholder(/search role by name/i).fill(`${randomOpenMRSRoleName.roleName}`);
await this.page.getByRole('button', { name: 'Search' }).press('Enter');
}

async searchSupersetRole() {
await expect(this.page.getByPlaceholder('Search role by name')).toBeVisible();
await this.page.getByPlaceholder('Search role by name').fill(`${randomSupersetRoleName.roleName}`);
await expect(this.page.getByPlaceholder(/search role by name/i)).toBeVisible();
await this.page.getByPlaceholder(/search role by name/i).fill(`${randomSupersetRoleName.roleName}`);
await this.page.getByRole('button', { name: 'Search' }).press('Enter');
}

async searchOdooRole() {
await expect(this.page.getByPlaceholder('Search role by name')).toBeVisible();
await this.page.getByPlaceholder('Search role by name').fill(`${randomOdooGroupName.groupName}`);
await expect(this.page.getByPlaceholder(/search role by name/i)).toBeVisible();
await this.page.getByPlaceholder(/search role by name/i).fill(`${randomOdooGroupName.groupName}`);
await this.page.getByRole('button', { name: 'Search' }).press('Enter');
}

Expand All @@ -99,7 +96,7 @@ export class Keycloak {
}

async deleteSyncedRole() {
await this.page.getByRole('row', { name: `${randomSupersetRoleName.roleName}` }).getByLabel('Actions').click();
await this.page.getByRole('row', { name: `${randomSupersetRoleName.roleName}` }).getByLabel(/actions/i).click();
await this.page.getByRole('menuitem', { name: 'Delete' }).click();
await this.page.getByTestId('confirm').click();
await expect(this.page.getByText(`The role has been deleted`)).toBeVisible();
Expand Down
24 changes: 7 additions & 17 deletions e2e/utils/functions/odoo.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { expect, Page } from '@playwright/test';
import { ODOO_URL } from '../configs/globalSetup';
import { Keycloak } from './keycloak';
import { delay, patientName } from './openmrs';

export var randomOdooGroupName = {
Expand All @@ -14,7 +13,7 @@ export class Odoo {
async open() {
await this.page.goto(`${ODOO_URL}`);
if (`${process.env.TEST_PRO}` == 'true') {
await this.page.getByRole('link', { name: 'Login with Single Sign-On' }).click();
await this.page.getByRole('link', { name: /login with single sign-on/i }).click();
} else {
await this.enterLoginCredentials();
}
Expand Down Expand Up @@ -49,15 +48,11 @@ export class Odoo {
await this.page.getByRole('button', { name: 'Add a product' }).click();
await this.page.locator('td.o_data_cell:nth-child(2) div:nth-child(1) input').fill('Acétaminophene Co 500mg');
await this.page.getByText('Acétaminophene Co 500mg').first().click();
await this.page.locator('input[name="product_uom_qty"]').clear();
await this.page.locator('input[name="product_uom_qty"]').fill('8');
await this.page.locator('td.o_data_cell:nth-child(7) input').clear();
await this.page.locator('td.o_data_cell:nth-child(7) input').fill('2.00');
await this.page.locator('td.o_data_cell:nth-child(9)').click();
await delay(2000);
await this.page.locator('td.o_data_cell:nth-child(9)').click(), delay(2000);
await expect(this.page.locator('td.o_data_cell:nth-child(9)')).toHaveText('$ 16.00');
await this.page.getByRole('button', { name: 'Confirm' }).click();
await delay(3000);
await this.page.getByRole('button', { name: 'Confirm' }).click(), delay(3000);
await expect(this.page.locator('td.o_data_cell:nth-child(2) span:nth-child(1) span')).toHaveText('Acétaminophene Co 500mg');
await expect(this.page.locator('td.o_data_cell:nth-child(4)')).toHaveText('8');
await expect(this.page.locator('td.o_data_cell:nth-child(9)')).toHaveText('2.00');
Expand Down Expand Up @@ -90,8 +85,7 @@ export class Odoo {
await expect(this.page.getByText(/accounting/i)).toBeVisible();
await this.page.getByText(/accounting/i).click();
await this.page.getByLabel(/name/i).fill(`${randomOdooGroupName.groupName}`);
await this.page.getByRole('button', { name: /save/i }).click();
await delay(250000);
await this.page.getByRole('button', { name: /save/i }).click(), delay(250000);
}

async searchGroup() {
Expand All @@ -105,11 +99,9 @@ export class Odoo {
async updateGroup() {
await expect(this.page.getByRole('button', { name: /edit/i })).toBeVisible();
await this.page.getByRole('button', { name: /edit/i }).click();
await this.page.getByLabel(/name/i).clear();
await this.page.getByLabel(/name/i).fill(`${randomOdooGroupName.updatedGroupName}`);
await this.page.getByRole('button', { name: /save/i }).click();
randomOdooGroupName.groupName = `${randomOdooGroupName.updatedGroupName}`;
await delay(250000);
randomOdooGroupName.groupName = `${randomOdooGroupName.updatedGroupName}`, delay(250000);
}

async deleteGroup() {
Expand All @@ -118,10 +110,8 @@ export class Odoo {
await expect(this.page.getByRole('menuitemcheckbox', { name: /delete/i })).toBeVisible();
await this.page.getByRole('menuitemcheckbox', { name: /delete/i }).click();
await expect(this.page.getByRole('button', { name: /ok/i })).toBeVisible();
await this.page.getByRole('button', { name: /ok/i }).click();
await delay(2000);
await expect(this.page.getByText(`${randomOdooGroupName.groupName}` )).not.toBeVisible();
await delay(240000);
await this.page.getByRole('button', { name: /ok/i }).click(), delay(2000);
await expect(this.page.getByText(`${randomOdooGroupName.groupName}` )).not.toBeVisible(), delay(240000);
}

async logout() {
Expand Down
Loading

0 comments on commit 4d423e6

Please sign in to comment.