Peach: Local-first video metadata scraper and media manager.
ci(web): 串行运行共享服务的浏览器用例
longmeidao63d77031b853
diff --git a/frontend/package.json b/frontend/package.jsonindex 336c21c01..374dd136a 100644--- a/frontend/package.json+++ b/frontend/package.json@@ -13,7 +13,7 @@"lint": "oxlint -c .oxlintrc.json src/react","test": "vitest run","test:watch": "vitest",- "e2e": "node --test --test-reporter=tap \"e2e/**/*.test.ts\""+ "e2e": "node --test --test-concurrency=1 --test-reporter=tap \"e2e/**/*.test.ts\""},"dependencies": {"@remixicon/react": "4.9.0",diff --git a/tests/test_web_e2e.py b/tests/test_web_e2e.pyindex 814200c56..dc6f2b56e 100644--- a/tests/test_web_e2e.py+++ b/tests/test_web_e2e.py@@ -17,6 +17,7 @@ CI(`GITHUB_ACTIONS=true`)判失败,与 vitest 同一口径;浏览器不from __future__ import annotationsimport importlib.util+import jsonimport osimport shutilimport socket@@ -86,13 +87,12 @@ def refuse_network(*args, **kwargs):raise AssertionError("演示库的 process 不应向任何外部来源发请求")-def e2e_command(npm: str, node: str, concurrency: str = "") -> list[str]:- """资源受限运行可串行两个 Node 测试文件;日常与 CI 仍走 package script。"""- if not concurrency:- return [npm, "--prefix", str(FRONTEND), "run", "e2e", "--silent"]- if not concurrency.isdecimal() or int(concurrency) < 1:+def e2e_command(_npm: str, node: str, concurrency: str = "") -> list[str]:+ """两个文件共用服务;直接启动 Node 也省掉资源守卫内的一层 npm 进程。"""+ selected = concurrency or "1"+ if not selected.isdecimal() or int(selected) < 1:raise AssertionError("PEACH_E2E_CONCURRENCY 必须是正整数")- return [node, "--test", f"--test-concurrency={int(concurrency)}",+ return [node, "--test", f"--test-concurrency={int(selected)}","--test-reporter=tap", "e2e/**/*.test.ts"]@@ -265,13 +265,21 @@ class MissingPrerequisiteTests(unittest.TestCase):with self.assertRaises(unittest.SkipTest):missing_prerequisite("没有 npm")- def test_resource_limited_e2e_places_concurrency_before_the_test_glob(self):+ def test_e2e_files_share_one_server_and_run_serially(self):+ manifest = json.loads((FRONTEND / "package.json").read_text(encoding="utf-8"))+ self.assertEqual(+ manifest["scripts"]["e2e"],+ 'node --test --test-concurrency=1 --test-reporter=tap "e2e/**/*.test.ts"',+ )++ def test_e2e_command_serializes_by_default_and_places_the_override_before_the_glob(self):self.assertEqual(e2e_command("npm", "node", "1"), ["node", "--test", "--test-concurrency=1", "--test-reporter=tap","e2e/**/*.test.ts",])self.assertEqual(e2e_command("npm", "node"), [- "npm", "--prefix", str(FRONTEND), "run", "e2e", "--silent",+ "node", "--test", "--test-concurrency=1", "--test-reporter=tap",+ "e2e/**/*.test.ts",])with self.assertRaisesRegex(AssertionError, "必须是正整数"):e2e_command("npm", "node", "0")