The open-source app everyone uses to manage agents at work
TypeScript acpxagent-orchestrationagent-skillsagentic-aiai-agentsai-engineeringai-governanceai-toolsautonomous-agentsclaudeclaude-codeclaude-skillscodexhermesllmmcpmulti-agentopenclawproject-managementworkflow-automation
test(cli): cover API path construction (#9254)
馨冉876ac7596c42
diff --git a/cli/src/__tests__/common.test.ts b/cli/src/__tests__/common.test.tsindex f436bee0b4..1c6abbf23b 100644--- a/cli/src/__tests__/common.test.ts+++ b/cli/src/__tests__/common.test.ts@@ -4,7 +4,7 @@ import path from "node:path";import { afterEach, beforeEach, describe, expect, it } from "vitest";import { writeContext } from "../client/context.js";import { setStoredBoardCredential } from "../client/board-auth.js";-import { inferContentTypeFromPath, resolveApiBase, resolveCommandContext } from "../commands/client/common.js";+import { apiPath, inferContentTypeFromPath, resolveApiBase, resolveCommandContext } from "../commands/client/common.js";const ORIGINAL_ENV = { ...process.env };@@ -185,3 +185,17 @@ describe("inferContentTypeFromPath", () => {expect(inferContentTypeFromPath("noextension")).toBeUndefined();});});++describe("apiPath", () => {+ it("encodes dynamic path segments", () => {+ expect(apiPath`/api/issues/${"PAP-1/child"}/comments/${"needs review?"}`)+ .toBe("/api/issues/PAP-1%2Fchild/comments/needs%20review%3F");+ });++ it("rejects empty dynamic path segments", () => {+ expect(() => apiPath`/api/issues/${""}`).toThrow("Cannot build API path with an empty path segment.");+ expect(() => apiPath`/api/issues/${undefined}`).toThrow("Cannot build API path with an empty path segment.");+ expect(() => apiPath`/api/issues/${null}`).toThrow("Cannot build API path with an empty path segment.");+ expect(() => apiPath`/api/issues/${" "}`).toThrow("Cannot build API path with an empty path segment.");+ });+});