mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-17 05:20:47 +00:00
test: tighten heartbeat session store assertions
This commit is contained in:
@@ -82,6 +82,14 @@ describe("initSessionState - heartbeat should not trigger session reset", () =>
|
||||
});
|
||||
};
|
||||
|
||||
const expectPersistedSession = (sessionStore: Record<string, SessionEntry>): SessionEntry => {
|
||||
const entry = sessionStore["main:user123"];
|
||||
if (!entry) {
|
||||
throw new Error("Expected persisted session for main:user123");
|
||||
}
|
||||
return entry;
|
||||
};
|
||||
|
||||
it("should NOT reset session when Provider is 'heartbeat'", async () => {
|
||||
// Setup: Create a session entry that is "stale" (older than idle timeout)
|
||||
const now = Date.now();
|
||||
@@ -191,7 +199,7 @@ describe("initSessionState - heartbeat should not trigger session reset", () =>
|
||||
expect(heartbeatResult.sessionEntry.lastInteractionAt).toBe(staleTime);
|
||||
|
||||
const persistedAfterHeartbeat = loadSessionStore(storePath);
|
||||
expect(persistedAfterHeartbeat["main:user123"]?.lastInteractionAt).toBe(staleTime);
|
||||
expect(expectPersistedSession(persistedAfterHeartbeat).lastInteractionAt).toBe(staleTime);
|
||||
|
||||
const userResult = await initSessionState({
|
||||
ctx: createBaseCtx({
|
||||
@@ -278,7 +286,7 @@ describe("initSessionState - heartbeat should not trigger session reset", () =>
|
||||
expect(heartbeatResult.sessionId).toBe("legacy-idle-session");
|
||||
|
||||
const persistedAfterHeartbeat = loadSessionStore(storePath);
|
||||
expect(persistedAfterHeartbeat["main:user123"]?.lastInteractionAt).toBeUndefined();
|
||||
expect(expectPersistedSession(persistedAfterHeartbeat).lastInteractionAt).toBeUndefined();
|
||||
|
||||
const userResult = await initSessionState({
|
||||
ctx: createBaseCtx({
|
||||
|
||||
Reference in New Issue
Block a user