workspaceSidebarRemoteNotice.test.ts 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. import { beforeEach, describe, expect, it, vi } from "vitest";
  2. import { createElement } from "react";
  3. import { renderToStaticMarkup } from "react-dom/server";
  4. import type { RemoteConnectionLogEntry } from "@/hooks/useRemoteConnectionLogs.js";
  5. import type { WorkspaceTabState } from "@/store/tabStore.js";
  6. const {
  7. archiveWorkspaceTasks,
  8. confirmDialog,
  9. releaseWorkspacePreparation,
  10. toast,
  11. workspaceRuntimeState,
  12. } = vi.hoisted(() => ({
  13. archiveWorkspaceTasks: vi.fn(async () => []),
  14. confirmDialog: vi.fn(async () => true),
  15. releaseWorkspacePreparation: vi.fn(async () => undefined),
  16. toast: vi.fn(),
  17. workspaceRuntimeState: {
  18. draftStatus: "idle",
  19. taskRuntimeByTaskId: {} as Record<string, { status: string }>,
  20. },
  21. }));
  22. vi.mock("border-beam", () => ({
  23. BorderBeam: ({ children }: { children: unknown }) =>
  24. createElement("div", { "data-testid": "border-beam" }, children),
  25. }));
  26. vi.mock("lucide-react", () => {
  27. const createIcon = (name: string) => (props: Record<string, unknown>) =>
  28. createElement("svg", { "data-icon": name, ...props });
  29. return {
  30. CheckIcon: createIcon("check"),
  31. CircleAlert: createIcon("circle-alert"),
  32. Cloud: createIcon("cloud"),
  33. CopyIcon: createIcon("copy"),
  34. Ellipsis: createIcon("ellipsis"),
  35. ListTree: createIcon("list-tree"),
  36. Loader2: createIcon("loader-2"),
  37. Folder: createIcon("folder"),
  38. FolderOpen: createIcon("folder-open"),
  39. House: createIcon("house"),
  40. InfoIcon: createIcon("info"),
  41. LoaderCircle: createIcon("loader"),
  42. RefreshCwIcon: createIcon("refresh"),
  43. MessageCirclePlus: createIcon("message-circle-plus"),
  44. // 定制功能「重命名项目」菜单项使用的图标(见 WorkspaceSidebarItem 的 Pencil)。
  45. Pencil: createIcon("pencil"),
  46. UploadCloud: createIcon("upload-cloud"),
  47. XIcon: createIcon("x"),
  48. };
  49. });
  50. vi.mock("@/hooks/useConfirmDialog.js", () => ({
  51. useConfirmDialog: () => confirmDialog,
  52. }));
  53. vi.mock("@/components/ui/toast.js", () => ({
  54. toast,
  55. }));
  56. vi.mock("@/components/ui/button.js", () => ({
  57. Button: ({ children, className, ...props }: { children: unknown; className?: string }) =>
  58. createElement("button", { className, ...props }, children),
  59. buttonVariants: () => "button-variants",
  60. }));
  61. vi.mock("@/components/ui/collapsible.js", () => ({
  62. Collapsible: ({ children }: { children: unknown }) =>
  63. createElement("div", { "data-testid": "collapsible" }, children),
  64. CollapsibleContent: ({ children }: { children: unknown }) =>
  65. createElement("div", { "data-testid": "collapsible-content" }, children),
  66. CollapsibleTrigger: ({ children }: { children: unknown }) =>
  67. createElement("div", { "data-testid": "collapsible-trigger" }, children),
  68. }));
  69. vi.mock("@/components/ui/dropdown-menu.js", () => ({
  70. DropdownMenu: ({ children }: { children: unknown }) =>
  71. createElement("div", { "data-testid": "dropdown-menu" }, children),
  72. DropdownMenuContent: ({
  73. children,
  74. onClick,
  75. }: {
  76. children: unknown;
  77. onClick?: (event: { stopPropagation(): void }) => void;
  78. }) => {
  79. capturedWorkspaceMenuClick = onClick ?? null;
  80. return createElement("div", { "data-testid": "dropdown-menu-content" }, children);
  81. },
  82. DropdownMenuItem: ({
  83. children,
  84. onSelect,
  85. ...props
  86. }: {
  87. children: unknown;
  88. onSelect?: (event: { preventDefault(): void }) => void;
  89. "data-testid"?: string;
  90. }) => {
  91. if (onSelect && props["data-testid"]?.startsWith("workspace-close-")) {
  92. capturedWorkspaceRemoveSelect = onSelect;
  93. }
  94. return createElement("div", { "data-testid": "dropdown-menu-item", ...props }, children);
  95. },
  96. DropdownMenuTrigger: ({ children }: { children: unknown }) =>
  97. createElement("div", { "data-testid": "dropdown-menu-trigger" }, children),
  98. }));
  99. vi.mock("@/components/ui/tooltip.js", () => ({
  100. TooltipProvider: ({ children }: { children: unknown }) =>
  101. createElement("div", { "data-testid": "tooltip-provider" }, children),
  102. Tooltip: ({ children }: { children: unknown }) =>
  103. createElement("div", { "data-testid": "tooltip-root" }, children),
  104. TooltipTrigger: ({ children }: { children: unknown }) => children,
  105. TooltipContent: ({ children }: { children: unknown }) =>
  106. createElement("div", { "data-testid": "tooltip-content" }, children),
  107. }));
  108. vi.mock("@/ControlHintTooltip.js", () => ({
  109. ControlHintTooltip: ({ children, title }: { children: unknown; title: string }) =>
  110. createElement("div", { "data-title": title }, children),
  111. }));
  112. vi.mock("@/i18n/IntlProvider.js", () => ({
  113. useZCodeIntl: () => ({
  114. intl: {
  115. formatMessage: ({ id }: { id: string }) => {
  116. const messages: Record<string, string> = {
  117. "common.more": "更多",
  118. "workspaceSidebar.remove": "移除工作区",
  119. "workspaceSidebar.notConnected": "未连接",
  120. "workspaceSidebar.connecting": "连接中",
  121. "workspaceSidebar.reconnect": "重新连接",
  122. "workspaceSidebar.sshConnectionTitle": "SSH 连接",
  123. "workspaceSidebar.sshConnectionAlias": "Alias",
  124. "workspaceSidebar.sshConnectionHost": "Host",
  125. "workspaceSidebar.sshConnectionPath": "Path",
  126. "workspaceSidebar.unavailableLocalDirectory":
  127. "工作区目录不存在或无法访问,当前仅可查看历史记录。恢复该目录后重启 ZCode 即可继续使用。",
  128. "settings.skills.remoteSync.open": "同步 Skill",
  129. "settings.mcp.remoteSync.open": "同步 MCP",
  130. "taskList.newThread": "新建任务",
  131. };
  132. return messages[id] ?? id;
  133. },
  134. },
  135. }),
  136. }));
  137. vi.mock("@/TaskList.js", () => ({
  138. TaskList: () => createElement("div", { "data-testid": "task-list" }),
  139. }));
  140. vi.mock("@/WorkspaceSidebar/ReconnectingRemoteWorkspaceLogTooltip.js", () => ({
  141. ReconnectingRemoteWorkspaceLogTooltip: () =>
  142. createElement("div", { "data-testid": "reconnect-tooltip" }),
  143. }));
  144. vi.mock("@/lib/remoteWorkspaceHistory.js", () => ({
  145. buildWorkspaceSessionKey: (entry: { workspacePath: string; workspaceIdentity?: string }) =>
  146. entry.workspaceIdentity?.trim() || entry.workspacePath,
  147. formatRemoteWorkspaceDisplayLabel: (
  148. label: string,
  149. target?: { kind: string; sshConfigAlias?: string },
  150. ) => {
  151. if (target?.kind !== "ssh") {
  152. return label;
  153. }
  154. const sshConfigAlias = target.sshConfigAlias?.trim();
  155. return sshConfigAlias ? `${label} [SSH: ${sshConfigAlias}]` : label;
  156. },
  157. }));
  158. vi.mock("@/hooks/useWorkspaceServices.js", () => ({
  159. useBaseWorkspaceServices: () => ({
  160. fileService: {
  161. readdir: async () => [],
  162. },
  163. skillSyncService: {},
  164. mcpSyncService: {},
  165. pluginSyncService: {},
  166. }),
  167. useWorkspaceServices: () => ({
  168. skillSyncService: {},
  169. mcpSyncService: {},
  170. pluginSyncService: {},
  171. skillsService: {
  172. list: async () => [],
  173. },
  174. legacyTaskService: {
  175. renameTask: async () => ({}),
  176. setTaskPinned: async () => ({}),
  177. archiveTask: async () => ({}),
  178. archiveWorkspaceTasks,
  179. setTaskUnread: async () => ({}),
  180. },
  181. zcodeTaskService: {
  182. releaseWorkspacePreparation,
  183. },
  184. }),
  185. }));
  186. vi.mock("@/settings/RemoteSkillSyncDialog.js", () => ({
  187. RemoteSkillSyncDialog: () => createElement("div", { "data-testid": "remote-skill-sync-dialog" }),
  188. }));
  189. vi.mock("@/settings/RemoteMcpSyncDialog.js", () => ({
  190. RemoteMcpSyncDialog: () => createElement("div", { "data-testid": "remote-mcp-sync-dialog" }),
  191. }));
  192. vi.mock("@/settings/RemotePluginSyncDialog.js", () => ({
  193. RemotePluginSyncDialog: () =>
  194. createElement("div", { "data-testid": "remote-plugin-sync-dialog" }),
  195. }));
  196. vi.mock("@/store/taskQueryCacheStore.js", () => ({
  197. applyTaskQueryCacheMutation: () => {},
  198. invalidateTaskQueryCacheByScopes: () => {},
  199. }));
  200. vi.mock("@/store/zcodeSessionStore.js", () => ({
  201. useZCodeSessionStore: (selector: (state: Record<string, unknown>) => unknown) =>
  202. selector({
  203. startDraft: () => {},
  204. removeTaskState: () => {},
  205. upsertOptimisticTaskListItem: () => {},
  206. removeOptimisticTaskListItem: () => {},
  207. setTaskUnreadIndicator: () => {},
  208. }),
  209. selectWorkspaceZCodeState: () => ({
  210. activeTaskId: null,
  211. draftRuntime: { status: workspaceRuntimeState.draftStatus, error: null },
  212. taskRuntimeByTaskId: workspaceRuntimeState.taskRuntimeByTaskId,
  213. selectedProvider: "codex",
  214. }),
  215. }));
  216. const onReconnectRemoteWorkspace = vi.fn(async () => {});
  217. let capturedWorkspaceRemoveSelect: ((event: { preventDefault(): void }) => void) | null = null;
  218. let capturedWorkspaceMenuClick: ((event: { stopPropagation(): void }) => void) | null = null;
  219. function createRemoteWorkspaceTab(overrides: Partial<WorkspaceTabState> = {}): WorkspaceTabState {
  220. return {
  221. id: "workspace-remote",
  222. kind: "workspace",
  223. label: "remote-project",
  224. workspacePath: "/remote/project",
  225. remoteTarget: {
  226. kind: "ssh",
  227. host: "example.com",
  228. username: "dev",
  229. },
  230. workspaceIdentity: "ssh://dev@example.com/remote/project",
  231. ...overrides,
  232. };
  233. }
  234. function renderWorkspaceItem(params?: {
  235. tab?: WorkspaceTabState;
  236. remoteWorkspaceErrorByWorkspaceKey?: Record<string, string>;
  237. reconnectingRemoteWorkspaceKeys?: string[];
  238. reconnectingRemoteWorkspaceLogsByWorkspaceKey?: Record<string, RemoteConnectionLogEntry[]>;
  239. onOpenFileTree?: Parameters<typeof WorkspaceSidebarItem>[0]["onOpenFileTree"];
  240. closeTab?: Parameters<typeof WorkspaceSidebarItem>[0]["closeTab"];
  241. isExpanded?: boolean;
  242. taskListHasUnread?: boolean;
  243. taskListLiveWorkflowCount?: number;
  244. taskItems?: Parameters<typeof WorkspaceSidebarItem>[0]["taskItems"];
  245. }) {
  246. const tab = params?.tab ?? createRemoteWorkspaceTab();
  247. return renderToStaticMarkup(
  248. createElement(WorkspaceSidebarItem, {
  249. tab,
  250. isActiveWorkspace: false,
  251. isExpanded: params?.isExpanded ?? false,
  252. activateTab: () => {},
  253. closeTab: params?.closeTab ?? (() => {}),
  254. toggleWorkspaceExpanded: () => {},
  255. onSelectTask: () => {},
  256. onStartDraftInWorkspace: () => {},
  257. taskItems: params?.taskItems ?? [],
  258. taskListLoading: false,
  259. taskListHasMore: false,
  260. taskListHasUnread: params?.taskListHasUnread ?? false,
  261. taskListLiveWorkflowCount: params?.taskListLiveWorkflowCount ?? 0,
  262. onShowMoreTasks: () => {},
  263. reconnectingRemoteWorkspaceKeys: params?.reconnectingRemoteWorkspaceKeys ?? [],
  264. remoteWorkspaceErrorByWorkspaceKey: params?.remoteWorkspaceErrorByWorkspaceKey ?? {},
  265. reconnectingRemoteWorkspaceLogsByWorkspaceKey:
  266. params?.reconnectingRemoteWorkspaceLogsByWorkspaceKey ?? {},
  267. onReconnectRemoteWorkspace,
  268. onOpenFileTree: params?.onOpenFileTree,
  269. }),
  270. );
  271. }
  272. import { WorkspaceSidebarItem } from "@/WorkspaceSidebarItem.js";
  273. describe("WorkspaceSidebarItem remote notice", () => {
  274. beforeEach(() => {
  275. vi.stubGlobal("window", {
  276. matchMedia: () => ({ matches: true }),
  277. });
  278. onReconnectRemoteWorkspace.mockClear();
  279. archiveWorkspaceTasks.mockClear();
  280. confirmDialog.mockClear();
  281. confirmDialog.mockResolvedValue(true);
  282. releaseWorkspacePreparation.mockClear();
  283. toast.mockClear();
  284. workspaceRuntimeState.draftStatus = "idle";
  285. workspaceRuntimeState.taskRuntimeByTaskId = {};
  286. capturedWorkspaceRemoveSelect = null;
  287. capturedWorkspaceMenuClick = null;
  288. });
  289. it("远程项目仅仅未连接时,不显示叹号提示图标", () => {
  290. const html = renderWorkspaceItem();
  291. expect(html).not.toContain('data-icon="info"');
  292. expect(html).not.toContain('data-title="未连接"');
  293. });
  294. it("workspace 收起时显示聚合未读蓝点,展开时只保留 task 行提示", () => {
  295. const collapsedHtml = renderWorkspaceItem({ taskListHasUnread: true });
  296. const expandedHtml = renderWorkspaceItem({ isExpanded: true, taskListHasUnread: true });
  297. expect(collapsedHtml).toContain('data-workspace-unread-indicator="true"');
  298. expect(collapsedHtml).toContain("bg-sky-500 dark:bg-sky-400");
  299. expect(expandedHtml).not.toContain('data-workspace-unread-indicator="true"');
  300. });
  301. it("workspace 收起时在未读点旁显示在跑工作流的脉冲灯,>1 带数量;展开时不显示", () => {
  302. const one = renderWorkspaceItem({ taskListLiveWorkflowCount: 1 });
  303. const three = renderWorkspaceItem({ taskListHasUnread: true, taskListLiveWorkflowCount: 3 });
  304. const expanded = renderWorkspaceItem({ isExpanded: true, taskListLiveWorkflowCount: 2 });
  305. const none = renderWorkspaceItem();
  306. expect(one).toContain('data-workspace-workflow-indicator="true"');
  307. expect(one).toContain('data-count="1"');
  308. expect(one).toContain("animate-pulse bg-warning");
  309. expect(three).toContain('data-workspace-unread-indicator="true"');
  310. expect(three).toContain('data-count="3"');
  311. expect(three).toMatch(/data-count="3"[^>]*>.*3</);
  312. expect(expanded).not.toContain("data-workspace-workflow-indicator");
  313. expect(none).not.toContain("data-workspace-workflow-indicator");
  314. });
  315. it("失效的本地 workspace 标题后显示红色告警并禁用目录操作", () => {
  316. const html = renderWorkspaceItem({
  317. tab: createRemoteWorkspaceTab({
  318. id: "workspace-local-missing",
  319. label: "missing-project",
  320. workspacePath: "/workspace/missing-project",
  321. availability: "unavailable-local-directory",
  322. remoteSessionId: undefined,
  323. remoteTarget: undefined,
  324. workspaceIdentity: undefined,
  325. }),
  326. onOpenFileTree: () => {},
  327. });
  328. expect(html).toContain('data-icon="circle-alert"');
  329. expect(html).toContain("size-3.5 text-destructive");
  330. expect(html).toContain(
  331. "工作区目录不存在或无法访问,当前仅可查看历史记录。恢复该目录后重启 ZCode 即可继续使用。",
  332. );
  333. expect(html).toContain('data-icon="list-tree"');
  334. expect(html).toContain('disabled=""');
  335. });
  336. it("SSH 远程工作区有配置别名时,在任务列表标题后展示 SSH 别名标签", () => {
  337. const html = renderWorkspaceItem({
  338. tab: createRemoteWorkspaceTab({
  339. label: "root",
  340. workspacePath: "/root",
  341. remoteTarget: {
  342. kind: "ssh",
  343. host: "localhost",
  344. port: 2223,
  345. username: "root",
  346. sshConfigAlias: "linux-arm64",
  347. },
  348. workspaceIdentity: "remote:ssh:localhost:2223:root:/root",
  349. }),
  350. });
  351. expect(html).toContain("root [SSH: linux-arm64]");
  352. });
  353. it("SSH 远程工作区没有配置别名时,workspace tooltip 展示连接 host 和路径", () => {
  354. const html = renderWorkspaceItem({
  355. tab: createRemoteWorkspaceTab({
  356. label: "demo-project",
  357. workspacePath: "/srv/demo-project",
  358. remoteTarget: {
  359. kind: "ssh",
  360. host: "10.0.0.8",
  361. port: 2202,
  362. username: "root",
  363. },
  364. workspaceIdentity: "remote:ssh:10.0.0.8:2202:root:/srv/demo-project",
  365. }),
  366. });
  367. expect(html).toContain('data-testid="tooltip-content"');
  368. expect(html).toContain("SSH 连接");
  369. expect(html).toContain("root@10.0.0.8:2202");
  370. expect(html).toContain("/srv/demo-project");
  371. });
  372. it("远程项目有连接错误时,显示叹号提示图标和错误内容", () => {
  373. const html = renderWorkspaceItem({
  374. remoteWorkspaceErrorByWorkspaceKey: {
  375. "ssh://dev@example.com/remote/project": "ssh connection refused",
  376. },
  377. });
  378. expect(html).toContain('data-icon="info"');
  379. expect(html).toContain("ssh connection refused");
  380. });
  381. it("远程项目未连接时,不显示 file tree 入口", () => {
  382. const html = renderWorkspaceItem({ onOpenFileTree: () => {} });
  383. expect(html).not.toContain('data-icon="list-tree"');
  384. expect(html).not.toContain("workspaceSidebar.showFileTree");
  385. });
  386. it("远程项目已连接时,显示 file tree 入口", () => {
  387. const html = renderWorkspaceItem({
  388. tab: createRemoteWorkspaceTab({ remoteSessionId: "remote-session-1" }),
  389. onOpenFileTree: () => {},
  390. });
  391. expect(html).toContain('data-icon="list-tree"');
  392. expect(html).toContain("workspaceSidebar.showFileTree");
  393. });
  394. it("已连接 SSH 远程工作区的更多菜单显示同步 Skills 和 MCP 入口", () => {
  395. const html = renderWorkspaceItem({
  396. tab: createRemoteWorkspaceTab({ remoteSessionId: "remote-session-1" }),
  397. });
  398. expect(html).toContain('data-icon="upload-cloud"');
  399. expect(html).toContain("同步 Skill");
  400. expect(html).toContain("同步 MCP");
  401. });
  402. it("未连接远程工作区的更多菜单不显示同步 Skills 和 MCP 入口", () => {
  403. const html = renderWorkspaceItem();
  404. expect(html).not.toContain("同步 Skill");
  405. expect(html).not.toContain("同步 MCP");
  406. });
  407. it("远程项目重连中时,右侧 loading 图标使用连接日志 tooltip", () => {
  408. const html = renderWorkspaceItem({
  409. reconnectingRemoteWorkspaceKeys: ["ssh://dev@example.com/remote/project"],
  410. reconnectingRemoteWorkspaceLogsByWorkspaceKey: {
  411. "ssh://dev@example.com/remote/project": [
  412. {
  413. id: "log-1",
  414. level: "info",
  415. timestamp: "10:00:00",
  416. message: "connecting",
  417. },
  418. ],
  419. },
  420. });
  421. expect(html).toContain('data-testid="reconnect-tooltip"');
  422. });
  423. it("移除 workspace 会释放 runtime 且不批量归档已有 task", async () => {
  424. const closeTab = vi.fn();
  425. renderWorkspaceItem({ closeTab });
  426. await capturedWorkspaceRemoveSelect?.({
  427. preventDefault: () => {},
  428. });
  429. await Promise.resolve();
  430. expect(confirmDialog).not.toHaveBeenCalled();
  431. expect(closeTab).toHaveBeenCalledWith("workspace-remote");
  432. expect(releaseWorkspacePreparation).toHaveBeenCalledWith({
  433. workspacePath: "/remote/project",
  434. workspaceIdentity: "ssh://dev@example.com/remote/project",
  435. });
  436. expect(archiveWorkspaceTasks).not.toHaveBeenCalled();
  437. });
  438. it("运行中 workspace 移除被取消时不关闭 tab 也不释放 runtime", async () => {
  439. const closeTab = vi.fn();
  440. confirmDialog.mockResolvedValue(false);
  441. workspaceRuntimeState.taskRuntimeByTaskId = { task_running: { status: "streaming" } };
  442. renderWorkspaceItem({
  443. closeTab,
  444. taskItems: [
  445. {
  446. taskId: "task_running",
  447. traceId: "trace_running",
  448. title: "running task",
  449. workspacePath: "/remote/project",
  450. createdAt: 1,
  451. updatedAt: 1,
  452. mode: "agent",
  453. status: "running",
  454. },
  455. ],
  456. });
  457. await capturedWorkspaceRemoveSelect?.({
  458. preventDefault: () => {},
  459. });
  460. await Promise.resolve();
  461. expect(confirmDialog).toHaveBeenCalledWith(
  462. expect.objectContaining({
  463. title: "workspaceSidebar.removeRunningWorkspace.title",
  464. confirmVariant: "destructive",
  465. }),
  466. );
  467. expect(closeTab).not.toHaveBeenCalled();
  468. expect(releaseWorkspacePreparation).not.toHaveBeenCalled();
  469. });
  470. it("运行中 workspace 移除被确认后继续释放 runtime", async () => {
  471. const closeTab = vi.fn();
  472. workspaceRuntimeState.draftStatus = "creating";
  473. renderWorkspaceItem({ closeTab });
  474. await capturedWorkspaceRemoveSelect?.({
  475. preventDefault: () => {},
  476. });
  477. await Promise.resolve();
  478. expect(confirmDialog).toHaveBeenCalledOnce();
  479. expect(closeTab).toHaveBeenCalledWith("workspace-remote");
  480. expect(releaseWorkspacePreparation).toHaveBeenCalledWith({
  481. workspacePath: "/remote/project",
  482. workspaceIdentity: "ssh://dev@example.com/remote/project",
  483. });
  484. });
  485. it("workspace 操作菜单 click 必须阻止冒泡到 CollapsibleTrigger", () => {
  486. const stopPropagation = vi.fn();
  487. renderWorkspaceItem({ isExpanded: false });
  488. capturedWorkspaceMenuClick?.({ stopPropagation });
  489. expect(stopPropagation).toHaveBeenCalledOnce();
  490. });
  491. });