diff --git a/src/agents/tools/web-guarded-fetch.test.ts b/src/agents/tools/web-guarded-fetch.test.ts index 7dd874bd0c8..fa362abbda4 100644 --- a/src/agents/tools/web-guarded-fetch.test.ts +++ b/src/agents/tools/web-guarded-fetch.test.ts @@ -39,17 +39,14 @@ describe("web-guarded-fetch", () => { await withTrustedWebToolsEndpoint({ url: "https://example.com" }, async () => undefined); - expect(fetchWithSsrFGuard).toHaveBeenCalledWith( - expect.objectContaining({ - url: "https://example.com", - policy: { - allowRfc2544BenchmarkRange: true, - allowIpv6UniqueLocalRange: true, - hostnameAllowlist: ["example.com"], - }, - mode: GUARDED_FETCH_MODE.TRUSTED_ENV_PROXY, - }), - ); + const call = vi.mocked(fetchWithSsrFGuard).mock.calls[0]?.[0]; + expect(call?.url).toBe("https://example.com"); + expect(call?.policy).toEqual({ + allowRfc2544BenchmarkRange: true, + allowIpv6UniqueLocalRange: true, + hostnameAllowlist: ["example.com"], + }); + expect(call?.mode).toBe(GUARDED_FETCH_MODE.TRUSTED_ENV_PROXY); }); it("uses private-network policy only for self-hosted web tools endpoints", async () => { @@ -61,17 +58,12 @@ describe("web-guarded-fetch", () => { await withSelfHostedWebToolsEndpoint({ url: "http://127.0.0.1:8080" }, async () => undefined); - expect(fetchWithSsrFGuard).toHaveBeenCalledWith( - expect.objectContaining({ - url: "http://127.0.0.1:8080", - policy: expect.objectContaining({ - dangerouslyAllowPrivateNetwork: true, - allowRfc2544BenchmarkRange: true, - allowIpv6UniqueLocalRange: true, - }), - mode: GUARDED_FETCH_MODE.TRUSTED_ENV_PROXY, - }), - ); + const call = vi.mocked(fetchWithSsrFGuard).mock.calls[0]?.[0]; + expect(call?.url).toBe("http://127.0.0.1:8080"); + expect(call?.policy?.dangerouslyAllowPrivateNetwork).toBe(true); + expect(call?.policy?.allowRfc2544BenchmarkRange).toBe(true); + expect(call?.policy?.allowIpv6UniqueLocalRange).toBe(true); + expect(call?.mode).toBe(GUARDED_FETCH_MODE.TRUSTED_ENV_PROXY); }); it("keeps strict endpoint policy unchanged", async () => { @@ -83,12 +75,8 @@ describe("web-guarded-fetch", () => { await withStrictWebToolsEndpoint({ url: "https://example.com" }, async () => undefined); - expect(fetchWithSsrFGuard).toHaveBeenCalledWith( - expect.objectContaining({ - url: "https://example.com", - }), - ); const call = vi.mocked(fetchWithSsrFGuard).mock.calls[0]?.[0]; + expect(call?.url).toBe("https://example.com"); expect(call?.policy).toBeUndefined(); expect(call?.mode).toBe(GUARDED_FETCH_MODE.STRICT); });