From f821b7f26bdb521032381b34a3d751570271478c Mon Sep 17 00:00:00 2001 From: Delicious233 <101502465+DeliciousBuding@users.noreply.github.com> Date: Wed, 19 Aug 2026 03:48:06 +0800 Subject: [PATCH] =?UTF-8?q?test(shared):=20=E6=8A=BD=E5=8F=96=20AgentHubWo?= =?UTF-8?q?rkbench=20=E6=B5=8B=E8=AF=95=E5=85=B1=E4=BA=AB=20fixtures?= =?UTF-8?q?=EF=BC=88#1763=20=E9=A6=96=E6=AD=A5=EF=BC=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 将 agents / transcript 两个共享数据 fixture 抽到 workbenchTestFixtures.ts(纯数据、带类型,导出 workbenchAgents / workbenchTranscript),测试文件以别名导入。 - 不移动任何 vi.mock / 组件 / render;virtua 仍只在该文件内 mock。 - 测试 78/78 通过(前后一致),tsc --noEmit 0 错误, 主测试文件 3269 → 3134 行(-135)。 Co-authored-by: Cursor --- .../src/workbench/AgentHubWorkbench.test.tsx | 140 +--------------- .../src/workbench/workbenchTestFixtures.ts | 152 ++++++++++++++++++ 2 files changed, 156 insertions(+), 136 deletions(-) create mode 100644 app/shared/src/workbench/workbenchTestFixtures.ts diff --git a/app/shared/src/workbench/AgentHubWorkbench.test.tsx b/app/shared/src/workbench/AgentHubWorkbench.test.tsx index 5ad6f9061..018f4dbb4 100644 --- a/app/shared/src/workbench/AgentHubWorkbench.test.tsx +++ b/app/shared/src/workbench/AgentHubWorkbench.test.tsx @@ -3,11 +3,14 @@ import { act, cleanup, fireEvent, render, screen, waitFor, within } from '@testi import { afterEach, beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'; import { WORKBENCH_DATA_MODE_STORAGE_KEY, projectGroupMessageLoopTranscript } from '../demo'; import { createMockPlatform } from '../platform/createMockPlatform'; -import type { WorkbenchAgent } from '../platform/types'; import type { TranscriptBlock } from '../transcript/types'; import { AgentHubWorkbench } from './AgentHubWorkbench'; import { DESIGN_NAV_GLYPH_SIZE, DESIGN_NAV_GLYPH_STROKE_WIDTH } from './designIcons'; import { MAX_PENDING_DISPATCH_RETRIES } from './composer/pendingIntents'; +import { + workbenchAgents as agents, + workbenchTranscript as transcript, +} from './workbenchTestFixtures'; // Workbench chrome + transcript copy resolve through the shared test // i18next instance; opt into the zh bundle for this suite (Issue #1717). @@ -99,141 +102,6 @@ describe('AgentHubWorkbench', () => { window.localStorage.removeItem('agenthub.workbench.inspectorCollapsed'); }); - const agents: WorkbenchAgent[] = [ - { - id: 'builder', - name: 'Builder', - description: '代码实现', - status: 'available', - model: 'glm-5.1', - runtimeId: 'claude-code', - }, - { - id: 'reviewer', - name: 'Reviewer', - description: '架构复核', - status: 'available', - model: 'deepseek-v4-pro', - runtimeId: 'claude-code', - }, - ]; - - const transcript: TranscriptBlock[] = [ - { - id: 'msg-1', - kind: 'text', - author: { id: 'user', name: 'Delicious233', role: 'human' }, - text: '全面参考 tokendance-design/desktop', - }, - { - id: 'tool-1', - kind: 'tool_call', - author: { id: 'builder', name: 'Builder', role: 'agent' }, - toolName: 'Read', - status: 'completed', - evidenceRefs: [ - { id: 'run-v4', kind: 'run', label: 'Run v4', status: 'running' }, - { id: 'ev-tool', kind: 'tool', label: 'Read desktop/index.html', status: 'completed' }, - ], - }, - { - id: 'run-session-1', - kind: 'run_session', - author: { id: 'hub', name: 'Hub replay', role: 'system' }, - title: 'Hub replay for desktop run', - status: 'running', - meta: 'same Hub task projected from Edge run', - runId: 'run-v4', - taskId: 'task-v4', - edgeRunId: 'edge-run-v4', - adapterId: 'codex', - deviceId: 'desktop-device-1', - sourceLabel: 'Hub replay', - modeLabel: 'Replay', - targetLabel: 'Edge run evidence', - }, - { - id: 'thinking-1', - kind: 'thinking', - author: { id: 'builder', name: 'Builder', role: 'agent' }, - content: '正在分析 Desktop/Web shared UI 与 design demo 的消息块差距。', - isThinking: true, - }, - { - id: 'route-1', - kind: 'route_decision', - author: { id: 'builder', name: 'Builder', role: 'agent' }, - action: 'fanout', - targetAgent: 'Reviewer', - summary: '把页面路由、消息块和 floating layer 拆成可验证切片。', - }, - { - id: 'subagent-1', - kind: 'subagent', - author: { id: 'builder', name: 'Builder', role: 'agent' }, - title: '复核 blocks 对齐', - worker: 'Reviewer', - status: 'running', - summary: '检查 Thinking、Subagent、Result 等设计块是否进入 shared transcript。', - runId: 'review-v4-blocks', - }, - { - id: 'timeline-1', - kind: 'agent_timeline', - author: { id: 'builder', name: 'Builder', role: 'agent' }, - title: '运行时间线', - items: [ - { status: 'completed', label: '初始化会话', detail: '模型、工具权限和当前项目上下文已加载' }, - { status: 'running', label: '进入代码定位阶段', detail: '读取消息模型和 SQLite 索引入口' }, - ], - }, - { - id: 'child-1', - kind: 'child_agent', - author: { id: 'builder', name: 'Builder', role: 'agent' }, - title: 'Browser QA 截图验证', - agent: 'Browser QA', - status: 'completed', - summary: '确认 Desktop/Web 消息列能显示新增块。', - runId: 'browser-qa-v4', - parentRunId: 'run-v4', - }, - { - id: 'context-1', - kind: 'context_usage', - author: { id: 'builder', name: 'Builder', role: 'agent' }, - inputTokens: 38400, - outputTokens: 6200, - contextLimit: 200000, - cost: '$0.44', - modelLabel: 'GLM-5.1 / 200k', - }, - { - id: 'diff-1', - kind: 'diff', - author: { id: 'builder', name: 'Builder', role: 'agent' }, - title: 'app/shared/src/workbench/RightInspector.tsx', - files: ['app/shared/src/workbench/RightInspector.tsx'], - evidenceRefs: [{ id: 'ev-file', kind: 'file', label: 'app/shared/src/workbench/RightInspector.tsx' }], - }, - { - id: 'artifact-1', - kind: 'artifact', - author: { id: 'builder', name: 'Builder', role: 'agent' }, - title: 'visual-smoke-desktop.png', - evidenceRefs: [{ id: 'ev-artifact', kind: 'artifact', label: 'visual-smoke-desktop.png', status: 'completed' }], - }, - { - id: 'result-1', - kind: 'result', - author: { id: 'builder', name: 'Builder', role: 'agent' }, - success: true, - duration: '8m12s', - turns: 7, - summary: '协作进度 78% · Builder 完成 · Reviewer 复核中。', - }, - ]; - /** P76: inspector tabs beyond overview open on demand via + menu. */ function restoreInspectorTab(mode: 'files' | 'browser'): void { fireEvent.click(screen.getByRole('button', { name: '新建右侧窗口' })); diff --git a/app/shared/src/workbench/workbenchTestFixtures.ts b/app/shared/src/workbench/workbenchTestFixtures.ts new file mode 100644 index 000000000..96a4ff00e --- /dev/null +++ b/app/shared/src/workbench/workbenchTestFixtures.ts @@ -0,0 +1,152 @@ +/** + * Shared data fixtures for the AgentHubWorkbench integration suite (#1763). + * Pure data only — no React components, no vi.mock, no render harnesses — so + * any workbench test can reuse them without importing the integration file. + */ + +import type { WorkbenchAgent } from '../platform/types'; +import type { TranscriptBlock } from '../transcript/types'; + +export const workbenchAgents: WorkbenchAgent[] = [ + { + id: 'builder', + name: 'Builder', + description: '代码实现', + status: 'available', + model: 'glm-5.1', + runtimeId: 'claude-code', + }, + { + id: 'reviewer', + name: 'Reviewer', + description: '架构复核', + status: 'available', + model: 'deepseek-v4-pro', + runtimeId: 'claude-code', + }, +]; + +export const workbenchTranscript: TranscriptBlock[] = [ + { + id: 'msg-1', + kind: 'text', + author: { id: 'user', name: 'Delicious233', role: 'human' }, + text: '全面参考 tokendance-design/desktop', + }, + { + id: 'tool-1', + kind: 'tool_call', + author: { id: 'builder', name: 'Builder', role: 'agent' }, + toolName: 'Read', + status: 'completed', + evidenceRefs: [ + { id: 'run-v4', kind: 'run', label: 'Run v4', status: 'running' }, + { id: 'ev-tool', kind: 'tool', label: 'Read desktop/index.html', status: 'completed' }, + ], + }, + { + id: 'run-session-1', + kind: 'run_session', + author: { id: 'hub', name: 'Hub replay', role: 'system' }, + title: 'Hub replay for desktop run', + status: 'running', + meta: 'same Hub task projected from Edge run', + runId: 'run-v4', + taskId: 'task-v4', + edgeRunId: 'edge-run-v4', + adapterId: 'codex', + deviceId: 'desktop-device-1', + sourceLabel: 'Hub replay', + modeLabel: 'Replay', + targetLabel: 'Edge run evidence', + }, + { + id: 'thinking-1', + kind: 'thinking', + author: { id: 'builder', name: 'Builder', role: 'agent' }, + content: '正在分析 Desktop/Web shared UI 与 design demo 的消息块差距。', + isThinking: true, + }, + { + id: 'route-1', + kind: 'route_decision', + author: { id: 'builder', name: 'Builder', role: 'agent' }, + action: 'fanout', + targetAgent: 'Reviewer', + summary: '把页面路由、消息块和 floating layer 拆成可验证切片。', + }, + { + id: 'subagent-1', + kind: 'subagent', + author: { id: 'builder', name: 'Builder', role: 'agent' }, + title: '复核 blocks 对齐', + worker: 'Reviewer', + status: 'running', + summary: '检查 Thinking、Subagent、Result 等设计块是否进入 shared transcript。', + runId: 'review-v4-blocks', + }, + { + id: 'timeline-1', + kind: 'agent_timeline', + author: { id: 'builder', name: 'Builder', role: 'agent' }, + title: '运行时间线', + items: [ + { status: 'completed', label: '初始化会话', detail: '模型、工具权限和当前项目上下文已加载' }, + { status: 'running', label: '进入代码定位阶段', detail: '读取消息模型和 SQLite 索引入口' }, + ], + }, + { + id: 'child-1', + kind: 'child_agent', + author: { id: 'builder', name: 'Builder', role: 'agent' }, + title: 'Browser QA 截图验证', + agent: 'Browser QA', + status: 'completed', + summary: '确认 Desktop/Web 消息列能显示新增块。', + runId: 'browser-qa-v4', + parentRunId: 'run-v4', + }, + { + id: 'context-1', + kind: 'context_usage', + author: { id: 'builder', name: 'Builder', role: 'agent' }, + inputTokens: 38400, + outputTokens: 6200, + contextLimit: 200000, + cost: '$0.44', + modelLabel: 'GLM-5.1 / 200k', + }, + { + id: 'diff-1', + kind: 'diff', + author: { id: 'builder', name: 'Builder', role: 'agent' }, + title: 'app/shared/src/workbench/RightInspector.tsx', + files: ['app/shared/src/workbench/RightInspector.tsx'], + evidenceRefs: [ + { id: 'ev-file', kind: 'file', label: 'app/shared/src/workbench/RightInspector.tsx' }, + ], + }, + { + id: 'artifact-1', + kind: 'artifact', + author: { id: 'builder', name: 'Builder', role: 'agent' }, + title: 'visual-smoke-desktop.png', + evidenceRefs: [ + { + id: 'ev-artifact', + kind: 'artifact', + label: 'visual-smoke-desktop.png', + status: 'completed', + }, + ], + }, + { + id: 'result-1', + kind: 'result', + author: { id: 'builder', name: 'Builder', role: 'agent' }, + success: true, + duration: '8m12s', + turns: 7, + summary: '协作进度 78% · Builder 完成 · Reviewer 复核中。', + }, +];