The reader and the fact tables were siblings keyed by the same language, so React left the first edition's reader on screen and appended the new one. Distinct keys per sibling; whole-page switch test with real engine fact tables. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01N4f2nya58RoRu4yEmJgRGE
2.7 KiB
2.7 KiB
PROGRESS · 报告阅读页切换语言后正文不换 · 2026-09-30
任务书:
docs/tasks/TASK-report-language-switch-stale-20260930.md。产品 2026-09-30 说「请你执行」,由 Claude 直接执行。 分支codex/report-language-switch-stale-20260930,基线origin/staging=5604c11b(其中代码与已部署的da3ed2f3相同)。BUG-1126。
做了什么
| 任务 | 结果 |
|---|---|
| T1 去掉重复 key | personal-report-page.tsx:PersonalReportMarkdownView 的 key 改为 markdown-${shown},ReportFactTables 的 key 改为 facts-${shown},加一行注释。同一父级下的 ReportCalculationCharts 本来就没有 key,不受影响。 |
| T2 整页回归测试 | 新增 frontend/tests/report-language-switch-20260930.test.tsx,共 2 条:用 SidebarProvider 包住 PersonalReportPage 整页渲染,mock 的报告接口带真实引擎虚构盘 golden 的中英正文(report-reader-main-fictional-zh-pair.json / -en.json),以及由 report-density-fictional-engine.json 组装的中英核对表。修复前 2 条都失败(expected 1, actual 2:页面上有两份正文,React 报 Encountered two children with the same key);修复后通过。 |
| T3 记录 | BUG-1126 改为 resolved;CHANGELOG 加一条;docs/testing/report-english-edition-20260929.md 加第 10、11 步;任务板改状态。 |
测试的两处环境补丁(只在测试文件里):react-client-lifecycle-test-support 只在 window 上提供 requestAnimationFrame,懒渲染章节调用的是全局的,所以测试期间把它挂到全局上,结束后恢复;「无汉字」断言只检查 .personal-report-md-article,因为它旁边的「到底部」按钮属于应用外壳,按英文版决策 6 保持中文。
既有断言零改动。
验收数字(Linux,Node 22 /exec-daemon/node,本 worktree 自己 npm ci)
| 项 | 基线 | 交付 |
|---|---|---|
tsc --noEmit |
— | 0 错 |
npm run lint |
— | 0 error(126 warning,均为既有) |
npm test 总数 |
4487 | 4489(+2,按测试名比对只多了本单 2 条,没有消失的) |
| 失败 | 24 | 24,名单逐条一致(全是需要 Docker 的数据库 / 部署 / 备份套件,属环境缺口) |
cancelled |
0 | 0 |
next build |
— | 通过,/ 仍是 ○ Static |
首屏 gzip 没有测:改动只在 /reports/[reportId] 的客户端组件里,首页不引用这个组件,所以不影响首屏体积。
环境缺口
- 没有真实登录态:浏览器级走查留给产品,见
docs/testing/report-english-edition-20260929.md第 10、11 步。诊断阶段已在 staging 线上 JS 上复现缺陷(报告接口换成虚构盘数据),部署后用同一方法再核一次。