test(phase-0): v1.1 验收契约预置(AC-7~12/16~19)与两处棘轮台账登记
后端 9 支 @Disabled 契约只引用现存签名(mvn -o test-compile rc=0),逐条
钉住审计 ✅ 缺口:清空全表删、每日档按 id 越权、出厂默认下匿名可写的
interrupted/upload、12 格共享执行器与拒绝即内联、心跳抢锁变 40902、
批查整实体与无优雅停机、PENDING 被 Math.min(4) 钉死永不终态、
视频详情 SQL 双转义、无 statement timeout、删除多写无事务、
深 OFFSET/ORDER BY RAND/心跳整行/菜单每请求重算、补检 WARN 风暴与无 MDC。
两前端 3 支用 { skip } 预置 AC-16/17/18(网络错误登出、全局兜底与脱敏
上报、单次 PUT 无分片、element-plus 回首屏、列表无竞态门)。
台账两处按官方口径重钉,非放宽:source-pin-ledger 用仓内
UPDATE_SOURCE_PIN_BASELINE=1 生成(含他人 3 支零钉子件记账);
SourceScanTest 点名台账 10→22 名/8→16 支,逐个出处写在注释里。
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
/**
|
||||
* AC-16/AC-17(后管侧,R7/S1-F2、S1-F3):全局错误兜底与可见上报、大文件断点续传。
|
||||
*
|
||||
* Pending Phase 4 激活(`node --test tests/*.test.ts` 认 `{ skip }`,与 tests/live/** 同一写法)。
|
||||
*
|
||||
* 现状(`docs/audit/稳定性与性能综合审计-2026-10-28.md` §3.4):
|
||||
* - **S1-F2** `src/main.ts` 只有 `createApp → use(pinia/router) → installElement → mount`,
|
||||
* 没有 `app.config.errorHandler`、没有 `window.onerror` / `unhandledrejection`:渲染崩了
|
||||
* 只剩白屏;用户端那份还有 20 条内存环,后管连一份留痕都没有。
|
||||
* - **S1-F3** `src/pages/records/workbench-client-api.ts` 的 93MB 安装包走单次 PUT 预签名,
|
||||
* 中断即从 0 重传;confirm 失败的对象清理也在同一条通道上。
|
||||
*
|
||||
* 组件形状按本树既有惯例用源码尺子钉(对齐用户端
|
||||
* `frontend-vue/tests/session-expired-signout.test.ts` 的口径:无挂载测试的组件层用源码判据)。
|
||||
*/
|
||||
import { test } from 'node:test'
|
||||
import assert from 'node:assert/strict'
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { dirname, resolve } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
|
||||
const here = dirname(fileURLToPath(import.meta.url))
|
||||
const root = resolve(here, '..')
|
||||
const read = (rel: string) => readFileSync(resolve(root, rel), 'utf-8')
|
||||
|
||||
const PENDING_ERROR = 'Pending Phase 4: AC-16 全局错误兜底与脱敏上报'
|
||||
const PENDING_UPLOAD = 'Pending Phase 4: AC-17 93MB 包分片续传与孤儿对象清理'
|
||||
|
||||
test('pending_ac16_admin_渲染异常必须有全局兜底', { skip: PENDING_ERROR }, () => {
|
||||
const main = read('src/main.ts')
|
||||
assert.match(main, /app\.config\.errorHandler\s*=/,
|
||||
'S1-F2:渲染期异常必须被 Vue 全局兜底接住,不能只进 console')
|
||||
assert.match(main, /addEventListener\(\s*['"]unhandledrejection['"]/,
|
||||
'未捕获 Promise 同样要兜底(后管列表请求都是 promise 链)')
|
||||
assert.match(main, /addEventListener\(\s*['"]error['"]/,
|
||||
'脚本级崩溃(window error)必须留痕')
|
||||
})
|
||||
|
||||
test('pending_ac16_admin_上报必须挂在入口且不带凭据', { skip: PENDING_ERROR }, () => {
|
||||
const main = read('src/main.ts')
|
||||
assert.match(main, /installGlobalError|registerGlobalError|setupGlobalError/,
|
||||
'兜底与上报必须挂在入口上(只写在页面里=有些页面崩了没人接)')
|
||||
|
||||
const candidates = ['src/shared/api/error-report.ts', 'src/shared/telemetry/error-report.ts',
|
||||
'src/shared/errors/client-report.ts']
|
||||
const source = candidates.map((rel) => {
|
||||
try {
|
||||
return read(rel)
|
||||
} catch {
|
||||
return ''
|
||||
}
|
||||
}).join('\n')
|
||||
assert.match(source, /sendBeacon|reportClientError/,
|
||||
'崩溃必须能上报服务端,否则线上白屏永远无现场')
|
||||
assert.doesNotMatch(source, /aiimage_auth_token|authorization/i,
|
||||
'上报里不许带令牌原文(凭据零容忍,与 AC-1 同一把尺)')
|
||||
})
|
||||
|
||||
test('pending_ac17_安装包必须分片续传并可观察进度', { skip: PENDING_UPLOAD }, () => {
|
||||
const api = read('src/pages/records/workbench-client-api.ts')
|
||||
assert.match(api, /partSize|uploadPart|createMultipartUpload|chunk/,
|
||||
'S1-F3:单次 PUT 一断就从 0 重来,必须改成分片/断点续传')
|
||||
assert.match(api, /onProgress|progress/, '93MB 上传必须有可见进度')
|
||||
})
|
||||
|
||||
test('pending_ac17_confirm失败必须清理对象', { skip: PENDING_UPLOAD }, () => {
|
||||
const api = read('src/pages/records/workbench-client-api.ts')
|
||||
assert.match(api, /confirm[\s\S]{0,400}(abort|deleteObject|cleanup|remove)/,
|
||||
'confirm 失败必须清对象(工作台包凭据零容忍:拒绝新包不等于旧对象已处置)')
|
||||
})
|
||||
Reference in New Issue
Block a user