import { describe, expect, it } from "vitest"; import { buildTimelineEntriesDetailInput, } from "../router/timeline-read-shared.js"; import { TimelineDetailFiltersSchema, TimelineProjectContextDetailSchema, TimelineProjectIdSchema, } from "../router/timeline-read-schema-support.js"; describe("timeline read shared", () => { it("builds detail input from period and normalized filters", () => { expect( buildTimelineEntriesDetailInput({ startDate: "2026-04-01", durationDays: 3, resourceIds: [" resource_1 ", ""], projectIds: ["project_1"], chapters: [" Compositing "], }), ).toEqual({ period: { startDate: new Date("2026-04-01T00:00:00.000Z"), endDate: new Date("2026-04-03T00:00:00.000Z"), }, filters: { resourceIds: ["resource_1"], projectIds: ["project_1"], clientIds: undefined, chapters: ["Compositing"], eids: undefined, countryCodes: undefined, }, timelineInput: { startDate: new Date("2026-04-01T00:00:00.000Z"), endDate: new Date("2026-04-03T00:00:00.000Z"), resourceIds: ["resource_1"], projectIds: ["project_1"], clientIds: undefined, chapters: ["Compositing"], eids: undefined, countryCodes: undefined, }, }); }); it("shares detail filter schemas across timeline read endpoints", () => { expect(TimelineDetailFiltersSchema.parse({ startDate: "2026-04-01", durationDays: 14, resourceIds: ["resource_1"], countryCodes: ["DE"], })).toEqual({ startDate: "2026-04-01", endDate: undefined, durationDays: 14, resourceIds: ["resource_1"], projectIds: undefined, clientIds: undefined, chapters: undefined, eids: undefined, countryCodes: ["DE"], }); expect(TimelineProjectContextDetailSchema.parse({ projectId: "project_1", endDate: "2026-04-20", })).toEqual({ projectId: "project_1", startDate: undefined, endDate: "2026-04-20", durationDays: undefined, }); expect(TimelineProjectIdSchema.parse({ projectId: "project_1", })).toEqual({ projectId: "project_1", }); }); });