cf833a0a77
为什么:T6b 需要把「解析监控」改成「导入对账」,让差异、证据、待确认与处置在同一页闭环,同时保留平台侧流水。 做什么:新增对账 API 客户端;差异清单(R1-R8、证据等级、待确认徽标、处置按钮);批次概览与队列状态条;平台侧流水页签沿用原表;详情抽屉实时读取 WeKnora 阶段与失败,503 降级;导航改名但保留 tasks 模块 id。 边界:只读角色不显示触发/处置;1440/1024/768 用现有表格滚动与新增响应式规则;不伪造 URL 路由。 验证:npx tsc --noEmit、npm test(646+)、npm run build、make verify 全绿。
65 lines
2.3 KiB
TypeScript
65 lines
2.3 KiB
TypeScript
// @vitest-environment jsdom
|
|
import { act } from 'react'
|
|
import { createRoot } from 'react-dom/client'
|
|
import type { Root } from 'react-dom/client'
|
|
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
|
|
import { WeKnoraProgress } from './ReconciliationFindings'
|
|
|
|
let container: HTMLDivElement
|
|
let root: Root
|
|
beforeEach(() => {
|
|
;(globalThis as unknown as { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true
|
|
container = document.createElement('div')
|
|
document.body.appendChild(container)
|
|
root = createRoot(container)
|
|
})
|
|
afterEach(() => {
|
|
act(() => root.unmount())
|
|
container.remove()
|
|
vi.unstubAllGlobals()
|
|
})
|
|
describe('WeKnora progress drawer block', () => {
|
|
it('degrades to a read-only key message on 503', async () => {
|
|
vi.stubGlobal(
|
|
'fetch',
|
|
vi.fn().mockResolvedValue(
|
|
new Response(JSON.stringify({ error: 'runtime_read_unavailable', code: 'runtime_read_unavailable' }), {
|
|
status: 503,
|
|
})
|
|
)
|
|
)
|
|
await act(async () => root.render(<WeKnoraProgress documentID="doc-1" />))
|
|
await act(async () => await Promise.resolve())
|
|
expect(container.textContent).toContain('未配置 WeKnora 只读 Key')
|
|
})
|
|
it('shows stages and failures when available', async () => {
|
|
vi.stubGlobal(
|
|
'fetch',
|
|
vi.fn().mockResolvedValue(
|
|
new Response(
|
|
JSON.stringify({
|
|
data: {
|
|
document_id: 'doc-1',
|
|
parse_status: 'failed',
|
|
ingestion_status: 'failed',
|
|
wiki_status: 'none',
|
|
stages: [{ name: 'parse', status: 'failed', error_code: 'E1', finished_at: '2026-12-01T00:00:00Z' }],
|
|
failures: [
|
|
{ task_type: 'parse', fail_count: 2, failed_at: '2026-12-01T00:00:00Z', last_error: '解析失败' },
|
|
],
|
|
has_more_failures: false,
|
|
observed_at: '2026-12-01T00:00:00Z',
|
|
},
|
|
}),
|
|
{ status: 200 }
|
|
)
|
|
)
|
|
)
|
|
await act(async () => root.render(<WeKnoraProgress documentID="doc-1" />))
|
|
await act(async () => await Promise.resolve())
|
|
expect(container.textContent).toContain('parse')
|
|
expect(container.textContent).toContain('解析失败')
|
|
expect(container.textContent).toContain('failed')
|
|
})
|
|
})
|