mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-30 23:31:45 +00:00
chore: Fix types in tests 13/N.
This commit is contained in:
@@ -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" });
|
||||
|
||||
Reference in New Issue
Block a user