Harden the guards that could go green for the wrong reason

The bearer MINT matcher demanded a literal apiToken.create( in the very
file that documents how a whitespace-wrapped call walked past its T1
sibling; it is whitespace-tolerant now, asserts a non-zero match count,
and the always-true filter beside it is gone. The T1 resolver matcher no
longer demands tokenHash first in the where object. The English-leak
guard pins a non-zero key floor per bundle so a broken walker cannot
pass as no-leaks-found. The two audit-row integration suites poll for
the fire-and-forget rows instead of sleeping a fixed span, with one
deliberately widened grace kept for the absence assertion. And the
fixture fuses with 2027 horizons (suggested-actions next-due, the
printed-expiry trio) are now-anchored so they can never age into
inverted assertions.
This commit is contained in:
Marc-André Bombeck committed 2026-08-14 02:33:07 +02:00
1 parent b49013e6c6
commit 95baf58be7
8 files changed
+95 -30

No files matched your search

@@ -37,7 +37,12 @@ vi.mock("@/lib/ai/coach/bytes-codec", () => ({
encryptToBytes: (s: string) => new Uint8Array(Buffer.from(`enc:${s}`)),
}));
vi.mock("@/lib/measurement-reminders/scheduling", () => ({
computeReminderNextDueAt: vi.fn(() => new Date("2027-06-27T09:00:00Z")),
// Now-anchored: the fixed 2027 date was a fuse — on that day the mocked
// next-due flipped from future to past and every due/overdue assertion
// downstream inverted.
computeReminderNextDueAt: vi.fn(
() => new Date(Date.now() + 30 * 24 * 60 * 60 * 1000),
),
}));
vi.mock("@/lib/measurement-reminders/dto", () => ({
toMeasurementReminderDto: vi.fn((r: { id: string }) => ({ id: r.id })),
@@ -214,7 +214,10 @@ describe("POST /api/medications/[id]/inventory", () => {
state: "ACTIVE",
} as never);
const printed = "2027-06-01T00:00:00Z";
// Now-anchored so the fixture can never age into a past expiry.
const printed = new Date(
Date.now() + 300 * 24 * 60 * 60 * 1000,
).toISOString();
const res = await POST(
jsonReq("http://localhost/api/medications/med-1/inventory", {
unitsTotal: 4,