"use strict";
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 team_composer_1 = require("../team-composer");
const pattern_store_1 = require("../../walls/06-memory/stores/pattern-store");
const path = __importStar(require("path"));
const fs = __importStar(require("fs"));
describe('TeamComposer', () => {
    let composer;
    let store;
    const testDir = path.join(process.cwd(), '.fivo/cell');
    beforeEach(() => {
        if (!fs.existsSync(testDir)) {
            fs.mkdirSync(testDir, { recursive: true });
        }
        store = new pattern_store_1.PatternStore(testDir);
        composer = new team_composer_1.TeamComposer(store, testDir);
    });
    afterEach(() => {
        const teamDir = path.join(testDir, 'team');
        if (fs.existsSync(teamDir)) {
            fs.rmSync(teamDir, { recursive: true, force: true });
        }
    });
    test('computes team weight for junior', () => {
        const member = {
            username: 'junior_dev',
            seniority: 'junior',
            tenureMonths: 3,
            signalCount: 100,
            reviewApprovalRate: 0.8,
        };
        const weight = composer.computeTeamWeight(member);
        expect(weight).toBeGreaterThan(0);
        expect(weight).toBeLessThan(10);
    });
    test('computes team weight for lead', () => {
        const member = {
            username: 'lead_dev',
            seniority: 'lead',
            tenureMonths: 24,
            signalCount: 2000,
            reviewApprovalRate: 0.95,
        };
        const weight = composer.computeTeamWeight(member);
        expect(weight).toBeGreaterThan(15);
    });
    test('push and pull taste', () => {
        store.addOrUpdatePattern('variable_declaration', 'Prefers const', 'var', 'const', true);
        store.save();
        composer.pushTaste('alice');
        const members = composer.getTeamMembers();
        expect(members).toHaveLength(1);
        expect(members[0]).toBeTruthy();
        const taste = composer.pullTaste('alice');
        expect(taste).not.toBeNull();
        expect(taste.patterns.length).toBeGreaterThan(0);
    });
    test('pull team taste aggregates multiple members', () => {
        store.addOrUpdatePattern('variable_declaration', 'Prefers const', 'var', 'const', true);
        store.save();
        composer.pushTaste('alice');
        store.clear();
        store.addOrUpdatePattern('function_style', 'Prefers arrow', 'function', 'arrow', true);
        store.save();
        composer.pushTaste('bob');
        const teamTaste = composer.pullTeamTaste();
        expect(teamTaste).not.toBeNull();
        expect(teamTaste.patterns.length).toBeGreaterThanOrEqual(1);
    });
    test('getOnboardingWeight returns correct ramp', () => {
        expect(composer.getOnboardingWeight(1)).toBe(0.2);
        expect(composer.getOnboardingWeight(2)).toBe(0.4);
        expect(composer.getOnboardingWeight(3)).toBe(0.6);
        expect(composer.getOnboardingWeight(4)).toBe(0.8);
        expect(composer.getOnboardingWeight(5)).toBe(0.8);
    });
    test('getTeamMembers returns empty for no pushes', () => {
        expect(composer.getTeamMembers()).toHaveLength(0);
    });
});
//# sourceMappingURL=team-composer.test.js.map