























@@ -82,6 +82,14 @@ describe("initSessionState - heartbeat should not trigger session reset", () =>
8282});
8383};
848485+const expectPersistedSession = (sessionStore: Record<string, SessionEntry>): SessionEntry => {
86+const entry = sessionStore["main:user123"];
87+if (!entry) {
88+throw new Error("Expected persisted session for main:user123");
89+}
90+return entry;
91+};
92+8593it("should NOT reset session when Provider is 'heartbeat'", async () => {
8694// Setup: Create a session entry that is "stale" (older than idle timeout)
8795const now = Date.now();
@@ -191,7 +199,7 @@ describe("initSessionState - heartbeat should not trigger session reset", () =>
191199expect(heartbeatResult.sessionEntry.lastInteractionAt).toBe(staleTime);
192200193201const persistedAfterHeartbeat = loadSessionStore(storePath);
194-expect(persistedAfterHeartbeat["main:user123"]?.lastInteractionAt).toBe(staleTime);
202+expect(expectPersistedSession(persistedAfterHeartbeat).lastInteractionAt).toBe(staleTime);
195203196204const userResult = await initSessionState({
197205ctx: createBaseCtx({
@@ -278,7 +286,7 @@ describe("initSessionState - heartbeat should not trigger session reset", () =>
278286expect(heartbeatResult.sessionId).toBe("legacy-idle-session");
279287280288const persistedAfterHeartbeat = loadSessionStore(storePath);
281-expect(persistedAfterHeartbeat["main:user123"]?.lastInteractionAt).toBeUndefined();
289+expect(expectPersistedSession(persistedAfterHeartbeat).lastInteractionAt).toBeUndefined();
282290283291const userResult = await initSessionState({
284292ctx: createBaseCtx({
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。