Files
GitHub 211052f0e3 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 全绿
2026-09-01 22:56:38 +08:00

61 lines
2.2 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env bash
# easy-tdx 一键本地门禁(等价 CI 的质量检查,v1.27 新增;v1.28 补前端 E2E)。
#
# 用法: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
set -euo pipefail
cd "$(dirname "$0")/.."
PY="${PYTHON:-.venv/Scripts/python.exe}"
if [ ! -f "$PY" ]; then
PY="${PYTHON:-.venv/bin/python}"
fi
if [ ! -f "$PY" ]; then
PY="python"
fi
FAST=0
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/
echo "── ruff format --check ─────────────────────────────────"
"$PY" -m ruff format --check src/ tests/
echo "── mypy --strict ───────────────────────────────────────"
"$PY" -m mypy src/easy_tdx/
if [ "$FAST" = "1" ]; then
echo "── 跳过测试与前端(--fast)─────────────────────────────"
echo "✓ verify_ci (fast) 全部通过"
exit 0
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 全部通过"