From 1f5b7b250a86b2cab45e12044ad5bdcf3d8cf079 Mon Sep 17 00:00:00 2001 From: kdletters <61648117+kdletters@users.noreply.github.com> Date: Thu, 17 Sep 2026 18:03:15 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E9=A6=96=E9=A1=B5=E6=8E=A8?= =?UTF-8?q?=E8=8D=90=E4=BD=8D=E7=94=A8=E4=BE=8B=E6=96=AD=E8=A8=80=E5=88=B0?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 首页「灵感推荐」已被模板库推荐位替换,用例改为断言模板库推荐卡片、已下载徽标与共 N 个模板计数 - 用例改为断言点击推荐位进入模板库页面,且不触发下载或由模板创建项目 - 保留不请求已退役展示流接口的断言 --- .../tests/appSurface/home.suite.ts | 100 +++++++++++++++--- 1 file changed, 87 insertions(+), 13 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 a1ab75aad..47e386b36 100644 --- a/apps/ai-game-creator-shell/tests/appSurface/home.suite.ts +++ b/apps/ai-game-creator-shell/tests/appSurface/home.suite.ts @@ -182,24 +182,98 @@ export function registerClientHomeTests() { ); }); - it('shows the built-in inspiration masonry gallery and opens a dismissible preview without requesting the retired feed', async () => { + it('shows the home template recommendations and opens the library without creating a project', async () => { const fetchSpy = vi.spyOn(globalThis, 'fetch'); + const templateLibrarySnapshot = { + schemaVersion: 'game-template-library.v1', + library: 'genarrative-official', + libraryVersion: 3, + updatedAt: '2026-09-17T00:00:00Z', + fetchedAtMillis: 1, + source: 'remote', + templates: [ + { + id: 'lane-defense', + title: '星际防线', + summary: '塔防原型', + tags: ['塔防'], + runtime: 'phaser', + engine: 'Phaser', + engineVersion: '4.2.1', + templateVersion: '1.0.0', + updatedAt: '2026-09-17T00:00:00Z', + entry: 'index.html', + zipUrl: + 'https://agc-dev.oss-rg-china-mainland.aliyuncs.com/agc/templates/lane-defense.zip', + zipSizeBytes: 2048, + zipSha256: 'a'.repeat(64), + coverUrl: + 'https://agc-dev.oss-rg-china-mainland.aliyuncs.com/agc/templates/lane-defense.png', + coverWidth: 320, + coverHeight: 180, + installed: true, + installedVersion: '1.0.0', + installedAtMillis: 2, + }, + { + id: 'cozy-farm', + title: '悠然农场', + summary: '经营原型', + tags: ['经营'], + runtime: 'phaser', + engine: 'Phaser', + engineVersion: '4.2.1', + templateVersion: '1.0.0', + updatedAt: '2026-09-17T00:00:00Z', + entry: 'index.html', + zipUrl: + 'https://agc-dev.oss-rg-china-mainland.aliyuncs.com/agc/templates/cozy-farm.zip', + zipSizeBytes: 4096, + zipSha256: 'b'.repeat(64), + coverUrl: + 'https://agc-dev.oss-rg-china-mainland.aliyuncs.com/agc/templates/cozy-farm.png', + coverWidth: 320, + coverHeight: 180, + installed: false, + installedVersion: null, + installedAtMillis: null, + }, + ], + }; + const invoke = vi.fn(async (command: string) => { + if (command === 'read_game_creator_app_config') { + return { config: { selectedModelId: 'quality' } }; + } + if (command === 'fetch_game_template_library') { + return templateLibrarySnapshot; + } + throw new Error(`unexpected invoke ${command}`); + }); + window.__TAURI__ = { core: { invoke } }; renderLauncherAt('/?launcher'); - const inspiration = screen.getByLabelText('灵感推荐'); - const inspirationImages = within(inspiration).getAllByRole('button', { - name: /查看灵感图片/, + // 首页推荐位只展示封面、标题、运行时与已下载徽标,本机灵感图库已随模板库上线删除。 + const recommendations = await screen.findByLabelText('模板库推荐'); + const recommendationCards = within(recommendations).getAllByRole('button', { + name: /^查看模板 /u, }); - expect(inspirationImages.length).toBeGreaterThan(0); - expect(inspiration.closest('.overflow-y-auto')).not.toBeNull(); - expect(screen.queryByText('暂无灵感')).toBeNull(); + expect(recommendationCards.length).toBe(2); + expect(within(recommendationCards[0]!).getByText('已下载')).not.toBeNull(); - fireEvent.click(inspirationImages[0]!); - const preview = screen.getByRole('dialog', { name: '查看灵感图片' }); - fireEvent.click(screen.getByAltText('放大的灵感图片')); - expect(screen.getByRole('dialog', { name: '查看灵感图片' })).not.toBeNull(); - fireEvent.click(preview); - expect(screen.queryByRole('dialog', { name: '查看灵感图片' })).toBeNull(); + fireEvent.click(recommendationCards[0]!); + + // 点击推荐位只进入模板库页面,不在首页直接下载或创建项目。 + const librarySummary = await screen.findByText('共 2 个模板 · 已下载 1 个'); + expect(librarySummary).not.toBeNull(); + expect(screen.getByRole('button', { name: '返回' })).not.toBeNull(); + expect(screen.queryByLabelText('模板库推荐')).toBeNull(); + expect( + invoke.mock.calls.some( + ([command]) => + command === 'download_game_template' || + command === 'create_automatic_local_game_project_from_template', + ), + ).toBe(false); await act(async () => { await Promise.resolve();