diff --git a/apps/ai-game-creator-shell/tests/appSurface/chat-composer.suite.ts b/apps/ai-game-creator-shell/tests/appSurface/chat-composer.suite.ts index 3be5f7899..72914b130 100644 --- a/apps/ai-game-creator-shell/tests/appSurface/chat-composer.suite.ts +++ b/apps/ai-game-creator-shell/tests/appSurface/chat-composer.suite.ts @@ -471,7 +471,7 @@ export function registerChatComposerControlTests() { it('does not report a finished turn while the host has not acknowledged the send yet', async () => { const pending: Array<{ resolve: (value: string) => void }> = []; - const { surface } = await openDirectCodexSurface({ + const { invoke, surface } = await openDirectCodexSurface({ chat_with_game_creator_direct_codex: () => new Promise((resolve) => { pending.push({ resolve }); @@ -480,6 +480,15 @@ export function registerChatComposerControlTests() { const composer = within(surface).getByLabelText('陶泥儿对话内容'); await submitDirectTurn(surface, composer, '窗口期的消息'); + // 写权限门是异步的,先等命令真的发出去,否则下面的窗口期断言会在 invoke 还没发生时就 + // 通过、收尾的 `pending[0]?.resolve` 也变成空操作,用例根本没盖住它要盖的窗口。 + await waitFor(() => { + expect(invoke).toHaveBeenCalledWith( + 'chat_with_game_creator_direct_codex', + expectDirectTurnWithText('窗口期的消息'), + ); + }); + // 本地乐观气泡立刻可见;此刻原生既没回 turn.started,也没回显用户条目, // 这一轮属于「本地已发出、宿主未确认」,不得渲染成已结束。 await waitFor(() => {