Peach: Local-first video metadata scraper and media manager.
test(web): 独立运行路由冒烟并保存完整浏览器日志
longmeidao57e24fdf181b
diff --git a/.github/workflows/test.yml b/.github/workflows/test.ymlindex 7534ef954..7143e900f 100644--- a/.github/workflows/test.yml+++ b/.github/workflows/test.yml@@ -142,6 +142,13 @@ jobs:if: runner.os == 'Windows'shell: pwshrun: '& .\scripts\test.ps1 -Scope ${{ matrix.scope }} -Fresh -Base $env:BASE_SHA -ShardIndex ${{ matrix.shard_index }} -ShardCount ${{ matrix.shard_count }}'+ - name: 保存浏览器测试日志+ if: always() && runner.os == 'Windows' && matrix.scope != 'core'+ uses: actions/upload-artifact@v7+ with:+ name: browser-${{ matrix.python }}-${{ matrix.scope }}-${{ matrix.shard_index }}+ path: build/agent-verification/browser/*.tap+ if-no-files-found: ignore- name: 安装 macOS 依赖if: runner.os == 'macOS'shell: bash@@ -231,6 +238,13 @@ jobs:- name: 运行 web 域shell: pwshrun: '& .\scripts\test.ps1 -Scope web -Fresh'+ - name: 保存浏览器测试日志+ if: always()+ uses: actions/upload-artifact@v7+ with:+ name: browser-web+ path: build/agent-verification/browser/*.tap+ if-no-files-found: ignoreweb-vendor:name: 固定前端依赖diff --git a/docs/TESTING.md b/docs/TESTING.mdindex 4aa8b1b0f..818a9d195 100644--- a/docs/TESTING.md+++ b/docs/TESTING.md@@ -64,7 +64,7 @@ Dependabot 的 PR 一律在本地接管,不在网页上合:浏览器冒烟与设计决定断言(`tests/test_web_e2e.py`)由 `web-e2e` job 在 `windows-latest` 上执行 `web` 域。它装 Node 24、`frontend/node_modules`、ffmpeg,并经 `PEACH_E2E_CHROME` 指定 runner 自带的 Chrome。矩阵扩成全量(`plan` 输出的 `wide`)时,Windows 全量行本身就跑 `web` 域,这个 job 按条件跳过;`verified` 只在这种情况接受它的 skipped,别的 job 跳过照样算红。-浏览器用例分为设计检查和交互回归两批,每批限时 600 秒。两批及批内文件默认串行执行,覆盖 `frontend/e2e` 下全部 `*.test.ts`,包括子目录;任一批失败,整轮验证失败。+浏览器用例分为设计检查、交互回归和路由冒烟三批,每批限时 600 秒。各批及批内文件默认串行执行,覆盖 `frontend/e2e` 下全部 `*.test.ts`,包括子目录;任一批失败,整轮验证失败。完整 TAP 日志保存在 `build/agent-verification/browser/`,CI 在测试结束后上传该目录。需要外部前置条件(Node、ffmpeg、Chrome 等)的用例,本机缺条件时跳过,在 CI(`GITHUB_ACTIONS=true`)里判失败,判定集中在 `tests/support/conditions.py` 的 `missing_prerequisite`。所以 `python` 矩阵里 `core` 以外的行也装 Node,Windows 行另装 ffmpeg 与 Chrome。diff --git a/tests/test_web_e2e.py b/tests/test_web_e2e.pyindex 80aa1fabb..3cbfd4408 100644--- a/tests/test_web_e2e.py+++ b/tests/test_web_e2e.py@@ -100,14 +100,15 @@ def e2e_command(node: str, concurrency: str = "", files: tuple[str, ...] = ()) -def e2e_batches(frontend: Path) -> tuple[tuple[str, ...], ...]:- """设计检查与交互回归各占一批,所有文件串行执行,每批限时 600 秒。"""+ """设计检查、交互回归与路由冒烟各占一批,每批串行且限时 600 秒。"""files = tuple(sorted(path.relative_to(frontend).as_posix()for path in (frontend / "e2e").rglob("*.test.ts")))if not files:raise AssertionError("frontend/e2e 没有浏览器用例")design = tuple(path for path in files if path == "e2e/design.test.ts")- interactions = tuple(path for path in files if path not in design)- return tuple(batch for batch in (design, interactions) if batch)+ routes = tuple(path for path in files if path == "e2e/smoke.test.ts")+ interactions = tuple(path for path in files if path not in design + routes)+ return tuple(batch for batch in (design, interactions, routes) if batch)@windows_ledger_roots@@ -248,7 +249,10 @@ class WebE2ESmokeTests(unittest.TestCase):def test_every_route_holds_the_layout_and_runtime_invariants(self):env = dict(os.environ, PEACH_E2E_ORIGIN=self.origin, PEACH_E2E_ITEM=str(self.item),PEACH_E2E_CHROME=self.chrome)- for batch in e2e_batches(FRONTEND):+ log_root = ROOT / "build" / "agent-verification" / "browser"+ log_root.mkdir(parents=True, exist_ok=True)+ for index, batch in enumerate(e2e_batches(FRONTEND), 1):+ log_path = log_root / f"batch-{index}.tap"with self.subTest(files=batch):try:completed = subprocess.run(@@ -260,8 +264,10 @@ class WebE2ESmokeTests(unittest.TestCase):partial = expired.stdout or ""if isinstance(partial, bytes):partial = partial.decode("utf-8", errors="replace")- self.fail(f"本批 {E2E_SECONDS} 秒内没跑完,已输出:\n{partial[-4000:]}")+ log_path.write_text(partial, encoding="utf-8")+ self.fail(f"本批 {E2E_SECONDS} 秒内没跑完,完整日志:{log_path}\n{partial[-4000:]}")output = f"{completed.stdout}\n{completed.stderr}"+ log_path.write_text(output, encoding="utf-8")self.assertEqual(completed.returncode, 0, f"{output}\n--- serve.log ---\n{self._server_log()}")self.assertRegex(output, r"# pass [1-9]\d*", output)self.assertRegex(output, r"# fail 0\b", output)@@ -280,10 +286,11 @@ class MissingPrerequisiteTests(unittest.TestCase):path.touch()batches = e2e_batches(frontend)self.assertEqual(batches[0], ("e2e/design.test.ts",))+ self.assertEqual(batches[-1], ("e2e/smoke.test.ts",))flattened = tuple(path for batch in batches for path in batch)self.assertCountEqual(flattened, paths)self.assertEqual(len(flattened), len(set(flattened)))- self.assertEqual(e2e_command("node", files=batches[1])[-2:], list(batches[1]))+ self.assertEqual(e2e_command("node", files=batches[1])[-len(batches[1]):], list(batches[1]))def test_browser_batches_require_at_least_one_suite(self):with tempfile.TemporaryDirectory() as folder: