feat(reconciliation): 前端导入对账工作台
为什么:T6b 需要把「解析监控」改成「导入对账」,让差异、证据、待确认与处置在同一页闭环,同时保留平台侧流水。 做什么:新增对账 API 客户端;差异清单(R1-R8、证据等级、待确认徽标、处置按钮);批次概览与队列状态条;平台侧流水页签沿用原表;详情抽屉实时读取 WeKnora 阶段与失败,503 降级;导航改名但保留 tasks 模块 id。 边界:只读角色不显示触发/处置;1440/1024/768 用现有表格滚动与新增响应式规则;不伪造 URL 路由。 验证:npx tsc --noEmit、npm test(646+)、npm run build、make verify 全绿。
This commit is contained in:
@@ -0,0 +1,106 @@
|
||||
import { renderToStaticMarkup } from 'react-dom/server'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { ReconciliationFindingsView } from './ReconciliationFindings'
|
||||
import type { ReconciliationFinding, ReconciliationRun } from './reconciliation'
|
||||
|
||||
const run: ReconciliationRun = {
|
||||
id: 'run-1',
|
||||
kb_id: 'kb-1',
|
||||
state: 'succeeded',
|
||||
trigger: 'manual',
|
||||
started_at: '2026-12-01T02:00:00Z',
|
||||
finished_at: '2026-12-01T02:01:00Z',
|
||||
ledger_count: 12,
|
||||
kb_count: 11,
|
||||
counts: { R1: 1, R2: 0, R3: 2, R4: 0, R5: 0, R6: 0, R7: 0, R8: 0 },
|
||||
previous_counts: { R1: 0, R2: 0, R3: 2, R4: 0, R5: 0, R6: 0, R7: 0, R8: 0 },
|
||||
window_overlapped: true,
|
||||
error_code: '',
|
||||
}
|
||||
const finding: ReconciliationFinding = {
|
||||
id: 'f1',
|
||||
run_id: 'run-1',
|
||||
type: 'R1',
|
||||
publication_id: 'pub-1',
|
||||
document_id: 'doc-1',
|
||||
title: '缺失文件.pdf',
|
||||
path: '产品/缺失文件.pdf',
|
||||
source: '技术资料',
|
||||
target_scope: 'internal',
|
||||
ledger_state: 'completed',
|
||||
weknora_parse_status: '',
|
||||
normalized_state: '',
|
||||
ledger_sha256: '',
|
||||
declared_sha256: '',
|
||||
weknora_file_md5: '',
|
||||
evidence_level: 'none',
|
||||
confirmation_state: 'pending',
|
||||
detail: '台账认为应在库,单条读取返回 404',
|
||||
suggested_action: 'requeue_upload',
|
||||
action_state: 'open',
|
||||
weknora_url: '',
|
||||
}
|
||||
const props = {
|
||||
overview: null,
|
||||
runs: { items: [run], total: 1, limit: 20, offset: 0 },
|
||||
findings: { items: [finding], total: 1, limit: 20, offset: 0 },
|
||||
filters: { type: '', q: '' },
|
||||
selectedRunID: 'run-1',
|
||||
selectedKB: 'kb-1',
|
||||
kbOptions: [{ id: 'kb-1', name: '测试知识库' }],
|
||||
loading: false,
|
||||
busy: false,
|
||||
canOperate: true,
|
||||
canRemove: true,
|
||||
error: '',
|
||||
message: '',
|
||||
onTab: vi.fn(),
|
||||
onSelectRun: vi.fn(),
|
||||
onSelectKB: vi.fn(),
|
||||
onFilters: vi.fn(),
|
||||
onPage: vi.fn(),
|
||||
onRefresh: vi.fn(),
|
||||
onCreate: vi.fn(),
|
||||
onAction: vi.fn(),
|
||||
onDetail: vi.fn(),
|
||||
}
|
||||
describe('reconciliation findings', () => {
|
||||
it('shows batch counts, pending confirmation, evidence and actions', () => {
|
||||
const html = renderToStaticMarkup(<ReconciliationFindingsView {...props} />)
|
||||
for (const text of [
|
||||
'导入对账',
|
||||
'差异清单',
|
||||
'平台侧流水',
|
||||
'立即对账',
|
||||
'R1 丢失',
|
||||
'待确认',
|
||||
'无',
|
||||
'重排上传',
|
||||
'缺失文件.pdf',
|
||||
])
|
||||
expect(html).toContain(text)
|
||||
expect(html).toContain('当前筛选 1 项')
|
||||
expect(html).toContain('保留最近 30 批')
|
||||
})
|
||||
it('hides trigger and actions from a read-only role', () => {
|
||||
const html = renderToStaticMarkup(<ReconciliationFindingsView {...props} canOperate={false} canRemove={false} />)
|
||||
expect(html).not.toContain('立即对账')
|
||||
expect(html).not.toContain('>重排上传</button>')
|
||||
expect(html).toContain('只读角色')
|
||||
})
|
||||
it('renders loading, empty and error states', () => {
|
||||
const loading = renderToStaticMarkup(
|
||||
<ReconciliationFindingsView
|
||||
{...props}
|
||||
runs={{ items: [], total: 0, limit: 20, offset: 0 }}
|
||||
findings={{ items: [], total: 0, limit: 20, offset: 0 }}
|
||||
selectedRunID=""
|
||||
loading={true}
|
||||
/>
|
||||
)
|
||||
expect(loading).toContain('正在读取差异')
|
||||
expect(loading).toContain('还没有对账批次')
|
||||
const failed = renderToStaticMarkup(<ReconciliationFindingsView {...props} error="读取对账批次失败" />)
|
||||
expect(failed).toContain('读取对账批次失败')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user