Tests: cover shared inbound dedupe state

This commit is contained in:
Vincent Koc
2026-03-11 19:50:39 -04:00
parent f94b36f45f
commit f3282182f4

View 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();
}
});
});