Tests for wait_for_change handler validation, the wgc path and text mode

未关闭
#350 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
3/5
预计耗时
1-2 天
新手友好度
76/100
Issue 类型
功能
描述清晰度
描述清楚
活跃度
活跃
技术栈
typescript
领域
testing

调研方向

Read src/tools/waitForChange.ts and the existing mocking pattern in startRecording.test.ts:45-54; run npm test to see the current test setup. Add handler tests for the validation, WGC, text mode, cleanup, keep, and cancellation cases listed in the issue, using mocked capture helpers. Done when those cases pass without relying on a live screen.

由索引模型根据 Issue 内容生成。

描述

effort: medium help wanted priority: medium testing

Summary

The loops behind wait_for_change are unit-tested, but the handler that wires them runs only in the capture smoke and the opt-in local test. toolLayer.test.ts skips it because it polls a live screen. Local coverage: 32.4% lines / 26.5% branches.

Where

  • src/tools/waitForChange.ts:108-110 (mode/text mismatch), :118 (wgc needs one window), :138-147 (wgc size probe and temp-dir cleanup), :184-203 (text mode, gone), :219-223 (finally cleanup), :239-252 (keep/returnImage/cancelled)
  • src/__tests__/integration/toolLayer.test.ts:45

Impact

wait_for_change is the recommended replacement for sleeps in agent flows. A wrong elapsedSec, a leaked screencast-wait-* temp dir, or a broken text mode would not be caught on any CI leg except by the flaky Windows smoke.

Suggested fix

Handler tests with runFfmpegFrames, captureStill, readFrames and resolveCaptureTarget mocked (vi.mock, as in startRecording.test.ts:45-54):

  • mode "text" without text, and text without mode: isError with the "Use text with mode" message.
  • backend "wgc" with target "full": isError "watches one window".
  • wgc first still probes to 0x0: isError, and no screencast-wait-* dir left in tmpdir.
  • mode text, OCR finds the text: outcome "met" with matches; with gone: true: gone: true.
  • grab throws mid-loop: isError, stream aborted, work dir removed.
  • keep:true: screenshotPath exists; keep:false: the temp shot is removed; cancelled: no image.

Getting started

  • Relevant files: src/tools/waitForChange.ts, src/utils/waitLoop.ts
  • How to run tests: npm test

Filed by repo-audit/full-audit at b9b94fa. Severity: medium. Effort: M. audit-key: testing|src/tools/waitForChange.ts|register

主要语言
TypeScript
星标
1
派生
4
平均合并
14 小时 8 分钟
30 天内合并 PR
48

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

TMHSDigital/screencast-mcp 的其他 Issue

查看 TMHSDigital/screencast-mcp 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。