diff --git a/src/slack/sent-thread-cache.test.ts b/src/slack/sent-thread-cache.test.ts index 05af1958895..7421a7277e3 100644 --- a/src/slack/sent-thread-cache.test.ts +++ b/src/slack/sent-thread-cache.test.ts @@ -1,4 +1,5 @@ import { afterEach, describe, expect, it, vi } from "vitest"; +import { importFreshModule } from "../../test/helpers/import-fresh.js"; import { clearSlackThreadParticipationCache, hasSlackThreadParticipation, @@ -49,6 +50,29 @@ describe("slack sent-thread-cache", () => { expect(hasSlackThreadParticipation("A1", "C456", "1700000000.000002")).toBe(false); }); + it("shares thread participation across distinct module instances", async () => { + const cacheA = await importFreshModule( + import.meta.url, + "./sent-thread-cache.js?scope=shared-a", + ); + const cacheB = await importFreshModule( + import.meta.url, + "./sent-thread-cache.js?scope=shared-b", + ); + + cacheA.clearSlackThreadParticipationCache(); + + try { + cacheA.recordSlackThreadParticipation("A1", "C123", "1700000000.000001"); + expect(cacheB.hasSlackThreadParticipation("A1", "C123", "1700000000.000001")).toBe(true); + + cacheB.clearSlackThreadParticipationCache(); + expect(cacheA.hasSlackThreadParticipation("A1", "C123", "1700000000.000001")).toBe(false); + } finally { + cacheA.clearSlackThreadParticipationCache(); + } + }); + it("expired entries return false and are cleaned up on read", () => { recordSlackThreadParticipation("A1", "C123", "1700000000.000001"); // Advance time past the 24-hour TTL