weli d470e2e95e fix(department-e2e): use waitFor for role selector to avoid race condition
Replace one-shot isVisible() with waitFor() to handle the timing gap
where the SPA route guard is still resolving roles asynchronously.
The role selector renders after the route guard's read() call completes,
and isVisible() may return false if called before that.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-03 07:57:54 +08:00
2026-04-26 22:25:11 +08:00

huike-e2e-moicen

针对 已部署music-room.moicen.com(或任意 HUIKE_FRONT_BASE_URL)跑 Playwright,不 clone huike-front、不起 Postgres、不编译 Rust。全栈本地 E2E 见 alchemy-studio/huike-e2e

本机

npm ci
npx playwright install chromium
npx playwright test

走代理安装(默认 http://localhost:7890):npm run install:with-proxy

可选:复制 .env.e2e.example.env.e2e。音乐房串号用例填 MOICEN_E2E_UNIONID;管理端 /tasks 用例填 MOICEN_ADMIN_USER / MOICEN_ADMIN_PASSWORD(见 example 内说明)。勿提交 .env.e2e

用例概览:

文件 内容
tests/smoke-http.spec.ts requestGET / 返回 HTML(网关 / TLS / 静态入口底线,不启浏览器)
tests/core-full-chain.spec.ts 访客:未登录访问 /course 被送回 / 且见访客占位;已登录:黄金路径(会话→深链→课程体系壳层→JWT 与机构闭环);可选 MOICEN_HEALTHCHECK_URL
tests/guest-onboarding.spec.ts 未登录:仅见「请返回微信小程序完成登录」,不出现已登录工作台
tests/home-shell.spec.ts #app、伪造 unionid 不白屏、page_path 净化
tests/logged-in-and-isolation.spec.ts 需 Secret:登录后非访客态;异主 unionid 剥离;多角色选身份后见「欢迎回来」(不校验姓名)
tests/org-multi-tenant.spec.ts 需 Secret:机构选择页可达且呈现机构列表 UI
tests/org-data-isolation.spec.ts 需 SecretCurrentOrgId 与 JWT current_org_id 一致;多机构时可切换机构并更新上下文;/course 课程体系列表不出现「请求失败」错误态
tests/admin-tasks.spec.ts MOICEN_ADMIN_USER / MOICEN_ADMIN_PASSWORD:管理端登录后打开 /tasks

未配置 MOICEN_E2E_UNIONID 时,logged-in-and-isolationorg-multi-tenantorg-data-isolation 内用例全部 skip。未配置管理端账号时,admin-tasks 内用例 skip。

GitHub Actions

Settings → Secrets → Actions 配置 MOICEN_E2E_UNIONID 即可。未配 unionid 时仅跑访客与壳层用例。

可选:在 Settings → Secrets and variables → Actions → Variables 配置 MOICEN_HEALTHCHECK_URL(完整 URL,返回 2xx),用于可选后端健康检查用例;未配置时该条自动 skip。

Playwright 成功后,CI 会 SSH 到 moicen(需 SecretsMOICEN_SSH_PRIVATE_KEYMOICEN_SSH_USERMOICEN_SSH_KNOWN_HOSTS),在机上执行 scripts/moicen-remote-readonly-check.shTS_DATABASE_URL 探库、redis-cli ping、tail htyprocOpenResty error.log。fork 仓库发起的 PR 不会跑该步(无 Secrets)。主机名固定 moicen.com(写在 workflow)。

workflow_dispatch 可改目标 base_url默认定时:每天 06:30 UTC(见 .github/workflows/playwright-music-room.yml)。

与 moicen 运维文档

浏览器联调、在 UC 库查 union_id 等:见团队内 plan_skills/moicen/moicen-music-room-browser-test-runbook.md(与 huiwing-migration / 运维仓同路径即可)。

S
Description
E2E tests for moicen music-room
Readme 264 KiB
Languages
TypeScript 98.4%
Shell 1.6%