返回 DeepSeek-Reasonix
bridge-mock-session-navigation.test.ts
根目录 / desktop / frontend / src / __tests__ / bridge-mock-session-navigation.test.ts
1 import assert from "node:assert/strict";
2 import { rebindMockSessionTab } from "../lib/bridgeMockSessionNavigation";
3 import type { TabMeta } from "../lib/types";
4
5 const source = {
6 id: "tab-stable",
7 scope: "project",
8 workspaceRoot: "/old",
9 workspaceName: "old",
10 topicId: "legacy-old",
11 topicTitle: "Old",
12 label: "model",
13 ready: true,
14 running: false,
15 mode: "normal",
16 active: true,
17 cwd: "/old",
18 } as TabMeta;
19
20 const rebound = rebindMockSessionTab(
21 { hostId: "local", sessionId: "canonical-target" }, source,
22 [{ key: "workspace-new", kind: "project", root: "/new", label: "new", children: [
23 { key: "canonical-target", kind: "topic", topicId: "canonical-target", label: "Target" },
24 ] }], "/global", () => false,
25 );
26
27 assert.equal(rebound.id, source.id, "SessionRef navigation preserves the surface identity");
28 assert.deepEqual(rebound.session, { hostId: "local", sessionId: "canonical-target" });
29 assert.equal(rebound.sessionId, "canonical-target");
30 assert.equal(rebound.workspaceId, "project--new");
31 assert.equal(rebound.topicId, "canonical-target", "legacy fixture metadata follows the rebound session");
32 assert.throws(() => rebindMockSessionTab(
33 { hostId: "local", sessionId: "missing" }, undefined, [], "/global", () => false,
34 ), /not ready/, "navigation cannot invent a replacement surface");
35
36 console.log("PASS mock SessionRef navigation rebinds the existing tab identity");
37
37 lines TYPESCRIPT