feat(trial): assemble completed Agent workspace updates
This commit is contained in:
1 parent
8289f27f3e
commit
7c51bb4a00
38 files changed
+2081
-276
No files matched your search
@@ -3,13 +3,15 @@ import { afterEach, beforeEach, expect, it, vi } from 'vitest';
|
||||
import { CloudKnowledgePanel } from '@/pages/CloudAgents/CloudKnowledge';
|
||||
import type { CloudKnowledgeFile } from '../../shared/cloud-agents';
|
||||
|
||||
const api = vi.hoisted(() => ({ call: vi.fn(), uploadKnowledge: vi.fn() }));
|
||||
const api = vi.hoisted(() => ({ call: vi.fn(), uploadKnowledge: vi.fn(), list: vi.fn() }));
|
||||
vi.mock('@/lib/cloud-agents-api', () => ({ cloudAgentsApi: api }));
|
||||
const file: CloudKnowledgeFile = { file_id: 'file', name: '学习路线图.pdf', size: 3000, status: 'uploaded', chunk_count: 0, error: null, available: false };
|
||||
let items: CloudKnowledgeFile[];
|
||||
beforeEach(() => {
|
||||
vi.resetAllMocks(); items = [];
|
||||
api.list.mockResolvedValue({ agents: [], next_cursor: null });
|
||||
api.call.mockImplementation(async operation => {
|
||||
if (operation === 'received') return { agents: [] };
|
||||
if (operation === 'knowledge') return { databases: [{ kb_id: 'kb', name: '资料' }, { kb_id: 'other', name: '其他库' }], models: [] };
|
||||
if (operation === 'knowledgeFiles') return { files: items, next_offset: null };
|
||||
if (operation === 'processKnowledge') {
|
||||
@@ -33,7 +35,7 @@ it('uploads then processes automatically and refreshes through queue, parse, ind
|
||||
await screen.findByText('上传第一份文档,让智能体用你的资料回答。');
|
||||
vi.useFakeTimers();
|
||||
api.uploadKnowledge.mockImplementation(async () => { items = [file]; return file; });
|
||||
await act(async () => { fireEvent.click(screen.getByRole('button', { name: '上传文档', exact: true })); });
|
||||
await act(async () => { fireEvent.click(screen.getByRole('button', { name: '从电脑上传', exact: true })); });
|
||||
expect(screen.getByText('等待处理')).toBeVisible();
|
||||
expect(screen.queryByText(/0 个分块/)).not.toBeInTheDocument();
|
||||
expect(api.call).toHaveBeenCalledWith('processKnowledge', expect.objectContaining({ kb_id: 'kb', file_id: 'file' }));
|
||||
@@ -74,7 +76,7 @@ it('retains the saved upload and processing identity after an uncertain submissi
|
||||
});
|
||||
api.uploadKnowledge.mockImplementation(async () => { items = [file]; return file; });
|
||||
await open();
|
||||
fireEvent.click(screen.getByRole('button', { name: '上传文档', exact: true }));
|
||||
fireEvent.click(screen.getByRole('button', { name: '从电脑上传', exact: true }));
|
||||
expect(await screen.findByRole('alert')).toHaveTextContent('文件已保存,处理请求尚未确认');
|
||||
expect(screen.getByRole('article', { name: file.name })).toBeVisible();
|
||||
fireEvent.click(screen.getByRole('button', { name: '重试处理' }));
|
||||
@@ -169,12 +171,10 @@ it('imports an attachment and processes it without claiming immediate readiness'
|
||||
return original(operation, input);
|
||||
});
|
||||
await open();
|
||||
fireEvent.click(screen.getByRole('button', { name: '从对话附件导入' }));
|
||||
await screen.findByRole('option', { name: '我的对话' });
|
||||
fireEvent.change(screen.getByLabelText('附件来源对话'), { target: { value: 'thread' } });
|
||||
await screen.findByRole('option', { name: '附件.pdf' });
|
||||
fireEvent.change(screen.getByLabelText('入库附件'), { target: { value: 'attachment' } });
|
||||
fireEvent.click(screen.getByRole('button', { name: '确认导入知识库' }));
|
||||
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();
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user