fix(knowledge): align embedding configuration with Yuxi

This commit is contained in:
2026-09-14 23:37:16 +08:00
parent f92753329c
commit 5ed21835ae
5 changed files with 61 additions and 12 deletions

View File

@@ -6,7 +6,7 @@ const api = vi.hoisted(() => ({ call: vi.fn() }));
vi.mock('@/lib/cloud-agents-api', () => ({ cloudAgentsApi: api }));
const slug = 'ml-' + 'a'.repeat(32);
const empty = { databases: [], models: [] };
const available = { ...empty, models: [{ id: 'relay:fixture-embedding', name: '资料向量模型' }] };
const available = { ...empty, models: [{ id: 'relay:fixture-embedding', name: '资料向量模型', dimension: 1024 }] };
beforeEach(() => vi.resetAllMocks());
afterEach(cleanup);
@@ -20,11 +20,12 @@ function openCreation() {
it('explains who configures an empty embedding catalog and refreshes without losing the name', async () => {
api.call.mockResolvedValueOnce(empty).mockResolvedValueOnce(available);
openCreation();
expect(await screen.findByText('暂时没有可用的向量模型。请联系平台管理员完成云端配置,然后刷新。')).toBeVisible();
expect(await screen.findByText('暂时没有可用的向量模型。请联系平台管理员在 Yuxi 完成配置,然后刷新。')).toBeVisible();
expect(screen.getByRole('combobox', { name: '向量模型' })).toBeDisabled();
fireEvent.click(screen.getByText('管理员配置说明'));
expect(screen.getByText(/Yuxi 后台/)).toHaveTextContent('智能体管理 → 模型供应商');
expect(screen.getByText(/Works Square 运营后台/)).toHaveTextContent('模型管理');
expect(screen.getByText(/Yuxi 后台/)).toHaveTextContent('服务地址和 API Key');
expect(screen.queryByText(/Works Square 运营后台|one-api/)).not.toBeInTheDocument();
fireEvent.change(screen.getByRole('textbox', { name: '知识库名称' }), { target: { value: '创作资料' } });
fireEvent.click(screen.getByRole('button', { name: '刷新知识库与模型' }));
expect(await screen.findByRole('option', { name: '资料向量模型' })).toBeInTheDocument();