Skip to content

test(workbench): add unit tests for workbench surface modules #140

@HayWolf

Description

@HayWolf

来源

PR #136 review 评估后续跟进项。工作台 UI 模块分解后将纯函数提取到独立文件,缺少对应的 Vitest 单元测试。

涉及的 review comments

#10 — runtime-thread-surface-helpers.ts:22 — 14 个纯函数无测试

建议覆盖:mapSnapshotHelperStatus 所有状态映射(running/requested/created/dispatching/waiting_tool_result -> running, completed/failed -> 对应状态)、getHelperElapsedSeconds NaN dates 和 finishedAt < startedAt、formatToolCallCount 单复数、formatHelperToolCounts 排序、applyHelperSnapshot null 字段。

#11 — runtime-thread-surface-state.ts:107 — 关键纯函数无测试

建议覆盖:mergeSnapshotTools(live-only tools、stale-state 保护、same-state fallback)、shouldCompleteThinkingPhase vs shouldFinalizeReasoningOnly 边界、compareTimelineEntries tie-breaking、mapSnapshotToolState 各 status 分支、deriveSelectedRunMode。

#12 — runtime-thread-surface-tools.tsx:63 — 工具展示逻辑无测试

建议覆盖:quoteShellValue(空字符串、safe chars、单引号)、buildGitCommand(所有 git_* 分支)、getReadToolPresentation(缺失 path、range label 计算)、getQueryToolPresentation(find vs search vs unknown)、normalizeSearchFilePatternLabel(glob 模式)、summarizeInlineText(80 chars 截断)。

#24 — runtime-thread-surface-diff.tsx:19 — buildDiffPreviewRows diff 解析器无测试

建议覆盖:单 hunk diff、多 hunk diff(行号连续性)、空输入、仅文件头(---/+++)、畸形 @@ header 回退到 line 0、buildPlainPreviewRows 空/多行内容。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions