mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-09 21:10:59 +00:00
test(analytics): seed rollup-count probe in slim-slice route test
v1.4.36's perf wave added a `SELECT COUNT(*) FROM measurement_rollups` probe at the head of `computeSummariesSlice`. The slim-slice route test mocks `$queryRaw` with two `mockResolvedValueOnce` calls (aggregate + latest); the new probe consumed the first slot, leaving the aggregate read pointing at undefined and the route returning 500. Seed `n: BigInt(0)` as the first mock value so the route deterministically takes the legacy heavy-aggregate fallback path the rest of the test expects.
This commit is contained in:
1 parent
fa0f544e3f
commit
384179228a
1 file changed
+5
-1
@@ -266,8 +266,12 @@ describe("GET /api/analytics", () => {
|
||||
// contract the dashboard tile strip reads.
|
||||
it("returns the slim summaries slice when ?slice=summaries is set", async () => {
|
||||
const fiveDaysAgo = new Date(Date.now() - 5 * 24 * 60 * 60 * 1000);
|
||||
// Aggregate pass + latest pass. The mock returns one row per pass.
|
||||
// v1.4.36 — slim slice now opens with a cheap `SELECT COUNT(*) FROM
|
||||
// measurement_rollups` probe. Force `n: 0` so the route takes the
|
||||
// legacy heavy-aggregate fallback path that this test's fixtures
|
||||
// expect (aggregate + latest, two `$queryRaw` passes).
|
||||
vi.mocked(prisma.$queryRaw)
|
||||
.mockResolvedValueOnce([{ n: BigInt(0) }] as never)
|
||||
.mockResolvedValueOnce([
|
||||
{
|
||||
type: "WEIGHT",
|
||||
|
||||
Reference in new issue
Block a user