feat(trial): assemble completed Agent workspace updates

This commit is contained in:
鲨鱼辣椒 committed 2026-10-13 12:11:56 +08:00
1 parent 8289f27f3e
commit 7c51bb4a00
38 files changed
+2081 -276

No files matched your search

+9 -9
View File
@@ -63,7 +63,7 @@ it('never offers shared libraries to document management or mounts their mutatin
await screen.findByText('MakeLore知识 · 只读'); openUpload();
const manager = screen.getByRole('combobox', { name: '管理的知识库' });
expect(within(manager).queryByRole('option', { name: '创作指南' })).not.toBeInTheDocument();
expect(screen.queryByRole('button', { name: '上传文档', exact: true })).not.toBeInTheDocument();
expect(screen.queryByRole('button', { name: '从电脑上传', exact: true })).not.toBeInTheDocument();
expect(screen.queryByRole('button', { name: '删除知识库', exact: true })).not.toBeInTheDocument();
expect(api.call.mock.calls.every(([operation]) => operation !== 'knowledgeFiles')).toBe(true);
});
@@ -78,7 +78,7 @@ it('allows readable binding after an owned-list failure while withholding docume
expect(screen.queryByRole('group', { name: 'MakeLore知识' })).not.toBeInTheDocument();
choose('shared'); openUpload();
expect(screen.getByRole('combobox', { name: '管理的知识库' })).toBeDisabled();
expect(screen.queryByRole('button', { name: '上传文档', exact: true })).not.toBeInTheDocument();
expect(screen.queryByRole('button', { name: '从电脑上传', exact: true })).not.toBeInTheDocument();
failed = false;
fireEvent.click(screen.getByRole('button', { name: '刷新知识库', exact: true }));
await screen.findByText('MakeLore知识 · 只读');
@@ -116,9 +116,9 @@ it('selects an existing owned library for uploads and cancelling a file picker d
await openOwn();
expect(changes).toHaveBeenLastCalledWith(expect.objectContaining({ knowledges: ['shared', own.kb_id] }));
api.uploadKnowledge.mockResolvedValue(null);
fireEvent.click(screen.getByRole('button', { name: '上传文档', exact: true }));
fireEvent.click(screen.getByRole('button', { name: '从电脑上传', exact: true }));
await waitFor(() => expect(api.uploadKnowledge).toHaveBeenCalledTimes(1));
await waitFor(() => expect(screen.getByRole('button', { name: '上传文档', exact: true })).toBeEnabled());
await waitFor(() => expect(screen.getByRole('button', { name: '从电脑上传', exact: true })).toBeEnabled());
expect(api.call.mock.calls.every(([operation]) => operation !== 'processKnowledge')).toBe(true);
expect(screen.getByRole('button', { name: '移除知识库 创作指南' })).toBeVisible();
});
@@ -180,7 +180,7 @@ it('keeps an uncertain upload scoped to its library through retry cancellation a
const pending: Record<string, boolean> = {};
render(<CloudPendingContext.Provider value={(id, value) => { pending[id] = value; }}><Harness initial={['shared']} /></CloudPendingContext.Provider>);
await openOwn();
fireEvent.click(screen.getByRole('button', { name: '上传文档', exact: true }));
fireEvent.click(screen.getByRole('button', { name: '从电脑上传', exact: true }));
await screen.findByText('上传结果未确认');
expect(Object.values(pending).some(Boolean)).toBe(true);
const manager = screen.getByRole('combobox', { name: '管理的知识库' });
@@ -224,7 +224,7 @@ it('preserves uncertain processing while refreshing and releases it when the ser
it('retains unconfirmed operations in a disabled manager if its owned library disappears and requires explicit discard', async () => {
api.uploadKnowledge.mockRejectedValue(new Error('上传结果未确认'));
render(<Harness initial={['shared']} />); await openOwn();
fireEvent.click(screen.getByRole('button', { name: '上传文档', exact: true }));
fireEvent.click(screen.getByRole('button', { name: '从电脑上传', exact: true }));
await screen.findByText('上传结果未确认');
const before = api.call.mock.calls.filter(([operation]) => operation === 'knowledgeFiles').length;
databases = []; fireEvent.click(screen.getByRole('button', { name: '刷新知识库与模型' }));
@@ -249,7 +249,7 @@ it('automatically processes a confirmed upload that finishes while both knowledg
});
api.uploadKnowledge.mockImplementation(() => new Promise(value => { finishUpload = value; }));
render(<Harness />); await openOwn();
fireEvent.click(screen.getByRole('button', { name: '上传文档', exact: true }));
fireEvent.click(screen.getByRole('button', { name: '从电脑上传', exact: true }));
holdRefresh = true; fireEvent.click(screen.getByRole('button', { name: '刷新目录' }));
await screen.findByRole('option', { name: '正在读取我的知识库…' });
await act(async () => finishUpload({ file_id: 'confirmed', name: '资料.txt', size: 10, status: 'uploaded', chunk_count: 0, available: false, error: null }));
@@ -270,7 +270,7 @@ it('finishes an authorized upload through a failed ownership refresh and does no
});
api.uploadKnowledge.mockImplementation(() => new Promise(value => { finishUpload = value; }));
render(<Harness />); await openOwn();
fireEvent.click(screen.getByRole('button', { name: '上传文档', exact: true }));
fireEvent.click(screen.getByRole('button', { name: '从电脑上传', exact: true }));
holdRefresh = true; fireEvent.click(screen.getByRole('button', { name: '刷新知识库', exact: true }));
await screen.findByRole('option', { name: '正在读取我的知识库…' });
await act(async () => rejectRefresh(new Error('目录连接失败')));
@@ -316,6 +316,6 @@ it('keeps an owned but unusable library manageable without adding an invalid bin
await screen.findByText('上传第一份文档,让智能体用你的资料回答。');
expect(screen.getByText('这个知识库当前暂不可选用。你仍可管理自己的文件,刷新目录后再试。')).toBeVisible();
expect(changes).toHaveBeenCalledTimes(before);
expect(screen.getByRole('button', { name: '上传文档', exact: true })).toBeEnabled();
expect(screen.getByRole('button', { name: '从电脑上传', exact: true })).toBeEnabled();
expect(changes.mock.calls.at(-1)?.[0].knowledges).toEqual(['shared']);
});