diff options
Diffstat (limited to 'packages/cli/src/message.test.ts')
| -rw-r--r-- | packages/cli/src/message.test.ts | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/packages/cli/src/message.test.ts b/packages/cli/src/message.test.ts index a3f1e0b..440ec85 100644 --- a/packages/cli/src/message.test.ts +++ b/packages/cli/src/message.test.ts @@ -1,4 +1,5 @@ import { describe, expect, it } from "vitest"; +import { parseArgs } from "./args.js"; import { buildChatRequest, composeMessage } from "./message.js"; describe("composeMessage", () => { @@ -94,4 +95,53 @@ describe("buildChatRequest", () => { ); expect(req).not.toHaveProperty("reasoningEffort"); }); + + it("includes workspaceId when provided", () => { + const req = buildChatRequest( + { modelName: "m", text: "x", workspaceId: "my-work", showReasoning: false }, + { cwd: "/work", message: "x" }, + ); + expect(req.workspaceId).toBe("my-work"); + }); + + it("omits workspaceId when not provided", () => { + const req = buildChatRequest( + { modelName: "m", text: "x", showReasoning: false }, + { cwd: "/work", message: "x" }, + ); + expect(req).not.toHaveProperty("workspaceId"); + }); +}); + +describe("workspace flag → ChatRequest", () => { + const defaultServer = "http://localhost:24203"; + + it("--workspace flag sets workspaceId on request", () => { + const parsed = parseArgs(["my-model", "--text", "hi", "--workspace", "my-work"], { + defaultServer, + }); + expect(parsed.kind).toBe("chat"); + if (parsed.kind !== "chat") return; + const req = buildChatRequest(parsed, { cwd: "/work", message: "hi" }); + expect(req.workspaceId).toBe("my-work"); + }); + + it("--workspace flag omitted sends no workspaceId", () => { + const parsed = parseArgs(["my-model", "--text", "hi"], { defaultServer }); + expect(parsed.kind).toBe("chat"); + if (parsed.kind !== "chat") return; + const req = buildChatRequest(parsed, { cwd: "/work", message: "hi" }); + expect(req.workspaceId).toBeUndefined(); + expect(req).not.toHaveProperty("workspaceId"); + }); + + it("-w shorthand sets workspaceId on request", () => { + const parsed = parseArgs(["my-model", "--text", "hi", "-w", "shorthand"], { + defaultServer, + }); + expect(parsed.kind).toBe("chat"); + if (parsed.kind !== "chat") return; + const req = buildChatRequest(parsed, { cwd: "/work", message: "hi" }); + expect(req.workspaceId).toBe("shorthand"); + }); }); |
