Skip to content

Commit

Permalink
OZ-401: Patient with free text medication dosage becomes customer in …
Browse files Browse the repository at this point in the history
…Odoo (#72)
  • Loading branch information
kdaud authored Mar 22, 2024
1 parent e90a8f6 commit 30a2b33
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 30 deletions.
65 changes: 36 additions & 29 deletions e2e/tests/testOdooIntegration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,10 @@ test('Patient with lab order becomes customer in Odoo', async ({ page }) => {
await homePage.searchCustomerInOdoo();

// verify
const customer =
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();
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 tr:nth-child(1) td.o_data_cell.o_field_cell.o_badge_cell.o_readonly_modifier span").textContent();
const quotation = await page.locator("table tbody td.o_data_cell:nth-child(8)").textContent();
await expect(quotation?.includes("Quotation")).toBeTruthy();
});

Expand All @@ -48,12 +46,10 @@ test('Editing patient details with a synced lab order edits the corresponding cu
await homePage.goToOdoo();
await expect(page).toHaveURL(/.*web/);
await homePage.searchCustomerInOdoo();
const customer =
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();
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 tr:nth-child(1) td.o_data_cell.o_field_cell.o_badge_cell.o_readonly_modifier span").textContent();
const quotation = await page.locator("table tbody td.o_data_cell:nth-child(8)").textContent();
await expect(quotation?.includes("Quotation")).toBeTruthy();

// replay
Expand All @@ -64,9 +60,7 @@ test('Editing patient details with a synced lab order edits the corresponding cu
// verify
await page.goto(`${E2E_ODOO_URL}`);
await homePage.searchCustomerInOdoo();
const updatedCustomer =
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");

const updatedCustomer = await page.locator("table tbody td.o_data_cell:nth-child(4)");
await expect(updatedCustomer).toHaveText(`${patientName.updatedFirstName}` + ' ' + `${patientName.givenName}`);
await expect(quotation?.includes("Quotation")).toBeTruthy();
});
Expand All @@ -82,12 +76,10 @@ test('Patient with drug order becomes customer in Odoo', async ({ page }) => {
await homePage.searchCustomerInOdoo();

// verify
const customer =
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();
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 tr:nth-child(1) td.o_data_cell.o_field_cell.o_badge_cell.o_readonly_modifier span").textContent();
const quotation = await page.locator("table tbody td.o_data_cell:nth-child(8)").textContent();
await expect(quotation?.includes("Quotation")).toBeTruthy();
});

Expand All @@ -99,12 +91,10 @@ test('Editing patient details with a synced drug order edits corresponding custo
await expect(page).toHaveURL(/.*web/);
await homePage.searchCustomerInOdoo();

const customer =
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();
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 tr:nth-child(1) td.o_data_cell.o_field_cell.o_badge_cell.o_readonly_modifier span").textContent();
const quotation = await page.locator("table tbody td.o_data_cell:nth-child(8)").textContent();
await expect(quotation?.includes("Quotation")).toBeTruthy();

// replay
Expand All @@ -115,8 +105,7 @@ test('Editing patient details with a synced drug order edits corresponding custo
// verify
await page.goto(`${E2E_ODOO_URL}`);
await homePage.searchCustomerInOdoo();
const updatedCustomer =
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");
const updatedCustomer = await page.locator("table tbody td.o_data_cell:nth-child(4)");

await expect(updatedCustomer).toHaveText(`${patientName.updatedFirstName}` + ' ' + `${patientName.givenName }`);
await expect(quotation?.includes("Quotation")).toBeTruthy();
Expand All @@ -130,11 +119,11 @@ test('Revising a synced drug order edits corresponding quotation line in Odoo',
await expect(page).toHaveURL(/.*web/);
await homePage.searchCustomerInOdoo();

const customer =
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();
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 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 td.o_data_cell:nth-child(3) span");

await expect(drugOrderItem).toContainText('4.0 Tablet');
await expect(drugOrderItem).toContainText('Twice daily - 5 Days');
Expand All @@ -160,14 +149,13 @@ test('Discontinuing a synced drug order cancels corresponding quotation line in
await expect(page).toHaveURL(/.*web/);
await homePage.searchCustomerInOdoo();

const customer =
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();
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 tr:nth-child(1) td.o_data_cell.o_field_cell.o_badge_cell.o_readonly_modifier span");

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 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 td.o_data_cell:nth-child(2) span:nth-child(1) span");
await expect(drugOrderItem).toHaveText('Aspirin 325mg');

// replay
Expand All @@ -182,6 +170,25 @@ test('Discontinuing a synced drug order cancels corresponding quotation line in
await expect(quotation).toHaveText('Cancelled');
});

test('Patient with free text medication dosage becomes customer in Odoo', async ({ page }) => {
// setup
const homePage = new HomePage(page);
await homePage.prescribeFreeTextMedicationDosage();

await homePage.goToOdoo();
await expect(page).toHaveURL(/.*web/);

// replay
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();

const quotation = await page.locator("table tbody td.o_data_cell:nth-child(8)").textContent();
await expect(quotation?.includes("Quotation")).toBeTruthy();
});

test.afterEach(async ({ page }) => {
const homePage = new HomePage(page);
await homePage.deletePatient();
Expand Down
24 changes: 23 additions & 1 deletion e2e/utils/functions/testBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -354,7 +354,6 @@ export class HomePage {
await this.page.getByLabel('Order basket', { exact: true }).click();
await delay(3000);
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('button', { name: 'Order form' }).click();
Expand All @@ -378,6 +377,29 @@ export class HomePage {
await delay(5000);
}

async prescribeFreeTextMedicationDosage() {
await this.page.getByLabel('Order basket', { exact: true }).click();
await delay(3000);
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('button', { name: 'Order form' }).click();
await delay(4000);
await this.page.locator('div').filter({ hasText: /^Off$/ }).locator('div').click();
await this.page.getByPlaceholder('Free text dosage').fill('Take up to three tablets per day');
await this.page.getByLabel('Duration', { exact: true }).fill('3');
await this.page.getByLabel('Quantity to dispense').fill('9');
await this.page.getByLabel('Prescription refills').fill('2');
await this.page.getByPlaceholder('e.g. "Hypertension"').type('Hypertension');
await this.page.getByRole('button', { name: 'Save order' }).focus();
await expect(this.page.getByText('Save order')).toBeVisible();
await this.page.getByRole('button', { name: 'Save order' }).click();
await this.page.getByRole('button', { name: 'Sign and close' }).focus();
await expect(this.page.getByText('Sign and close')).toBeVisible();
await this.page.getByRole('button', { name: 'Sign and close' }).click();
await delay(5000);
}

async editDrugOrder() {
await this.page.getByRole('button', { name: 'Options', exact: true }).click();
await this.page.getByRole('menuitem', { name: 'Modify', exact: true }).click();
Expand Down

0 comments on commit 30a2b33

Please sign in to comment.