Mock fetch that returns 401 for any request (simulates bad key).
()
| 41 | |
| 42 | /** Mock fetch that returns 401 for any request (simulates bad key). */ |
| 43 | function makeAuthFailFetch(): InitDeps['fetchImpl'] { |
| 44 | return vi.fn( |
| 45 | async () => |
| 46 | new Response( |
| 47 | JSON.stringify({ |
| 48 | error: { |
| 49 | code: 'AUTH_INVALID', |
| 50 | message: 'Invalid API key', |
| 51 | nextAction: 'Provide a valid key.', |
| 52 | requestId: 'r-1', |
| 53 | }, |
| 54 | }), |
| 55 | { |
| 56 | status: 401, |
| 57 | headers: { 'content-type': 'application/json' }, |
| 58 | }, |
| 59 | ), |
| 60 | ) as unknown as InitDeps['fetchImpl']; |
| 61 | } |
| 62 | |
| 63 | // --------------------------------------------------------------------------- |
| 64 | // In-memory AgentFs |