From c5b597db74eab9203d70695590336a4054c232e7 Mon Sep 17 00:00:00 2001 From: Vincent Koc Date: Thu, 12 Mar 2026 01:25:01 -0400 Subject: [PATCH] Tests: cover shared Slack thread participation state --- src/slack/sent-thread-cache.test.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) 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