"use strict";
/**
 * RED-GREEN tests for the hook install snippet generator.
 *
 * @connexum/ai-governance  hook-install path (companion to W4.4 proxy onboarding)
 */
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    var desc = Object.getOwnPropertyDescriptor(m, k);
    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
      desc = { enumerable: true, get: function() { return m[k]; } };
    }
    Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
    if (k2 === undefined) k2 = k;
    o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
    Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
    o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
    var ownKeys = function(o) {
        ownKeys = Object.getOwnPropertyNames || function (o) {
            var ar = [];
            for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
            return ar;
        };
        return ownKeys(o);
    };
    return function (mod) {
        if (mod && mod.__esModule) return mod;
        var result = {};
        if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
        __setModuleDefault(result, mod);
        return result;
    };
})();
Object.defineProperty(exports, "__esModule", { value: true });
const node_test_1 = require("node:test");
const assert = __importStar(require("node:assert/strict"));
const hook_install_snippet_1 = require("./hook-install-snippet");
const ALL = [
    'claude-code',
    'openai-agents-py',
    'openai-agents-ts',
    'langchain-py',
    'langchain-ts',
    'crew-ai',
    'langgraph',
];
(0, node_test_1.describe)('hook install snippet generator', () => {
    (0, node_test_1.it)('SUPPORTED_HOOK_FRAMEWORKS lists all 7 frameworks', () => {
        const ids = hook_install_snippet_1.SUPPORTED_HOOK_FRAMEWORKS.map((f) => f.id).sort();
        assert.deepEqual(ids, [...ALL].sort());
    });
    (0, node_test_1.it)('every framework produces an install command + config path + snippet + verification', () => {
        for (const framework of ALL) {
            const s = (0, hook_install_snippet_1.buildHookInstallSnippet)({ framework, tenantId: 'tenant-1' });
            assert.ok(s.installCommand.length > 0, `${framework} installCommand`);
            assert.ok(s.configPath.length > 0, `${framework} configPath`);
            assert.ok(s.snippet.length > 0, `${framework} snippet`);
            assert.ok(s.verificationStep.length > 0, `${framework} verificationStep`);
            assert.ok(s.snippet.includes('tenant-1'), `${framework} snippet must embed tenantId`);
        }
    });
    (0, node_test_1.it)('claude-code uses settings.json and PreToolUse / PostToolUse hooks', () => {
        const s = (0, hook_install_snippet_1.buildHookInstallSnippet)({ framework: 'claude-code', tenantId: 'tenant-1' });
        assert.match(s.configPath, /\.claude\/settings\.json$/);
        assert.match(s.snippet, /PreToolUse/);
        assert.match(s.snippet, /PostToolUse/);
        assert.match(s.installCommand, /npx @connexum\/ai-governance init/);
    });
    (0, node_test_1.it)('openai-agents-py uses pip + wrap_agent', () => {
        const s = (0, hook_install_snippet_1.buildHookInstallSnippet)({ framework: 'openai-agents-py', tenantId: 'tenant-1' });
        assert.match(s.installCommand, /pip install connexum-governance/);
        assert.match(s.snippet, /wrap_agent/);
        assert.match(s.snippet, /tenant_id="tenant-1"/);
    });
    (0, node_test_1.it)('openai-agents-ts uses npm + wrapAgent', () => {
        const s = (0, hook_install_snippet_1.buildHookInstallSnippet)({ framework: 'openai-agents-ts', tenantId: 'tenant-1' });
        assert.match(s.installCommand, /npm install @connexum\/ai-governance/);
        assert.match(s.snippet, /wrapAgent/);
        assert.match(s.snippet, /tenantId: 'tenant-1'/);
    });
    (0, node_test_1.it)('langchain-py uses callbacks=[cb]', () => {
        const s = (0, hook_install_snippet_1.buildHookInstallSnippet)({ framework: 'langchain-py', tenantId: 'tenant-1' });
        assert.match(s.snippet, /ConnexumGovernanceCallback/);
        assert.match(s.snippet, /callbacks=\[cb\]/);
    });
    (0, node_test_1.it)('langchain-ts uses callbacks: [cb]', () => {
        const s = (0, hook_install_snippet_1.buildHookInstallSnippet)({ framework: 'langchain-ts', tenantId: 'tenant-1' });
        assert.match(s.snippet, /ConnexumGovernanceCallback/);
        assert.match(s.snippet, /callbacks: \[cb\]/);
    });
    (0, node_test_1.it)('crew-ai uses GovernedCrew', () => {
        const s = (0, hook_install_snippet_1.buildHookInstallSnippet)({ framework: 'crew-ai', tenantId: 'tenant-1' });
        assert.match(s.snippet, /GovernedCrew/);
        assert.match(s.snippet, /connexum_tenant_id="tenant-1"/);
    });
    (0, node_test_1.it)('langgraph uses attach_governance', () => {
        const s = (0, hook_install_snippet_1.buildHookInstallSnippet)({ framework: 'langgraph', tenantId: 'tenant-1' });
        assert.match(s.snippet, /attach_governance/);
    });
    (0, node_test_1.it)('endpoint override is honored', () => {
        const s = (0, hook_install_snippet_1.buildHookInstallSnippet)({
            framework: 'claude-code',
            tenantId: 'tenant-1',
            endpoint: 'https://staging-events.my-cc.io/api/v1/events',
        });
        assert.ok(s.snippet.includes('staging-events.my-cc.io'));
    });
    (0, node_test_1.it)('default endpoint references proxy.my-cc.io', () => {
        const s = (0, hook_install_snippet_1.buildHookInstallSnippet)({ framework: 'claude-code', tenantId: 'tenant-1' });
        assert.ok(s.endpoint.includes('proxy.my-cc.io'));
        assert.ok(s.snippet.includes('proxy.my-cc.io'));
    });
    (0, node_test_1.it)('missing tenantId throws (fail-closed)', () => {
        assert.throws(() => (0, hook_install_snippet_1.buildHookInstallSnippet)({ framework: 'claude-code', tenantId: '' }), /tenantId is required/);
    });
    (0, node_test_1.it)('verificationStep mentions the dashboard + 5-second window for every framework', () => {
        for (const framework of ALL) {
            const s = (0, hook_install_snippet_1.buildHookInstallSnippet)({ framework, tenantId: 'tenant-1' });
            assert.match(s.verificationStep, /dashboard/i);
            assert.match(s.verificationStep, /5 seconds/);
        }
    });
});
//# sourceMappingURL=hook-install-snippet.test.js.map