mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-12 07:20:45 +00:00
Tests: cover shared Slack thread participation state
This commit is contained in:
@@ -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<typeof import("./sent-thread-cache.js")>(
|
||||
import.meta.url,
|
||||
"./sent-thread-cache.js?scope=shared-a",
|
||||
);
|
||||
const cacheB = await importFreshModule<typeof import("./sent-thread-cache.js")>(
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user