refactor(api): extract timeline quick assign support
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import {
|
||||
buildTimelineQuickAssignAssignmentInput,
|
||||
buildTimelineQuickAssignMetadata,
|
||||
calculateTimelineAllocationPercentage,
|
||||
} from "../router/timeline-allocation-quick-assign-support.js";
|
||||
|
||||
describe("timeline allocation quick assign support", () => {
|
||||
it("rounds allocation percentages and clamps them to 100", () => {
|
||||
expect(calculateTimelineAllocationPercentage(3.9)).toBe(49);
|
||||
expect(calculateTimelineAllocationPercentage(9)).toBe(100);
|
||||
});
|
||||
|
||||
it("builds source metadata for quick assign operations", () => {
|
||||
expect(buildTimelineQuickAssignMetadata("quickAssign")).toEqual({ source: "quickAssign" });
|
||||
expect(buildTimelineQuickAssignMetadata("batchQuickAssign")).toEqual({ source: "batchQuickAssign" });
|
||||
});
|
||||
|
||||
it("builds assignment create payloads for quick assign flows", () => {
|
||||
expect(
|
||||
buildTimelineQuickAssignAssignmentInput({
|
||||
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: 6,
|
||||
role: "Engineer",
|
||||
roleId: "role_1",
|
||||
status: "PROPOSED",
|
||||
source: "quickAssign",
|
||||
}),
|
||||
).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: 6,
|
||||
percentage: 75,
|
||||
role: "Engineer",
|
||||
roleId: "role_1",
|
||||
status: "PROPOSED",
|
||||
metadata: { source: "quickAssign" },
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user