test(web): permit loopback integration fixture

This commit is contained in:
Dudu-0223
2026-08-24 12:05:17 +08:00
parent 9d5fa7a593
commit c406560452
@@ -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<ReturnType<Context['plugin']>>
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('<h1>Hello</h1><p>World</p>') }
server = createServer((req, res) => { handler(req, res) })
await new Promise<void>(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<void>(resolve => server.close(() => { resolve() }))
})