From 67d2f0842154ef87686cf332c80255e7aa798197 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Tue, 22 Sep 2026 14:59:13 +0800 Subject: [PATCH] =?UTF-8?q?=E7=AA=97=E5=8F=A3=E6=9C=9F=E6=B8=B2=E6=9F=93?= =?UTF-8?q?=E7=94=A8=E4=BE=8B=E5=85=88=E7=AD=89=20invoke=20=E5=8F=91?= =?UTF-8?q?=E5=87=BA=EF=BC=8C=E5=88=AB=E8=AE=A9=E6=96=AD=E8=A8=80=E5=9C=A8?= =?UTF-8?q?=E5=91=BD=E4=BB=A4=E6=9C=AA=E5=8F=91=E5=87=BA=E6=97=B6=E5=B0=B1?= =?UTF-8?q?=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - chat-composer 的 does not report a finished turn 用例捕获 invoke 并先等它被调用,再断言窗口期不出现终态文案 - 写权限门是异步的:不等待时断言会在 invoke 之前通过、收尾的 pending[0]?.resolve 变成空操作,用例盖不住它声称覆盖的窗口 --- .../tests/appSurface/chat-composer.suite.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) 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(() => {