Skip to content

Commit 273a0be

Browse files
committed
fix(agent): mock buildAuthHeaders in tests for CI compatibility
1 parent 5a8752f commit 273a0be

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

apps/sim/executor/handlers/agent/agent-handler.test.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,30 @@ vi.mock('@/providers', () => ({
6161
}),
6262
}))
6363

64+
vi.mock('@/executor/utils/http', () => ({
65+
buildAuthHeaders: vi.fn().mockResolvedValue({ 'Content-Type': 'application/json' }),
66+
buildAPIUrl: vi.fn((path: string, params?: Record<string, string>) => {
67+
const url = new URL(path, 'http://localhost:3000')
68+
if (params) {
69+
for (const [key, value] of Object.entries(params)) {
70+
if (value !== undefined && value !== null) {
71+
url.searchParams.set(key, value)
72+
}
73+
}
74+
}
75+
return url
76+
}),
77+
extractAPIErrorMessage: vi.fn(async (response: Response) => {
78+
const defaultMessage = `API request failed with status ${response.status}`
79+
try {
80+
const errorData = await response.json()
81+
return errorData.error || defaultMessage
82+
} catch {
83+
return defaultMessage
84+
}
85+
}),
86+
}))
87+
6488
vi.mock('@sim/db', () => ({
6589
db: {
6690
select: vi.fn().mockReturnValue({

0 commit comments

Comments
 (0)