feat(qa): DEC-N4 把授权与 basis 门槛下沉成共用闸,既有两处转化区块同闸

只有新成果槽有反伪造门槛,CaseStudiesSection 与 detail-trust-section 没有 ——
同一类主张走两套标准,等于门槛只在新增位置有效。

- 新增 src/lib/constants/case-publish-gate.ts:判据(授权 + ≥1 个 basis==='verified' +
  禁词扫描)下沉成一处实现,禁词/口径真源仍是 metrics-basis.ts;
  results-slot 的 casePublishBlockers 改为委托它 ⇒ 三处消费同一闸,无第二套真源。
- detail-case-studies-section / detail-trust-section 逐条过闸,被封条 console.error 喊出原因,
  全封或空 ⇒ return null(L3EmptyFallback 契约不变)。
- dataProofs 不套 verified 硬闸:它已在 weakestBasis + MetricsBasisNote 契约下且自述目标口径,
  硬清会误伤全站已标注数字(代码注释里写明理由)。
- 实测门槛下会隐藏的既有条目 = 0 条(seeds 里 caseStudies 全是空数组、
  CMS dev.db 11 条内容的 caseStudies 长度全为 0)⇒ 线上转化页无可见变化,
  这是前瞻性 fail-closed 加固,不是内容清洗。
- 转红的只有两处旧断言("未授权案例照常渲染"),按测试夹具补 authorized/basis 处理,
  并新增负例。⚠ CMS content-types 的 caseStudies schema 还没有这两个字段,
  业务要真出案例须先扩 schema —— 登记为残留。

仪器自证:把闸改成恒真(return [])⇒ EXIT=1、20 例转红(覆盖 gate 本体、results-slot 原有用例、
两区块负例、solution-detail 消费页);还原后 EXIT=0。
同批登记 §12.3 DEC-N3(判据从令牌声明移到消费点、8 条归零)与 §12.4(build 的 tsc 比 jest 严)。
读数:tsc EXIT=0、全量 jest 145 套件/1795 例 EXIT=0、check:visual EXIT=0、check:dead EXIT=0。
This commit is contained in:
zhangxiang committed 2026-10-17 07:51:24 +08:00
1 parent 20d5cd0943
commit 2e0099426f
12 files changed
+574 -23

No files matched your search

+58 -1
View File
@@ -208,7 +208,8 @@ const mockProduct = {
heroThemeId: 'erp',
bundle: 'enterprise' as const,
caseStudies: [
{ client: '某制造企业', industry: '制造业', challenge: '库存管理混乱', solution: '实施ERP系统', result: '库存周转率提升200%' },
// DEC-N4 同闸:卡片型案例必须带授权 + basis=verified 才渲染(门槛见 case-publish-gate)
{ client: '某制造企业', industry: '制造业', challenge: '库存管理混乱', solution: '实施ERP系统', result: '库存周转率提升200%', authorized: true, basis: 'verified' as const },
],
dataProofs: [
{ metric: '效率提升', value: '300%', description: '业务流程效率提升' },
@@ -492,6 +493,62 @@ describe('DetailTrustSection', () => {
expect(screen.getByTestId('case-client')).toHaveTextContent('某制造企业');
});
// ── DEC-N4 同闸:DetailTrustSection 案例块必须过与首页成果槽同一门槛 ──
describe('案例块反伪造门槛(DEC-N4 同闸)', () => {
const gated = mockProduct.caseStudies[0]!;
it('缺 basis(即便已授权)⇒ 成果主张整块不渲染,且原因被喊出来', async () => {
const { DetailTrustSection } = await import('./detail-trust-section');
const spy = jest.spyOn(console, 'error').mockImplementation(() => {});
const { container } = render(
<DetailTrustSection
caseStudies={[{ ...gated, basis: undefined }]}
certifications={mockProduct.certifications}
/>
);
expect(screen.queryByText('他们已经实现了转型突破')).not.toBeInTheDocument();
expect(screen.queryByTestId('case-study-card')).not.toBeInTheDocument();
expect(container.querySelector('[data-testid="detail-trust-case-studies"]')).not.toBeInTheDocument();
expect(spy).toHaveBeenCalledWith(expect.stringMatching(/basis === "verified"/));
spy.mockRestore();
});
it('未授权(authorized 不为 true,即便口径已 verified)⇒ 不渲染', async () => {
const { DetailTrustSection } = await import('./detail-trust-section');
const spy = jest.spyOn(console, 'error').mockImplementation(() => {});
render(
<DetailTrustSection
caseStudies={[{ ...gated, authorized: false }]}
certifications={mockProduct.certifications}
/>
);
expect(screen.queryByText('他们已经实现了转型突破')).not.toBeInTheDocument();
expect(spy).toHaveBeenCalledWith(expect.stringMatching(/未授权公开/));
spy.mockRestore();
});
it('授权 + verified 口径 ⇒ 渲染(正控制,防"闸恒真/恒假"两种假绿)', async () => {
const { DetailTrustSection } = await import('./detail-trust-section');
render(<DetailTrustSection caseStudies={[gated]} />);
expect(screen.getByText('他们已经实现了转型突破')).toBeInTheDocument();
expect(screen.getByTestId('detail-trust-case-studies')).toBeInTheDocument();
});
it('非 verified 口径(target / team-history)同样被闸住——闸要能拒绝"数字真、出处假"', async () => {
const { DetailTrustSection } = await import('./detail-trust-section');
const spy = jest.spyOn(console, 'error').mockImplementation(() => {});
render(
<DetailTrustSection
caseStudies={[{ ...gated, basis: 'team-history' }, { ...gated, client: '另一企业', basis: 'target' }]}
/>
);
expect(screen.queryByText('他们已经实现了转型突破')).not.toBeInTheDocument();
expect(screen.queryByTestId('case-study-card')).not.toBeInTheDocument();
expect(spy).toHaveBeenCalledWith(expect.stringMatching(/basis === "verified"/));
spy.mockRestore();
});
});
it('should render certifications', async () => {
const { DetailTrustSection } = await import('./detail-trust-section');
render(