MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / setupE2eMocks

Function setupE2eMocks

sdk/e2e/utils/e2e-mocks.ts:423–457  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

421let mocksApplied = false
422
423export 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}

Callers 1

getApiKeyFunction · 0.90

Calls 1

buildMockAgentTemplateFunction · 0.85

Tested by

no test coverage detected