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.
This commit is contained in:
Marc-André Bombeck committed 2026-10-22 01:15:01 +02:00
1 parent 832a9da98a
commit f4acf0e246
2 files changed
+45

No files matched your search

+29
View File
@@ -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(),
@@ -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":