Files
knowledge-governance/web/src/SourceCatalogBrowser.locator.test.tsx
T
姚章浩 1c80b07f2c
build / build (push) Successful in 1m59s
fix(ui): 修复F12-F16入口与追溯缺陷
Dockerfile 运行阶段补齐 dws_dingtalk_scan(F12),并新增 runtime-scripts 门禁
做脚本依赖闭包正负例;就绪探测每次解析当前端点/绑定/凭据并区分 404、未配置、
不可达(F13);路由写入来源路径与父目录,历史空值仅按同连接同 item 的意图读时
补齐(F14);目标筛选显示短 ID 与当前绑定/历史并提供快捷筛选(F15);刷新终态
移除后台运行、展示失败时间/旧快照/脱敏原因/作业 ID 与重试(F16)。

验证:make verify 17 项全过(identity 本地按设计 skipped);一次性 schema 的
Monitor 目录/路由集成用例通过;8088 部署与真实 UI 验收仍由父会话执行。
2026-11-05 10:38:26 +08:00

97 lines
2.7 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 { SourceCatalogBrowserView } from './SourceCatalogBrowser'
import type { CatalogNode, CatalogNodePage, CatalogSource } from './sourceCatalog'
// F14 的界面入口:已导入的文件能从这里直接跳到解析监控(不再靠手抄文件名)。
const source: CatalogSource = {
connection_id: 'conn-atom',
source_type: 'dingtalk',
name: 'ATOM知识库',
root_node_id: 'root-1',
folder_count: 1,
file_count: 1,
observed_at: '2026-10-26T10:41:01Z',
snapshot_only: true,
snapshot_status: 'ready',
last_refresh_duration_ms: 0,
}
const file: CatalogNode = {
node_id: 'node-atom-file',
parent_node_id: 'node-atom-folder',
node_type: 'file',
name: '末端航插线序问题.adoc.docx',
direct_child_count: 0,
subtree_file_count: 1,
subtree_bytes: 1024,
size_bytes: 1024,
visibility: 'internal',
imported_count: 1,
parsed_count: 1,
active_count: 0,
failed_count: 0,
routable_count: 1,
}
const page: CatalogNodePage = {
current: {
...file,
node_id: 'node-atom-folder',
node_type: 'folder',
name: '售后机器出厂问题整改',
parent_node_id: undefined,
},
breadcrumbs: [
{ node_id: 'root-1', name: 'ATOM知识库' },
{ node_id: 'node-atom-folder', name: '售后机器出厂问题整改' },
],
items: [file],
total: 1,
limit: 50,
offset: 0,
}
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()
})
describe('source directory to processing handoff', () => {
it('offers 查看处理 for an imported file and passes the exact node identity', () => {
const onViewProcessing = vi.fn()
act(() =>
root.render(
<SourceCatalogBrowserView
sources={[source]}
selectedSource={source}
page={page}
loading={false}
error={null}
onSelectSource={vi.fn()}
onOpenFolder={vi.fn()}
onNavigateTo={vi.fn()}
onBack={vi.fn()}
onPageChange={vi.fn()}
onRefresh={vi.fn()}
onViewProcessing={onViewProcessing}
/>
)
)
const button = [...container.querySelectorAll('button')].find((item) => item.textContent === '查看处理')
expect(button).toBeTruthy()
act(() => button?.click())
expect(onViewProcessing).toHaveBeenCalledWith(file)
})
})