fix(knowledge): keep computer upload and place creation below it

This commit is contained in:
鲨鱼辣椒 committed 2026-10-13 13:39:30 +08:00
1 parent a6126c0ae2
commit a589a864d7
11 files changed
+97 -944

No files matched your search

+2 -17
View File
@@ -33,6 +33,7 @@ async function tick() { await act(async () => { await vi.advanceTimersByTimeAsyn
it('uploads then processes automatically and refreshes through queue, parse, index and readiness', async () => {
await open();
await screen.findByText('上传第一份文档,让智能体用你的资料回答。');
expect(screen.queryByRole('button', { name: '从聊天选择文件' })).not.toBeInTheDocument();
vi.useFakeTimers();
api.uploadKnowledge.mockImplementation(async () => { items = [file]; return file; });
await act(async () => { fireEvent.click(screen.getByRole('button', { name: '从电脑上传', exact: true })); });
@@ -48,6 +49,7 @@ it('uploads then processes automatically and refreshes through queue, parse, ind
expect(screen.getByText('可用于回答')).toBeVisible();
expect(screen.getByText(/12 段可检索内容/)).toBeVisible();
expect(api.uploadKnowledge).toHaveBeenCalledTimes(1);
expect(api.call.mock.calls.some(([operation]) => ['threads', 'attachments', 'importKnowledgeAttachment'].includes(operation))).toBe(false);
});
it('does not call zero chunks searchable and distinguishes loading from an empty library', async () => {
@@ -162,23 +164,6 @@ it('keeps all loaded pages refreshing and ignores a late response from the previ
expect(screen.getByText('上传第一份文档,让智能体用你的资料回答。')).toBeVisible();
});
it('imports an attachment and processes it without claiming immediate readiness', async () => {
const original = api.call.getMockImplementation()!;
api.call.mockImplementation(async (operation, input) => {
if (operation === 'threads') return { threads: [{ thread_id: 'thread', title: '我的对话' }], next_offset: null };
if (operation === 'attachments') return { attachments: [{ file_id: 'attachment', file_name: '附件.pdf' }] };
if (operation === 'importKnowledgeAttachment') { items = [file]; return file; }
return original(operation, input);
});
await open();
fireEvent.click(screen.getByRole('button', { name: '从聊天选择文件' }));
fireEvent.click(await screen.findByRole('button', { name: '选择对话 我的对话' }));
fireEvent.click(await screen.findByRole('checkbox', { name: '选择文件 附件.pdf' }));
fireEvent.click(screen.getByRole('button', { name: '导入 1 个文件' }));
await screen.findByText('等待处理');
expect(screen.queryByText('可用于回答')).not.toBeInTheDocument();
});
it('keeps indexed content available when replacement cleanup fails and permits retry', async () => {
items = [{ ...file, status: 'indexed', chunk_count: 4, available: true, replaces_file_id: 'old',
processing_task: { task_id: 'task', status: 'failed', error: '旧文档清理失败' } }];