mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-06-16 11:39:38 +08:00
- 提取 AI 面板的自动洞察与内联历史为独立展示组件 - 保持会话切换与发送主链留在 AIChatPanel 中 - 补充模式内容与消息边界相关回归测试 - 完成 vitest、生产构建与本地预览切换验证
45 lines
2.2 KiB
TypeScript
45 lines
2.2 KiB
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { readFileSync } from 'node:fs';
|
|
|
|
const source = readFileSync(new URL('./AIChatPanel.tsx', import.meta.url), 'utf8');
|
|
|
|
describe('AIChatPanel message render isolation', () => {
|
|
it('keeps per-message render failures scoped to the broken bubble', () => {
|
|
expect(source).toContain('class AIMessageRenderBoundary extends React.Component');
|
|
expect(source).toContain('[AI Message Render Error]');
|
|
expect(source).toContain('这条 AI 消息渲染失败,已自动隔离');
|
|
expect(source).toContain('__gonaviLastAIMessageRenderError');
|
|
expect(source).toContain('<AIMessageRenderBoundary');
|
|
expect(source).toContain('onDeleteMessage={handleDeleteMessage}');
|
|
});
|
|
|
|
it('loads user prompt settings and appends them as system messages', () => {
|
|
expect(source).toContain('AIGetUserPromptSettings');
|
|
expect(source).toContain("window.addEventListener('gonavi:ai:config-changed'");
|
|
expect(source).toContain('以下是当前用户的自定义补充提示词');
|
|
expect(source).toContain("appendCustomPromptGroup(['database'])");
|
|
});
|
|
|
|
it('loads MCP tools and skills into the runtime tool chain', () => {
|
|
expect(source).toContain('AIListMCPTools');
|
|
expect(source).toContain('AIGetSkills');
|
|
expect(source).toContain('executeLocalAIToolCall');
|
|
expect(source).toContain('以下是当前启用的 Skill');
|
|
expect(source).toContain('buildAvailableAIChatTools');
|
|
});
|
|
|
|
it('teaches the runtime to use deeper schema tools when analyzing structure details', () => {
|
|
expect(source).toContain('get_indexes、get_foreign_keys、get_triggers、get_table_ddl');
|
|
expect(source).toContain('toolContextMap: toolContextMapRef.current');
|
|
expect(source).toContain('buildToolResultMessage');
|
|
});
|
|
|
|
it('keeps the v2 history mode sorted by the latest updated session first', () => {
|
|
expect(source).toContain('const orderedAISessions = useMemo(');
|
|
expect(source).toContain('right.updatedAt - left.updatedAt');
|
|
expect(source).toContain('const panelHistorySessions = useMemo(');
|
|
expect(source).toContain('orderedAISessions.slice(0, 8)');
|
|
expect(source).toContain('sessions={panelHistorySessions}');
|
|
});
|
|
});
|