Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

✅ test(agent): fix the env hook deny test broken on canary since #20709 (#20738)

Arvin Xu927be0319fb4
diff --git a/apps/server/src/modules/AgentRuntime/__tests__/RuntimeExecutors.test.ts b/apps/server/src/modules/AgentRuntime/__tests__/RuntimeExecutors.test.ts
index 7acd884b254..6d016a1fd4e 100644
--- a/apps/server/src/modules/AgentRuntime/__tests__/RuntimeExecutors.test.ts
+++ b/apps/server/src/modules/AgentRuntime/__tests__/RuntimeExecutors.test.ts
@@ -6064,10 +6064,17 @@ describe('RuntimeExecutors', { timeout: 60_000 }, () => {
}),
);
}
+ // Under `toolCall`, afterToolCall gates a completed result: a call the
+ // before control denied never runs, so it has no result to gate.
expect(
fetchSpy.mock.calls.map(([, init]) => JSON.parse(String(init?.body)).hookType),
- ).toEqual(['beforeToolCall', 'afterToolCall']);
- expect(JSON.parse(String(fetchSpy.mock.calls[1][1]?.body)).mocked).toBe(false);
+ ).toEqual(
+ permissionDecision === 'allow'
+ ? ['beforeToolCall', 'afterToolCall']
+ : ['beforeToolCall'],
+ );
+ if (permissionDecision === 'allow')
+ expect(JSON.parse(String(fetchSpy.mock.calls[1][1]?.body)).mocked).toBe(false);
} finally {
fetchSpy.mockRestore();
vi.unstubAllEnvs();