feat: 集成 AI 对话与只读查询工具
This commit is contained in:
41
apps/admin/src/components/AiChat/bubble.integration.test.tsx
Normal file
41
apps/admin/src/components/AiChat/bubble.integration.test.tsx
Normal 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('查询今天的系统概览');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user