test(phase-0): 确认基线全绿并预置迭代验收测试契约

This commit is contained in:
2026-10-31 01:14:39 +08:00
parent ffb043c24f
commit 5c283a79fc
7 changed files with 783 additions and 4 deletions
@@ -0,0 +1,43 @@
// AC-11(R4):后管版本/教程大档上传接线的「源码尺子」那一半。
//
// Pending Phase 4 激活。今天 `src/pages/records/version-api.ts` 与 `tutorial-api.ts`
// 都是 presign → 一次 PUT 直传(512MB 级也一样,蓝图 §1.2 R4 实读);本文件要求两条
// 路径接上既有 `/api/files/chunk/**` 分片通道(断点续传/按片重试)。
//
// 跑法:npm test(node --test tests/*.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 SKIP = 'Pending Phase 4: 断点续传大档接线(AC-11)'
const LARGE_UPLOAD_FILES = [
'src/pages/records/version-api.ts',
'src/pages/records/tutorial-api.ts',
]
test('后管版本/教程大档必须接分片通道', { skip: SKIP }, () => {
for (const file of LARGE_UPLOAD_FILES) {
const source = readFileSync(resolve(root, file), 'utf-8')
assert.match(
source,
/files\/chunk/,
`AC-11:${file} 仍是 presign 直传(512MB 断网从 0 重来,没有分片续传)`,
)
}
})
test('分片接线不得只落注释', { skip: SKIP }, () => {
for (const file of LARGE_UPLOAD_FILES) {
const source = readFileSync(resolve(root, file), 'utf-8')
const codeLines = source
.split('\n')
.filter((line) => !line.trim().startsWith('//') && !line.trim().startsWith('*'))
.join('\n')
assert.match(codeLines, /files\/chunk/, `AC-11:${file} 的分片引用只出现在注释里`)
}
})