mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
Tests: cover shared inbound dedupe state
This commit is contained in:
43
src/auto-reply/reply/inbound-dedupe.test.ts
Normal file
43
src/auto-reply/reply/inbound-dedupe.test.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
import { afterEach, describe, expect, it } from "vitest";
|
||||
import { importFreshModule } from "../../../test/helpers/import-fresh.js";
|
||||
import type { MsgContext } from "../templating.js";
|
||||
import { resetInboundDedupe } from "./inbound-dedupe.js";
|
||||
|
||||
const sharedInboundContext: MsgContext = {
|
||||
Provider: "discord",
|
||||
Surface: "discord",
|
||||
From: "discord:user-1",
|
||||
To: "channel:c1",
|
||||
OriginatingChannel: "discord",
|
||||
OriginatingTo: "channel:c1",
|
||||
SessionKey: "agent:main:discord:channel:c1",
|
||||
MessageSid: "msg-1",
|
||||
};
|
||||
|
||||
describe("inbound dedupe", () => {
|
||||
afterEach(() => {
|
||||
resetInboundDedupe();
|
||||
});
|
||||
|
||||
it("shares dedupe state across distinct module instances", async () => {
|
||||
const inboundA = await importFreshModule<typeof import("./inbound-dedupe.js")>(
|
||||
import.meta.url,
|
||||
"./inbound-dedupe.js?scope=shared-a",
|
||||
);
|
||||
const inboundB = await importFreshModule<typeof import("./inbound-dedupe.js")>(
|
||||
import.meta.url,
|
||||
"./inbound-dedupe.js?scope=shared-b",
|
||||
);
|
||||
|
||||
inboundA.resetInboundDedupe();
|
||||
inboundB.resetInboundDedupe();
|
||||
|
||||
try {
|
||||
expect(inboundA.shouldSkipDuplicateInbound(sharedInboundContext)).toBe(false);
|
||||
expect(inboundB.shouldSkipDuplicateInbound(sharedInboundContext)).toBe(true);
|
||||
} finally {
|
||||
inboundA.resetInboundDedupe();
|
||||
inboundB.resetInboundDedupe();
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user