mirror of
https://github.com/openclaw/openclaw.git
synced 2026-08-26 12:26:38 -06:00
test: dedupe sessions send a2a mock reads
This commit is contained in:
@@ -25,6 +25,17 @@ vi.mock("./agent-step.js", () => ({
|
||||
runAgentStep: vi.fn().mockResolvedValue("Test announce reply"),
|
||||
}));
|
||||
|
||||
function firstMockArg(
|
||||
mock: { mock: { calls: unknown[][] } },
|
||||
label: string,
|
||||
): Record<string, unknown> {
|
||||
const call = mock.mock.calls[0];
|
||||
if (!call) {
|
||||
throw new Error(`Expected ${label} to be called`);
|
||||
}
|
||||
return call[0] as Record<string, unknown>;
|
||||
}
|
||||
|
||||
describe("runSessionsSendA2AFlow announce delivery", () => {
|
||||
let gatewayCalls: CallGatewayOptions[];
|
||||
let sessionListRows: SessionListRow[];
|
||||
@@ -187,14 +198,11 @@ describe("runSessionsSendA2AFlow announce delivery", () => {
|
||||
waitRunId: "run-delayed",
|
||||
});
|
||||
|
||||
const waitInput = vi.mocked(waitForAgentRun).mock.calls.at(0)?.[0] as
|
||||
| { runId?: string }
|
||||
| undefined;
|
||||
expect(waitInput?.runId).toBe("run-delayed");
|
||||
const snapshotInput = vi.mocked(readLatestAssistantReplySnapshot).mock.calls.at(0)?.[0] as
|
||||
| { sessionKey?: string }
|
||||
| undefined;
|
||||
expect(snapshotInput?.sessionKey).toBe("agent:main:discord:group:dev");
|
||||
expect(firstMockArg(vi.mocked(waitForAgentRun), "agent run wait").runId).toBe("run-delayed");
|
||||
expect(
|
||||
firstMockArg(vi.mocked(readLatestAssistantReplySnapshot), "assistant reply snapshot")
|
||||
.sessionKey,
|
||||
).toBe("agent:main:discord:group:dev");
|
||||
expect(runAgentStep).not.toHaveBeenCalled();
|
||||
expect(gatewayCalls.find((call) => call.method === "send")).toBeUndefined();
|
||||
});
|
||||
@@ -213,11 +221,9 @@ describe("runSessionsSendA2AFlow announce delivery", () => {
|
||||
roundOneReply: "Worker completed successfully",
|
||||
});
|
||||
|
||||
const stepInput = vi.mocked(runAgentStep).mock.calls.at(0)?.[0] as
|
||||
| { message?: string; transcriptMessage?: string }
|
||||
| undefined;
|
||||
expect(stepInput?.message).toBe("Agent-to-agent announce step.");
|
||||
expect(stepInput?.transcriptMessage).toBe("");
|
||||
const stepInput = firstMockArg(vi.mocked(runAgentStep), "agent step");
|
||||
expect(stepInput.message).toBe("Agent-to-agent announce step.");
|
||||
expect(stepInput.transcriptMessage).toBe("");
|
||||
expect(gatewayCalls.find((call) => call.method === "send")).toBeUndefined();
|
||||
},
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user