Files
knowledge-governance/web/src/DocumentWorkbench.test.tsx
姚章浩 e34306b2db
build / build (push) Failing after 18s
fix(ui): 已释放窗口不再渲染 held 文案,版本页不再把 500 说成未接线
发布管理:maintenanceSummary 只看 job.state === 'failed' 就给 held 处置文案;
窗口已 released 的旧作业(libsync-internal-1793399248431728863)因此自相矛盾。
改为仅 held 时给 recoveryError,已释放时给 releasedFailure(如实记录失败,不提供强制成功)。

版本记录:LoadVersionHistorySyncState 把可空的 finished_at 扫进 time.Time;
部署重启触发的同步在"进行中"时该列为 NULL,扫描失败使整页 500
(nginx access log:GET /api/v1/version-history?limit=30 → 500,74 字节错误体)。
改为指针接值再判空。前端同时区分"未配置/加载失败"并显示服务端 code。

RED/GREEN:新增 Go 集成用例(NULL finished_at)、两条前端用例;
make verify 16/16 通过(local 档案)。
2026-11-01 19:34:31 +08:00

84 lines
2.6 KiB
TypeScript

import { describe, expect, it, vi } from 'vitest'
import { renderToStaticMarkup } from 'react-dom/server'
import { DocumentWorkbenchView } from './DocumentWorkbench'
import { document } from './documentFixture'
describe('document engineer workbench', () => {
it('shows real file names, source categories and scope without technical identifiers', () => {
const manual = {
...document,
id: 'manual',
title: 'P3 验收文档',
source_type: 'manual' as const,
connection_id: 'manual-1',
}
const html = renderToStaticMarkup(
<DocumentWorkbenchView
items={[document, manual]}
connections={[]}
mode="directory"
loading={false}
error={null}
onRefresh={vi.fn()}
onRetry={vi.fn()}
retryingId={null}
/>
)
for (const text of [
'来源与目录',
'手册.pdf',
'使用指南',
'对外',
'解析完成',
'PP分类',
'未接通目录',
'文件名',
'显示 1 份验收文档',
])
expect(html).toContain(text)
expect(html).not.toContain('P3 验收文档')
expect(html).not.toContain('<code>a</code>')
expect(html).not.toContain('只走这 8 步')
})
it('shows monitoring and no fabricated page progress or production availability', () => {
const html = renderToStaticMarkup(
<DocumentWorkbenchView
items={[document, { ...document, id: 'active', processing_state: 'processing' }]}
connections={[]}
mode="monitor"
loading={false}
error={null}
onRefresh={vi.fn()}
onRetry={vi.fn()}
retryingId={null}
/>
)
expect(html).toContain('解析监控')
expect(html).toContain('来源处理概览')
expect(html).toContain('已就绪 1 / 2')
expect(html).toContain('独立解析')
expect(html).toContain('内容复用')
expect(html).toContain('处理中 1')
expect(html).toContain('解析完成不代表已上线')
expect(html).not.toContain('100%')
expect(html).not.toContain('生产可用')
})
it('does not display zero as a successful load when the request failed', () => {
const html = renderToStaticMarkup(
<DocumentWorkbenchView
items={[]}
connections={[]}
mode="directory"
loading={false}
error="加载失败"
onRefresh={vi.fn()}
onRetry={vi.fn()}
retryingId={null}
/>
)
expect(html).toContain('加载失败')
expect(html).not.toContain('aria-label="当前目录统计"')
expect(html).not.toContain('没有符合条件的文件')
})
})