1008946-knowledge-status-polling.spec.ts
1.83 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { test, expect } from "@playwright/test";
/**
* 缺陷 1008946 - 上传到知识库的文件解析完之后,不更新前端的状态
*
* 根因:Workspace.vue 缺少对 knowledgeStatus === 'processing' 文件的轮询机制。
* 文件上传 SSE 在任务提交给知识服务后即关闭,知识处理(向量化)异步完成后
* 前端无感知,状态停留在 processing 直到手动刷新。
*
* 修复:在 Workspace.vue 增加 hasProcessingFiles computed + 10 秒轮询,
* 与 KnowledgeBase/FileList.vue 保持一致。
*/
test.describe("知识库文件状态自动更新 (#1008946)", () => {
test("hasProcessingFiles 逻辑:递归扫描树中 processing 文件", async () => {
type FileNode = {
type: "file" | "folder";
knowledgeStatus?: string;
children?: FileNode[];
};
const check = (nodes: FileNode[]): boolean =>
nodes.some((n) =>
n.type === "file"
? n.knowledgeStatus === "processing"
: check(n.children || []),
);
// 无 processing 文件
expect(
check([
{ type: "folder", children: [{ type: "file", knowledgeStatus: "completed" }] },
{ type: "file", knowledgeStatus: "not_supported" },
]),
).toBe(false);
// 顶层 processing 文件
expect(check([{ type: "file", knowledgeStatus: "processing" }])).toBe(true);
// 深层嵌套 processing 文件
expect(
check([
{
type: "folder",
children: [
{
type: "folder",
children: [{ type: "file", knowledgeStatus: "processing" }],
},
],
},
]),
).toBe(true);
// 空树
expect(check([])).toBe(false);
// processing 完成后变为 completed
expect(check([{ type: "file", knowledgeStatus: "completed" }])).toBe(false);
});
});