mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-11 13:52:20 +00:00
Adds prev/next-day paging to the intraday pulse "shape of the day" chart
(TileHeader right slot, next disabled at today) so a user can step back
through prior days on the existing date-scoped route.
Raises DENSE_INTRADAY_RETENTION_DAYS from 14 to 90 — a self-hoster's own
storage is the trade-off for three months of full 10-minute-resolution
history instead of two weeks. Days outside the window keep folding to
hourly-mean stats: rows as before; loadIntradayPulse now falls back to
that hourly tier when a day's raw samples are gone, so the navigator
shows a coarser shape instead of an empty chart. The tension-window
read is suppressed on hourly days — it needs per-sample resolution to
stay honest. A new resolution field on the DTO ("tenMin" | "hourly")
drives a small note in the chart.
33 lines
1.2 KiB
TypeScript
33 lines
1.2 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { shiftDateKey } from "@/lib/tz/format";
|
|
|
|
describe("shiftDateKey", () => {
|
|
it("steps a day key backward and forward", () => {
|
|
expect(shiftDateKey("2026-06-15", -1)).toBe("2026-06-14");
|
|
expect(shiftDateKey("2026-06-15", 1)).toBe("2026-06-16");
|
|
});
|
|
|
|
it("rolls over a month boundary", () => {
|
|
expect(shiftDateKey("2026-06-01", -1)).toBe("2026-05-31");
|
|
expect(shiftDateKey("2026-05-31", 1)).toBe("2026-06-01");
|
|
});
|
|
|
|
it("rolls over a year boundary", () => {
|
|
expect(shiftDateKey("2026-01-01", -1)).toBe("2025-12-31");
|
|
expect(shiftDateKey("2025-12-31", 1)).toBe("2026-01-01");
|
|
});
|
|
|
|
it("is unaffected by DST transitions (pure UTC-anchored calendar math)", () => {
|
|
// Europe/Berlin spring-forward day 2026-03-29 — the day key itself is
|
|
// just a calendar date, so stepping across it is a plain +/-1 day.
|
|
expect(shiftDateKey("2026-03-29", 1)).toBe("2026-03-30");
|
|
expect(shiftDateKey("2026-03-29", -1)).toBe("2026-03-28");
|
|
});
|
|
|
|
it("supports multi-day deltas", () => {
|
|
expect(shiftDateKey("2026-06-15", 7)).toBe("2026-06-22");
|
|
expect(shiftDateKey("2026-06-15", -30)).toBe("2026-05-16");
|
|
});
|
|
});
|