From 1a8c30c865aa26c85df3ea0814ab5038634e3e73 Mon Sep 17 00:00:00 2001 From: kdletters Date: Wed, 16 Sep 2026 02:01:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=8E=E5=8F=B0=E8=BD=AE?= =?UTF-8?q?=E8=AF=A2=E5=B9=B2=E6=89=B0=E4=BC=9A=E8=AF=9D=E9=9A=94=E7=A6=BB?= =?UTF-8?q?=E6=B5=8B=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 只核对刷新之后最后一次目标会话读取的完整参数 避免无关活动回合轮询改变全局最后调用而造成偶发失败 补充 IPC 异步测试边界约定 --- .../tests/appSurface/developer-agent-window.suite.ts | 8 ++++++-- docs/project-memory/shared-memory/pitfalls.md | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/apps/ai-game-creator-shell/tests/appSurface/developer-agent-window.suite.ts b/apps/ai-game-creator-shell/tests/appSurface/developer-agent-window.suite.ts index a39b53478..e83e4128c 100644 --- a/apps/ai-game-creator-shell/tests/appSurface/developer-agent-window.suite.ts +++ b/apps/ai-game-creator-shell/tests/appSurface/developer-agent-window.suite.ts @@ -649,17 +649,21 @@ export function registerDeveloperAgentWindowTests() { sourceSessionId: createdSessionId, title: '', }); + const refreshCallStart = invoke.mock.calls.length; fireEvent.click(screen.getByRole('button', { name: '刷新状态' })); expect(await screen.findByText('只属于新会话的问题')).not.toBeNull(); await waitFor(() => { - expect(invoke).toHaveBeenLastCalledWith( + const runtimeReads = invoke.mock.calls + .slice(refreshCallStart) + .filter(([command]) => command === 'read_game_creator_agent_runtime'); + expect(runtimeReads.at(-1)).toEqual([ 'read_game_creator_agent_runtime', { projectPath: '/tmp/authorized-game', agentId: 'design-director', sessionId: archivedForkedSessionId, }, - ); + ]); }); }); diff --git a/docs/project-memory/shared-memory/pitfalls.md b/docs/project-memory/shared-memory/pitfalls.md index 1ae8c60d6..444798e15 100644 --- a/docs/project-memory/shared-memory/pitfalls.md +++ b/docs/project-memory/shared-memory/pitfalls.md @@ -5615,3 +5615,4 @@ Cocos Creator 根目录由 `package.json.creator.version` 与普通 `assets/` - 在 hook 内运行临时仓库测试时,`cwd` 不会覆盖继承的 `GIT_DIR`、`GIT_WORK_TREE` 或 `GIT_INDEX_FILE`。未隔离的 Git/lint-staged 子进程可能向真实仓库提交 fixture,甚至把测试版 ESLint、Prettier 配置带入主分支。 - fixture 子进程统一清除 `GIT_*` 环境,并用一次性外层 linked worktree 验证引用、索引、配置不变;原有工程检查规则保持完整,不能用逐项关闭规则修复 fixture 污染。 - Vitest 的 `toHaveBeenCalledWith` 匹配任意一次调用,失败输出会列出其它命令;应先定位相同命令的真实参数差异,不能由其它调用的序号推断时序故障。 +- 存在后台轮询的 IPC mock 不应要求目标命令占据全局最后一次调用。验证刷新时先记录调用边界,再筛选该边界之后的目标命令,严格核对其最后一次参数,避免后台查询影响断言,也避免旧调用掩盖刷新未执行。