23de918e94
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
26 lines
1.0 KiB
TypeScript
26 lines
1.0 KiB
TypeScript
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;
|
|
}
|
|
});
|