import { renderToStaticMarkup } from 'react-dom/server'
import { describe, expect, it, vi } from 'vitest'
import { WeKnoraMonitorView } from './WeKnoraMonitor'
import type { MonitorTaskPage } from './monitorTasks'
const page: MonitorTaskPage = {
items: [
{
id: 'tp-1',
title: '维护手册.pdf',
path: '产品/维护',
node_id: 'node-1',
parent_node_id: 'folder-1',
source_id: 's1',
source_name: '技术资料',
target_scope: 'internal',
target_kb: 'test-kb',
action: 'update',
stage: 'parsing',
status: 'attention',
detail: 'remote_parse_failed',
updated_at: '2026-10-27T02:00:00Z',
retry_kind: 'upload',
failure_id: '',
retry_count: 2,
version_id: 'v1',
},
{
id: 'tp-2',
title: '过期资料.pdf',
path: '历史',
node_id: 'node-2',
parent_node_id: 'folder-2',
source_id: 's1',
source_name: '技术资料',
target_scope: 'external',
target_kb: 'test-public',
action: 'remove',
stage: 'finished',
status: 'completed',
detail: '已从测试库移除;来源文件保留',
updated_at: '2026-10-27T02:01:00Z',
retry_kind: '',
failure_id: '',
retry_count: 0,
version_id: 'v2',
},
],
total: 145,
limit: 20,
offset: 0,
sources: [{ id: 's1', name: '技术资料' }],
targets: [],
bindings: { internal: '', external: '' },
retryable: 1,
}
const props = {
overview: null,
metrics: null,
page,
loading: false,
error: '',
message: '',
filters: { q: '', source: '', scope: '', target: '', action: '', status: 'active', stage: '', since: '', until: '' },
selected: [],
busy: false,
canOperate: true,
onFilters: vi.fn(),
onPage: vi.fn(),
onSelection: vi.fn(),
onSelectAll: vi.fn(),
onRetry: vi.fn(),
onDetail: vi.fn(),
onRefresh: vi.fn(),
}
describe('unified monitor', () => {
it('shows metric cards before a single server-paginated file table without manual start or lane tabs', () => {
const html = renderToStaticMarkup(