test: add a CDP-based pre-release UI smoke harness

The DSH sandbox blocks named pipes, so Chromium/WebView2 cannot start inside
it (window renders white, msedgewebview2 exits immediately; Edge headless
fails with a Mojo platform-channel access-denied fatal). UI verification
therefore moves to a script the user runs from a normal desktop shell.

- agent/tests/ui-smoke.ps1: launches the built exe with an isolated config
  and --remote-debugging-port, waits for the port, runs the driver, closes.
- agent/tests/ui-smoke.mjs: connects over CDP, snapshots the page (preview
  content, headings, fold toggles, highlighted code, window.ipc bridge),
  saves a screenshot and a JSON report for the agent to read.
- The driver was validated against a mock CDP server; the real end-to-end run
  needs a desktop shell (sandbox cannot host WebView2).
This commit is contained in:
2026-11-04 15:15:24 +08:00
parent fadba614a8
commit 0b97bcb6dc
5 changed files with 360 additions and 1 deletions

View File

@@ -215,6 +215,7 @@ cargo test
- 架构拆分阶段 1(功能不变,`1115052`):`assets/page/{page.html,page.css,page.js}` 存页面;新增 `src/markdown.rs`(md→html 管线)、`src/page.rs`(页面组装,只填 `__MDP_*__` 占位符)、`src/escape.rs`(JS/HTML 转义)。`main.rs` 5535 → 3709 行;页面输出用 home/doc/startup 三组快照做 sha256 对比,逐字节一致。
- 架构拆分阶段 2(功能不变,2026-11-03 晚):新增 `src/config.rs`(路径/zoom/窗口几何/对话框);删除 macOS/Linux/Finder 扩展代码、非 Windows 分支和 `objc2` 依赖(仓库现在只能在 Windows 编译);测试模块移到文件末尾;`main.rs` 3709 → 2822 行。59 tests(删除死代码时移除 3 个平台专用测试)。
- 已决定、未实施:移除应用启动时的 HKCU 关联写入;`publish.ps1` 维持现状(继续写关联)。
- 发布前 UI 冒烟:`agent/tests/ui-smoke.ps1`(普通桌面 PowerShell;启动 CDP、断言页面渲染、截图、写 `target/ui-test/ui-smoke.json`)。DSH 沙箱禁止命名管道,WebView2/Chromium 在沙箱内无法启动(窗口白屏、`msedgewebview2.exe` 立即退出),所以这一项只能由用户手动跑。`ui-smoke.mjs` 已用 mock CDP 服务验证通过。
- 规则调整(`agent/AGENTS.md`):仓库内新增文件/拆模块不需要事先询问;bug 修复、重构、测试、文档可直接做(每项独立提交);只有仓库外修改、发布、新第三方库(>200 KB vendored 资源)和不变量变化需要先问。
- 下一步(讨论中,未动手):编辑区样式化——加粗、标题加粗加大、行内代码换字体。
- 技术前提:`<textarea>` 不支持字符级样式;改字号会改变软换行与光标位置,透明叠加层只适合“同字号”样式。