fix(reconciliation): 平台抽屉补 WeKnora 跳转链接
build / build (push) Failing after 26s

- 为什么:白盒复检 P1——平台侧文件详情抽屉 503 只有文案,需求 §8 要求跳转链接;/monitor/tasks 行没有 URL。
- 做什么:抽出 KnowledgeBaseConsoleURL,finding 与 /monitor/tasks 共用同一拼接;handler 用当前生效测试端点填 weknora_url,前端抽屉透传给 WeKnoraProgress;openapi/需求 §7 同步。
- 补证据:stage=weknora 真库合并用例;对账扫描改为真实 HTTP 桩断言零写;progress 投影断言上游密钥字段不外泄。
- 验证:make verify 17 项 success;go test ./... exit 0;web 648 测试 + build;monitor_tasks 真库集成用例 PASS。
This commit is contained in:
Zhero & Rin
2026-12-01 15:00:25 +08:00
committed by 姚章浩
parent 7d21251605
commit 095aa3ed68
16 changed files with 344 additions and 28 deletions
+68
View File
@@ -0,0 +1,68 @@
// @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 { TaskDetail } from './WeKnoraMonitor'
import type { MonitorTask } from './monitorTasks'
const item: MonitorTask = {
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: 'kb-1',
document_id: 'doc-1',
weknora_url: 'https://weknora.test/platform/knowledge-bases/kb-1',
action: 'update',
stage: 'parsing',
status: 'running',
detail: '正在解析处理',
updated_at: '2026-12-01T02:00:00Z',
retry_kind: '',
failure_id: '',
retry_count: 0,
version_id: 'v1',
}
let container: HTMLDivElement
let root: Root
beforeEach(() => {
// React's test-only global; the test environment exposes it without a type.
const reactTestGlobal: { IS_REACT_ACT_ENVIRONMENT: boolean } = globalThis as unknown as {
IS_REACT_ACT_ENVIRONMENT: boolean
}
reactTestGlobal.IS_REACT_ACT_ENVIRONMENT = true
// jsdom does not implement the dialog methods the drawer calls on mount.
HTMLDialogElement.prototype.showModal = function showModal(this: HTMLDialogElement) {
this.open = true
}
container = document.createElement('div')
document.body.appendChild(container)
root = createRoot(container)
})
afterEach(() => {
act(() => root.unmount())
container.remove()
vi.unstubAllGlobals()
})
describe('platform task drawer', () => {
it('offers the WeKnora jump link when progress answers 503', async () => {
vi.stubGlobal(
'fetch',
vi.fn().mockResolvedValue(
new Response(JSON.stringify({ error: 'runtime_read_unavailable', code: 'runtime_read_unavailable' }), {
status: 503,
})
)
)
await act(async () => root.render(<TaskDetail item={item} onClose={vi.fn()} />))
await act(async () => await Promise.resolve())
expect(container.textContent).toContain('未配置 WeKnora 只读 Key')
expect(container.querySelector('a[href="https://weknora.test/platform/knowledge-bases/kb-1"]')).not.toBeNull()
})
})
+4 -2
View File
@@ -506,7 +506,7 @@ export function WeKnoraMonitorView(p: ViewProps) {
</main>
)
}
function TaskDetail({
export function TaskDetail({
item,
onClose,
onLocateSource,
@@ -572,7 +572,9 @@ function TaskDetail({
))}
</section>
) : null}
{item.document_id ? <WeKnoraProgress documentID={item.document_id} compact /> : null}
{item.document_id ? (
<WeKnoraProgress documentID={item.document_id} weknoraURL={item.weknora_url} compact />
) : null}
<p className="monitor-muted">新增、更新完成表示测试库处理完成;移除完成表示测试库内容移除,不代表生产发布。</p>
{item.status === 'attention' ? (
<p className="monitor-alert">
+2
View File
@@ -10,6 +10,8 @@ export interface MonitorTask {
target_scope: string
target_kb: string
document_id?: string
// 目标测试知识库的控制台链接;后端按当前生效测试端点生成,未配置时为空。
weknora_url?: string
action: string
stage: string
status: string