All files / api/src/connectors/evaluations/__mocks__ mock-storage-connector.ts

100% Statements 67/67
100% Branches 1/1
100% Functions 1/1
100% Lines 67/67

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76  1x           1x 13x   13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x   13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x 13x  
import type { UserDataStorageConnector } from '@api/types/connector';
import { vi } from 'vitest';
 
/**
 * Creates a mock storage connector for testing evaluations.
 * Returns a connector that provides a default model configuration.
 */
export function createMockStorageConnector(): UserDataStorageConnector {
  return {
    // Required methods for evaluation model resolution
    getSystemSettings: vi.fn().mockResolvedValue({
      id: 'settings-1',
      judge_model_id: 'model-123',
      reflection_model_id: 'model-123',
      evaluation_generation_model_id: 'model-123',
      embedding_model_id: 'embed-123',
      created_at: new Date().toISOString(),
      updated_at: new Date().toISOString(),
    }),
    getModels: vi.fn().mockResolvedValue([
      {
        id: 'model-123',
        ai_provider_id: 'provider-123',
        model_name: 'gpt-4o-mini',
        model_type: 'text',
        embedding_dimensions: null,
        created_at: new Date().toISOString(),
        updated_at: new Date().toISOString(),
      },
    ]),
    getAIProviderAPIKeys: vi.fn().mockResolvedValue([
      {
        id: 'provider-123',
        ai_provider: 'openai',
        api_key: 'test-api-key',
        created_at: new Date().toISOString(),
        updated_at: new Date().toISOString(),
      },
    ]),
    // Stub other methods (not used in evaluation tests)
    getAgents: vi.fn(),
    getAgentById: vi.fn(),
    createAgent: vi.fn(),
    updateAgent: vi.fn(),
    deleteAgent: vi.fn(),
    getSkills: vi.fn(),
    getSkillById: vi.fn(),
    createSkill: vi.fn(),
    updateSkill: vi.fn(),
    deleteSkill: vi.fn(),
    getSkillOptimizationClusters: vi.fn(),
    createSkillOptimizationClusters: vi.fn(),
    updateSkillOptimizationCluster: vi.fn(),
    deleteSkillOptimizationClusters: vi.fn(),
    getSkillOptimizationArms: vi.fn(),
    createSkillOptimizationArms: vi.fn(),
    updateSkillOptimizationArm: vi.fn(),
    deleteSkillOptimizationArms: vi.fn(),
    getSkillOptimizationEvaluations: vi.fn(),
    createSkillOptimizationEvaluation: vi.fn(),
    updateSkillOptimizationEvaluation: vi.fn(),
    deleteSkillOptimizationEvaluation: vi.fn(),
    createModel: vi.fn(),
    updateModel: vi.fn(),
    deleteModel: vi.fn(),
    getSkillModels: vi.fn(),
    addSkillModel: vi.fn(),
    removeSkillModel: vi.fn(),
    createAIProviderAPIKey: vi.fn(),
    getAIProviderAPIKeyById: vi.fn(),
    updateAIProviderAPIKey: vi.fn(),
    deleteAIProviderAPIKey: vi.fn(),
    updateSystemSettings: vi.fn(),
  } as unknown as UserDataStorageConnector;
}