feat(platform): checkpoint current implementation state
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
vi.mock("../sse/event-bus.js", () => ({
|
||||
emitAllocationCreated: vi.fn(),
|
||||
emitAllocationDeleted: vi.fn(),
|
||||
emitAllocationUpdated: vi.fn(),
|
||||
}));
|
||||
|
||||
@@ -13,11 +15,20 @@ vi.mock("../router/timeline-allocation-inline-support.js", () => ({
|
||||
applyTimelineInlineAllocationUpdate: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("../router/timeline-allocation-fragment-support.js", () => ({
|
||||
carveTimelineAllocationRange: vi.fn(),
|
||||
}));
|
||||
|
||||
vi.mock("../router/timeline-allocation-procedure-support.js", () => ({
|
||||
shiftTimelineAllocations: vi.fn(),
|
||||
}));
|
||||
|
||||
import { emitAllocationUpdated } from "../sse/event-bus.js";
|
||||
import {
|
||||
emitAllocationCreated,
|
||||
emitAllocationDeleted,
|
||||
emitAllocationUpdated,
|
||||
} from "../sse/event-bus.js";
|
||||
import { carveTimelineAllocationRange } from "../router/timeline-allocation-fragment-support.js";
|
||||
import {
|
||||
createTimelineBatchQuickAssignments,
|
||||
createTimelineQuickAssignment,
|
||||
@@ -26,12 +37,16 @@ import { applyTimelineInlineAllocationUpdate } from "../router/timeline-allocati
|
||||
import { shiftTimelineAllocations } from "../router/timeline-allocation-procedure-support.js";
|
||||
import {
|
||||
applyTimelineAllocationBatchShiftMutation,
|
||||
carveTimelineAllocationRangeMutation,
|
||||
createTimelineBatchQuickAssignMutation,
|
||||
createTimelineQuickAssignMutation,
|
||||
updateTimelineAllocationInlineMutation,
|
||||
} from "../router/timeline-allocation-router-support.js";
|
||||
|
||||
const emitAllocationCreatedMock = vi.mocked(emitAllocationCreated);
|
||||
const emitAllocationDeletedMock = vi.mocked(emitAllocationDeleted);
|
||||
const emitAllocationUpdatedMock = vi.mocked(emitAllocationUpdated);
|
||||
const carveTimelineAllocationRangeMock = vi.mocked(carveTimelineAllocationRange);
|
||||
const createTimelineBatchQuickAssignmentsMock = vi.mocked(createTimelineBatchQuickAssignments);
|
||||
const createTimelineQuickAssignmentMock = vi.mocked(createTimelineQuickAssignment);
|
||||
const applyTimelineInlineAllocationUpdateMock = vi.mocked(applyTimelineInlineAllocationUpdate);
|
||||
@@ -183,4 +198,59 @@ describe("timeline allocation router support", () => {
|
||||
mode: "preserve-duration",
|
||||
});
|
||||
});
|
||||
|
||||
it("carves an allocation range and emits update/create/delete events for every affected fragment", async () => {
|
||||
const db = {} as never;
|
||||
const startDate = new Date("2026-04-09T00:00:00.000Z");
|
||||
const endDate = new Date("2026-04-10T00:00:00.000Z");
|
||||
|
||||
carveTimelineAllocationRangeMock.mockResolvedValueOnce({
|
||||
action: "split",
|
||||
allocationGroupId: "group_1",
|
||||
updatedAllocationIds: ["allocation_left"],
|
||||
createdAllocationIds: ["allocation_right"],
|
||||
deletedAllocationIds: ["allocation_removed"],
|
||||
projectId: "project_1",
|
||||
resourceId: "resource_1",
|
||||
});
|
||||
|
||||
await expect(
|
||||
carveTimelineAllocationRangeMutation({
|
||||
db,
|
||||
allocationId: "allocation_1",
|
||||
startDate,
|
||||
endDate,
|
||||
}),
|
||||
).resolves.toEqual({
|
||||
action: "split",
|
||||
allocationGroupId: "group_1",
|
||||
updatedAllocationIds: ["allocation_left"],
|
||||
createdAllocationIds: ["allocation_right"],
|
||||
deletedAllocationIds: ["allocation_removed"],
|
||||
projectId: "project_1",
|
||||
resourceId: "resource_1",
|
||||
});
|
||||
|
||||
expect(carveTimelineAllocationRangeMock).toHaveBeenCalledWith({
|
||||
db,
|
||||
allocationId: "allocation_1",
|
||||
startDate,
|
||||
endDate,
|
||||
});
|
||||
expect(emitAllocationUpdatedMock).toHaveBeenCalledWith({
|
||||
id: "allocation_left",
|
||||
projectId: "project_1",
|
||||
resourceId: "resource_1",
|
||||
});
|
||||
expect(emitAllocationCreatedMock).toHaveBeenCalledWith({
|
||||
id: "allocation_right",
|
||||
projectId: "project_1",
|
||||
resourceId: "resource_1",
|
||||
});
|
||||
expect(emitAllocationDeletedMock).toHaveBeenCalledWith(
|
||||
"allocation_removed",
|
||||
"project_1",
|
||||
"resource_1",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user