From f5dc6050c4a9993a299e558d8e80accdb1cd918c Mon Sep 17 00:00:00 2001 From: Linghong Date: Fri, 14 Aug 2026 12:19:30 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9C=80=E8=BF=91=E9=A1=B9?= =?UTF-8?q?=E7=9B=AE=E6=89=93=E5=BC=80=E7=9B=AE=E5=BD=95=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E7=AB=9E=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 状态文案是在 await invoke 之后才 setStatus 的,而测试的 waitFor 只等到 invoke 被调用——invoke 在点击处理器里是同步发出的,第一次检查就通过并 立即返回,此时状态写入和随后的渲染都还没发生。断言能否看到文案取决于 RTL 内部恰好冲刷了几个微任务,CI 负载高时就翻车。 改用 findByText 显式等待。1543 那条是同一形态的隐患,一并改掉。 Co-Authored-By: Claude Opus 5 --- apps/ai-game-creator-shell/tests/appSurface/home.suite.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 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 f4046af9b..ace0c0a08 100644 --- a/apps/ai-game-creator-shell/tests/appSurface/home.suite.ts +++ b/apps/ai-game-creator-shell/tests/appSurface/home.suite.ts @@ -1515,7 +1515,7 @@ export function registerRecentProjectsTests() { 'open_game_creator_workspace_window', expect.anything(), ); - expect(screen.getByText('已打开项目目录')).not.toBeNull(); + expect(await screen.findByText('已打开项目目录')).not.toBeNull(); expect(window.localStorage.length).toBe(1); }); @@ -1540,7 +1540,7 @@ export function registerRecentProjectsTests() { projectPath: '/tmp/typed-game', }); }); - expect(screen.getByText('已打开项目目录')).not.toBeNull(); + expect(await screen.findByText('已打开项目目录')).not.toBeNull(); }); it('rejects invalid typed launcher project directories before opening them', () => {