test: add a bypass wrapper for the UI smoke script

Windows PowerShell with an AllSigned policy refuses unsigned .ps1 files.
ui-smoke.cmd runs ui-smoke.ps1 with a process-scoped -ExecutionPolicy Bypass
(no system policy change) and keeps the window open when double-clicked.
This commit is contained in:
2026-11-04 17:12:32 +08:00
parent 590a9a016c
commit 2fc3f740ca
3 changed files with 17 additions and 4 deletions

View File

@@ -76,11 +76,13 @@ cargo fmt -- --check
~~~powershell
cd D:\Scripts\md-preview\AgentLowWorking
.\agent\tests\ui-smoke.ps1 # 开发构建 + code-samples.md
.\agent\tests\ui-smoke.ps1 -Expect home # 启动页
.\agent\tests\ui-smoke.ps1 -KeepOpen # 失败时留着窗口人工看
.\agent\tests\ui-smoke.cmd # 推荐:双击或从 cmd 运行,脚本内部用 Bypass
.\agent\tests\ui-smoke.ps1 # 若执行策略允许 .ps1
powershell -NoProfile -ExecutionPolicy Bypass -File .\agent\tests\ui-smoke.ps1
~~~
> 本机执行策略可能是 AllSigned:直接跑未签名 .ps1 会被拒绝,所以提供了 `.cmd` 包装(内部 `-ExecutionPolicy Bypass`,不修改系统策略)。
- 脚本用独立配置目录(`target\ui-test\config`)启动 exe,设置 `WEBVIEW2_ADDITIONAL_BROWSER_ARGUMENTS=--remote-debugging-port=9333`,等端口起来后调用 `agent/tests/ui-smoke.mjs`。
- mjs 通过 CDP 读取页面快照、断言(页面加载、`#preview` 有内容、`window.ipc` 桥、页面 API、标题/折叠按钮/代码高亮),再截图,写 `target/ui-test/ui-smoke.json` 与 `ui-smoke.png`。
- Agent 可以直接读这两个文件定位问题;失败时把 report 里的 checks 贴出来即可。