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

@@ -0,0 +1,65 @@
#!/usr/bin/env bash
# §12 收尾验证车道(2026-10-17)
#
# 为什么写成脚本而不是逐条手敲:本仓反复栽在「取退出码的写法把闸吞掉」——
# `cmd | tail` 拿的是 tail 的状态,`A && B; echo $?` 会把 A 的红丢掉。
# 这里每条命令都单独重定向到文件、紧跟 `echo $?` 记进汇总,汇总就是证据。
#
# 用法:
# nohup bash docs/acceptance/2026-10-17-final/run-lane.sh > /tmp/12-lane.out 2>&1 &
# tail -f /tmp/12-lane-summary.txt
#
# 前提:先 `npm run build`(本脚本不代跑 build;E2E_TARGET=production 打的是
# dist/standalone/server.js,postbuild 须已装配 dist/static + public)。
# 端口:车道内所有步骤串行,避免与残留 server 抢 3000(本仓有「静默复用旧服务」的历史坑)。
set -u
cd "$(git rev-parse --show-toplevel)" || exit 1
LOGDIR=/tmp/12-lane
mkdir -p "$LOGDIR"
SUM=/tmp/12-lane-summary.txt
: > "$SUM"
step() {
local name="$1"; shift
local log="$LOGDIR/$name.log"
echo ">>> $name" | tee -a "$SUM"
"$@" > "$log" 2>&1
local code=$?
echo " $name EXIT=$code (log: $log)" | tee -a "$SUM"
}
# 装配自检:产物缺 dist/static 时,axe 会 bgMismatch 报红而 Lighthouse 仍错误 exit 0(§5.34)
if [ -d dist/standalone/dist/static ] && [ -d dist/standalone/public ]; then
echo " assembly OK (dist/static + public present)" | tee -a "$SUM"
else
echo " assembly MISSING -> 先 npm run build" | tee -a "$SUM"
exit 2
fi
step type-check npm run type-check
step lint npm run lint
step coverage npm run test:coverage
step integration-real npm run test:integration:real
step a11y npm run check:a11y
step visual-grammar npm run check:visual
step accents npm run check:accents
step dead npm run check:dead
step motion npm run check:motion
# GA4 那 16 例只在 production 目标下真断言:dev 下 GoogleAnalytics.tsx 提前 return null,
# 用例内 test.skip 触发 ⇒ 记为 skipped 而不是 passed(§5 表格的口径)。
step ga4-prod bash -c 'cd e2e && E2E_TARGET=production npx playwright test ga4-event-tracking.spec.ts --project=chromium --project=chromium-mobile --project=firefox --project=webkit'
step e2e-fast npm run test:e2e:fast
step security-headers npm run test:security:headers
step axe-routes npm run check:axe:routes
step axe npm run check:axe
step lighthouse npm run lighthouse
# 视觉只读比对(不写基线)。AUTH-VISUAL 的写入是单独动作,不在本车道内。
step visual-readonly bash -c 'cd e2e && npx playwright test visual-regression.spec.ts --update-snapshots=none'
echo "=== DONE ===" | tee -a "$SUM"
grep -c 'EXIT=0' "$SUM" | sed 's/^/green_steps=/' | tee -a "$SUM"
grep -c 'EXIT=[1-9]' "$SUM" | sed 's/^/nonzero_steps=/' | tee -a "$SUM"