From 769f7631d57cccbd6310cd405f442dff3c5e51e5 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Mon, 16 Feb 2026 22:47:34 +0000 Subject: [PATCH] refactor(test): dedupe duplicate dispatch test flow --- .../reply/dispatch-from-config.test.ts | 30 +++++++++---------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/auto-reply/reply/dispatch-from-config.test.ts b/src/auto-reply/reply/dispatch-from-config.test.ts index 4173669ce3..3e5d49f233 100644 --- a/src/auto-reply/reply/dispatch-from-config.test.ts +++ b/src/auto-reply/reply/dispatch-from-config.test.ts @@ -59,6 +59,7 @@ const { resetInboundDedupe } = await import("./inbound-dedupe.js"); const noAbortResult = { handled: false, aborted: false } as const; const emptyConfig = {} as OpenClawConfig; +type DispatchReplyArgs = Parameters[0]; function createDispatcher(): ReplyDispatcher { return { @@ -81,6 +82,17 @@ function firstToolResultPayload(dispatcher: ReplyDispatcher): ReplyPayload | und | undefined; } +async function dispatchTwiceWithFreshDispatchers(params: Omit) { + await dispatchReplyFromConfig({ + ...params, + dispatcher: createDispatcher(), + }); + await dispatchReplyFromConfig({ + ...params, + dispatcher: createDispatcher(), + }); +} + describe("dispatchReplyFromConfig", () => { beforeEach(() => { resetInboundDedupe(); @@ -352,16 +364,9 @@ describe("dispatchReplyFromConfig", () => { }); const replyResolver = vi.fn(async () => ({ text: "hi" }) as ReplyPayload); - await dispatchReplyFromConfig({ + await dispatchTwiceWithFreshDispatchers({ ctx, cfg, - dispatcher: createDispatcher(), - replyResolver, - }); - await dispatchReplyFromConfig({ - ctx, - cfg, - dispatcher: createDispatcher(), replyResolver, }); @@ -457,16 +462,9 @@ describe("dispatchReplyFromConfig", () => { }); const replyResolver = vi.fn(async () => ({ text: "hi" }) as ReplyPayload); - await dispatchReplyFromConfig({ + await dispatchTwiceWithFreshDispatchers({ ctx, cfg, - dispatcher: createDispatcher(), - replyResolver, - }); - await dispatchReplyFromConfig({ - ctx, - cfg, - dispatcher: createDispatcher(), replyResolver, });