test(import): cover the HealthKit glucose shape against the relaxed constraint

A HealthKit blood-glucose sample carries no context either — the mapping has
no field for one — so the batch ingest was building the same row the old
CHECK refused. Fold that source into the case that pins the contextless
shape.

Refs #640
This commit is contained in:
Marc-André Bombeck committed 2026-07-25 21:57:06 +02:00
1 parent e43e758c8d
commit 208a2248cd
1 file changed
+6 -5
@@ -189,10 +189,11 @@ describe("measurements.glucose_context — surviving CHECK half", () => {
it("accepts the contextless shape the device writers build", async () => {
await signIn();
// The Nightscout SGV upsert and the MCP / Telegram single-value capture
// both build a BLOOD_GLUCOSE row with no context. Under the old
// constraint every one of those inserts was refused by the database.
const sources = ["NIGHTSCOUT", "MCP", "TELEGRAM"] as const;
// The Nightscout SGV upsert, the HealthKit batch mapping, and the MCP /
// Telegram single-value captures all build a BLOOD_GLUCOSE row with no
// context. Under the old constraint every one of those inserts was
// refused by the database.
const sources = ["NIGHTSCOUT", "APPLE_HEALTH", "MCP", "TELEGRAM"] as const;
for (const [index, source] of sources.entries()) {
await getPrismaClient().measurement.create({
data: {
@@ -209,7 +210,7 @@ describe("measurements.glucose_context — surviving CHECK half", () => {
const rows = await getPrismaClient().measurement.findMany({
where: { userId: USER, type: "BLOOD_GLUCOSE" },
});
expect(rows).toHaveLength(3);
expect(rows).toHaveLength(sources.length);
expect(rows.every((row) => row.glucoseContext === null)).toBe(true);
});
});