Skip to content

Commit

Permalink
OZ-635: E2E tests should use the order basket when ordering lab tests (
Browse files Browse the repository at this point in the history
  • Loading branch information
kdaud authored Jul 8, 2024
1 parent 6ac4603 commit db3b8fd
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 45 deletions.
9 changes: 3 additions & 6 deletions e2e/tests/odoo-openmrs-flows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ test.beforeEach(async ({ page }) => {
test('Ordering a lab test for an OpenMRS patient creates the corresponding Odoo customer with a filled quotation.', async ({ page }) => {
// replay
await openmrs.goToLabOrderForm();
await page.getByRole('button', { name: 'Add', exact: true }).click();
await page.locator('#tab select').selectOption('857AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
await page.getByPlaceholder('Search for a test type').fill('Blood urea nitrogen');
await openmrs.saveLabOrder();

// verify
Expand All @@ -37,8 +36,7 @@ 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 }) => {
// replay
await openmrs.goToLabOrderForm();
await page.getByRole('button', { name: 'Add', exact: true }).click();
await page.locator('#tab select').selectOption('857AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
await page.getByPlaceholder('Search for a test type').fill('Blood urea nitrogen');
await openmrs.saveLabOrder();
await odoo.open();
await expect(page).toHaveURL(/.*web/);
Expand Down Expand Up @@ -151,8 +149,7 @@ test('Discontinuing a synced OpenMRS drug order for an Odoo customer with a sing
test('Discontinuing a synced OpenMRS drug order for an Odoo customer with multiple quotation lines removes the corresponding quoatation.', async ({ page }) => {
// setup
await openmrs.goToLabOrderForm();
await page.getByRole('button', { name: 'Add', exact: true }).click();
await page.locator('#tab select').selectOption('857AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
await page.getByPlaceholder('Search for a test type').fill('Blood urea nitrogen');
await openmrs.saveLabOrder();
await openmrs.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`);
await openmrs.createDrugOrder();
Expand Down
24 changes: 9 additions & 15 deletions e2e/tests/openmrs-senaite-flows.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ test.beforeEach(async ({ page }) => {
test('Ordering a lab test for an OpenMRS patient creates the corresponding SENAITE client with an analysis request.', async ({ page }) => {
// replay
await openmrs.goToLabOrderForm();
await page.getByRole('button', { name: 'Add', exact: true }).click();
await page.locator('#tab select').selectOption('857AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
await page.getByPlaceholder('Search for a test type').fill('Blood urea nitrogen');
await openmrs.saveLabOrder();

// verify
Expand All @@ -34,8 +33,7 @@ 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 }) => {
// replay
await openmrs.goToLabOrderForm();
await page.getByRole('button', { name: 'Add', exact: true }).click();
await page.locator('#tab select').selectOption('857AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
await page.getByPlaceholder('Search for a test type').fill('Blood urea nitrogen');
await openmrs.saveLabOrder();
await senaite.open();
await expect(page).toHaveURL(/.*senaite/);
Expand All @@ -56,9 +54,9 @@ 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 }) => {
// replay
await openmrs.goToLabOrderForm();
await page.getByRole('button', { name: 'Add', exact: true }).click();
await page.locator('#tab select').selectOption('857AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
await page.getByPlaceholder('Search for a test type').fill('Blood urea nitrogen');
await openmrs.saveLabOrder();

await senaite.open();
await expect(page).toHaveURL(/.*senaite/);
await senaite.searchClient();
Expand All @@ -85,8 +83,7 @@ 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 }) => {
// replay
await openmrs.goToLabOrderForm();
await page.getByRole('button', { name: 'Add', exact: true }).click();
await page.locator('#tab select').selectOption('857AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
await page.getByPlaceholder('Search for a test type').fill('Blood urea nitrogen');
await openmrs.saveLabOrder();
await senaite.open();
await expect(page).toHaveURL(/.*senaite/);
Expand All @@ -99,7 +96,7 @@ test('Voiding a synced OpenMRS lab order cancels the corresponding SENAITE analy
await expect(analysisRequest).toHaveText('Blood urea nitrogen Template');
await page.goto(`${O3_URL}`);
await openmrs.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`);
await openmrs.voidEncounter();
await openmrs.cancelLabOrder();

// verify
await page.goto(`${SENAITE_URL}`);
Expand All @@ -110,8 +107,7 @@ 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 }) => {
// replay
await openmrs.goToLabOrderForm();
await page.getByRole('button', { name: 'Add', exact: true }).click();
await page.locator('#tab select').selectOption('1325AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
await page.getByPlaceholder('Search for a test type').fill('Hepatitis C test - qualitative');
await openmrs.saveLabOrder();
await senaite.open();
await expect(page).toHaveURL(/.*senaite/);
Expand All @@ -135,8 +131,7 @@ 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 }) => {
// replay
await openmrs.goToLabOrderForm();
await page.getByRole('button', { name: 'Add', exact: true }).click();
await page.locator('#tab select').selectOption('655AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
await page.getByPlaceholder('Search for a test type').fill('Total bilirubin');
await openmrs.saveLabOrder();
await senaite.open();
await expect(page).toHaveURL(/.*senaite/);
Expand All @@ -160,8 +155,7 @@ 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 }) => {
// replay
await openmrs.goToLabOrderForm();
await page.getByRole('button', { name: 'Add', exact: true }).click();
await page.locator('#tab select').selectOption('161447AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
await page.getByPlaceholder('Search for a test type').fill('Stool microscopy with concentration');
await openmrs.saveLabOrder();
await senaite.open();
await expect(page).toHaveURL(/.*senaite/);
Expand Down
45 changes: 21 additions & 24 deletions e2e/utils/functions/openmrs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,10 +217,12 @@ export class OpenMRS {
await expect(this.page.getByText('Appointment cancelled successfully')).toBeVisible();
}

async createLabOrder() {
async goToLabOrderForm() {
await this.page.getByLabel('Order basket', { exact: true }).click();
await this.page.getByRole('button', { name: 'Add', exact: true }).nth(1).click();
await this.page.getByPlaceholder('Search for a test type').fill('Urobilinogen');
}

async saveLabOrder() {
await delay(3000);
await this.page.getByRole('button', { name: 'Order form' }).click();
await this.page.getByRole('button', { name: 'Save order' }).click();
Expand All @@ -229,29 +231,16 @@ export class OpenMRS {
await delay(3000);
}

async goToLabOrderForm() {
await this.page.getByLabel('Clinical forms').click();
await delay(3000);
await expect(this.page.getByText('Laboratory Test Orders')).toBeVisible();
await this.page.getByText('Laboratory Test Orders').click();
}

async saveLabOrder() {
await this.page.getByRole('button', { name: 'Save and close' }).click();
await expect(this.page.getByText('Lab order(s) generated')).toBeVisible();
await this.page.getByRole('button', { name: 'Close', exact: true }).click();
await delay(5000);
}

async updateLabOrder() {
await this.page.getByRole('link', { name: 'Visits' }).click();
await this.page.getByRole('tab', { name: 'All encounters' }).click();
await this.page.getByRole('button', { name: 'Options', exact: true }).click();
await this.page.getByRole('menuitem', { name: 'Edit this encounter' }).click();
await this.page.locator('#tab select').selectOption('160225AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA');
await this.page.getByRole('button', { name: 'Save and close' }).click();
await expect(this.page.getByText('Lab order(s) generated')).toBeVisible();
await delay(5000);
await this.page.getByRole('link', { name: 'Orders' }).click();
await this.page.getByRole('button', { name: 'Options' }).nth(0).click();
await this.page.getByRole('menuitem', { name: 'Modify order' }).click();
await this.page.getByPlaceholder('Search for a test type').fill('Sickle cell screening test');
await delay(3000);
await this.page.getByRole('button', { name: 'Order form' }).click();
await this.page.getByRole('button', { name: 'Save order' }).click();
await this.page.getByRole('button', { name: 'Sign and close' }).click();
await delay(3000);
}

async voidEncounter() {
Expand All @@ -265,6 +254,14 @@ export class OpenMRS {
await delay(5000);
}

async cancelLabOrder() {
await this.page.getByRole('link', { name: 'Orders' }).click();
await this.page.getByRole('button', { name: 'Options' }).nth(0).click();
await this.page.getByRole('menuitem', { name: 'Cancel Order' }).click();
await this.page.getByRole('button', { name: 'Sign and close' }).click();
await delay(3000);
}

async viewTestResults() {
await this.searchPatient(`${patientName.firstName + ' ' + patientName.givenName}`);
await this.page.getByRole('link', { name: 'Results Viewer' }).click();
Expand Down

0 comments on commit db3b8fd

Please sign in to comment.