1c80b07f2c
build / build (push) Successful in 1m59s
Dockerfile 运行阶段补齐 dws_dingtalk_scan(F12),并新增 runtime-scripts 门禁 做脚本依赖闭包正负例;就绪探测每次解析当前端点/绑定/凭据并区分 404、未配置、 不可达(F13);路由写入来源路径与父目录,历史空值仅按同连接同 item 的意图读时 补齐(F14);目标筛选显示短 ID 与当前绑定/历史并提供快捷筛选(F15);刷新终态 移除后台运行、展示失败时间/旧快照/脱敏原因/作业 ID 与重试(F16)。 验证:make verify 17 项全过(identity 本地按设计 skipped);一次性 schema 的 Monitor 目录/路由集成用例通过;8088 部署与真实 UI 验收仍由父会话执行。
173 lines
5.5 KiB
TypeScript
173 lines
5.5 KiB
TypeScript
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(<WeKnoraMonitorView {...props} />)
|
||
expect(html).toContain('monitor-metric-grid')
|
||
expect(html.indexOf('monitor-metric-grid')).toBeLessThan(html.indexOf('<h2>文件处理</h2>'))
|
||
expect(html.match(/<table/g)).toHaveLength(1)
|
||
for (const s of [
|
||
'维护手册.pdf',
|
||
'过期资料.pdf',
|
||
'处理动作',
|
||
'当前阶段',
|
||
'处理状态',
|
||
'状态说明',
|
||
'共 145',
|
||
'重试所选',
|
||
'服务与依赖',
|
||
])
|
||
expect(html).toContain(s)
|
||
expect(html).not.toContain('开始处理')
|
||
expect(html).not.toContain('role="tab"')
|
||
expect(html).toContain('value="active" selected=""')
|
||
})
|
||
it('does not claim healthy zeroes or 100% when metrics are unavailable', () => {
|
||
const html = renderToStaticMarkup(<WeKnoraMonitorView {...props} error="无法读取运行指标" />)
|
||
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(<WeKnoraMonitorView {...props} />)
|
||
expect(html).toContain('已从测试库移除;来源文件保留')
|
||
expect(html).toContain('aria-label="选择维护手册.pdf"')
|
||
expect(html).not.toContain('aria-label="选择过期资料.pdf"')
|
||
})
|
||
})
|
||
describe('target identity and probe attribution', () => {
|
||
it('labels same-named targets with short id and current/history state', () => {
|
||
const current = '0c84a098-d3ed-4b82-a165-e6de9691d6a8'
|
||
const historical = 'sc-ed1f812c4e5fabe817fc6351104938c4'
|
||
const withTargets = {
|
||
...page,
|
||
items: [
|
||
{ ...page.items[0], target_kb: current },
|
||
{ ...page.items[1], target_kb: historical },
|
||
],
|
||
targets: [
|
||
{ id: current, name: current, scope: 'internal' },
|
||
{ id: historical, name: historical, scope: 'internal' },
|
||
],
|
||
bindings: { internal: current, external: '' },
|
||
}
|
||
const html = renderToStaticMarkup(<WeKnoraMonitorView {...props} page={withTargets} />)
|
||
expect(html).toContain('0c84a098')
|
||
expect(html).toContain('当前绑定')
|
||
expect(html).toContain('sc-ed1f8')
|
||
expect(html).toContain('历史')
|
||
expect(html).toContain('产品/维护')
|
||
})
|
||
it('shows liveness and the sanitized probe target separately from readiness', () => {
|
||
const overview = {
|
||
mode: 'real',
|
||
simulated: false,
|
||
observed_at: '2026-11-05T02:00:00Z',
|
||
host: {
|
||
cpu_percent: 1,
|
||
memory_used_bytes: 1,
|
||
memory_total_bytes: 2,
|
||
disk_used_bytes: 1,
|
||
disk_total_bytes: 2,
|
||
gpu_state: 'none',
|
||
gpu_detail: '',
|
||
simulated: false,
|
||
},
|
||
services: [],
|
||
knowledge_bases: [],
|
||
health: [
|
||
{
|
||
key: 'weknora',
|
||
name: 'WeKnora API',
|
||
liveness: 'up',
|
||
readiness: 'blocked',
|
||
reason: 'WeKnora 探测目标知识库不存在(实例 weknora.test · 知识库 1b52c140)',
|
||
latency_ms: 3,
|
||
observed_at: '2026-11-05T02:00:00Z',
|
||
last_success_at: null,
|
||
consecutive_failures: 1,
|
||
probe_target: '实例 weknora.test · 知识库 1b52c140',
|
||
configured: true,
|
||
applicable: true,
|
||
},
|
||
],
|
||
}
|
||
const html = renderToStaticMarkup(<WeKnoraMonitorView {...props} overview={overview} />)
|
||
expect(html).toContain('存活 up')
|
||
expect(html).toContain('探测对象 实例 weknora.test · 知识库 1b52c140')
|
||
})
|
||
})
|