mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
test(medications): make compliance and analytics tests timezone-stable
These tests passed in Europe/Berlin but failed under UTC (or against the shipped engine) because they leant on the host clock: - intake route test: the mocked user had no timezone, so slot resolution fell back to the host TZ and the 07:00 schedule slot only matched in Berlin. Pin the user to Europe/Berlin. - health-score: 30 daily takes seeded at an unaligned now-i*DAY shifted their Berlin hour with the runner TZ, dropping them out of the 08:00-10:00 on-time band. Anchor each take to a fixed 07:30 UTC. - sleep-stages: the night sat on the trailing-30-day window edge for a fixed calendar instant. Anchor it to now-5d. - weekly-compliance: not a timezone issue. The dose-window engine treats a weekly dose inside the 4-day overdue tail as still-takeable, not missed, so skipping the most-recent Monday no longer lowers the rate. Skip an older, settled-miss Monday instead; the gap assertion stands.
This commit is contained in:
1 parent
dfb6a7f298
commit
050ddbecb2
4 files changed
+32
-6
No files matched your search
@@ -96,7 +96,14 @@ import { getSession } from "@/lib/auth/session";
|
||||
|
||||
const SESSION_OK = {
|
||||
session: { id: "sess-1", expiresAt: new Date(Date.now() + 3_600_000) },
|
||||
user: { id: "user-1", username: "marc", role: "USER" as const },
|
||||
user: {
|
||||
id: "user-1",
|
||||
username: "marc",
|
||||
role: "USER" as const,
|
||||
// Pin the user timezone so slot-instant resolution is deterministic
|
||||
// regardless of the host TZ (CI runs in UTC, local in Europe/Berlin).
|
||||
timezone: "Europe/Berlin",
|
||||
},
|
||||
};
|
||||
|
||||
const MED_OK = { id: "med-1", userId: "user-1" };
|
||||
|
||||
Reference in new issue
Block a user