diff --git a/src/app/api/dashboard/summary/__tests__/route.test.ts b/src/app/api/dashboard/summary/__tests__/route.test.ts index 92e523fec..17b47abd1 100644 --- a/src/app/api/dashboard/summary/__tests__/route.test.ts +++ b/src/app/api/dashboard/summary/__tests__/route.test.ts @@ -1,4 +1,4 @@ -import { describe, it, expect, vi, beforeEach } from "vitest"; +import { describe, it, expect, vi, beforeEach, afterEach } from "vitest"; import { NextRequest } from "next/server"; vi.mock("@/lib/db", () => ({ @@ -94,6 +94,14 @@ beforeEach(() => { } as never); }); +// v1.4.48 L13 — restore real timers no matter how a test exits. A failed +// assertion inside an `it` that opted into fake timers would otherwise +// leak the fake clock into the next test in the file (or, worse, the +// next file in the same vitest worker). +afterEach(() => { + vi.useRealTimers(); +}); + describe("GET /api/dashboard/summary", () => { it("returns 401 when unauthenticated", async () => { vi.mocked(getSession).mockResolvedValue(null); @@ -653,7 +661,7 @@ describe("GET /api/dashboard/summary", () => { data: { compliance: { scheduledToday: number; takenToday: number } }; }; expect(body.data.compliance.scheduledToday).toBe(1); - vi.useRealTimers(); + // v1.4.48 L13 — suite-level `afterEach` restores real timers. }); it("computes intake compliance for today", async () => { diff --git a/src/app/api/medications/intake/__tests__/route.test.ts b/src/app/api/medications/intake/__tests__/route.test.ts index c5c4ccada..a60c60529 100644 --- a/src/app/api/medications/intake/__tests__/route.test.ts +++ b/src/app/api/medications/intake/__tests__/route.test.ts @@ -1,4 +1,4 @@ -import { describe, it, expect, vi, beforeEach } from "vitest"; +import { describe, it, expect, vi, beforeEach, afterEach } from "vitest"; import { NextRequest } from "next/server"; vi.mock("@/lib/db", () => ({ @@ -103,6 +103,14 @@ beforeEach(() => { vi.mocked(prisma.auditLog.create).mockResolvedValue({} as never); }); +// v1.4.48 L13 — restore real timers no matter how a test exits. A failed +// assertion inside an `it` that opted into fake timers would otherwise +// leak the fake clock into the next test in the file (or, worse, the +// next file in the same vitest worker). +afterEach(() => { + vi.useRealTimers(); +}); + describe("GET /api/medications/intake", () => { it("returns 401 when unauthenticated", async () => { vi.mocked(getSession).mockResolvedValue(null); @@ -262,7 +270,7 @@ describe("GET /api/medications/intake", () => { ); expect(res.status).toBe(200); expect(prisma.medicationIntakeEvent.createMany).not.toHaveBeenCalled(); - vi.useRealTimers(); + // v1.4.48 L13 — suite-level `afterEach` restores real timers. }); it("returns compliance buckets for the last N days", async () => { diff --git a/src/components/ui/__tests__/textarea.test.tsx b/src/components/ui/__tests__/textarea.test.tsx index 69b1fcd87..23fe3c323 100644 --- a/src/components/ui/__tests__/textarea.test.tsx +++ b/src/components/ui/__tests__/textarea.test.tsx @@ -63,20 +63,6 @@ describe("