From c4065604520b7296b838546e90e5d54536ff8db9 Mon Sep 17 00:00:00 2001 From: Dudu-0223 Date: Mon, 24 Aug 2026 12:05:17 +0800 Subject: [PATCH] test(web): permit loopback integration fixture --- packages/web/tool-web/tests/integration.spec.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/packages/web/tool-web/tests/integration.spec.ts b/packages/web/tool-web/tests/integration.spec.ts index 1aa1fa6416..225c74a2dc 100644 --- a/packages/web/tool-web/tests/integration.spec.ts +++ b/packages/web/tool-web/tests/integration.spec.ts @@ -2,8 +2,9 @@ * Integration: the real fetch backend (`dsh-web-fetch-http`) + a real search provider * (`dsh-web-search-exa`) + the real seam (`dsh-web`) + the model tool (`dsh-tool-web`) + the * tool-call timeout policy (`dsh-tool-call-timeout-policy`), exercised through `ctx.tools.execute()` — - * nothing bypasses the tool registry. Fetch verifies world effects against loopback HTTP; search - * uses the real Exa provider with only its network boundary stubbed. + * nothing bypasses the tool registry. Fetch verifies world effects against loopback HTTP with + * public-address resolution replaced by the fixture address; search uses the real Exa provider + * with only its network boundary stubbed. */ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest' @@ -18,6 +19,7 @@ import * as WebFetchLocal from '@deepseek-ai/dsh-web-fetch-http' import * as WebSearchExa from '@deepseek-ai/dsh-web-search-exa' import * as ToolWeb from '@deepseek-ai/dsh-tool-web' import * as TimeoutPolicy from '@deepseek-ai/dsh-tool-call-timeout-policy' +import { publicHttpNetwork } from '../../web-fetch-http/src/network.ts' const testToolSignal = new AbortController().signal @@ -30,6 +32,7 @@ let ctx: Context let fiber: Awaited> beforeEach(async () => { + vi.spyOn(publicHttpNetwork, 'resolve').mockResolvedValue([{ address: '127.0.0.1', family: 4 }]) handler = (_req, res) => { res.writeHead(200, { 'content-type': 'text/html' }); res.end('

Hello

World

') } server = createServer((req, res) => { handler(req, res) }) await new Promise(resolve => server.listen(0, '127.0.0.1', resolve)) @@ -52,6 +55,7 @@ beforeEach(async () => { afterEach(async () => { await fiber.dispose() vi.unstubAllGlobals() + vi.restoreAllMocks() await new Promise(resolve => server.close(() => { resolve() })) })