perf(test): slim raw-body directive integration

This commit is contained in:
Peter Steinberger
2026-02-14 20:07:53 +00:00
parent e1220c48f5
commit 5daaab3692
2 changed files with 42 additions and 62 deletions

View File

@@ -195,6 +195,47 @@ describe("initSessionState RawBody", () => {
expect(result.triggerBodyNormalized).toBe("/status");
});
it("uses the default per-agent sessions store when config store is unset", async () => {
const root = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-session-store-default-"));
const stateDir = path.join(root, ".openclaw");
const agentId = "worker1";
const sessionKey = `agent:${agentId}:telegram:12345`;
const sessionId = "sess-worker-1";
const sessionFile = path.join(stateDir, "agents", agentId, "sessions", `${sessionId}.jsonl`);
const storePath = path.join(stateDir, "agents", agentId, "sessions", "sessions.json");
vi.stubEnv("OPENCLAW_STATE_DIR", stateDir);
try {
await fs.mkdir(path.dirname(storePath), { recursive: true });
await saveSessionStore(storePath, {
[sessionKey]: {
sessionId,
sessionFile,
updatedAt: Date.now(),
},
});
const cfg = {} as OpenClawConfig;
const result = await initSessionState({
ctx: {
Body: "hello",
ChatType: "direct",
Provider: "telegram",
Surface: "telegram",
SessionKey: sessionKey,
},
cfg,
commandAuthorized: true,
});
expect(result.sessionEntry.sessionId).toBe(sessionId);
expect(result.sessionEntry.sessionFile).toBe(sessionFile);
expect(result.storePath).toBe(storePath);
} finally {
vi.unstubAllEnvs();
}
});
});
describe("initSessionState reset policy", () => {