Files
CapaKraken/packages/api/src/__tests__/timeline-allocation-mutation-schema-support.test.ts
T

69 lines
1.9 KiB
TypeScript

import { AllocationStatus } from "@capakraken/shared";
import { describe, expect, it } from "vitest";
import {
timelineBatchQuickAssignInputSchema,
timelineBatchShiftAllocationsInputSchema,
timelineQuickAssignInputSchema,
} from "../router/timeline-allocation-mutation-schema-support.js";
describe("timeline allocation mutation schema support", () => {
it("applies defaults for quick assign input", () => {
expect(
timelineQuickAssignInputSchema.parse({
resourceId: "resource_1",
projectId: "project_1",
startDate: "2026-04-01T00:00:00.000Z",
endDate: "2026-04-05T00:00:00.000Z",
}),
).toEqual({
resourceId: "resource_1",
projectId: "project_1",
startDate: new Date("2026-04-01T00:00:00.000Z"),
endDate: new Date("2026-04-05T00:00:00.000Z"),
hoursPerDay: 8,
role: "Team Member",
status: AllocationStatus.PROPOSED,
});
});
it("applies defaults to each batch quick assign entry", () => {
expect(
timelineBatchQuickAssignInputSchema.parse({
assignments: [
{
resourceId: "resource_1",
projectId: "project_1",
startDate: "2026-04-01T00:00:00.000Z",
endDate: "2026-04-05T00:00:00.000Z",
},
],
}),
).toEqual({
assignments: [
{
resourceId: "resource_1",
projectId: "project_1",
startDate: new Date("2026-04-01T00:00:00.000Z"),
endDate: new Date("2026-04-05T00:00:00.000Z"),
hoursPerDay: 8,
role: "Team Member",
status: AllocationStatus.PROPOSED,
},
],
});
});
it("defaults batch shift mode to move", () => {
expect(
timelineBatchShiftAllocationsInputSchema.parse({
allocationIds: ["allocation_1"],
daysDelta: 3,
}),
).toEqual({
allocationIds: ["allocation_1"],
daysDelta: 3,
mode: "move",
});
});
});