feat: complete TaskTree CLI parity

This commit is contained in:
root
2026-07-18 06:41:31 +02:00
parent 16fed1bdba
commit cc1a946ef2
9 changed files with 445 additions and 43 deletions
+57
View File
@@ -23,3 +23,60 @@ test("--overapi preserves the command DTO and only changes transport", async ()
globalThis.fetch = originalFetch;
}
});
test("TaskTree command surface covers hierarchy, lifecycle, batch, stats, and reports", async () => {
const originalFetch = globalThis.fetch;
const received: unknown[] = [];
globalThis.fetch = (async (_input, init) => {
const command = JSON.parse(String(init?.body));
received.push(command);
return Response.json({ ok: true, operation: command.operation, data: {} });
}) as typeof fetch;
const env = { HWLAB_TASKTREE_API_URL: "http://tasktree.test" };
try {
const cases: Array<[string[], unknown, string?]> = [
[["group", "stats", "--group", "tg_1", "--overapi"], { operation: "group.stats", groupId: "tg_1" }],
[["task", "list", "--group", "tg_1", "--overapi"], { operation: "task.list", groupId: "tg_1" }],
[["task", "get", "--task", "tt_1", "--overapi"], { operation: "task.get", taskId: "tt_1" }],
[["task", "create", "--group", "tg_1", "--parent", "tt_1", "--stdin", "--overapi"], {
operation: "task.create", groupId: "tg_1", parentId: "tt_1", title: "Child"
}, "Child\n"],
[["task", "create-batch", "--group", "tg_1", "--parent", "tt_1", "One", "Two", "--overapi"], {
operation: "task.create-batch", groupId: "tg_1", parentId: "tt_1", titles: ["One", "Two"]
}],
[["task", "update", "--task", "tt_1", "--stdin", "--overapi"], {
operation: "task.update", taskId: "tt_1", title: "Renamed"
}, "Renamed\n"],
[["task", "start", "--task", "tt_1", "--overapi"], { operation: "task.start", taskId: "tt_1" }],
[["task", "done", "--task", "tt_1", "--overapi"], { operation: "task.complete", taskId: "tt_1" }],
[["task", "remove", "--task", "tt_1", "--overapi"], { operation: "task.delete", taskId: "tt_1" }],
[["report", "list", "--task", "tt_1", "--overapi"], { operation: "report.list", taskId: "tt_1" }],
[["report", "get", "--report", "tr_1", "--overapi"], { operation: "report.get", reportId: "tr_1" }],
[["report", "write", "--task", "tt_1", "--title", "Execution", "--stdin", "--overapi"], {
operation: "report.write", taskId: "tt_1", title: "Execution", body: "# Result\n\nPassed.\n"
}, "# Result\n\nPassed.\n"]
];
for (const [argv, expected, stdin] of cases) {
await runTaskTreeCli(argv, env, stdin);
assert.deepEqual(received.at(-1), expected);
}
} finally {
globalThis.fetch = originalFetch;
}
});
test("TaskTree help and public operations do not expose the legacy domain term", async () => {
const result = await runTaskTreeCli(["--help"]);
assert.doesNotMatch(JSON.stringify(result), /mdtodo/iu);
});
test("TaskTree rejects ambiguous title input and empty update patches before transport", async () => {
await assert.rejects(
runTaskTreeCli(["task", "create", "--group", "tg_1", "--title", "One", "--stdin", "--overapi"], { HWLAB_TASKTREE_API_URL: "http://tasktree.test" }, "Two"),
(error: any) => error?.code === "title_source_conflict"
);
await assert.rejects(
runTaskTreeCli(["task", "update", "--task", "tt_1", "--overapi"], { HWLAB_TASKTREE_API_URL: "http://tasktree.test" }),
(error: any) => error?.code === "update_patch_required"
);
});