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:
@@ -18,7 +18,7 @@
|
|||||||
| `scripts/build.ps1` | 开发构建(cargo test + build --release + 校验) |
|
| `scripts/build.ps1` | 开发构建(cargo test + build --release + 校验) |
|
||||||
| `scripts/publish.ps1` | 用户手动发布到 Nutstore(Medium) |
|
| `scripts/publish.ps1` | 用户手动发布到 Nutstore(Medium) |
|
||||||
| `tests/smoke.ps1` | cargo test + 关联检查 + 可选隔离启动 |
|
| `tests/smoke.ps1` | cargo test + 关联检查 + 可选隔离启动 |
|
||||||
| `tests/ui-smoke.ps1` + `ui-smoke.mjs` | 发布前 UI 冒烟:CDP 断言页面渲染、截图、JSON 报告(需普通桌面 PowerShell + Node 21+) |
|
| `tests/ui-smoke.cmd` / `ui-smoke.ps1` + `ui-smoke.mjs` | 发布前 UI 冒烟:CDP 断言页面渲染、截图、JSON 报告(需普通桌面 PowerShell + Node 21+;`.cmd` 内部用 Bypass,适合 AllSigned 策略) |
|
||||||
| `tests/fixtures/` | 手工/冒烟用 Markdown 样例 |
|
| `tests/fixtures/` | 手工/冒烟用 Markdown 样例 |
|
||||||
| `reports/` | 验证记录(文本;截图放 `agent/tmp/`,不入库) |
|
| `reports/` | 验证记录(文本;截图放 `agent/tmp/`,不入库) |
|
||||||
| `notes/` | 草稿 |
|
| `notes/` | 草稿 |
|
||||||
|
|||||||
@@ -76,11 +76,13 @@ cargo fmt -- --check
|
|||||||
|
|
||||||
~~~powershell
|
~~~powershell
|
||||||
cd D:\Scripts\md-preview\AgentLowWorking
|
cd D:\Scripts\md-preview\AgentLowWorking
|
||||||
.\agent\tests\ui-smoke.ps1 # 开发构建 + code-samples.md
|
.\agent\tests\ui-smoke.cmd # 推荐:双击或从 cmd 运行,脚本内部用 Bypass
|
||||||
.\agent\tests\ui-smoke.ps1 -Expect home # 启动页
|
.\agent\tests\ui-smoke.ps1 # 若执行策略允许 .ps1
|
||||||
.\agent\tests\ui-smoke.ps1 -KeepOpen # 失败时留着窗口人工看
|
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`。
|
- 脚本用独立配置目录(`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`。
|
- mjs 通过 CDP 读取页面快照、断言(页面加载、`#preview` 有内容、`window.ipc` 桥、页面 API、标题/折叠按钮/代码高亮),再截图,写 `target/ui-test/ui-smoke.json` 与 `ui-smoke.png`。
|
||||||
- Agent 可以直接读这两个文件定位问题;失败时把 report 里的 checks 贴出来即可。
|
- Agent 可以直接读这两个文件定位问题;失败时把 report 里的 checks 贴出来即可。
|
||||||
|
|||||||
11
agent/tests/ui-smoke.cmd
Normal file
11
agent/tests/ui-smoke.cmd
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
@echo off
|
||||||
|
setlocal
|
||||||
|
rem Double-clickable wrapper: Windows PowerShell may refuse unsigned .ps1 files
|
||||||
|
rem (AllSigned policy). This runs the script with a process-scoped Bypass.
|
||||||
|
set "SCRIPT=%~dp0ui-smoke.ps1"
|
||||||
|
"%SystemRoot%\System32\WindowsPowerShell\v1.0\powershell.exe" -NoProfile -ExecutionPolicy Bypass -File "%SCRIPT%" %*
|
||||||
|
set "CODE=%ERRORLEVEL%"
|
||||||
|
if not "%CODE%"=="0" echo.&echo UI smoke exited with code %CODE%.
|
||||||
|
rem Keep the window open when launched without arguments (double-click).
|
||||||
|
if "%~1"=="" pause
|
||||||
|
exit /b %CODE%
|
||||||
Reference in New Issue
Block a user