后端 overview 早已区分 known / unknown+empty_baseline / unknown 非空 / unreachable, 页面只判断 state === 'known',把"已证空"和"读不到"都写成"未知",并在两种情况下 都给出"建立目标权威基线"入口——而该接口对空目标返回 409 library_baseline_target_empty、对读不到的目标返回 503 library_baseline_unprobeable。 按后端真实契约做最小分类: - LibraryKnown 补 empty_baseline 与 unreachable 两个已存在的字段/状态; - 页面按四类分别呈现:known 显示生效版本+快照摘要;空目标写明"已读且为空/首次发布/ 写前仍生成完整预备份";非空缺权威版本才指向基线入口;不可读照实说读取失败; - baselineNeeded 从"非 known"收窄为"非空且无权威版本",不动授权、写闸、预备份、 容量与 worker 执行准入等任何后端检查,也不放宽后端的 409。 行为测试新增四类状态、空→不可读→空刷新不残留旧状态、空目标无候选时按钮禁用; 原"非 known 一律未知"的断言随文案更正。本地门禁 16 项 success (tests-web 498 passed,tsc -b 无错)。
This commit is contained in:
@@ -184,8 +184,9 @@ describe('ReleaseTargetsView(确认稿布局)', () => {
|
||||
it('未接入项显示“未接入/未知”,不用 0 / 无变化冒充', () => {
|
||||
const html = render()
|
||||
expect(html).toContain('生产当前')
|
||||
// 生产没有权威版本时必须写未知,不能拿测试快照顶替
|
||||
expect(html).toContain('未知(尚未建立权威版本)')
|
||||
// 生产没有权威版本时必须写"非空且尚无权威版本",不能拿测试快照顶替,
|
||||
// 也不能把所有非 known 一律写成"未知"(空目标与读不到是另外两类)。
|
||||
expect(html).toContain('目标非空,尚无权威版本')
|
||||
expect(html).toContain('尚无记录 · 生产与测试的文档级差异读取未接线')
|
||||
expect(html).toContain('未接入')
|
||||
})
|
||||
@@ -708,6 +709,124 @@ describe('ReleaseTargetsView(确认稿布局)', () => {
|
||||
})
|
||||
})
|
||||
|
||||
// 后端 /api/v1/library/overview 已经区分四类生产目标状态(library_flow.go unknownLibraryTarget、
|
||||
// library_baseline.go:81 的空目标 409)。页面此前只判断 state === 'known',于是"已证空"和
|
||||
// "读不到"都被写成"未知"、并给出必然 409 的"建立目标权威基线"入口。
|
||||
describe('生产目标四类状态:known / 空 / 非空 / 不可读', () => {
|
||||
const baseline = { canStart: true, pending: false, onStart: vi.fn() }
|
||||
const emptyTarget: LibraryOverview['production'] = {
|
||||
state: 'unknown',
|
||||
empty_baseline: true,
|
||||
reason: '生产目标可读且为空:本次是首次发布,写入前仍会生成完整预备份',
|
||||
}
|
||||
const nonEmptyTarget: LibraryOverview['production'] = {
|
||||
state: 'unknown',
|
||||
reason: '目标非空且尚无权威版本',
|
||||
}
|
||||
const unreadableTarget: LibraryOverview['production'] = {
|
||||
state: 'unreachable',
|
||||
reason: '无法读取目标整库状态:请检查目标连接后重试,不能据此判定空库或建立基线',
|
||||
}
|
||||
const knownTarget: LibraryOverview['production'] = {
|
||||
state: 'known',
|
||||
version: {
|
||||
id: 'v-known',
|
||||
kind: 'production_effective',
|
||||
snapshot_id: 'c'.repeat(64),
|
||||
version_label: '生效 20261030-01',
|
||||
source_job_id: 'libsync-known',
|
||||
evidence: {},
|
||||
created_by: 'admin',
|
||||
created_at: '2026-10-30T09:00:00Z',
|
||||
},
|
||||
}
|
||||
|
||||
it('空目标:写明"已读且为空/首次发布/写前仍预备份",且不给会 409 的建基线入口', () => {
|
||||
const html = render({
|
||||
baseline,
|
||||
overview: {
|
||||
...overview,
|
||||
production: emptyTarget,
|
||||
// 接口在空基线上不再给"建立基线"缺项(librarySyncGateWithGrant:657-661)
|
||||
gate: { sync_allowed: false, reasons: ['没有与目标快照匹配的有效发布授权'] },
|
||||
},
|
||||
})
|
||||
expect(html).toContain('目标已读且为空')
|
||||
expect(html).toContain('首次发布')
|
||||
expect(html).toContain('写前仍会生成完整预备份')
|
||||
// 页面不能把"已证空"写成未知,也不能引导去建一个必然被 409 拒绝的基线。
|
||||
expect(html).not.toContain('未知(尚未建立权威版本)')
|
||||
expect(html).not.toMatch(/建立目标权威基线(维护隔离)<\/button>/)
|
||||
})
|
||||
|
||||
it('非空且无生效版本:仍指向既有基线入口,不谎称空库', () => {
|
||||
const html = render({
|
||||
baseline,
|
||||
overview: {
|
||||
...overview,
|
||||
production: nonEmptyTarget,
|
||||
gate: {
|
||||
sync_allowed: false,
|
||||
reasons: [
|
||||
'目标非空且没有生效版本记录:先建立目标权威基线(维护隔离下捕获整库并逐类校验),或确认目标确实是空库',
|
||||
],
|
||||
},
|
||||
},
|
||||
})
|
||||
expect(html).toContain('目标非空')
|
||||
expect(html).toMatch(/建立目标权威基线(维护隔离)<\/button>/)
|
||||
expect(html).not.toContain('目标已读且为空')
|
||||
})
|
||||
|
||||
it('不可读:照实说读取失败,既不认定空也不认定非空,更不引导建基线', () => {
|
||||
const html = render({
|
||||
baseline,
|
||||
overview: {
|
||||
...overview,
|
||||
production: unreadableTarget,
|
||||
gate: { sync_allowed: false, reasons: [unreadableTarget.reason!] },
|
||||
},
|
||||
})
|
||||
expect(html).toContain('无法读取目标整库状态')
|
||||
expect(html).not.toContain('目标已读且为空')
|
||||
expect(html).not.toContain('目标非空')
|
||||
expect(html).not.toMatch(/建立目标权威基线(维护隔离)<\/button>/)
|
||||
})
|
||||
|
||||
it('known:显示权威生效版本与快照摘要,不再写未知', () => {
|
||||
const html = render({ baseline, overview: { ...overview, production: knownTarget } })
|
||||
expect(html).toContain('生效 20261030-01')
|
||||
expect(html).toContain(knownTarget.version!.snapshot_id.slice(0, 12))
|
||||
expect(html).not.toContain('未知(尚未建立权威版本)')
|
||||
expect(html).not.toMatch(/建立目标权威基线(维护隔离)<\/button>/)
|
||||
})
|
||||
|
||||
it('刷新后分类只由当前 overview 决定:空 → 不可读 → 空 不残留旧状态', () => {
|
||||
const seenEmpty = render({ baseline, overview: { ...overview, production: emptyTarget } })
|
||||
const seenUnreadable = render({ baseline, overview: { ...overview, production: unreadableTarget } })
|
||||
const recovered = render({ baseline, overview: { ...overview, production: emptyTarget } })
|
||||
expect(seenEmpty).toContain('目标已读且为空')
|
||||
expect(seenUnreadable).not.toContain('目标已读且为空')
|
||||
expect(seenUnreadable).toContain('无法读取目标整库状态')
|
||||
expect(recovered).toContain('目标已读且为空')
|
||||
expect(recovered).not.toContain('无法读取目标整库状态')
|
||||
})
|
||||
|
||||
it('空目标但没有测试封存:启动同步保持禁用并说明缺候选', () => {
|
||||
const html = render({
|
||||
baseline,
|
||||
overview: {
|
||||
...overview,
|
||||
production: emptyTarget,
|
||||
test_sealed: undefined,
|
||||
test_sealed_reason: '还没有该目标的测试封存',
|
||||
},
|
||||
})
|
||||
expect(html).toMatch(/<button[^>]*class="rel-primary"[^>]*disabled/)
|
||||
expect(html).toContain('尚无测试封存')
|
||||
})
|
||||
})
|
||||
|
||||
// E5:轮询必须覆盖"投递 → 终态读回"。
|
||||
// 旧实现只按封存队列的作业判断,于是点了同步/恢复/建立基线之后页面根本不刷新,
|
||||
// 看上去像"还没启动";要么反过来,一个失败作业被永远轮询下去。
|
||||
|
||||
Reference in New Issue
Block a user