From 9bcd6d928c08d5a7a3f09048c7916c60559e2f19 Mon Sep 17 00:00:00 2001 From: AIGameCreator App Date: Thu, 9 Jul 2026 01:14:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3Agent=E8=81=8A=E5=A4=A9?= =?UTF-8?q?=E9=AA=8C=E8=AF=81=E5=8F=A3=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 前端测试不再用回显用户输入冒充真实回复 Rust LLM provider 测试断言回复不是用户原文 --- .../src-tauri/src/tests.rs | 2 + .../tests/appSurface.test.ts | 39 +++++++++++-------- 2 files changed, 25 insertions(+), 16 deletions(-) diff --git a/apps/ai-game-creator-shell/src-tauri/src/tests.rs b/apps/ai-game-creator-shell/src-tauri/src/tests.rs index 14dbd1838..2eb944627 100644 --- a/apps/ai-game-creator-shell/src-tauri/src/tests.rs +++ b/apps/ai-game-creator-shell/src-tauri/src/tests.rs @@ -956,6 +956,7 @@ async fn chat_with_game_creator_agent_uses_project_context_and_chat_llm_route() .expect("chat reply"); assert_eq!(reply.reply_text, "可以,我们先把角色规范图定清楚。"); + assert_ne!(reply.reply_text, "我要生成一个月光厨师角色图"); let request = receiver .recv_timeout(Duration::from_secs(1)) .expect("captured chat llm request"); @@ -1033,6 +1034,7 @@ async fn chat_with_game_creator_role_agent_uses_agent_context_and_route() { .expect("role chat reply"); assert_eq!(reply.reply_text, "可以,我会先收敛角色规范图的视觉方向。"); + assert_ne!(reply.reply_text, "我要生成一个开罗风格的 dota"); let request = receiver .recv_timeout(Duration::from_secs(1)) .expect("captured role chat llm request"); diff --git a/apps/ai-game-creator-shell/tests/appSurface.test.ts b/apps/ai-game-creator-shell/tests/appSurface.test.ts index 5afae6340..572205c48 100644 --- a/apps/ai-game-creator-shell/tests/appSurface.test.ts +++ b/apps/ai-game-creator-shell/tests/appSurface.test.ts @@ -83,6 +83,13 @@ function emptyProjectPolicy() { }; } +const roleAgentMockReply = + '专业 Agent 已完成本轮判断:先补齐角色规范图、验收口径和后续生成条件。'; + +function mockRoleAgentReply() { + return roleAgentMockReply; +} + afterEach(() => { cleanup(); window.history.pushState({}, '', '/'); @@ -910,7 +917,7 @@ describe('AI 游戏创作 App 界面边界', () => { } if (command === 'chat_with_game_creator_role_agent') { return { - replyText: `Agent 真回复:${String(args?.prompt ?? '')}`, + replyText: mockRoleAgentReply(), }; } if (command === 'append_local_conversation_message') { @@ -959,7 +966,7 @@ describe('AI 游戏创作 App 界面边界', () => { ).not.toBeNull(); expect( await screen.findByText( - 'Agent 真回复:请单独评估这个角色设定流程', + roleAgentMockReply, ), ).not.toBeNull(); expect(invoke).toHaveBeenCalledWith('append_local_conversation_message', { @@ -976,7 +983,7 @@ describe('AI 游戏创作 App 界面边界', () => { agentId: 'design-director', message: { role: 'assistant', - content: 'Agent 真回复:请单独评估这个角色设定流程', + content: roleAgentMockReply, agentId: null, }, }); @@ -1217,7 +1224,7 @@ describe('AI 游戏创作 App 界面边界', () => { } if (command === 'chat_with_game_creator_role_agent') { return { - replyText: `Agent 真回复:${String(args?.prompt ?? '')}`, + replyText: mockRoleAgentReply(), }; } if (command === 'append_local_conversation_message') { @@ -2285,7 +2292,7 @@ describe('AI 游戏创作 App 界面边界', () => { } if (command === 'chat_with_game_creator_role_agent') { return { - replyText: `Agent 真回复:${String(args?.prompt ?? '')}`, + replyText: mockRoleAgentReply(), }; } if (command === 'append_local_conversation_message') { @@ -10649,7 +10656,7 @@ describe('AI 游戏创作 App 界面边界', () => { } if (command === 'chat_with_game_creator_role_agent') { return { - replyText: `Agent 真回复:${String(args?.prompt ?? '')}`, + replyText: mockRoleAgentReply(), }; } if (command === 'append_local_conversation_message') { @@ -11116,7 +11123,7 @@ describe('AI 游戏创作 App 界面边界', () => { } if (command === 'chat_with_game_creator_role_agent') { return { - replyText: `Agent 真回复:${String(args?.prompt ?? '')}`, + replyText: mockRoleAgentReply(), }; } if (command === 'append_local_conversation_message') { @@ -11177,7 +11184,7 @@ describe('AI 游戏创作 App 界面边界', () => { ).not.toBeNull(); expect( screen.getByText( - 'Agent 真回复:优先保留轻量像素风', + roleAgentMockReply, ), ).not.toBeNull(); expect(invoke).toHaveBeenCalledWith('read_local_conversation', { @@ -11218,7 +11225,7 @@ describe('AI 游戏创作 App 界面边界', () => { agentId: 'design-director', message: { role: 'assistant', - content: 'Agent 真回复:优先保留轻量像素风', + content: roleAgentMockReply, agentId: null, }, }); @@ -11577,7 +11584,7 @@ describe('AI 游戏创作 App 界面边界', () => { } if (command === 'chat_with_game_creator_role_agent') { return { - replyText: `Agent 真回复:${String(args?.prompt ?? '')}`, + replyText: mockRoleAgentReply(), }; } if (command === 'append_local_conversation_message') { @@ -11637,7 +11644,7 @@ describe('AI 游戏创作 App 界面边界', () => { expect(screen.getByText('先记住这个方向')).not.toBeNull(); expect( screen.getByText( - 'Agent 真回复:先记住这个方向', + roleAgentMockReply, ), ).not.toBeNull(); expect(invoke).toHaveBeenCalledWith('append_local_conversation_message', { @@ -11654,7 +11661,7 @@ describe('AI 游戏创作 App 界面边界', () => { agentId: 'design-director', message: { role: 'assistant', - content: 'Agent 真回复:先记住这个方向', + content: roleAgentMockReply, agentId: null, }, }); @@ -11796,7 +11803,7 @@ describe('AI 游戏创作 App 界面边界', () => { } if (command === 'chat_with_game_creator_role_agent') { return { - replyText: `Agent 真回复:${String(args?.prompt ?? '')}`, + replyText: mockRoleAgentReply(), }; } if (command === 'append_local_conversation_message') { @@ -12030,7 +12037,7 @@ describe('AI 游戏创作 App 界面边界', () => { expect(screen.getByText('先保留这个方向')).not.toBeNull(); expect( screen.queryByText( - 'Agent 真回复:先保留这个方向', + roleAgentMockReply, ), ).toBeNull(); expect(screen.getByLabelText('Agent 对话内容')).toHaveProperty('value', ''); @@ -12142,7 +12149,7 @@ describe('AI 游戏创作 App 界面边界', () => { } if (command === 'chat_with_game_creator_role_agent') { return { - replyText: `Agent 真回复:${String(args?.prompt ?? '')}`, + replyText: mockRoleAgentReply(), }; } if (command === 'append_local_conversation_message') { @@ -12188,7 +12195,7 @@ describe('AI 游戏创作 App 界面边界', () => { expect(screen.getByText('先记住这个方向')).not.toBeNull(); expect( screen.getByText( - 'Agent 真回复:先记住这个方向', + roleAgentMockReply, ), ).not.toBeNull(); expect(screen.getByLabelText('Agent 对话内容')).toHaveProperty('value', '');