feat: T10 回归测试 Bug 修复与功能完善

修复 BUG-001 至 BUG-009 及 T10-1 至 T10-6 相关问题:
- 打卡积分显示与累加逻辑优化
- 食谱计算器 Tab 选中样式修复
- 食物百科列表图片与简介展示修复
- 食物详情页数据加载修复
- AI营养师差异化回复优化
- 健康知识/营养知识名称统一
- 饮食指南/科普文章详情页内容展示修复
- 帖子营养统计数据展示修复
- 社区帖子类型中文命名统一
- 帖子详情标签中文显示修复
- 食谱营养AI填充功能完善
- 食谱收藏/点赞功能修复

新增:
- ToolNutritionFillService 营养填充服务
- T10 回归测试用例 (Playwright)
- 知识文章数据 SQL 脚本

涉及模块:
- crmeb-common: VO/Request/Response 优化
- crmeb-service: 业务逻辑完善
- crmeb-front: API 接口扩展
- msh_single_uniapp: 前端页面修复
- tests/e2e: 回归测试用例
This commit is contained in:
2026-03-05 09:35:00 +08:00
parent 6f2dc27fbc
commit d8d2025543
44 changed files with 1536 additions and 165 deletions

View File

@@ -0,0 +1,73 @@
# T10 Full Regression Test Report
**Plan:** smooth-moseying-tiger · **Task:** T10 Full regression testing
**Date:** 2026-03-04
**Scope:** Verify all 6 fixes: post detail tag, post/recipe AI fill, recipe favorite, recipe like visual, knowledge navigation.
---
## Summary
| # | Issue | Test ID | Pass/Fail | Notes |
|---|--------|---------|-----------|--------|
| 1 | Post detail tag shows Chinese | T10-1 | *(run tests)* | Asserts `.meal-tag`/`.type-tag` has Chinese on post detail |
| 2 | Post nutrition AI fill works | T10-2 | *(run tests)* | Clicks "AI 补充营养", expects stats and no error |
| 3 | Recipe nutrition AI fill works | T10-3 | *(run tests)* | Recipe detail shows nutrition (API or AI fill) |
| 4 | Recipe favorite no error | T10-4 | *(run tests)* | Favorite button shows 已收藏/已取消收藏, no 操作失败 |
| 5 | Recipe like emoji changes visual | T10-5 | *(run tests)* | Like button emoji 🤍 ↔ ❤️ on click |
| 6 | Knowledge articles can navigate to detail | T10-6 | *(run tests)* | 科普文章 → first item → detail has content |
**To get pass/fail:** Run `./scripts/run-t10-regression.sh` or `npx playwright test tests/e2e/bug-regression.spec.ts --grep "T10"`, then set each row to PASS or FAIL from the test output.
---
## How to Run
**Prerequisites:** Frontend at `http://localhost:8080`, backend API at `http://127.0.0.1:20822`, logged-in test account (phone/password in spec).
```bash
cd /Users/apple/scott2026/msh-system
npx playwright test tests/e2e/bug-regression.spec.ts --grep "T10" --reporter=list
```
To run with HTML report:
```bash
npx playwright test tests/e2e/bug-regression.spec.ts --grep "T10" --reporter=html
npx playwright show-report tests/e2e/reports
```
---
## Test Descriptions
| # | Issue | What the test does |
|---|--------|---------------------|
| **1** | **Post detail tag shows Chinese** | Opens community → first post → checks `.meal-tag` / `.type-tag` contains Chinese (e.g. 早餐/午餐/晚餐/分享). |
| **2** | **Post nutrition AI fill works** | Opens a post detail; if "🤖 AI 补充营养" is visible, clicks it, waits ~8s; asserts no error and nutrition stats appear. |
| **3** | **Recipe nutrition AI fill works** | Opens recipe detail (from tool main or `recipe-detail?id=1`), waits for nutrition card; asserts nutrition values are present (from API or AI fill). |
| **4** | **Recipe favorite no error** | Opens recipe detail, clicks favorite (⭐) button; expects toast "已收藏" or "已取消收藏" and no "操作失败". |
| **5** | **Recipe like emoji changes visual** | Opens recipe detail, reads like button emoji (🤍/❤️), clicks like; asserts emoji or state changes. |
| **6** | **Knowledge articles can navigate to detail** | Goes to nutrition-knowledge → 科普文章 tab → clicks first article; asserts detail page has visible content. |
---
## After Running: Fill Pass/Fail
Replace **Run tests to fill** in the Summary table with **PASS** or **FAIL** per test, and add any Notes (e.g. timeout, missing data, API error).
Example:
| # | Issue | Test ID | Pass/Fail | Notes |
|---|--------|---------|-----------|--------|
| 1 | Post detail tag shows Chinese | T10-1 | PASS | |
| 2 | Post nutrition AI fill works | T10-2 | PASS | |
| ... | ... | ... | ... | ... |
---
## Related Existing Tests
- **TC-B07** Diet guide & science article detail content (same scope as item 6).
- **TC-B08** Post detail nutrition stats visible.
- **TC-B09** Community tabs and post type tags in Chinese (list page; T10-1 checks post *detail* page).

