feat(tasktree): restore derived outline numbering

This commit is contained in:
root
2026-07-21 10:14:38 +02:00
parent 70e47f0253
commit 38990c4e81
6 changed files with 63 additions and 12 deletions
+17
View File
@@ -3,6 +3,7 @@ import { test } from "bun:test";
import { createTaskTreeDispatcher } from "./dispatcher.ts";
import { createTaskTreeHttpApp } from "./http.ts";
import { numberTaskTree } from "./outline-ref.ts";
import { projectTimelineTasks, TaskTreeStore } from "./store.ts";
test("HTTP command endpoint returns the same dispatcher DTO", async () => {
@@ -29,6 +30,22 @@ test("HTTP command endpoint returns the same dispatcher DTO", async () => {
assert.deepEqual(await response.json(), expected);
});
test("outline references follow the current sibling order and tree depth", () => {
const task = (id: string, parentId: string | null, sortOrder: number): any => ({
id, groupId: "tg_1", parentId, kind: parentId ? "subtask" : "task", title: id, description: "", status: "pending",
startAt: null, dueAt: null, sortOrder, createdAt: `2026-07-21T00:00:0${sortOrder}.000Z`, updatedAt: "2026-07-21T00:00:00.000Z"
});
const numbered = numberTaskTree([
task("root-2", null, 5), task("child-2", "root-1", 4), task("grandchild", "child-1", 3),
task("root-1", null, 0), task("child-1", "root-1", 2)
]);
assert.deepEqual(Object.fromEntries(numbered.map((item) => [item.id, item.outlineRef])), {
"root-1": "R1", "child-1": "R1.1", grandchild: "R1.1.1", "child-2": "R1.2", "root-2": "R2"
});
const afterSiblingDeletion = numberTaskTree(numbered.filter((item) => item.id !== "child-2"));
assert.equal(afterSiblingDeletion.find((item) => item.id === "child-1")?.outlineRef, "R1.1");
});
test("dispatcher keeps batch validation atomic and completion gated", async () => {
let batchCalls = 0;
let createCalls = 0;