# Seed Verification Guide (Staging) ## Service Startup (Local) - Backend: `go run ./backend/main.go serve` (default `http://localhost:8080`). - Portal frontend: `npm -C frontend/portal install` then `npm -C frontend/portal run dev` (default `http://localhost:5174`, remote use `http://10.1.1.104:5174`). - Superadmin frontend: `npm -C frontend/superadmin install` then `npm -C frontend/superadmin run dev` (default `http://localhost:5173`, remote use `http://10.1.1.104:5173`). - Portal dev server proxies `/v1` to `http://localhost:8080` (`frontend/portal/vite.config.js`). - Superadmin dev server proxies `/super/v1` and `/v1` to `http://localhost:8080` (`frontend/superadmin/vite.config.mjs`). ## Chrome DevTools MCP - Chrome remote debugging已由远程机器启动,无需本机手动启动浏览器。 - Use MCP to connect at `http://10.1.1.104:9222` (SSH forwarded DevTools port). - Open target URLs via MCP and run page-level assertions (no API-level calls required). ## AI Auto-Handling Prereqs - **Seed 检查/执行** - DB 查询(示例):`SELECT COUNT(*) FROM tenants;` - 若结果为 0,执行 `go run ./backend/main.go seed` 后再继续。 - **tenantCode 获取** - DB 查询:`SELECT code FROM tenants ORDER BY id DESC LIMIT 1;` - 将结果注入到 Portal URL `/t/:tenantCode`。 - **清理浏览器存储** - 在 MCP 中执行脚本:清理 `localStorage` / `sessionStorage`,并清除 cookies。 - 示例:`chrome-devtools_evaluate_script` → `() => { localStorage.clear(); sessionStorage.clear(); document.cookie.split(';').forEach(c => document.cookie = c.replace(/^ +/, '').replace(/=.*/, '=;expires=' + new Date().toUTCString() + ';path=/')); }` ### MCP Example Flow (AI Guidance) 1. **Open Portal Home** - `chrome-devtools_new_page` → `http://10.1.1.104:5174/t/:tenantCode` - `chrome-devtools_wait_for` text: `探索戏曲` or page title 2. **Portal Login** - Navigate to `/t/:tenantCode/auth/login` - Tick checkbox `#terms` (required) - `chrome-devtools_fill` phone input with `13800138000` - Click `获取验证码`, wait for OTP step - `chrome-devtools_fill` OTP input with `1234` - Click `登录 / 注册` - `chrome-devtools_wait_for` text: `个人中心` or user nickname 3. **Verify Orders & Library** - Navigate to `/t/:tenantCode/me/orders` and assert at least 1 row - Navigate to `/t/:tenantCode/me/library` and assert at least 1 item 4. **Open Content Detail** - From home list, click the first content card - Assert detail page loads and cover/media is visible 5. **Superadmin Login** - `chrome-devtools_new_page` → `http://10.1.1.104:5173/super/auth/login` - Fill `#username` with `superadmin` and `#password1` with `superadmin123` - Click `Sign In` - Wait for dashboard cards or `Dashboard` text 6. **Superadmin Lists** - `/super/superadmin/orders` → verify flagged order badge - `/super/superadmin/finance` → verify ledger table row - `/super/superadmin/notifications` → verify template rows 7. **Console/Error Checks** - After each page, call `chrome-devtools_list_console_messages` and fail on `error` entries. - Use `chrome-devtools_take_snapshot` to locate table rows by text. ## Run Seed - Execute `go run ./backend/main.go seed`. - Ensure no panics; capture console output for troubleshooting. ## Data Validation (DB/Logs) - Users: verify `creator`, `test`, `superadmin`, `negative` exist in `users.username`. - Tenant: read `tenants.code` to obtain `tenantCode` (example: `SELECT code FROM tenants ORDER BY id DESC LIMIT 1;`). - Memberships: `tenant_users` includes `creator` as `tenant_admin`, `test` as `member`. - Orders: `orders` has `content_purchase` + `withdrawal`, plus flagged/reconciled records. - Ledger: `tenant_ledgers` has at least one row. - Templates: `notification_templates` contains order/audit/interaction types. ## Portal Smoke (Use tenantCode) - Tenant code: query DB (`SELECT code FROM tenants ORDER BY id DESC LIMIT 1;`), then open `http://10.1.1.104:5174/t/:tenantCode`.- Login: OTP is fixed to `1234` (see `backend/app/services/user.go`). - Home: `/t/:tenantCode` lists content. - Detail: open any content detail; cover and main asset render. - Login: sign in as `test` (phone `13800138000`, OTP `1234`) and open `/t/:tenantCode/me`. - Orders & Library: `/t/:tenantCode/me/orders` and `/t/:tenantCode/me/library` show data. - Likes/Favorites: content detail shows prefilled like/favorite; toggle to confirm. - Notifications: `/t/:tenantCode/me/notifications` shows unread items. ## Superadmin Smoke - Open `http://localhost:5173/super/auth/login`. - Login: `superadmin` / `superadmin123`. - Users: list includes `negative`; balance anomaly list returns result. - Orders: list includes flagged/reconciled and refund orders. - Withdrawals: list contains `created`/`paid`/`failed` statuses. - Finance: ledger list has data; order anomaly list returns missing paid/refund items. - Content/Reports: content list is populated; report list has pending item. - Templates: order/audit/interaction templates present. - System Configs: `site_name` and `support_email` present. ## Manual-Only Coverage - Upload flow (init/part/complete) requires real storage integration; seed only preloads assets.