






















@@ -31,6 +31,30 @@ async function withTempHome<T>(
3131}
3232}
333334+function noteArg(noteFn: ReturnType<typeof vi.fn>, argIndex: number): unknown {
35+const call = noteFn.mock.calls.at(0);
36+if (!call) {
37+throw new Error("Expected note call");
38+}
39+return call.at(argIndex);
40+}
41+42+function noteBody(noteFn: ReturnType<typeof vi.fn>): string {
43+const value = noteArg(noteFn, 0);
44+if (typeof value !== "string") {
45+throw new Error("Expected note body");
46+}
47+return value;
48+}
49+50+function noteTitle(noteFn: ReturnType<typeof vi.fn>): string {
51+const value = noteArg(noteFn, 1);
52+if (typeof value !== "string") {
53+throw new Error("Expected note title");
54+}
55+return value;
56+}
57+3458describe("resolveClaudeCliProjectDirForWorkspace", () => {
3559it("matches Claude's sanitized workspace project dir shape", () => {
3660expect(
@@ -98,8 +122,8 @@ describe("noteClaudeCliHealth", () => {
98122);
99123100124expect(noteFn).toHaveBeenCalledTimes(1);
101-expect(noteFn.mock.calls[0]?.[1]).toBe("Claude CLI");
102-const body = String(noteFn.mock.calls[0]?.[0]);
125+expect(noteTitle(noteFn)).toBe("Claude CLI");
126+const body = noteBody(noteFn);
103127expect(body).toContain("Binary: /opt/homebrew/bin/claude.");
104128expect(body).toContain("Headless Claude auth: OK (oauth).");
105129expect(body).toContain(
@@ -170,7 +194,7 @@ describe("noteClaudeCliHealth", () => {
170194);
171195172196expect(noteFn).toHaveBeenCalledTimes(1);
173-const body = String(noteFn.mock.calls[0]?.[0]);
197+const body = noteBody(noteFn);
174198expect(body).toContain(`Agent xiaoao workspace: ${claudeWorkspace} (writable).`);
175199expect(body).toContain(`Agent xiaoao Claude project dir: ${projectDir} (present).`);
176200expect(body).not.toContain(defaultWorkspace);
@@ -201,7 +225,7 @@ describe("noteClaudeCliHealth", () => {
201225},
202226);
203227204-const body = String(noteFn.mock.calls[0]?.[0]);
228+const body = noteBody(noteFn);
205229expect(body).toContain("Headless Claude auth: OK (oauth).");
206230expect(body).toContain(`OpenClaw auth profile: missing (${CLAUDE_CLI_PROFILE_ID})`);
207231expect(body).toContain(
@@ -234,7 +258,7 @@ describe("noteClaudeCliHealth", () => {
234258},
235259);
236260237-const body = String(noteFn.mock.calls[0]?.[0]);
261+const body = noteBody(noteFn);
238262expect(body).toContain('Binary: command "claude" was not found on PATH.');
239263expect(body).toContain("Headless Claude auth: unavailable without interactive prompting.");
240264expect(body).toContain("claude auth login");
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。