refactor(api): extract timeline quick assign support
This commit is contained in:
@@ -5,9 +5,6 @@ import {
|
||||
buildTimelineAllocationEntryUpdate,
|
||||
buildTimelineAllocationMetadata,
|
||||
buildTimelineBatchShiftAuditChanges,
|
||||
buildTimelineQuickAssignAssignmentInput,
|
||||
buildTimelineQuickAssignMetadata,
|
||||
calculateTimelineAllocationPercentage,
|
||||
shiftTimelineAllocationWindow,
|
||||
validateTimelineAllocationDateRanges,
|
||||
} from "../router/timeline-allocation-mutation-support.js";
|
||||
@@ -39,43 +36,6 @@ describe("timeline allocation mutation support", () => {
|
||||
)).toThrowError(TRPCError);
|
||||
});
|
||||
|
||||
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" },
|
||||
});
|
||||
});
|
||||
|
||||
it("shifts and clamps allocation windows for each batch-shift mode", () => {
|
||||
expect(
|
||||
shiftTimelineAllocationWindow({
|
||||
|
||||
Reference in New Issue
Block a user