diff --git a/tests/integration/csv-import-contextless-glucose.test.ts b/tests/integration/csv-import-contextless-glucose.test.ts index dad86ab24..9918bd2e0 100644 --- a/tests/integration/csv-import-contextless-glucose.test.ts +++ b/tests/integration/csv-import-contextless-glucose.test.ts @@ -18,6 +18,8 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; import { cookieJar } from "./mock-next-headers"; import { getPrismaClient, truncateAllTables } from "./setup"; +import { MGDL_PER_MMOL } from "@/lib/glucose"; + const USER = "user-csv-glucose"; vi.mock("next/headers", async () => { @@ -111,7 +113,10 @@ describe("POST /api/import/csv — contextless glucose (real Postgres)", () => { expect(rows[0].glucoseContext).toBeNull(); expect(rows[0].source).toBe("IMPORT"); expect(rows[0].unit).toBe("mg/dL"); - expect(rows[0].value).toBeCloseTo(95.4848, 3); + // Derived from the shared factor rather than pinned, for the same reason + // as below: a literal here re-pins whichever copy of the conversion the + // import path happened to use when it was written. + expect(rows[0].value).toBeCloseTo(5.3 * MGDL_PER_MMOL, 3); expect(rows[0].externalId).toBe("sensor-1"); expect(rows[0].measuredAt.toISOString()).toBe("2024-04-03T02:15:00.000Z"); }); @@ -141,7 +146,10 @@ describe("POST /api/import/csv — contextless glucose (real Postgres)", () => { }); expect(rows).toHaveLength(1); expect(rows[0].glucoseContext).toBeNull(); - expect(rows[0].value).toBeCloseTo(106.2944, 3); + // Derived, not pinned: this carried the import path's own copy of the + // conversion factor, so unifying the two conversions left it asserting a + // number the code no longer produces. + expect(rows[0].value).toBeCloseTo(5.9 * MGDL_PER_MMOL, 3); }); it("keeps a named context, and still refuses one that is not in the enum", async () => {