test: invoke auth and reply callbacks

This commit is contained in:
Peter Steinberger
2026-05-08 06:26:18 +01:00
parent bc735f4fde
commit 03c41eac2d
2 changed files with 5 additions and 2 deletions

View File

@@ -1358,11 +1358,13 @@ describe("dispatchReplyFromConfig", () => {
opts?: GetReplyOptions,
_cfg?: OpenClawConfig,
) => {
expect(requireToolResultHandler(opts?.onToolResult)).toEqual(expect.any(Function));
const onToolResult = requireToolResultHandler(opts?.onToolResult);
await onToolResult({ text: "tool output" });
return { text: "hi" } satisfies ReplyPayload;
};
await dispatchReplyFromConfig({ ctx, cfg, dispatcher, replyResolver });
expect(dispatcher.sendToolResult).toHaveBeenCalledWith({ text: "tool output" });
expect(dispatcher.sendFinalReply).toHaveBeenCalledTimes(1);
});

View File

@@ -547,7 +547,8 @@ describe("modelsAuthLoginCommand", () => {
expect(ctx.env).toBe(process.env);
expect(ctx.allowSecretRefPrompt).toBe(false);
expect(ctx.isRemote).toBe(false);
expect(ctx.openUrl).toEqual(expect.any(Function));
await ctx.openUrl("https://example.com/auth");
expect(mocks.openUrl).toHaveBeenCalledWith("https://example.com/auth");
expect(ctx.oauth).toMatchObject({
createVpsAwareHandlers: expect.any(Function),
});