返回 DeepSeek-Reasonix
session-recovery-version-host-bridge.test.ts
根目录 / desktop / frontend / src / __tests__ / session-recovery-version-host-bridge.test.ts
1 import { bindSessionVersionInspector, requestSessionVersions } from "../lib/sessionRecoveryVersionHostBridge";
2 import type { RecoveryLineageView, SessionMeta } from "../lib/types";
3
4 const session = (path: string): SessionMeta => ({
5 path, preview: path, turns: 1, turnsState: "valid", createdAt: 1,
6 lastActivityAt: 1, modTime: 1, current: false, open: false,
7 scope: "global", topicId: "topic",
8 });
9 const view: RecoveryLineageView = {
10 groupId: "group", state: "diverged", branchCount: 2, unresolved: 2,
11 cleanupEligible: 0, members: [],
12 };
13 const received: string[] = [];
14
15 requestSessionVersions(session("first"), view);
16 requestSessionVersions(session("latest"), view);
17 const unbind = bindSessionVersionInspector((next) => received.push(next.path));
18 if (received.join(",") !== "latest") throw new Error(`queued request mismatch: ${received.join(",")}`);
19
20 requestSessionVersions(session("live"), view);
21 if (received.join(",") !== "latest,live") throw new Error(`live request mismatch: ${received.join(",")}`);
22
23 unbind();
24 requestSessionVersions(session("remount"), view);
25 bindSessionVersionInspector((next) => received.push(next.path));
26 if (received.join(",") !== "latest,live,remount") throw new Error(`remount request mismatch: ${received.join(",")}`);
27
28 console.log(" PASS session version host bridge preserves last-click-wins across lazy mounting");
29
29 lines TYPESCRIPT