()
| 421 | let mocksApplied = false |
| 422 | |
| 423 | export function setupE2eMocks(): void { |
| 424 | if (mocksApplied) { |
| 425 | return |
| 426 | } |
| 427 | mocksApplied = true |
| 428 | |
| 429 | spyOn(databaseModule, 'getUserInfoFromApiKey').mockImplementation( |
| 430 | async ({ fields }) => |
| 431 | Object.fromEntries( |
| 432 | fields.map((field) => [field, MOCK_USER[field]]), |
| 433 | ) as unknown as Awaited< |
| 434 | ReturnType<typeof databaseModule.getUserInfoFromApiKey> |
| 435 | >, |
| 436 | ) |
| 437 | spyOn(databaseModule, 'fetchAgentFromDatabase').mockImplementation( |
| 438 | async ({ parsedAgentId }) => buildMockAgentTemplate(parsedAgentId), |
| 439 | ) |
| 440 | spyOn(databaseModule, 'startAgentRun').mockImplementation( |
| 441 | async () => `mock-run-${Math.random().toString(36).slice(2, 10)}`, |
| 442 | ) |
| 443 | spyOn(databaseModule, 'finishAgentRun').mockImplementation(async () => {}) |
| 444 | spyOn(databaseModule, 'addAgentStep').mockImplementation( |
| 445 | async () => `mock-step-${Math.random().toString(36).slice(2, 10)}`, |
| 446 | ) |
| 447 | |
| 448 | spyOn(llmModule, 'promptAiSdkStream').mockImplementation( |
| 449 | promptAiSdkStreamMock, |
| 450 | ) |
| 451 | spyOn(llmModule, 'promptAiSdk').mockImplementation(promptAiSdkMock) |
| 452 | spyOn(llmModule, 'promptAiSdkStructured').mockImplementation( |
| 453 | promptAiSdkStructuredMock as typeof llmModule.promptAiSdkStructured, |
| 454 | ) |
| 455 | |
| 456 | spyOn(CodebuffClient.prototype, 'checkConnection').mockResolvedValue(true) |
| 457 | } |
no test coverage detected