From 20b34918d360c8b85cf42d00647a9bebf6d1e502 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=8E=8B=E5=BE=B7=E5=AE=87?= Date: Thu, 17 Sep 2026 16:19:38 +0800 Subject: [PATCH] =?UTF-8?q?UI=20=E7=BC=96=E8=BE=91=E5=99=A8=E6=A1=A5?= =?UTF-8?q?=E6=8E=A5=E7=94=A8=E4=BE=8B=E6=94=B9=E5=9B=9E=E7=9C=9F=E5=AE=9E?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - apps/ai-game-creator-shell/tests/appSurface/project-development.suite.ts:`ensure_ui_design_resource_for_prototype` 的 mock 从返回 `null` 改为返回真实形状的桥接结果(asset + manifest + committedProjectRevision + created),并新增 `data-resource-view-state === 'resources.ui-editor'` 断言,让用例真的覆盖它名字里的成功路径而不是被组件吞进错误分支。 --- .../appSurface/project-development.suite.ts | 36 ++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/apps/ai-game-creator-shell/tests/appSurface/project-development.suite.ts b/apps/ai-game-creator-shell/tests/appSurface/project-development.suite.ts index 885d8cc33..62b408736 100644 --- a/apps/ai-game-creator-shell/tests/appSurface/project-development.suite.ts +++ b/apps/ai-game-creator-shell/tests/appSurface/project-development.suite.ts @@ -6566,7 +6566,32 @@ export function registerProjectWorkbenchFoundationTests() { }; } if (command === 'ensure_ui_design_resource_for_prototype') { - return null; + // 必须返回真实形状的成功结果:返回 `null` 会让 `result.manifest.projectId` + // 抛 TypeError 并被组件吞进错误分支,用例就永远测不到它名字里的成功路径。 + return { + asset: { + id: 'ui-design-doc', + kind: GAME_CREATION_APP_UI_DESIGN_DOC_ASSET_KIND, + mediaType: GAME_CREATION_APP_UI_DESIGN_DOC_MEDIA_TYPE, + localPath: 'assets/ui-design.json', + source: { kind: 'generated' as const }, + }, + manifest: { + ...manifest, + assets: [ + ...manifest.assets, + { + id: 'ui-design-doc', + kind: GAME_CREATION_APP_UI_DESIGN_DOC_ASSET_KIND, + mediaType: GAME_CREATION_APP_UI_DESIGN_DOC_MEDIA_TYPE, + localPath: 'assets/ui-design.json', + source: { kind: 'generated' as const }, + }, + ], + }, + committedProjectRevision: 1, + created: true, + }; } throw new Error(`unexpected invoke ${command}`); }, @@ -6599,6 +6624,15 @@ export function registerProjectWorkbenchFoundationTests() { }), }), ); + // 成功路径:桥接结果被接受后画布切到 UI 编辑器视图;走错误分支时会停在 + // `resources.selected.*` 并在提示条上留下原因,这条断言让用例真的覆盖它名字里的事。 + await waitFor(() => + expect( + screen + .getByLabelText('项目主视窗') + .getAttribute('data-resource-view-state'), + ).toBe('resources.ui-editor'), + ); }); it('refuses to embed a non-loopback game preview in the client workbench', () => {