Skip to content

Commit

Permalink
OZ-763: E2E test verifying that patient's date of birth is synced to …
Browse files Browse the repository at this point in the history
…Odoo (#119)
  • Loading branch information
kdaud authored Dec 19, 2024
1 parent 3fbe087 commit 1537ab8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 10 additions & 0 deletions e2e/tests/odoo-openmrs-flows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ test('Editing the details of an OpenMRS patient with a synced lab order edits th
await odoo.searchCustomer();
await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(4)')).toContainText(`${patientName.firstName + ' ' + patientName.givenName}`);
await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(8) span')).toHaveText('Quotation');
await page.getByRole('cell', { name: `${patientName.firstName + ' ' + patientName.givenName}` }).click();
await expect(page.locator('.o_group>table:nth-child(1) :nth-child(2) td:nth-child(2)>span')).toHaveText('08/16/2002');

// replay
await page.goto(`${O3_URL}`);
Expand All @@ -52,6 +54,9 @@ test('Editing the details of an OpenMRS patient with a synced lab order edits th
await odoo.searchCustomer();
await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(4)')).toHaveText(`${patientName.updatedFirstName}` + ' ' + `${patientName.givenName}`);
await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(8) span')).toHaveText('Quotation');
await page.getByRole('cell', { name: `${patientName.firstName + ' ' + patientName.givenName}` }).click();
await expect(page.locator('.o_group>table:nth-child(1) :nth-child(2) td:nth-child(2)>span')).not.toHaveText('08/16/2002');
await expect(page.locator('.o_group>table:nth-child(1) :nth-child(2) td:nth-child(2)>span')).toHaveText('08/18/2003');
});

test('Ordering a drug for an OpenMRS patient creates the corresponding Odoo customer with a filled quotation.', async ({ page }) => {
Expand Down Expand Up @@ -81,6 +86,8 @@ test('Editing the details of an OpenMRS patient with a synced drug order edits t
await odoo.searchCustomer();
await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(4)')).toContainText(`${patientName.firstName + ' ' + patientName.givenName}`);
await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(8) span')).toHaveText('Quotation');
await page.getByRole('cell', { name: `${patientName.firstName + ' ' + patientName.givenName}` }).click();
await expect(page.locator('.o_group>table:nth-child(1) :nth-child(2) td:nth-child(2)>span')).toHaveText('08/16/2002');

// replay
await page.goto(`${O3_URL}`);
Expand All @@ -93,6 +100,9 @@ test('Editing the details of an OpenMRS patient with a synced drug order edits t
await odoo.searchCustomer();
await expect(page.locator('table tbody td.o_data_cell:nth-child(4)')).toHaveText(`${patientName.updatedFirstName}` + ' ' + `${patientName.givenName }`);
await expect(page.locator('tr.o_data_row:nth-child(1) td:nth-child(8) span')).toHaveText('Quotation');
await page.getByRole('cell', { name: `${patientName.firstName + ' ' + patientName.givenName}` }).click();
await expect(page.locator('.o_group>table:nth-child(1) :nth-child(2) td:nth-child(2)>span')).not.toHaveText('08/16/2002');
await expect(page.locator('.o_group>table:nth-child(1) :nth-child(2) td:nth-child(2)>span')).toHaveText('08/18/2003');
});

test('Revising details of a synced OpenMRS drug order modifies the corresponding Odoo quotation line.', async ({ page }) => {
Expand Down
10 changes: 6 additions & 4 deletions e2e/utils/functions/openmrs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,9 @@ export class OpenMRS {
await this.page.getByLabel('Family Name').clear();
await this.page.getByLabel('Family Name').fill(`${patientName.givenName}`);
await this.page.locator('label').filter({ hasText: /^Male$/ }).locator('span').first().click();
await this.page.locator('div').filter({ hasText: /^Date of Birth Known\?YesNo$/ }).getByRole('tab', { name: 'No' }).click();
await expect(this.page.getByLabel('Estimated age in years')).toBeVisible();
await this.page.getByLabel('Estimated age in years').clear();
await this.page.getByLabel('Estimated age in years').fill(`${Math.floor(Math.random() * 99)}`);
await this.page.locator('div[aria-label="day, "]').fill('16');
await this.page.locator('div[aria-label="month, "]').fill('08');
await this.page.locator('div[aria-label="year, "]').fill('2002');
await expect(this.page.getByText('Register Patient')).toBeVisible();
await this.page.getByRole('button', { name: 'Register Patient' }).click();
await expect(this.page.getByText('New Patient Created')).toBeVisible();
Expand Down Expand Up @@ -360,6 +359,9 @@ export class OpenMRS {
await this.page.getByLabel('First Name').type(`${patientName.updatedFirstName}`);
await delay(2000);
await this.page.locator('label').filter({ hasText: 'Female' }).locator('span').first().click();
await this.page.locator('div[aria-label="day, "]').fill('18');
await this.page.locator('div[aria-label="month, "]').fill('08');
await this.page.locator('div[aria-label="year, "]').fill('2003');
await this.page.getByRole('button', { name: 'Update Patient' }).click();
await expect(this.page.getByText('Patient Details Updated')).toBeVisible();
patientName.firstName = `${patientName.updatedFirstName}`;
Expand Down

0 comments on commit 1537ab8

Please sign in to comment.