View File

@@ -0,0 +1,21 @@
-- T04: Check database for knowledge articles (v2_knowledge)
-- Run against your DB: mysql -u user -p your_db < docs/sql/check_knowledge_articles.sql
-- Or use API: GET /api/front/tool/knowledge/stats (returns total, byType, byStatus)
--
-- If (guide + article, published) counts are 0: run docs/sql/seed_v2_knowledge_guide_article.sql
-- If data exists but list click doesn't open detail: check front-end console for
-- [nutrition-knowledge] goToDetail logs (item keys, resolved id, navigate url).
SELECT 'v2_knowledge: total' AS report, COUNT(*) AS cnt FROM v2_knowledge;
SELECT type, status, COUNT(*) AS cnt
FROM v2_knowledge
GROUP BY type, status
ORDER BY type, status;
-- Published count by type (guide + article must be > 0 for list/click to work)
SELECT type, COUNT(*) AS cnt
FROM v2_knowledge
WHERE status = 'published'
GROUP BY type
ORDER BY type;

View File

@@ -0,0 +1,43 @@
-- T04/T05: Seed v2_knowledge with guide/article rows when none exist (status='published')
-- 1) Check first: run docs/sql/check_knowledge_articles.sql or GET /api/front/tool/knowledge/stats
-- 2) If (guide + article, published) counts are 0, run this once.
-- Usage: mysql -u user -p your_db < docs/sql/seed_v2_knowledge_guide_article.sql
-- Example (local): mysql -h 127.0.0.1 -u test_java -p test_java < docs/sql/seed_v2_knowledge_guide_article.sql
INSERT INTO `v2_knowledge` (
`title`, `content`, `summary`, `cover_image`, `type`, `category`,
`view_count`, `like_count`, `collect_count`, `share_count`, `status`,
`is_recommend`, `sort_order`, `published_at`
) VALUES
-- 饮食指南 (type=guide)
(
'慢性肾病饮食指南概述',
'<p>慢性肾病CKD患者需在医生或营养师指导下调整饮食以延缓病情、减少并发症。</p><p>基本原则:适量优质蛋白、控制钾磷钠、限水(必要时)、充足热量。</p>',
'CKD饮食基本原则优质蛋白、控钾磷钠、限水与充足热量。',
NULL, 'guide', '饮食指南', 0, 0, 0, 0, 'published', 1, 10, NOW()
),
(
'优质蛋白怎么选',
'<p>优质蛋白主要来自蛋、奶、瘦肉、鱼及大豆类。</p><p>非优质蛋白(如米面、部分豆类)需在总蛋白控制下搭配,避免加重肾脏负担。</p>',
'蛋奶瘦肉鱼及大豆为优质蛋白来源,需在总蛋白限量内合理选择。',
NULL, 'guide', '饮食指南', 0, 0, 0, 0, 'published', 1, 9, NOW()
),
(
'钾与磷的饮食控制要点',
'<p>高钾食物:香蕉、橙子、土豆、番茄、深色蔬菜等,需根据血钾水平限量和焯水去钾。</p><p>高磷食物:奶制品、坚果、动物内脏、全谷等,需配合磷结合剂与饮食控制。</p>',
'高钾高磷食物识别与限量、焯水去钾等实用要点。',
NULL, 'guide', '饮食指南', 0, 0, 0, 0, 'published', 1, 8, NOW()
),
-- 科普文章 (type=article)
(
'认识慢性肾病分期与营养',
'<p>CKD 15期营养重点不同早期注重预防与均衡中晚期需严格控蛋白、钾、磷、钠及液体。</p><p>定期复查并与营养师沟通,制定个体化饮食方案。</p>',
'各分期营养侧重点与个体化饮食方案简介。',
NULL, 'article', '科普', 0, 0, 0, 0, 'published', 1, 10, NOW()
),
(
'透析患者一日饮食安排建议',
'<p>透析日与非透析日可在营养师指导下微调蛋白与液体。</p><p>建议定时定量、少盐少油、适量优质蛋白,并注意钾磷控制。</p>',
'透析患者日常饮食安排与注意事项。',
NULL, 'article', '科普', 0, 0, 0, 0, 'published', 1, 9, NOW()
);