


























@@ -51,6 +51,15 @@ vi.mock("../status.js", async () => {
5151};
5252});
535354+function firstMockArg(mock: { mock: { calls: unknown[][] } }, label: string): unknown {
55+expect(mock.mock.calls).toHaveLength(1);
56+const [arg] = mock.mock.calls[0] ?? [];
57+if (!arg) {
58+throw new Error(`expected ${label} to receive arguments`);
59+}
60+return arg;
61+}
62+5463function buildInfoParams(
5564commandBodyNormalized: string,
5665cfg: OpenClawConfig,
@@ -214,11 +223,11 @@ describe("info command handlers", () => {
214223215224expect(statusResult?.shouldContinue).toBe(false);
216225217-expect(vi.mocked(buildStatusReply)).toHaveBeenCalledWith(
218-expect.objectContaining({
219- parentSessionKey: "discord:group:parent-room",
220- }),
221-);
226+const statusReplyParams = firstMockArg(
227+vi.mocked(buildStatusReply),
228+"buildStatusReply",
229+) as Parameters<typeof buildStatusReply>[0];
230+expect(statusReplyParams.parentSessionKey).toBe("discord:group:parent-room");
222231});
223232224233it("preserves the shared session store path when routing /status", async () => {
@@ -231,11 +240,11 @@ describe("info command handlers", () => {
231240const statusResult = await handleStatusCommand(params, true);
232241233242expect(statusResult?.shouldContinue).toBe(false);
234-expect(vi.mocked(buildStatusReply)).toHaveBeenCalledWith(
235-expect.objectContaining({
236- storePath: "/tmp/target-session-store.json",
237- }),
238-);
243+const statusReplyParams = firstMockArg(
244+vi.mocked(buildStatusReply),
245+"buildStatusReply",
246+) as Parameters<typeof buildStatusReply>[0];
247+expect(statusReplyParams.storePath).toBe("/tmp/target-session-store.json");
239248});
240249241250it("prefers the target session entry when routing /status", async () => {
@@ -259,15 +268,13 @@ describe("info command handlers", () => {
259268const statusResult = await handleStatusCommand(params, true);
260269261270expect(statusResult?.shouldContinue).toBe(false);
262-expect(vi.mocked(buildStatusReply)).toHaveBeenCalledWith(
263-expect.objectContaining({
264-sessionEntry: expect.objectContaining({
265-sessionId: "target-session",
266-parentSessionKey: "target-parent",
267-}),
268-parentSessionKey: "target-parent",
269-}),
270-);
271+const statusReplyParams = firstMockArg(
272+vi.mocked(buildStatusReply),
273+"buildStatusReply",
274+) as Parameters<typeof buildStatusReply>[0];
275+expect(statusReplyParams.sessionEntry?.sessionId).toBe("target-session");
276+expect(statusReplyParams.sessionEntry?.parentSessionKey).toBe("target-parent");
277+expect(statusReplyParams.parentSessionKey).toBe("target-parent");
271278});
272279273280it("forwards resolved fast mode to /status", async () => {
@@ -280,11 +287,11 @@ describe("info command handlers", () => {
280287const statusResult = await handleStatusCommand(params, true);
281288282289expect(statusResult?.shouldContinue).toBe(false);
283-expect(vi.mocked(buildStatusReply)).toHaveBeenCalledWith(
284-expect.objectContaining({
285- resolvedFastMode: true,
286- }),
287-);
290+const statusReplyParams = firstMockArg(
291+vi.mocked(buildStatusReply),
292+"buildStatusReply",
293+) as Parameters<typeof buildStatusReply>[0];
294+expect(statusReplyParams.resolvedFastMode).toBe(true);
288295});
289296290297it("uses the canonical target session agent when listing /commands", async () => {
@@ -300,10 +307,10 @@ describe("info command handlers", () => {
300307const result = await handleCommandsListCommand(params, true);
301308302309expect(result?.shouldContinue).toBe(false);
303-expect(listSkillCommandsForAgentsMock).toHaveBeenCalledWith(
304-expect.objectContaining({
305- agentIds: ["target"],
306- }),
307-);
310+const listParams = firstMockArg(
311+listSkillCommandsForAgentsMock,
312+"listSkillCommandsForAgents",
313+) as { agentIds?: string[] };
314+expect(listParams.agentIds).toEqual(["target"]);
308315});
309316});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。