From 6550e9a4bb4ddd785f43f108181bd0734789932e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Sat, 3 Oct 2026 14:16:18 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B5=8B=E8=AF=95=EF=BC=9A=E8=A1=A5=E5=9B=9E?= =?UTF-8?q?=E5=85=A5=E9=98=9F=E8=A2=AB=E6=8B=92=E6=B6=88=E6=81=AF=E4=B8=8D?= =?UTF-8?q?=E8=90=BD=E7=9B=98=E3=80=81=E4=B8=8D=E9=87=8D=E6=94=BE=E7=9A=84?= =?UTF-8?q?=E6=96=AD=E8=A8=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - home.suite.ts 的入队被拒用例恢复 persistedMessages 桩,并让历史切片返回它 - 增加断言:被拒消息不落历史条目、不被乐观渲染成用户气泡、不写本地历史 - 增加 cleanup + 重挂载断言:重进项目不重放被拒消息与拒绝文案,且不自动重试 --- .../tests/appSurface/home.suite.ts | 34 +++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/apps/ai-game-creator-shell/tests/appSurface/home.suite.ts b/apps/ai-game-creator-shell/tests/appSurface/home.suite.ts index d897eb29b..800a6ce7d 100644 --- a/apps/ai-game-creator-shell/tests/appSurface/home.suite.ts +++ b/apps/ai-game-creator-shell/tests/appSurface/home.suite.ts @@ -2544,6 +2544,7 @@ export function registerHomeProjectCreationTests() { 'failed-direct-project', '直连失败项目', ); + const persistedMessages: Array> = []; const invoke = vi.fn( async (command: string, args?: Record) => { if (command === 'get_local_game_manifest') { @@ -2552,7 +2553,11 @@ export function registerHomeProjectCreationTests() { } if (command === 'read_direct_project_history_slice') { expect(args).toEqual({ projectPath, limit: 20 }); - return { items: [], hasMore: false, firstItemId: null }; + return { + items: [...persistedMessages], + hasMore: false, + firstItemId: null, + }; } if (command === 'append_local_permission_log') { return {}; @@ -2601,13 +2606,38 @@ export function registerHomeProjectCreationTests() { await screen.findAllByText('项目权限策略拒绝了本次调用'), ).not.toBeNull(); expect(screen.queryAllByText(/permissionRejected/)).toHaveLength(0); - // 入队没成立:只发一次命令,失败之后不自动重试、也不重放。 + // 入队没成立:被拒消息不得留下任何历史条目,也不得被乐观渲染成已成立的用户消息。 + expect(persistedMessages).toHaveLength(0); + expect(screen.queryAllByText('生成一个游戏')).toHaveLength(0); + expect( + invoke.mock.calls.filter( + ([command]) => command === 'append_local_conversation_message', + ), + ).toHaveLength(0); + // 入队没成立:只发一次命令,失败之后不自动重试。 expect( invoke.mock.calls.filter( ([command]) => command === 'enqueue_direct_codex_turn', ), ).toHaveLength(1); cleanup(); + + // 重进项目:被拒消息不得从历史里被重放,拒绝文案也不该被当成历史条目。 + render( + React.createElement(App, { + initialProjectPath: projectPath, + initialProjectManifest: manifest, + }), + ); + await waitFor(() => { + expect(screen.queryAllByText('生成一个游戏')).toHaveLength(0); + }); + expect(screen.queryAllByText('项目权限策略拒绝了本次调用')).toHaveLength(0); + expect( + invoke.mock.calls.filter( + ([command]) => command === 'enqueue_direct_codex_turn', + ), + ).toHaveLength(1); }); }