/**
 * RED-GREEN tests for F-NEW-PRODUCT-PROXY-SELFSERVE-ONBOARDING (W4.4).
 *
 * @connexum/ai-governance  F-NEW-PRODUCT-PROXY-SELFSERVE-ONBOARDING
 */
import { describe, it } from 'node:test';
import * as assert from 'node:assert/strict';
import { buildProxyOnboardingPayload, SUPPORTED_PROVIDERS, } from './proxy-onboarding.js';
const ALL_PROVIDERS = [
    'anthropic',
    'openai',
    'gemini-aistudio',
    'gemini-vertex',
    'bedrock',
    'azure-openai',
    'deepseek',
    'replicate',
    'huggingface',
];
describe('F-NEW-PRODUCT-PROXY-SELFSERVE-ONBOARDING (W4.4)', () => {
    it('SUPPORTED_PROVIDERS covers all 9 Mode A v1 providers', () => {
        assert.equal(SUPPORTED_PROVIDERS.length, 9);
        const ids = SUPPORTED_PROVIDERS.map((p) => p.id).sort();
        assert.deepEqual(ids, [...ALL_PROVIDERS].sort());
    });
    it('every provider produces a non-empty TypeScript snippet', () => {
        for (const provider of ALL_PROVIDERS) {
            const payload = buildProxyOnboardingPayload({ tenantId: 'tenant-1', provider });
            assert.equal(payload.language, 'typescript');
            assert.ok(payload.snippet.length > 0, `${provider} TS snippet`);
            assert.ok(payload.snippet.includes('proxy.my-cc.io'), `${provider} TS snippet must reference proxy host`);
        }
    });
    it('every provider produces a non-empty Python snippet', () => {
        for (const provider of ALL_PROVIDERS) {
            const payload = buildProxyOnboardingPayload({
                tenantId: 'tenant-1',
                provider,
                language: 'python',
            });
            assert.equal(payload.language, 'python');
            assert.ok(payload.snippet.length > 0, `${provider} Python snippet`);
            assert.ok(payload.snippet.includes('proxy.my-cc.io'), `${provider} Python snippet must reference proxy host`);
        }
    });
    it('snippet embeds the tenantId', () => {
        const payload = buildProxyOnboardingPayload({
            tenantId: 'org-acme-7821',
            provider: 'anthropic',
        });
        assert.ok(payload.snippet.includes('org-acme-7821'));
    });
    it('Anthropic TS snippet references X-LLM-API-Key header', () => {
        const payload = buildProxyOnboardingPayload({
            tenantId: 'tenant-1',
            provider: 'anthropic',
        });
        assert.ok(payload.snippet.includes('X-LLM-API-Key'));
    });
    it('OpenAI TS snippet uses /openai/v1 path', () => {
        const payload = buildProxyOnboardingPayload({
            tenantId: 'tenant-1',
            provider: 'openai',
        });
        assert.ok(payload.snippet.includes('/openai/v1'));
    });
    it('Azure OpenAI snippet includes X-Azure-Resource header', () => {
        const payload = buildProxyOnboardingPayload({
            tenantId: 'tenant-1',
            provider: 'azure-openai',
        });
        assert.ok(payload.snippet.includes('X-Azure-Resource'));
    });
    it('proxyHost override is honored', () => {
        const payload = buildProxyOnboardingPayload({
            tenantId: 'tenant-1',
            provider: 'anthropic',
            proxyHost: 'staging-proxy.my-cc.io',
        });
        assert.equal(payload.proxyBaseUrl, 'https://staging-proxy.my-cc.io');
        assert.ok(payload.snippet.includes('staging-proxy.my-cc.io'));
    });
    it('envVars match the provider', () => {
        const a = buildProxyOnboardingPayload({ tenantId: 't', provider: 'anthropic' });
        const b = buildProxyOnboardingPayload({ tenantId: 't', provider: 'bedrock' });
        assert.ok('ANTHROPIC_API_KEY' in a.envVars);
        assert.ok('AWS_ACCESS_KEY_ID' in b.envVars);
    });
    it('firstEventEndpoint includes URL-encoded tenant id', () => {
        const payload = buildProxyOnboardingPayload({
            tenantId: 'acme co/123',
            provider: 'anthropic',
        });
        assert.ok(payload.firstEventEndpoint.includes('acme%20co%2F123'));
    });
    it('missing tenantId throws (fail-closed)', () => {
        assert.throws(() => buildProxyOnboardingPayload({ tenantId: '', provider: 'anthropic' }), /tenantId is required/);
    });
});
//# sourceMappingURL=proxy-onboarding.test.js.map