refactor(test): dedupe duplicate dispatch test flow

This commit is contained in:
Peter Steinberger
2026-02-16 22:47:34 +00:00
parent af5d4ac7d3
commit 769f7631d5

View File

@@ -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<typeof dispatchReplyFromConfig>[0];
function createDispatcher(): ReplyDispatcher {
return {
@@ -81,6 +82,17 @@ function firstToolResultPayload(dispatcher: ReplyDispatcher): ReplyPayload | und
| undefined;
}
async function dispatchTwiceWithFreshDispatchers(params: Omit<DispatchReplyArgs, "dispatcher">) {
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,
});