import assert from "node:assert/strict"; import { test } from "bun:test"; import { runTaskTreeCli } from "./tasktree-cli.ts"; test("--overapi preserves the command DTO and only changes transport", async () => { const originalFetch = globalThis.fetch; let received: unknown; globalThis.fetch = (async (input, init) => { assert.equal(String(input), "http://tasktree.test/v1/tasktree/commands"); received = JSON.parse(String(init?.body)); return Response.json({ ok: true, operation: "timeline.get", data: { group: { id: "tg_1" }, tasks: [], milestones: [], reports: [] } }); }) as typeof fetch; try { const result = await runTaskTreeCli(["timeline", "--group", "tg_1", "--overapi"], { HWLAB_TASKTREE_API_URL: "http://tasktree.test" }); assert.deepEqual(received, { operation: "timeline.get", groupId: "tg_1" }); assert.equal(result.transport, "api"); assert.equal(result.httpStatus, 200); assert.equal(result.operation, "timeline.get"); } finally { globalThis.fetch = originalFetch; } });