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: '产品/维护', 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: '历史', 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: [], 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() expect(html).toContain('monitor-metric-grid') expect(html.indexOf('monitor-metric-grid')).toBeLessThan(html.indexOf('

文件处理

')) expect(html.match(/ { const html = renderToStaticMarkup() expect(html).toContain('无法读取运行指标') expect(html).not.toContain('100%') expect(html).toContain('尚未取得服务状态') }) it('keeps removal semantics and does not offer retry for completed rows', () => { const html = renderToStaticMarkup() expect(html).toContain('已从测试库移除;来源文件保留') expect(html).toContain('aria-label="选择维护手册.pdf"') expect(html).not.toContain('aria-label="选择过期资料.pdf"') }) })