fix(cms): resolve admin dogfood findings on auth, content editing, and UX

修复 CMS / Admin 后台 dogfood 专项测试发现的阻塞性与体验性问题:
- 登录后无限重定向(Secure Cookie + Edge Runtime JWT 兼容)
- 内容新增/编辑保存 400/500(默认不加密请求体、自动生成唯一 slug)
- 编辑时提交 status 导致验证错误
- 原生 confirm 阻塞自动化测试,改为 AlertDialog
- 表单字段可访问性(id/htmlFor/fieldset)
- JSON 数组标签字段新增 TagInput 组件
- 操作反馈统一使用 Sonner Toast
- 后台隐藏营销 Cookie 横幅
- 媒体库空状态优化

添加 dogfood-cms-regression 与 dogfood-cms-output 报告、截图及工作流路由测试。
This commit is contained in:
张翔
2026-07-25 08:03:06 +08:00
parent f6f5766bb9
commit d9c0e5f2c1
48 changed files with 1445 additions and 106 deletions
+69
View File
@@ -0,0 +1,69 @@
# Dogfood Report: Novalon CMS / Admin 后台修复后回归测试
| Field | Value |
|-------|-------|
| **Date** | 2026-07-25 |
| **App URL** | http://localhost:3000 |
| **Session** | novalon-cms-regression |
| **Scope** | CMS / Admin 后台核心流程:登录、内容(新闻)CRUD、页面区域配置、媒体库、角色权限、退出登录 |
## Summary
本次回归测试基于 CMS 专项 dogfood 发现的 2 个阻塞性问题 + 5 个体验性问题修复后进行,验证所有修复项是否生效、核心管理流程是否可正常使用。
| Severity | Count |
|----------|-------|
| Critical | 0 |
| High | 0 |
| Medium | 0 |
| Low | 0 |
| **Total** | **0** |
## Regression Checklist
| # | Step | Expected | Result | Screenshot |
|---|------|----------|--------|------------|
| 1 | 访问 `/admin/login` | 登录页正常加载,无营销 Cookie 横幅 | ✅ 通过 | [01-login-page.png](screenshots/01-login-page.png) |
| 2 | 使用 admin / admin123 登录 | 登录成功并跳转仪表盘 | ✅ 通过 | [02-dashboard.png](screenshots/02-dashboard.png) |
| 3 | 进入新闻资讯列表 | 列表加载正常 | ✅ 通过 | [03-news-list.png](screenshots/03-news-list.png) |
| 4 | 点击新增新闻并填写表单 | 创建表单加载,字段标签可访问 | ✅ 通过 | [04-news-create-form.png](screenshots/04-news-create-form.png) |
| 5 | 提交创建 | 显示成功 Toast,无 400/500 | ✅ 通过 | [05-news-create-success.png](screenshots/05-news-create-success.png) |
| 6 | 返回列表查看新创建记录 | 列表中出现新记录 | ✅ 通过 | [06-news-after-save-eval.png](screenshots/06-news-after-save-eval.png) |
| 7 | 搜索新闻标题 | 搜索结果正确 | ✅ 通过 | [07-news-search.png](screenshots/07-news-search.png) |
| 8 | 编辑新闻标题 | 编辑表单加载,字段标签可访问 | ✅ 通过 | [08-news-edit-form.png](screenshots/08-news-edit-form.png) |
| 9 | 保存第一次编辑 | 显示保存成功 Toast | ✅ 通过 | [09-news-edit-success.png](screenshots/09-news-edit-success.png) |
| 10 | 再次编辑标题 | 列表与编辑页数据一致 | ✅ 通过 | [10-news-edit-success-2.png](screenshots/10-news-edit-success-2.png) |
| 11 | 打开删除确认对话框 | 显示自定义 AlertDialog(非原生 confirm | ✅ 通过 | [11-news-delete-dialog.png](screenshots/11-news-delete-dialog.png) |
| 12 | 确认删除 | 删除成功并显示 Toast,列表无该记录 | ✅ 通过 | [12-news-delete-success.png](screenshots/12-news-delete-success.png) |
| 13 | 进入页面区域配置 | 区域列表加载正常 | ✅ 通过 | [13-zones-page.png](screenshots/13-zones-page.png) |
| 14 | 点击编辑首页 Hero Banner | 编辑抽屉/表单打开 | ✅ 通过 | [14-zones-edit.png](screenshots/14-zones-edit.png) / [15-zones-edit-form.png](screenshots/15-zones-edit-form.png) |
| 15 | 保存区域配置 | 显示保存成功 Toast | ✅ 通过 | [16-zones-save-success.png](screenshots/16-zones-save-success.png) |
| 16 | 进入媒体库 | 空状态提示友好,提供上传入口 | ✅ 通过 | [17-media-empty.png](screenshots/17-media-empty.png) |
| 17 | 进入角色权限页 | 权限矩阵加载正常 | ✅ 通过 | [18-roles-page.png](screenshots/18-roles-page.png) |
| 18 | 保存权限配置 | 显示保存成功 Toast | ✅ 通过 | [19-roles-save-success.png](screenshots/19-roles-save-success.png) |
| 19 | 退出登录 | 成功退出并返回登录页 | ✅ 通过 | [20-logout.png](screenshots/20-logout.png) |
## Issues
未发现新问题。
## 修复验证说明
| 原问题 | 修复点 | 回归验证结果 |
|--------|--------|--------------|
| 登录后无限重定向回登录页 | `src/lib/auth.ts` 根据请求协议动态设置 `Secure` Cookie`src/middleware.ts` 改用 Web Crypto API 兼容 Edge Runtime | ✅ 登录成功并正常跳转 |
| 内容新增/编辑保存 400 | `src/lib/admin-api.ts` 默认不加密请求体,仅显式 `encrypt: true` 时加密 | ✅ 创建/编辑均保存成功 |
| 内容创建 500slug 冲突) | `src/app/api/admin/items/route.ts` 自动生成唯一 slug | ✅ 创建成功 |
| 编辑时提交 status 导致错误 | 编辑请求移除 `status` 字段 | ✅ 编辑保存成功 |
| 删除使用原生 confirm 阻塞自动化 | `src/app/admin/content/[modelCode]/page.tsx` 改用 AlertDialog | ✅ 可正常删除 |
| 表单字段可访问性不足 | `src/app/admin/content/[modelCode]/[itemId]/page.tsx` 添加 id/htmlFor/fieldset | ✅ 表单结构正确 |
| 标签字段渲染异常 | 新增 `TagInput` 组件处理 JSON 数组字段 | ✅ 标签输入正常 |
| 操作无 Toast 反馈 | 编辑/区域/角色/媒体库页面统一使用 Sonner toast | ✅ 保存/删除均有反馈 |
| 后台显示营销 Cookie 横幅 | `CookieConsent.tsx` 判断 `/admin` 路由并隐藏 | ✅ 登录页无横幅 |
| 媒体库空状态简陋 | `src/app/admin/media/page.tsx` 优化空状态设计 | ✅ 空状态友好 |
## Console / Network Notes
- 测试期间 API 响应正常:登录、内容 CRUD、区域保存、权限保存均返回 200/201。
- 未观察到阻断性控制台错误。
- 仅出现 Next.js 开发模式提示:`Detected scroll-behavior: smooth`,属于非阻断性开发提示。
Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 101 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 63 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 70 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 65 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 57 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 80 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 58 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 100 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 94 KiB