Skip to content

Commit a30373e

Browse files
committed
test(slack): seed canonical session entries
1 parent 4ca59b5 commit a30373e

2 files changed

Lines changed: 29 additions & 4 deletions

File tree

extensions/slack/src/monitor/message-handler/prepare.test-helpers.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import path from "node:path";
44
import type { App } from "@slack/bolt";
55
import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
66
import type { RuntimeEnv } from "openclaw/plugin-sdk/runtime-env";
7+
import type { SessionEntry } from "openclaw/plugin-sdk/session-store-runtime";
78
import { resolvePreferredOpenClawTmpDir } from "openclaw/plugin-sdk/temp-path";
89
import type { ResolvedSlackAccount } from "../../accounts.js";
910
import type { SlackChannelConfigEntries } from "../channel-config.js";
@@ -78,6 +79,17 @@ export function createSlackTestAccount(
7879
};
7980
}
8081

82+
export function createSlackStoredSessionEntry({
83+
sessionId,
84+
updatedAt = Date.now(),
85+
...entry
86+
}: { sessionId: string; updatedAt?: number } & Omit<
87+
Partial<SessionEntry>,
88+
"sessionId" | "updatedAt"
89+
>): SessionEntry {
90+
return { ...entry, sessionId, updatedAt };
91+
}
92+
8193
export function createSlackSessionStoreFixture(prefix: string) {
8294
let fixtureRoot = "";
8395
let caseId = 0;

extensions/slack/src/monitor/message-handler/prepare.test.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import { testing as slackRoutingTesting } from "./prepare-routing.js";
2626
import { prepareSlackMessage } from "./prepare.js";
2727
import {
2828
createInboundSlackTestContext,
29+
createSlackStoredSessionEntry,
2930
createSlackSessionStoreFixture,
3031
createSlackTestAccount,
3132
} from "./prepare.test-helpers.js";
@@ -1733,7 +1734,11 @@ Second paragraph should still reach the agent after Slack's preview cutoff.`;
17331734
history.mockClear();
17341735
await saveSessionStore(
17351736
storePath,
1736-
{ [prepared.ctxPayload.SessionKey!]: { updatedAt: Date.now() } },
1737+
{
1738+
[prepared.ctxPayload.SessionKey!]: createSlackStoredSessionEntry({
1739+
sessionId: "existing-dm-session",
1740+
}),
1741+
},
17371742
{ skipMaintenance: true },
17381743
);
17391744
const existing = await prepareMessageWith(
@@ -1864,7 +1869,11 @@ Second paragraph should still reach the agent after Slack's preview cutoff.`;
18641869
});
18651870
await saveSessionStore(
18661871
storePath,
1867-
{ [threadKeys.sessionKey]: { updatedAt: Date.now() } },
1872+
{
1873+
[threadKeys.sessionKey]: createSlackStoredSessionEntry({
1874+
sessionId: "existing-thread-session",
1875+
}),
1876+
},
18681877
{ skipMaintenance: true },
18691878
);
18701879

@@ -2069,8 +2078,12 @@ Second paragraph should still reach the agent after Slack's preview cutoff.`;
20692078
await saveSessionStore(
20702079
storePath,
20712080
{
2072-
"agent:main:main": { updatedAt: Date.now() },
2073-
"agent:main:main:thread:650.000": { updatedAt: Date.now() },
2081+
"agent:main:main": createSlackStoredSessionEntry({
2082+
sessionId: "existing-main-dm-session",
2083+
}),
2084+
"agent:main:main:thread:650.000": createSlackStoredSessionEntry({
2085+
sessionId: "existing-main-thread-session",
2086+
}),
20742087
},
20752088
{ skipMaintenance: true },
20762089
);

0 commit comments

Comments
 (0)