Skip to content

Commit

Permalink
(fix) Attempt to fix e2e test errors (#2149)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibacher authored Dec 11, 2024
1 parent c66783a commit 3186a62
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 15 deletions.
12 changes: 6 additions & 6 deletions e2e/commands/visit-operations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,16 @@ export const startVisit = async (api: APIRequestContext, patientId: string): Pro
},
});

await expect(visitRes.ok()).toBeTruthy();
expect(visitRes.ok()).toBeTruthy();
return await visitRes.json();
};

export const endVisit = async (api: APIRequestContext, uuid: string) => {
const visitRes = await api.post(`visit/${uuid}`, {
export const endVisit = async (api: APIRequestContext, visit: Visit) => {
const visitRes = await api.post(`visit/${visit.uuid}`, {
data: {
location: process.env.E2E_LOGIN_DEFAULT_LOCATION_UUID,
startDatetime: dayjs().subtract(1, 'D').format('YYYY-MM-DDTHH:mm:ss.SSSZZ'),
visitType: '7b0f5697-27e3-40c4-8bae-f4049abfb4ed',
location: visit.location.uuid,
startDatetime: visit.startDatetime,
visitType: visit.visitType.uuid,
stopDatetime: dayjs().format('YYYY-MM-DDTHH:mm:ss.SSSZZ'),
},
});
Expand Down
2 changes: 1 addition & 1 deletion e2e/specs/biometrics.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,6 @@ test('Record biometrics', async ({ page }) => {
});

test.afterEach(async ({ api }) => {
await endVisit(api, visit.uuid);
await endVisit(api, visit);
await deletePatient(api, patient.uuid);
});
2 changes: 1 addition & 1 deletion e2e/specs/clinical-forms.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,6 @@ test('Form state is retained when minimizing a form in the workspace', async ({
});

test.afterEach(async ({ api }) => {
await endVisit(api, visit.uuid);
await endVisit(api, visit);
await deletePatient(api, patient.uuid);
});
2 changes: 1 addition & 1 deletion e2e/specs/drug-orders.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,6 @@ test('Record, edit and discontinue a drug order', async ({ page }) => {
});

test.afterEach(async ({ api }) => {
await endVisit(api, visit.uuid);
await endVisit(api, visit);
await deletePatient(api, patient.uuid);
});
2 changes: 1 addition & 1 deletion e2e/specs/lab-orders.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,6 @@ test.describe.serial('Running laboratory order tests sequentially', () => {
});

test.afterAll(async ({ api }) => {
await endVisit(api, visit.uuid);
await endVisit(api, visit);
await deletePatient(api, patient.uuid);
});
2 changes: 1 addition & 1 deletion e2e/specs/results-viewer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,6 @@ test('Record and edit test results', async ({ page }) => {
});

test.afterEach(async ({ api }) => {
await endVisit(api, visit.uuid);
await endVisit(api, visit);
await deletePatient(api, patient.uuid);
});
2 changes: 1 addition & 1 deletion e2e/specs/visit-note.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,6 @@ test('Add and delete a visit note', async ({ page }) => {
});

test.afterEach(async ({ api }) => {
await endVisit(api, visit.uuid);
await endVisit(api, visit);
await deletePatient(api, patient.uuid);
});
2 changes: 1 addition & 1 deletion e2e/specs/vitals.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,6 @@ test('Record vital signs', async ({ page }) => {
});

test.afterEach(async ({ api }) => {
await endVisit(api, visit.uuid);
await endVisit(api, visit);
await deletePatient(api, patient.uuid);
});
10 changes: 8 additions & 2 deletions packages/esm-patient-common-lib/src/orders/postOrders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,14 @@ export async function postOrders(encounterUuid: string, abortController: AbortCo
const orders = patientItems[grouping];
for (let i = 0; i < orders.length; i++) {
const order = orders[i];
const dto = postDataPrepFunctions[grouping](order, patientUuid, encounterUuid);
await postOrder(dto, abortController).catch((error) => {
const dataPrepFn = postDataPrepFunctions[grouping];

if (typeof dataPrepFn !== 'function') {
console.warn(`The postDataPrep function registered for ${grouping} orders is not a function`);
continue;
}

await postOrder(dataPrepFn(order, patientUuid, encounterUuid), abortController).catch((error) => {
erroredItems.push({
...order,
orderError: error,
Expand Down

0 comments on commit 3186a62

Please sign in to comment.