feat(e2e): Playwright E2E 前端测试基建 — 后端合成数据 mock 模式 + 5 用例 + CI

- web/e2e_mock.py:EASY_TDX_E2E_MOCK=1 时 lifespan 替换 TDX/MAC 客户端为
  确定性合成数据(CRC32 播种随机游走,分页语义对齐真实 /bars);回测/WF/
  评估/自选/策略库仍走真实后端,SSE 由 QuoteStreamer 真轮询(mock 下 2s 一拍)
- web-ui:@playwright/test + playwright.config.ts(webServer 自动起 serve,
  EASY_TDX_CONFIG_DIR 指向每轮临时目录);e2e/ 5 用例覆盖看板五指数/SSE、
  自选增删、回测全流程、附加分析(WF 柱状图+一条龙评估卡)、策略库保存
- package.json 加 test:e2e;CI frontend job 追加 E2E;verify_ci.sh 补前端段
- tests/unit/test_e2e_mock.py(11 例)守护 mock 契约;本地 npx playwright test 全绿
This commit is contained in:
GitHub
2026-09-01 22:56:38 +08:00
parent 6b67885588
commit 211052f0e3
15 changed files with 1042 additions and 18 deletions
+22 -5
View File
@@ -1,8 +1,9 @@
#!/usr/bin/env bash
# easy-tdx 一键本地门禁(等价 CI 的质量检查,v1.27 新增)。
# easy-tdx 一键本地门禁(等价 CI 的质量检查,v1.27 新增v1.28 补前端 E2E)。
#
# 用法:bash scripts/verify_ci.sh [--fast]
# --fast 跳过全量测试(只跑 ruff + mypy + 格式检查)
# 用法:bash scripts/verify_ci.sh [--fast] [--no-frontend]
# --fast 跳过全量测试与前端(只跑 ruff + mypy + 格式检查)
# --no-frontend 跳过前端 typecheck+build+E2E(只跑 Python 侧)
#
# 可选安装为 git hookpre-push):
# ln -s ../../scripts/verify_ci.sh .git/hooks/pre-push
@@ -19,7 +20,13 @@ if [ ! -f "$PY" ]; then
fi
FAST=0
[ "${1:-}" = "--fast" ] && FAST=1
NO_FRONTEND=0
for arg in "$@"; do
case "$arg" in
--fast) FAST=1 ;;
--no-frontend) NO_FRONTEND=1 ;;
esac
done
echo "── ruff check ──────────────────────────────────────────"
"$PY" -m ruff check src/ tests/
@@ -31,7 +38,7 @@ echo "── mypy --strict ─────────────────
"$PY" -m mypy src/easy_tdx/
if [ "$FAST" = "1" ]; then
echo "── 跳过测试(--fast)───────────────────────────────────"
echo "── 跳过测试与前端(--fast)─────────────────────────────"
echo "✓ verify_ci (fast) 全部通过"
exit 0
fi
@@ -39,5 +46,15 @@ fi
echo "── pytest(全量单元测试)────────────────────────────────"
"$PY" -m pytest tests/ -q --ignore=tests/integration
if [ "$NO_FRONTEND" = "0" ] && [ -d web-ui/node_modules ]; then
echo "── 前端 typecheck + build ──────────────────────────────"
(cd web-ui && npm run build)
echo "── Playwright E2Emock 模式,无需真实行情)────────────"
(cd web-ui && npm run test:e2e)
else
echo "── 跳过前端(--no-frontend 或 web-ui/node_modules 缺失)─"
fi
echo ""
echo "✓ verify_ci 全部通过"