fix(detail): 源码注释不再渲染成页面文字,并补一条有敏感性证明的回归守卫
上一笔(d9f9ee77)为了修「注释占了 ternary 分支根位导致 Turpock 报
`Expected '</', got 'ident'`」,把 solution-detail-content-v3.tsx 的两处解释性注释
从分支根位挪进了 JSX children —— 但没包 `{/* … */}`,于是它们是**文字节点**:
<div className="w-14 h-px bg-brand" />
/* tracking-[0.4em] 是记档外的裸字面量… */ ← 读者在 /solutions/* 页面上看得见
<span className="text-xs tracking-widest …">Solutions</span>
位置 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**。
This commit is contained in:
1 parent
ffc43fdeb7
commit
c2f4beecbe
2 files changed
+28
-5
No files matched your search
@@ -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(<SolutionDetailContentV3 solution={baseSolution} />);
|
||||
|
||||
// 敏感性证明: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(/\*\//);
|
||||
});
|
||||
});
|
||||
@@ -169,8 +169,8 @@ function SolutionsSection({ solutions }: SolutionsSectionProps) {
|
||||
<SectionLabel className="justify-center">
|
||||
<div className="flex items-center gap-5">
|
||||
<div className="w-14 h-px bg-brand" />
|
||||
/* tracking-[0.4em] 是记档外的裸字面量(--letter-spacing-widest = 0.12em);
|
||||
近单色对标的按钮/eyebrow 实测 letterSpacing: normal。收到记档里。 */
|
||||
{/* tracking-[0.4em] 是记档外的裸字面量(--letter-spacing-widest = 0.12em);
|
||||
近单色对标的按钮/eyebrow 实测 letterSpacing: normal。收到记档里。 */}
|
||||
<span className="text-xs tracking-widest uppercase font-bold text-brand-ink">
|
||||
Solutions
|
||||
</span>
|
||||
@@ -315,9 +315,9 @@ function SuiteCombinationSection({ suiteCombination, products }: SuiteCombinatio
|
||||
</StaggerReveal>
|
||||
|
||||
<ScrollReveal delay={0.2} className="flex items-center justify-center lg:col-span-1 bg-bg-elevated">
|
||||
/* 装饰圆改方角牌:rounded-full 只留给功能性的圆(头像/开关钮/滑块),
|
||||
这是套件组合图的中心节点装饰,两家对标实测都没有装饰性圆形 */
|
||||
<div className="w-20 h-20 rounded-cta bg-brand-soft border border-border-rule flex items-center justify-center text-brand-ink font-bold text-xl">
|
||||
{/* 装饰圆改方角牌:rounded-full 只留给功能性的圆(头像/开关钮/滑块),
|
||||
这是套件组合图的中心节点装饰,两家对标实测都没有装饰性圆形 */}
|
||||
<div className="w-20 h-20 rounded-cta bg-brand-soft border border-border-rule flex items-center justify-center text-brand-ink font-bold text-xl">
|
||||
+
|
||||
</div>
|
||||
</ScrollReveal>
|
||||
|
||||
Reference in new issue
Block a user