fix(ci): mock secureFetchWithPinnedIP in tools tests to prevent timeouts

This commit is contained in:
Waleed Latif
2026-04-09 14:22:19 -07:00
parent 2eef467519
commit 5819bfa564

View File

@@ -26,6 +26,8 @@ const {
mockListCustomTools,
mockGetCustomToolByIdOrTitle,
mockGenerateInternalToken,
mockSecureFetchWithPinnedIP,
mockValidateUrlWithDNS,
} = vi.hoisted(() => ({
mockIsHosted: { value: false },
mockEnv: { NEXT_PUBLIC_APP_URL: 'http://localhost:3000' } as Record<string, string | undefined>,
@@ -40,6 +42,8 @@ const {
mockListCustomTools: vi.fn(),
mockGetCustomToolByIdOrTitle: vi.fn(),
mockGenerateInternalToken: vi.fn(),
mockSecureFetchWithPinnedIP: vi.fn(),
mockValidateUrlWithDNS: vi.fn(),
}))
// Mock feature flags
@@ -73,6 +77,11 @@ vi.mock('@/lib/auth/internal', () => ({
vi.mock('@/lib/billing/core/usage-log', () => ({}))
vi.mock('@/lib/core/security/input-validation.server', () => ({
secureFetchWithPinnedIP: (...args: unknown[]) => mockSecureFetchWithPinnedIP(...args),
validateUrlWithDNS: (...args: unknown[]) => mockValidateUrlWithDNS(...args),
}))
vi.mock('@/lib/core/rate-limiter/hosted-key', () => ({
getHostedKeyRateLimiter: () => mockRateLimiterFns,
}))
@@ -476,6 +485,11 @@ describe('Automatic Internal Route Detection', () => {
beforeEach(() => {
process.env.NEXT_PUBLIC_APP_URL = 'http://localhost:3000'
cleanupEnvVars = setupEnvVars({ NEXT_PUBLIC_APP_URL: 'http://localhost:3000' })
mockValidateUrlWithDNS.mockResolvedValue({ isValid: true, resolvedIP: '93.184.216.34' })
mockSecureFetchWithPinnedIP.mockResolvedValue(
new Response(JSON.stringify({}), { status: 200, headers: { 'content-type': 'application/json' } })
)
})
afterEach(() => {