mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 21:54:32 +00:00
chore: Fix types in tests 3/N.
This commit is contained in:
@@ -73,7 +73,8 @@ function expectChannels(call: Record<string, unknown>, channel: string) {
|
||||
}
|
||||
|
||||
function readAgentCommandCall(fromEnd = 1) {
|
||||
return vi.mocked(agentCommand).mock.calls.at(-fromEnd)?.[0] as Record<string, unknown>;
|
||||
const calls = vi.mocked(agentCommand).mock.calls as unknown[][];
|
||||
return (calls.at(-fromEnd)?.[0] ?? {}) as Record<string, unknown>;
|
||||
}
|
||||
|
||||
function expectAgentRoutingCall(params: {
|
||||
@@ -272,7 +273,8 @@ describe("gateway server agent", () => {
|
||||
test("agent routes bare /new through session reset before running greeting prompt", async () => {
|
||||
await writeMainSessionEntry({ sessionId: "sess-main-before-reset" });
|
||||
const spy = vi.mocked(agentCommand);
|
||||
const callsBefore = spy.mock.calls.length;
|
||||
const calls = spy.mock.calls as unknown[][];
|
||||
const callsBefore = calls.length;
|
||||
const res = await rpcReq(ws, "agent", {
|
||||
message: "/new",
|
||||
sessionKey: "main",
|
||||
@@ -280,8 +282,8 @@ describe("gateway server agent", () => {
|
||||
});
|
||||
expect(res.ok).toBe(true);
|
||||
|
||||
await vi.waitFor(() => expect(spy.mock.calls.length).toBeGreaterThan(callsBefore));
|
||||
const call = spy.mock.calls.at(-1)?.[0] as Record<string, unknown>;
|
||||
await vi.waitFor(() => expect(calls.length).toBeGreaterThan(callsBefore));
|
||||
const call = (calls.at(-1)?.[0] ?? {}) as Record<string, unknown>;
|
||||
expect(call.message).toBe(BARE_SESSION_RESET_PROMPT);
|
||||
expect(typeof call.sessionId).toBe("string");
|
||||
expect(call.sessionId).not.toBe("sess-main-before-reset");
|
||||
@@ -399,10 +401,7 @@ describe("gateway server agent", () => {
|
||||
});
|
||||
|
||||
const evt = await finalChatP;
|
||||
const payload =
|
||||
evt.payload && typeof evt.payload === "object"
|
||||
? (evt.payload as Record<string, unknown>)
|
||||
: {};
|
||||
const payload = evt.payload && typeof evt.payload === "object" ? evt.payload : {};
|
||||
expect(payload.sessionKey).toBe("main");
|
||||
expect(payload.runId).toBe("run-auto-1");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user