chore: Fix types in tests 13/N.

This commit is contained in:
cpojer
2026-02-17 11:58:39 +09:00
parent 81fd771cb9
commit 50fd2a99ba
15 changed files with 43 additions and 40 deletions

View File

@@ -5,9 +5,11 @@ import type { GetReplyOptions, ReplyPayload } from "../types.js";
import type { ReplyDispatcher } from "./reply-dispatcher.js";
import { buildTestCtx } from "./test-ctx.js";
type AbortResult = { handled: boolean; aborted: boolean; stoppedSubagents?: number };
const mocks = vi.hoisted(() => ({
routeReply: vi.fn(async () => ({ ok: true, messageId: "mock" })),
tryFastAbortFromMessage: vi.fn(async () => ({
routeReply: vi.fn(async (_params: unknown) => ({ ok: true, messageId: "mock" })),
tryFastAbortFromMessage: vi.fn<() => Promise<AbortResult>>(async () => ({
handled: false,
aborted: false,
})),
@@ -117,8 +119,8 @@ describe("dispatchReplyFromConfig", () => {
const replyResolver = async (
_ctx: MsgContext,
_opts: GetReplyOptions | undefined,
_cfg: OpenClawConfig,
_opts?: GetReplyOptions,
_cfg?: OpenClawConfig,
) => ({ text: "hi" }) satisfies ReplyPayload;
await dispatchReplyFromConfig({ ctx, cfg, dispatcher, replyResolver });
@@ -141,8 +143,8 @@ describe("dispatchReplyFromConfig", () => {
const replyResolver = async (
_ctx: MsgContext,
_opts: GetReplyOptions | undefined,
_cfg: OpenClawConfig,
_opts?: GetReplyOptions,
_cfg?: OpenClawConfig,
) => ({ text: "hi" }) satisfies ReplyPayload;
await dispatchReplyFromConfig({ ctx, cfg, dispatcher, replyResolver });
@@ -172,8 +174,8 @@ describe("dispatchReplyFromConfig", () => {
const replyResolver = async (
_ctx: MsgContext,
opts: GetReplyOptions | undefined,
_cfg: OpenClawConfig,
opts?: GetReplyOptions,
_cfg?: OpenClawConfig,
) => {
expect(opts?.onToolResult).toBeDefined();
await opts?.onToolResult?.({
@@ -205,8 +207,8 @@ describe("dispatchReplyFromConfig", () => {
const replyResolver = async (
_ctx: MsgContext,
opts: GetReplyOptions | undefined,
_cfg: OpenClawConfig,
opts?: GetReplyOptions,
_cfg?: OpenClawConfig,
) => {
expect(opts?.onToolResult).toBeDefined();
expect(typeof opts?.onToolResult).toBe("function");
@@ -228,8 +230,8 @@ describe("dispatchReplyFromConfig", () => {
const replyResolver = async (
_ctx: MsgContext,
opts: GetReplyOptions | undefined,
_cfg: OpenClawConfig,
opts?: GetReplyOptions,
_cfg?: OpenClawConfig,
) => {
expect(opts?.onToolResult).toBeDefined();
await opts?.onToolResult?.({ text: "🔧 exec: ls" });
@@ -260,8 +262,8 @@ describe("dispatchReplyFromConfig", () => {
const replyResolver = async (
_ctx: MsgContext,
opts: GetReplyOptions | undefined,
_cfg: OpenClawConfig,
opts?: GetReplyOptions,
_cfg?: OpenClawConfig,
) => {
// Simulate tool result emission
await opts?.onToolResult?.({ text: "🔧 exec: ls" });
@@ -287,8 +289,8 @@ describe("dispatchReplyFromConfig", () => {
const replyResolver = async (
_ctx: MsgContext,
opts: GetReplyOptions | undefined,
_cfg: OpenClawConfig,
opts?: GetReplyOptions,
_cfg?: OpenClawConfig,
) => {
expect(opts?.onToolResult).toBeDefined();
await opts?.onToolResult?.({ text: "🔧 tools/sessions_send" });