feat(release): 按确认稿重做发布管理(两库页签 + 单作业区 + 版本抽屉)
build / build (push) Failing after 19s

- 顶部只有对内/对外两个知识库页签,切换只渲染选中库的一个作业区
- 同步前:生产当前→拟发布、新增/更新/删除与 Wiki 完整快照、准备清单、
  版本与快照/启动同步、本次变更 + 生产保护与恢复、五段作业阶段
- 同步中:作业阶段/版本/已用时 + 四类数据卡 + 同步明细与异常,未接入项
  只显示状态、不编百分比
- 版本与快照抽屉按 scope 列全部封存记录与分项摘要,恢复入口在真实演练前禁用
- 存储口径移到系统设置→存储管理只读区;保留/清理/自动清理标未接线
- 生产段无真实数据一律"未接入/尚无记录",启动同步禁用并说明
This commit is contained in:
姚章浩
2026-10-28 13:23:55 +08:00
parent bb64c32654
commit 58d0483d44
8 changed files with 1469 additions and 673 deletions
+91 -58
View File
@@ -3,7 +3,7 @@ import { describe, expect, it, vi } from 'vitest'
import { ReleaseTargetsView } from './ReleaseTargets'
import type { LibraryCaptureJob, LibrarySnapshot, LibrarySnapshotList } from './librarySnapshots'
const snapshot: LibrarySnapshot = {
const internalSnapshot: LibrarySnapshot = {
snapshot_id: 'f992d64ea45bf737a0721a465b5aef2b150ef7757157eb84f3aaf8b6972d98f9',
scope: 'internal',
knowledge_base_id: '0c84a098-d3ed-4b82-a165-e6de9691d6a8',
@@ -17,11 +17,11 @@ const snapshot: LibrarySnapshot = {
retriever_engine: 'elasticsearch_v8',
embedding_model: 'text-embedding-v4',
embedding_dimension: 1024,
index_mapping_sha256: '137cde2965f3b56521f5fb722b4e0617f46d0e509e571b217fe01e090d5e4d01',
index_mapping_sha256: 'a'.repeat(64),
},
parts: [
{ kind: 'database', name: 'knowledges', sha256: 'a'.repeat(64), count: 4, bytes: 10654 },
{ kind: 'index', name: 'chunks', sha256: 'b'.repeat(64), count: 122, bytes: 1624880 },
{ kind: 'database', name: 'knowledges', sha256: 'b'.repeat(64), count: 4, bytes: 10654 },
{ kind: 'index', name: 'chunks', sha256: 'c'.repeat(64), count: 122, bytes: 1624880 },
],
logical_bytes: 55309044,
unique_bytes: 55309040,
@@ -29,7 +29,15 @@ const snapshot: LibrarySnapshot = {
totals: { documents: 4, chunks: 38, index_documents: 122, resources: 21, wiki_pages: 31 },
}
const job: LibraryCaptureJob = {
const externalSnapshot: LibrarySnapshot = {
...internalSnapshot,
snapshot_id: '01343b0b310b3977c2fdda05f5b8a6272148c4f7bfa124a6c5944123cf0c51c3',
scope: 'external',
created_at: '2026-10-28T03:35:53.000000000Z',
totals: { documents: 0, chunks: 0, index_documents: 0, resources: 0, wiki_pages: 1 },
}
const runningJob: LibraryCaptureJob = {
job_id: 'library-capture-internal-1',
capture_job: 'lib-internal-20261028T033457',
scope: 'internal',
@@ -38,14 +46,14 @@ const job: LibraryCaptureJob = {
last_error: '',
requested_by: 'yaozhanghao',
created_at: '2026-10-28T03:34:50Z',
updated_at: '2026-10-28T03:34:51Z',
updated_at: '2026-10-28T03:34:55Z',
}
const page: LibrarySnapshotList = {
available: true,
reason: '',
archive_root: '/var/lib/knowledge-governance/library',
snapshots: [snapshot],
snapshots: [internalSnapshot, externalSnapshot],
versions: 2,
content_bytes: 55309693,
blob_file_bytes: 55309693,
@@ -59,75 +67,100 @@ const page: LibrarySnapshotList = {
capture_reason: '',
}
const baseProps = {
type ViewProps = Parameters<typeof ReleaseTargetsView>[0]
const base: ViewProps = {
page,
jobs: [] as LibraryCaptureJob[],
jobs: [],
loading: false,
error: null,
notice: null,
expanded: null,
pendingScope: null,
scope: 'internal',
onScope: vi.fn(),
drawerOpen: false,
onDrawer: vi.fn(),
expandedSnapshot: null,
onExpandSnapshot: vi.fn(),
pendingCapture: false,
canCapture: true,
onRefresh: () => undefined,
canWrite: true,
now: new Date('2026-10-28T03:35:00Z').getTime(),
onRefresh: vi.fn(),
onCapture: vi.fn(),
onToggleExpanded: () => undefined,
}
const render = (overrides: Partial<typeof baseProps> = {}) =>
renderToStaticMarkup(<ReleaseTargetsView {...baseProps} {...overrides} />)
const render = (overrides: Partial<ViewProps> = {}) => renderToStaticMarkup(<ReleaseTargetsView {...base} {...overrides} />)
describe('ReleaseTargetsView', () => {
it('shows exactly the two library targets with real counts and integrity wording', () => {
describe('ReleaseTargetsView(确认稿布局)', () => {
it('顶部只有两个知识库页签,且一次只显示选中库的作业区', () => {
const html = render()
expect(html).toContain('对内')
expect(html).toContain('对外')
expect(html).not.toContain('第三目标')
expect(html).toContain('122')
expect(html).toContain('31')
expect(html).toMatch(/完整性:读取时已重算 2 项摘要/)
expect(html).toContain('text-embedding-v4')
expect(html).toContain('对内知识库')
expect(html).toContain('对外知识库')
expect(html).toContain('role="tab"')
// 只显示一个主作业卡:选中库标题出现一次,另一个库不渲染作业卡
expect(html.match(/· 已封存,生产同步未接入/g)?.length).toBe(1)
expect(html).not.toContain('对外知识库 · 尚无')
})
it('keeps the unbuilt chain stages disabled instead of faking progress', () => {
it('未接入项显示“未接入”,不用 0 / 无变化冒充', () => {
const html = render()
expect(html).toMatch(/生产预备份[\s\S]*未接线/)
expect(html).toMatch(/同步到生产[\s\S]*未授权/)
expect(html).toMatch(/校验 \/ 恢复[\s\S]*未接线/)
expect(html).not.toMatch(/\d+%/)
// Disabled actions carry a reason in the title attribute.
expect(html).toContain('title="生产独立预备份与恢复演练未接线"')
expect(html).toContain('title="生产写入需要独立授权闸口,当前未开放"')
expect(html).toContain('生产当前')
expect(html).toContain('未接入')
expect(html).toContain('尚无记录 · 变更清单来自生产与测试版本对比')
})
it('offers the capture action only when the agent is wired and the role allows it', () => {
expect(render()).toContain('发起对内封存')
const readonly = render({ canCapture: false })
expect(readonly).toContain('发起封存需要知识工程师及以上权限')
it('“启动同步”保持禁用并说明原因,不把封存当成同步', () => {
const html = render()
expect(html).toMatch(/<button[^>]*class="rel-primary"[^>]*disabled/)
expect(html).toContain('生产同步未接线')
expect(html).toContain('封存测试版本')
})
it('版本与快照抽屉按 scope 列出全部历史并区分测试封存/不可直接恢复', () => {
const html = render({ drawerOpen: true, expandedSnapshot: internalSnapshot.snapshot_id })
expect(html).toContain('版本与快照')
expect(html).toContain('封存 f992d64ea45b')
expect(html).toContain('测试封存')
expect(html).toContain('不可直接恢复')
expect(html).toContain('恢复至该版本')
expect(html).toMatch(/恢复至该版本[^<]*<\/button>/)
expect(html).toContain('分项数量 / 字节 / 摘要(2 项)')
expect(html).toContain('不支持只选择 Wiki 或某张数据表恢复')
})
it('抽屉只展示当前选中库的历史', () => {
const html = render({ drawerOpen: true, scope: 'external' })
expect(html).toContain('封存 01343b0b310b')
expect(html).not.toContain('封存 f992d64ea45b')
})
it('同步中布局显示四类数据卡与明细,且不编造百分比', () => {
const html = render({ jobs: [runningJob] })
expect(html).toContain('正在封存测试版本')
expect(html).toContain('数据库 · 文档与分块')
expect(html).toContain('原文件 · 图片 · 附件')
expect(html).toContain('检索索引 · 向量')
expect(html).toContain('Wiki · 完整快照')
expect(html).toContain('同步明细')
// 唯一允许出现的百分比是免责声明里的「100% ≠ 作业完成」,没有任何进度主张
expect(html.match(/[1-9]\d*%/g) ?? []).toEqual(['100%'])
expect(html).toContain('文件传输 100% ≠ 作业完成')
expect(html).toContain('不编造百分比')
})
it('无权限时不给封存入口,未接线时说明通道状态', () => {
expect(render({ canCapture: false, canWrite: false })).toContain('封存需要知识工程师及以上权限')
const unwired = render({
page: { ...page, capture_available: false, capture_reason: '未接线:主机侧封存 agent 没有挂载' },
canCapture: false,
canWrite: true,
page: { ...page, capture_available: false, capture_reason: '主机侧封存 agent 未接线' },
})
expect(unwired).toContain('未接线:主机侧封存 agent 没有挂载')
expect(unwired).not.toContain('发起对内封存')
expect(unwired).toContain('封存通道未接线')
})
it('reports the live job instead of a guessed stage', () => {
const html = render({ jobs: [job] })
expect(html).toContain('执行中')
expect(html).toContain('lib-internal-20261028T033457')
expect(html).toContain('yaozhanghao')
// A running job disables the capture button for that scope.
expect(html).toMatch(/disabled[^>]*>发起对内封存/)
})
it('states that storage numbers are content accounting, not reclaimable space', () => {
const html = render()
expect(html).toContain('被版本引用的去重内容')
expect(html).toContain('不是可回收空间')
expect(html).toMatch(/保留策略、依赖保护、清理预览都没有接线/)
})
it('shows an empty target as an invitation, with the blocking reason', () => {
const html = render({ page: { ...page, snapshots: [], available: false, reason: '未接线:归档根未配置' } })
expect(html).toContain('未接线:归档根未配置')
it('无封存时给出“尚无封存”而不是空表', () => {
const html = render({ page: { ...page, snapshots: [] } })
expect(html).toContain('尚无测试封存')
expect(html).toContain('还没有测试库封存')
})
})