"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const globals_1 = require("@jest/globals");
const defaults_1 = require("../../src/providers/defaults");
// Mock logger to avoid console output during tests
jest.mock('../../src/logger', () => ({
    debug: jest.fn(),
}));
class MockProvider {
    constructor(id) {
        this.providerId = id;
    }
    id() {
        return this.providerId;
    }
    async callApi() {
        return {};
    }
}
(0, globals_1.describe)('Provider override tests', () => {
    const originalEnv = process.env;
    (0, globals_1.beforeEach)(() => {
        // Reset environment before each test
        process.env = { ...originalEnv };
        // Clear any previous provider settings
        (0, defaults_1.setDefaultCompletionProviders)(undefined);
        (0, defaults_1.setDefaultEmbeddingProviders)(undefined);
    });
    (0, globals_1.afterEach)(() => {
        process.env = originalEnv;
        jest.clearAllMocks();
    });
    (0, globals_1.it)('should override all completion providers when setDefaultCompletionProviders is called', async () => {
        // Setup a mock provider
        const mockProvider = new MockProvider('test-completion-provider');
        await (0, defaults_1.setDefaultCompletionProviders)(mockProvider);
        const providers = await (0, defaults_1.getDefaultProviders)();
        // Check that all completion providers were overridden
        (0, globals_1.expect)(providers.datasetGenerationProvider.id()).toBe('test-completion-provider');
        (0, globals_1.expect)(providers.gradingJsonProvider.id()).toBe('test-completion-provider');
        (0, globals_1.expect)(providers.gradingProvider.id()).toBe('test-completion-provider');
        (0, globals_1.expect)(providers.suggestionsProvider.id()).toBe('test-completion-provider');
        (0, globals_1.expect)(providers.synthesizeProvider.id()).toBe('test-completion-provider');
        // Verify embedding provider was not affected
        (0, globals_1.expect)(providers.embeddingProvider.id()).not.toBe('test-completion-provider');
    });
    (0, globals_1.it)('should override embedding provider when setDefaultEmbeddingProviders is called', async () => {
        // Setup a mock provider
        const mockProvider = new MockProvider('test-embedding-provider');
        await (0, defaults_1.setDefaultEmbeddingProviders)(mockProvider);
        const providers = await (0, defaults_1.getDefaultProviders)();
        // Check that embedding provider was overridden
        (0, globals_1.expect)(providers.embeddingProvider.id()).toBe('test-embedding-provider');
        // Verify completion providers were not affected
        (0, globals_1.expect)(providers.datasetGenerationProvider.id()).not.toBe('test-embedding-provider');
        (0, globals_1.expect)(providers.gradingJsonProvider.id()).not.toBe('test-embedding-provider');
        (0, globals_1.expect)(providers.gradingProvider.id()).not.toBe('test-embedding-provider');
        (0, globals_1.expect)(providers.suggestionsProvider.id()).not.toBe('test-embedding-provider');
        (0, globals_1.expect)(providers.synthesizeProvider.id()).not.toBe('test-embedding-provider');
    });
    (0, globals_1.it)('should allow both completion and embedding provider overrides simultaneously', async () => {
        const mockCompletionProvider = new MockProvider('test-completion-provider');
        const mockEmbeddingProvider = new MockProvider('test-embedding-provider');
        await (0, defaults_1.setDefaultCompletionProviders)(mockCompletionProvider);
        await (0, defaults_1.setDefaultEmbeddingProviders)(mockEmbeddingProvider);
        const providers = await (0, defaults_1.getDefaultProviders)();
        // Check completion providers
        (0, globals_1.expect)(providers.datasetGenerationProvider.id()).toBe('test-completion-provider');
        (0, globals_1.expect)(providers.gradingJsonProvider.id()).toBe('test-completion-provider');
        (0, globals_1.expect)(providers.gradingProvider.id()).toBe('test-completion-provider');
        (0, globals_1.expect)(providers.suggestionsProvider.id()).toBe('test-completion-provider');
        (0, globals_1.expect)(providers.synthesizeProvider.id()).toBe('test-completion-provider');
        // Check embedding provider
        (0, globals_1.expect)(providers.embeddingProvider.id()).toBe('test-embedding-provider');
    });
});
//# sourceMappingURL=defaults.test.js.map