From c2f4beecbe31a00aaf80238a48113c7bd22f5b1d Mon Sep 17 00:00:00 2001 From: zhangxiang Date: Sat, 17 Oct 2026 01:06:14 +0800 Subject: [PATCH] =?UTF-8?q?fix(detail):=20=E6=BA=90=E7=A0=81=E6=B3=A8?= =?UTF-8?q?=E9=87=8A=E4=B8=8D=E5=86=8D=E6=B8=B2=E6=9F=93=E6=88=90=E9=A1=B5?= =?UTF-8?q?=E9=9D=A2=E6=96=87=E5=AD=97=EF=BC=8C=E5=B9=B6=E8=A1=A5=E4=B8=80?= =?UTF-8?q?=E6=9D=A1=E6=9C=89=E6=95=8F=E6=84=9F=E6=80=A7=E8=AF=81=E6=98=8E?= =?UTF-8?q?=E7=9A=84=E5=9B=9E=E5=BD=92=E5=AE=88=E5=8D=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 上一笔(d9f9ee77)为了修「注释占了 ternary 分支根位导致 Turpock 报 `Expected ' /* tracking-[0.4em] 是记档外的裸字面量… */ ← 读者在 /solutions/* 页面上看得见 Solutions 位置 L171(eyebrow 区)与 L317(套件组合中心牌)。 为什么三道门禁全绿也没拦住(这才是本笔的重点): `npm run type-check` EXIT=0、`test:unit` 1747 例全通过、`npm run build` EXIT=0、 视觉基线也不认得它 —— **合法 JSX 的编译与测试成功,对「内容是否被正确渲染」这一维根本不敏感**。 唯一拦住它的是 ESLint `react/jsx-no-comment-textnodes`(severity=error,2 处 ⇒ EXIT=1), 而那个 EXIT=1 被我自己 `npm run lint | tail -6` 的管道吃掉成了 "LINT=0"。 本仓 memory 里已明写过「管道吞退出码」,同一轮仍复犯 ⇒ 见 §5.38, 现改为**重定向到文件再读 `$?`**:`✖ 83 problems (2 errors, 81 warnings)` 才是当时的真实读数。 守卫配了敏感性证明,不写空断言: - 先断言被污染的两段 DOM 确实渲染了(`Solutions` / `推荐产品组合` / `+`), 否则「找不到 `/*`」可能只是「那段根本没出现」—— 空断言当守卫是假绿的一种。 - 再断言 `container.textContent` 不含 `/*` 与 `*/`。 - **变异验证已执行**:把 L171 的注释改回裸文本节点 ⇒ 仅这一条转红、其余三条仍绿、EXIT=1; 还原 ⇒ 4 passed。读数见 `docs/acceptance/qa-tracker.md` §11.2 D-2。 复测:该 spec 4 passed / EXIT=0;`npx eslint <该文件>` EXIT=0; `npm run lint > /tmp/lint.txt 2>&1` ⇒ **EXIT=0,0 error / 81 warning**。 --- .../solution-detail-content-v3.test.tsx | 23 +++++++++++++++++++ .../solutions/solution-detail-content-v3.tsx | 10 ++++---- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/src/app/(marketing)/solutions/solution-detail-content-v3.test.tsx b/src/app/(marketing)/solutions/solution-detail-content-v3.test.tsx index 2f17952..ca7af17 100644 --- a/src/app/(marketing)/solutions/solution-detail-content-v3.test.tsx +++ b/src/app/(marketing)/solutions/solution-detail-content-v3.test.tsx @@ -140,4 +140,27 @@ describe('SolutionDetailContentV3 - L3 信任层三档策略', () => { expect(screen.getByText('ISO 27001')).toBeInTheDocument(); }); + + /** + * 回归守卫(本仓真实踩到,2026-10-17):把「为什么这样改」的注释直接写在 JSX 子节点位置 + * (`/* ... *\/` 而非 `{/* ... *\/}`)是**合法 JSX**,build 与 1746 例单测全绿, + * 但注释会作为文字节点渲染到页面上。ESLint 的 react/jsx-no-comment-textnodes 是唯一 + * 静态防线,而它被判绿是因为 `npm run lint | tail` 把 EXIT=1 吞成了 0 + * (管道吞退出码,见 docs/lessons-learned.md)。 + * + * 因此这条断言配了**敏感性证明**:先确认两个曾被污染的区域真的渲染了, + * 否则「找不到注释」可能只是「那段 DOM 根本没出现」—— 空断言当守卫是假绿的一种。 + */ + it('does not render source comments as page text (jsx-no-comment-textnodes regression)', () => { + const { container } = render(); + + // 敏感性证明:L164 SolutionsSection 的 eyebrow、L317 SuiteCombinationSection 的中心牌都在 + expect(screen.getByText('Solutions')).toBeInTheDocument(); + expect(screen.getByText('推荐产品组合')).toBeInTheDocument(); + expect(screen.getByText('+')).toBeInTheDocument(); + + // 被验的那一维 + expect(container.textContent).not.toMatch(/\/\*/); + expect(container.textContent).not.toMatch(/\*\//); + }); }); diff --git a/src/app/(marketing)/solutions/solution-detail-content-v3.tsx b/src/app/(marketing)/solutions/solution-detail-content-v3.tsx index e26f11c..fad1ae8 100644 --- a/src/app/(marketing)/solutions/solution-detail-content-v3.tsx +++ b/src/app/(marketing)/solutions/solution-detail-content-v3.tsx @@ -169,8 +169,8 @@ function SolutionsSection({ solutions }: SolutionsSectionProps) {
- /* tracking-[0.4em] 是记档外的裸字面量(--letter-spacing-widest = 0.12em); - 近单色对标的按钮/eyebrow 实测 letterSpacing: normal。收到记档里。 */ + {/* tracking-[0.4em] 是记档外的裸字面量(--letter-spacing-widest = 0.12em); + 近单色对标的按钮/eyebrow 实测 letterSpacing: normal。收到记档里。 */} Solutions @@ -315,9 +315,9 @@ function SuiteCombinationSection({ suiteCombination, products }: SuiteCombinatio - /* 装饰圆改方角牌:rounded-full 只留给功能性的圆(头像/开关钮/滑块), - 这是套件组合图的中心节点装饰,两家对标实测都没有装饰性圆形 */ -
+ {/* 装饰圆改方角牌:rounded-full 只留给功能性的圆(头像/开关钮/滑块), + 这是套件组合图的中心节点装饰,两家对标实测都没有装饰性圆形 */} +
+