返回 DeepSeek-Reasonix
session-mcp-list-export.test.ts
根目录 / desktop / frontend / src / __tests__ / session-mcp-list-export.test.ts
1 import assert from "node:assert/strict";
2 import { describe, it } from "node:test";
3 import { mcpListAttribution, sessionItemsToJson } from "../lib/sessionExportData";
4 import type { Item } from "../lib/useController";
5
6 describe("session export MCP list attribution", () => {
7 it("counts shared host, disk cache, and remote tools/list sources", () => {
8 const items: Item[] = [
9 { kind: "tool", id: "1", name: "use_capability", args: "{}", readOnly: true, status: "done", output: JSON.stringify({ source: "shared_host", network_call: false }) },
10 { kind: "tool", id: "2", name: "use_capability", args: "{}", readOnly: true, status: "done", output: JSON.stringify({ source: "disk_cache" }) },
11 { kind: "tool", id: "3", name: "use_capability", args: "{}", readOnly: true, status: "done", output: JSON.stringify({ source: "remote", network_call: true }) },
12 { kind: "notice", id: "4a", level: "info", code: "mcp_tools_list", text: "MCP tools/list", detail: JSON.stringify({ source: "shared_host", network_call: false }) },
13 { kind: "notice", id: "4b", level: "info", code: "mcp_tools_list", text: "MCP tools/list", detail: JSON.stringify({ source: "disk_cache", network_call: false }) },
14 { kind: "notice", id: "4c", level: "info", code: "mcp_tools_list", text: "MCP tools/list", detail: JSON.stringify({ source: "remote", network_call: true }) },
15 { kind: "tool", id: "5", name: "business_api", args: "{}", readOnly: true, status: "done", output: JSON.stringify({ source: "remote", network_call: true }) },
16 { kind: "notice", id: "6", level: "info", text: "deployment completed", detail: JSON.stringify({ source: "remote", network_call: true }) },
17 ];
18 const got = mcpListAttribution(items);
19 assert.deepEqual(got, { sharedHost: 1, diskCache: 1, remote: 1, networkCalls: 1 });
20 const exported = JSON.parse(sessionItemsToJson("session", items));
21 assert.equal(exported.mcpList.sharedHost, 1);
22 assert.equal(exported.items.length, 8);
23 });
24 });
25
25 lines TYPESCRIPT