feat: 集成 AI 对话与只读查询工具

This commit is contained in:
2026-07-23 14:24:40 +08:00
parent 302dbe0621
commit f3b59935d6
52 changed files with 4942 additions and 4 deletions

View File

@@ -0,0 +1,41 @@
import { act } from 'react';
import { createRoot } from 'react-dom/client';
import { Bubble } from '@ant-design/x';
import { afterEach, describe, expect, it } from 'vitest';
import { aiBubbleRoles } from './AiChatDrawer';
import type { AiChatMessage } from './types';
let container: HTMLDivElement | null = null;
let root: ReturnType<typeof createRoot> | null = null;
afterEach(async () => {
if (root) await act(async () => root?.unmount());
container?.remove();
root = null;
container = null;
});
describe('AI chat bubble rendering', () => {
it('renders a structured user message instead of passing the object to React', async () => {
const message: AiChatMessage = {
role: 'user',
content: '查询今天的系统概览',
reasoningContent: '',
toolRuns: [],
};
container = document.createElement('div');
document.body.appendChild(container);
root = createRoot(container);
await act(async () => {
root?.render(
<Bubble.List
role={aiBubbleRoles}
items={[{ key: 'user-1', role: 'user', status: 'local', content: message }]}
/>,
);
});
expect(container.textContent).toContain('查询今天的系统概览');
});
});