mirror of
https://github.com/openclaw/openclaw.git
synced 2026-02-19 18:39:20 -05:00
refactor(test): dedupe duplicate dispatch test flow
This commit is contained in:
@@ -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,
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user