feat(knowledge): 展示文档处理进度并自动衔接导入索引
This commit is contained in:
@@ -151,6 +151,28 @@ describe('Main cloud Agents boundary', () => {
|
||||
expect(transport).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('preserves knowledge readiness and processing fields through Main upload and attachment import', async () => {
|
||||
const directory = await mkdtemp(join(tmpdir(), 'makelore-knowledge-status-'));
|
||||
try {
|
||||
const source = join(directory, 'replacement.txt');
|
||||
await writeFile(source, 'knowledge content');
|
||||
desktop.pick.mockResolvedValue({ canceled: false, filePaths: [source] });
|
||||
const file = { file_id: 'new-file', name: 'replacement.txt', size: 17, status: 'indexed', error: null,
|
||||
chunk_count: 2, available: true, replaces_file_id: 'old-file',
|
||||
processing_task: { task_id: 'task', status: 'success', error: null } };
|
||||
const transport = vi.fn().mockResolvedValueOnce(session())
|
||||
.mockResolvedValueOnce(json({ ...file, access_token: 'never-render' }))
|
||||
.mockResolvedValueOnce(json({ ...file, access_token: 'never-render' }));
|
||||
const module = moduleFor(transport);
|
||||
const request = { slug: draft.slug, kb_id: 'kb_test', operation_id: input.operation_id };
|
||||
expect(await module.uploadKnowledge({ ...request, replaces_file_id: 'old-file' })).toEqual(file);
|
||||
expect(await module.execute({ operation: 'importKnowledgeAttachment', input: {
|
||||
...request, thread_id: 'thread', attachment_id: 'attachment',
|
||||
} })).toEqual(file);
|
||||
expect(new URL(transport.mock.calls[1][0]).searchParams.get('replaces_file_id')).toBe('old-file');
|
||||
} finally { await rm(directory, { recursive: true, force: true }); }
|
||||
});
|
||||
|
||||
it('notifies only a new unread terminal state and resets its baseline on account switch', async () => {
|
||||
vi.useFakeTimers();
|
||||
const transport = vi.fn().mockResolvedValueOnce(session()).mockResolvedValueOnce(json({ agents: [], next_cursor: null }))
|
||||
|
||||
Reference in New Issue
Block a user