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 8a84e24b4..8f65a77bf 100644 --- a/apps/ai-game-creator-shell/tests/appSurface/home.suite.ts +++ b/apps/ai-game-creator-shell/tests/appSurface/home.suite.ts @@ -1384,6 +1384,11 @@ export function registerHomeProjectCreationTests() { manifest, }; } + // DirectProject 聊天容器自己订阅项目清单(项目身份与 `@` 引用素材都来自它), + // 首轮需求要等清单到位才认领,所以这里必须提供清单读数。 + if (command === 'get_local_game_manifest') { + return manifest; + } if (command === 'chat_with_game_creator_direct_codex') { chatHarness.completeDirectThreadTurn({ turnId: String(args?.clientTurnId ?? ''), @@ -1512,6 +1517,9 @@ export function registerHomeProjectCreationTests() { manifest, }; } + if (command === 'get_local_game_manifest') { + return manifest; + } if (command === 'upload_local_asset') { return { id: 'asset-upload-1', @@ -1575,28 +1583,37 @@ export function registerHomeProjectCreationTests() { mediaType: 'image/png', bytes: fileBytes, }); - expect(invoke).toHaveBeenCalledWith('chat_with_game_creator_direct_codex', { - projectPath: automaticProjectPath, - prompt: '按这个角色做游戏', - creationType: 'game', - clientTurnId: expect.any(String), - userItem: { - id: expect.stringMatching(/^direct-codex:[A-Za-z0-9-]+:user$/), - type: 'message', - role: 'user', - // 首页附件随首轮一起进 canonical content:它就是这一轮输入的一部分。 - content: [ - { type: 'input_text', text: '按这个角色做游戏' }, - { - type: 'agc_attachment_reference', - name: '角色参考.png', - mediaType: 'image/png', - size: attachment.size, - localPath: 'assets/uploads/reference.png', - status: 'imported', + // 首轮需求由 DirectProject 聊天容器认领:它要先读到项目清单(项目身份就绪)才发送, + // 所以这里等一等,不能在「工作台已出现」的同一帧断言。 + await waitFor(() => { + expect(invoke).toHaveBeenCalledWith( + 'chat_with_game_creator_direct_codex', + { + projectPath: automaticProjectPath, + // `prompt` 是 canonical content 的可读投影:首页附件作为 + // `agc_attachment_reference` 也在这一轮输入里,按同一口径展开成 `@名称`。 + prompt: '按这个角色做游戏@角色参考.png', + creationType: 'game', + clientTurnId: expect.any(String), + userItem: { + id: expect.stringMatching(/^direct-codex:[A-Za-z0-9-]+:user$/), + type: 'message', + role: 'user', + // 首页附件随首轮一起进 canonical content:它就是这一轮输入的一部分。 + content: [ + { type: 'input_text', text: '按这个角色做游戏' }, + { + type: 'agc_attachment_reference', + name: '角色参考.png', + mediaType: 'image/png', + size: attachment.size, + localPath: 'assets/uploads/reference.png', + status: 'imported', + }, + ], }, - ], - }, + }, + ); }); expect(invoke).not.toHaveBeenCalledWith( 'chat_with_game_creator_home_direct_codex',