// @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( ) ) const button = [...container.querySelectorAll('button')].find((item) => item.textContent === '查看处理') expect(button).toBeTruthy() act(() => button?.click()) expect(onViewProcessing).toHaveBeenCalledWith(file) }) })