From d2caba8d7c94a29740424f62235176a6eed0af2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Hartmut=20N=C3=B6renberg?= Date: Mon, 6 Apr 2026 09:40:14 +0200 Subject: [PATCH] fix(test): use relative dates in insights summary test Hardcoded dates (2026-03-20 / 2026-04-05) were now in the past, causing the demand window filter (endDate >= now) to exclude the mock demand requirement and miss the expected staffing anomaly. Co-Authored-By: Claude Sonnet 4.6 --- .../assistant-tools-insights-summary.test.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/packages/api/src/__tests__/assistant-tools-insights-summary.test.ts b/packages/api/src/__tests__/assistant-tools-insights-summary.test.ts index db30331..3ebfda4 100644 --- a/packages/api/src/__tests__/assistant-tools-insights-summary.test.ts +++ b/packages/api/src/__tests__/assistant-tools-insights-summary.test.ts @@ -43,26 +43,30 @@ describe("assistant insights summary tools", () => { }); it("routes insights summary reads through the insights router path", async () => { + const now = new Date(); + const daysAgo = (n: number) => new Date(now.getTime() - n * 24 * 60 * 60 * 1000); + const daysFromNow = (n: number) => new Date(now.getTime() + n * 24 * 60 * 60 * 1000); + const db = { project: { findMany: vi.fn().mockResolvedValue([ { budgetCents: 100_000, - startDate: new Date("2026-03-01T00:00:00.000Z"), - endDate: new Date("2026-03-31T00:00:00.000Z"), + startDate: daysAgo(30), + endDate: daysFromNow(30), demandRequirements: [ { headcount: 3, - startDate: new Date("2026-03-20T00:00:00.000Z"), - endDate: new Date("2026-04-05T00:00:00.000Z"), + startDate: daysAgo(5), + endDate: daysFromNow(10), _count: { assignments: 1 }, }, ], assignments: [ { resourceId: "res_1", - startDate: new Date("2026-03-01T00:00:00.000Z"), - endDate: new Date("2026-03-31T00:00:00.000Z"), + startDate: daysAgo(30), + endDate: daysFromNow(30), hoursPerDay: 8, dailyCostCents: 10_000, status: "ACTIVE",