发布页原来只有一个永远 disabled 的"启动同步",title 还写着"生产同步执行链 尚未接线"——执行链其实已经存在。现在: - 管理员看到"签发同步授权(30 分钟)"(action=sync,绑定范围+目标快照), 签发与执行仍是两步,不会自动签发; - 闸口全满足时"启动同步"真的按 POST /library/syncs 投递,被拒时逐条显示 接口返回的缺项; - 目标非空又无生效版本时,管理员看到"建立目标权威基线(维护隔离)"; - 测试封存候选改用接口给的 test_sealed(来自版本登记),不再拿归档里最新 一份顶替; - 维护卡片区分"未运行维护 / 维护能力未接线 / 能力未知",逐项列出缺的变量。 验证:vitest 99 个文件 469 个用例全绿,tsc --noEmit 无错;反向自检(把按钮 改回恒 disabled、把维护文案改回旧句)两处按预期变红后复原。
This commit is contained in:
@@ -92,7 +92,7 @@ const overview: LibraryOverview = {
|
||||
reasons: [
|
||||
'生产写入闸口关闭(PRODUCTION_RELEASE_REQUESTS_ENABLED=false)',
|
||||
'没有已核验的生产恢复演练证据(PRODUCTION_BACKUP_RESTORE_VERIFIED=false)',
|
||||
'生产当前权威版本未知,不能启动写入',
|
||||
'目标非空且没有生效版本记录:先建立目标权威基线(维护隔离下捕获整库并逐类校验),或确认目标确实是空库',
|
||||
'本次目标快照还没有生产预备份',
|
||||
],
|
||||
},
|
||||
@@ -150,6 +150,8 @@ const base: ViewProps = {
|
||||
canCapture: true,
|
||||
canWrite: true,
|
||||
canRestore: false,
|
||||
sync: { canSign: false, pendingGrant: false, onGrant: vi.fn(), canStart: false, pending: false, onStart: vi.fn() },
|
||||
baseline: { canStart: false, pending: false, onStart: vi.fn() },
|
||||
restore: null,
|
||||
restoreNotice: null,
|
||||
pendingRestore: false,
|
||||
@@ -173,7 +175,7 @@ describe('ReleaseTargetsView(确认稿布局)', () => {
|
||||
expect(html).toContain('对外知识库')
|
||||
expect(html).toContain('role="tab"')
|
||||
// 只显示一个主作业卡:选中库标题出现一次,另一个库不渲染作业卡
|
||||
expect(html.match(/· 已封存,生产同步未接入/g)?.length).toBe(1)
|
||||
expect(html.match(/· 已封存,同步按条件放行/g)?.length).toBe(1)
|
||||
expect(html).not.toContain('对外知识库 · 尚无')
|
||||
})
|
||||
|
||||
@@ -355,8 +357,92 @@ describe('ReleaseTargetsView(确认稿布局)', () => {
|
||||
})
|
||||
|
||||
it('无封存时给出“尚无封存”而不是空表', () => {
|
||||
const html = render({ page: { ...page, snapshots: [] } })
|
||||
// 归档没有快照时接口也不会给 test_sealed:两处必须一致,否则页面会把
|
||||
// 一个不存在的封存显示成"已封存"。
|
||||
const html = render({
|
||||
page: { ...page, snapshots: [] },
|
||||
overview: { ...overview, test_sealed: undefined, test_sealed_reason: '还没有该目标的测试封存' },
|
||||
})
|
||||
expect(html).toContain('尚无测试封存')
|
||||
expect(html).toContain('还没有测试库封存')
|
||||
})
|
||||
|
||||
it('管理员在缺同步授权时看到签发入口,工程师只看到“需管理员签发”', () => {
|
||||
const admin = render({
|
||||
sync: { canSign: true, pendingGrant: false, onGrant: vi.fn(), canStart: false, pending: false, onStart: vi.fn() },
|
||||
})
|
||||
expect(admin).toContain('签发同步授权(30 分钟)')
|
||||
// 授权入口不能顺手把执行也放行:闸口条件仍然逐条可见
|
||||
expect(admin).toContain('生产写入闸口关闭')
|
||||
const engineer = render()
|
||||
expect(engineer).not.toContain('签发同步授权')
|
||||
expect(engineer).toContain('同步授权只能由管理员按目标+快照签发')
|
||||
})
|
||||
|
||||
it('目标非空又没有权威版本时,管理员看到建立基线入口;有生效版本时不显示', () => {
|
||||
const admin = render({
|
||||
baseline: { canStart: true, pending: false, onStart: vi.fn() },
|
||||
})
|
||||
expect(admin).toContain('建立目标权威基线(维护隔离)')
|
||||
expect(admin).toContain('目标非空且没有生效版本记录')
|
||||
const known = render({
|
||||
baseline: { canStart: true, pending: false, onStart: vi.fn() },
|
||||
overview: {
|
||||
...overview,
|
||||
production: {
|
||||
state: 'known',
|
||||
version: {
|
||||
id: 'v1',
|
||||
kind: 'production_effective',
|
||||
snapshot_id: 'a'.repeat(64),
|
||||
version_label: '基线 abc',
|
||||
source_job_id: 'libbase-1',
|
||||
evidence: {},
|
||||
created_by: 'admin',
|
||||
created_at: '2026-10-29T09:00:00Z',
|
||||
},
|
||||
},
|
||||
},
|
||||
})
|
||||
// 有生效版本时不再提供基线入口(缺项说明文字里仍会提到它存在,所以只断言按钮)
|
||||
expect(known).not.toMatch(/建立目标权威基线(维护隔离)<\/button>/)
|
||||
})
|
||||
|
||||
it('闸口全满足时“启动同步”真的可点,并给出执行说明', () => {
|
||||
const html = render({
|
||||
sync: { canSign: false, pendingGrant: false, onGrant: vi.fn(), canStart: true, pending: false, onStart: vi.fn() },
|
||||
overview: { ...overview, gate: { sync_allowed: true, reasons: [] } },
|
||||
})
|
||||
expect(html).toMatch(/<button[^>]*class="rel-primary"[^>]*>▶ 启动同步/)
|
||||
expect(html).not.toMatch(/class="rel-primary"[^>]*disabled/)
|
||||
expect(html).toContain('先固定测试版本,再备份目标并写入')
|
||||
})
|
||||
|
||||
it('维护卡片区分“未运行维护”与“没有维护能力”', () => {
|
||||
const wired = render({
|
||||
maintenance: {
|
||||
held: false,
|
||||
capability: {
|
||||
configured: true,
|
||||
missing: [],
|
||||
instance: 'kgseal-app',
|
||||
project: 'kgseal-weknora',
|
||||
writers: ['app'],
|
||||
ingress_service: 'ingress',
|
||||
},
|
||||
},
|
||||
})
|
||||
expect(wired).toContain('未运行维护')
|
||||
expect(wired).toContain('维护能力已接线:实例 kgseal-app · 写入者 app')
|
||||
expect(wired).not.toContain('也没有维护能力配置')
|
||||
const broken = render({
|
||||
maintenance: { held: false, capability: { configured: false, missing: ['LIBRARY_TARGET_WRITERS'] } },
|
||||
})
|
||||
expect(broken).toContain('能力未接线')
|
||||
expect(broken).toContain('维护能力未接线:缺少 LIBRARY_TARGET_WRITERS')
|
||||
// 接口没给能力信息时不能猜成"没有能力"
|
||||
const unknown = render({ maintenance: { held: false } })
|
||||
expect(unknown).toContain('维护能力状态未知')
|
||||
expect(unknown).not.toContain('也没有维护能力配置')
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user