From f4acf0e246a44e179870822626ac772e4b18dcb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc-Andr=C3=A9=20Bombeck?= Date: Thu, 22 Oct 2026 01:15:01 +0200 Subject: [PATCH] test(openapi): call the provenance reads and fill the list layout in the GET contract run The two provenance reads take required query parameters and had no entry, so the run could not call them. Give them a day and a range on the steps, seed a second steps source for the last week so the pick and the comparison have two sources to explain, and save a labs list order so the module list layout read answers with a row. --- tests/integration/contract-seed.ts | 29 +++++++++++++++++++ .../integration/openapi-get-contract.test.ts | 16 ++++++++++ 2 files changed, 45 insertions(+) diff --git a/tests/integration/contract-seed.ts b/tests/integration/contract-seed.ts index c297e90c2..a08484fd2 100644 --- a/tests/integration/contract-seed.ts +++ b/tests/integration/contract-seed.ts @@ -255,6 +255,19 @@ export async function seedContractAccount( : {}), })), }); + // A second source for the steps on the last week, so the provenance reads + // explain a pick between two sources and the comparison has a pair. + await prisma.measurement.createMany({ + data: [1, 2, 3, 4, 5, 6, 7].map((n) => ({ + userId: CONTRACT_USER_ID, + type: "ACTIVITY_STEPS" as const, + value: 6500 + ((n * 613) % 4000), + unit: "count", + measuredAt: daysAgo(n, 21), + source: "APPLE_HEALTH" as const, + externalId: `contract-steps-watch-${n}`, + })), + }); const firstMeasurement = await prisma.measurement.findFirst({ where: { userId: CONTRACT_USER_ID, type: "WEIGHT" }, orderBy: { measuredAt: "desc" }, @@ -790,6 +803,22 @@ export async function seedContractAccount( { id: ids.lab }, ); } + // A saved manual order for the labs list, so the layout read carries an + // order with an id in it. + if (ids.lab) { + await write( + "module-list-layout", + "PUT", + "api/settings/module-list-layout", + { + version: 1, + list: "labs", + view: "list", + order: [ids.lab], + sortDir: "manual", + }, + ); + } await write("procedure", "POST", "api/encounters", { kind: "PROCEDURE", occurredAt: daysAgo(25).toISOString(), diff --git a/tests/integration/openapi-get-contract.test.ts b/tests/integration/openapi-get-contract.test.ts index 47fffdb99..f21ed4cbc 100644 --- a/tests/integration/openapi-get-contract.test.ts +++ b/tests/integration/openapi-get-contract.test.ts @@ -210,6 +210,22 @@ function queriesFor( return [{ nutrient: "vitamin_d" }]; case "/api/day/index": return [{ from: day(14), to: day(0) }]; + case "/api/measurements/provenance": + return [ + { type: "ACTIVITY_STEPS", date: day(2) }, + { type: "WEIGHT", date: day(2) }, + ]; + case "/api/measurements/provenance/compare": + return [ + { type: "ACTIVITY_STEPS", from: day(14), to: day(0) }, + { + type: "ACTIVITY_STEPS", + from: day(14), + to: day(0), + a: "APPLE_HEALTH", + b: "MANUAL", + }, + ]; case "/api/documents/inbound/source": return [{ sourceSystem: "PAPERLESS", sourceId: "4711" }]; case "/api/documents/sources/{system}/search":