# huike-e2e-moicen 项目指南 ## 项目结构 本仓库为 huike-music-room 前端 H5 的端到端(Playwright)测试套件。 兄弟目录: - `../huike-back/` — 后端(Rust/Diesel) - `../huike-front/` — 前端(Vue 3 SPA + Vant) ## 交流风格 - 使用中文 - 不道歉,不冗余收尾 - 引用代码时用真实文件路径 ## E2E 测试失败/跳过修复原则 当 E2E 测试出现 `failed` 或 `skipped` 时,**必须先判断是测试 outdated 还是 case 确实测出了 bug**,再决定修复方案: - **测试 outdated**(选择器不存在、UI 已变更、流程已改)→ 更新测试以匹配当前 UI/API 行为 - **真实 bug**(测试断言暴露了代码缺陷)→ 修复业务代码 - **数据依赖 skip**(无排课数据、无事件等)→ 保留动态 skip 逻辑,确保有数据时不跳过 - **会话 flake**(登录态丢失、机构页未渲染)→ 保留 skip 兜底,但检查是否有可改进的等待策略 不要盲目删除 failing test 或把 failing test 改成 skip。每条 skip/fail 都要有明确理由。 ## 自托管 Gitea 仓库地址:`ssh://git@ci.moicen.com:2222/weli/huike-e2e-moicen.git` | 用户 | Gitea 账号 | Repo 权限 | SSH 公钥 | |------|-----------|-----------|----------| | weli(我) | weli(admin) | 所有者 | `~/.ssh/id_rsa.moicen` | | xiaoli(小李) | xiaoli | write | RSA 4096(指纹 SHA256:YebA...) | | moicen / 木老师 | moicen | write | `ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIBocSvErIeT9+jugoah+8sga6v1kBArI8jqVpbvWYBPX moicen@foxmail.com` | SSH 连接服务器(部署用):`ssh -i ~/.ssh/id_rsa.moicen weli@101.43.244.164` ## 仓库迁移注意 - `authcore`(Firebase Auth Core)是**公开仓库**,不要托管到自托管 Gitea - huike-e2e-moicen、huike-front、huike-back、resty_functions 这 4 个仓库需要统一管理 GitHub ↔ Gitea 同步 ## 工具链 - 文本检索:`rg`(ripgrep) - E2E 测试:`npx playwright test` ## 本地执行 E2E 测试(先本地,再 CI) 推送前先在本机对 moicen 测试服执行 Playwright 测试,避免反复推送等 CI 结果: ```bash cd /Users/weli/works/huiwing-migration/huike-e2e-moicen # 执行指定测试文件 npx playwright test tests/clazz-ui.spec.ts --reporter=list # 执行全部测试 npx playwright test --reporter=list # 带 UI 调试模式 npx playwright test --ui ``` 测试通过后再 commit & push 触发远程 CI。 ## CI 工作流 ### 等待 CI 完成 使用 Monitor 工具配合 `gh run watch`,CI 完成后会自动通知: ```bash # 获取最新 CI run ID gh run list --repo alchemy-studio/huike-e2e-moicen --limit 1 --json databaseId --jq '.[0].databaseId' # Monitor 会自动通知每次状态刷新和最终完成 Monitor: command: gh run watch --repo alchemy-studio/huike-e2e-moicen 2>&1 | grep -E --line-buffered '(✓ master|✘ master|╳ master|X master)|Process completed' description: Watch CI run completion ``` 注意:**不要用 `Bash run_in_background` + `gh run watch`**,因为 Bash 后台任务不会在完成时通知,你会卡住等不到结果。必须用 **Monitor** 工具,它会在每行 stdout 输出时通知你。 也可以用 `gh run watch --job=` 监控特定 job。 `gh run watch` 依赖当前目录的 git remote 确定仓库,所以要在 `huike-e2e-moicen` 目录下跑,或者用 `--repo` 参数显式指定。 ### 两个 Workflow | Workflow | 环境 | 触发方式 | 测试范围 | |----------|------|----------|----------| | `music-room Playwright` | 测试服 (moicen.com) | push/PR 自动 + 手动 + 每日 06:30 UTC | 全部测试(含登录) | | `production Smoke` | 正式服 (huiwings.cn) | 手动触发 + 每日 05:00 UTC | 仅访客测试(`--grep-invert "已登录"`) |