"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const database_1 = require("../walls/06-memory/database/database");
const proactive_insights_1 = require("../walls/06-memory/stores/proactive-insights");
describe('Proactive Insights', () => {
    beforeAll(() => { (0, database_1.getDb)(); });
    afterEach(() => {
        const db = (0, database_1.getDb)();
        db.prepare('DELETE FROM memory_events WHERE project = ?').run('alerts-test');
    });
    it('returns empty for no data', () => {
        const alerts = (0, proactive_insights_1.generateProactiveAlerts)('nonexistent');
        expect(alerts.length).toBe(0);
    });
    it('getAlertSummary returns summary object', () => {
        const s = (0, proactive_insights_1.getAlertSummary)('nonexistent');
        expect(s).toHaveProperty('total');
        expect(s).toHaveProperty('critical');
        expect(s).toHaveProperty('warnings');
        expect(s).toHaveProperty('alerts');
    });
    it('detects repeat mistakes', () => {
        const db = (0, database_1.getDb)();
        for (let i = 0; i < 4; i++) {
            db.prepare(`INSERT INTO memory_events (project, type, summary, importance, created_at)
         VALUES (?, 'error', 'TypeError: cannot read', 7, datetime('now'))`).run('alerts-test');
        }
        const alerts = (0, proactive_insights_1.generateProactiveAlerts)('alerts-test');
        expect(alerts.some(a => a.type === 'repeat_mistake')).toBe(true);
    });
    it('detects low verification', () => {
        const db = (0, database_1.getDb)();
        for (let i = 0; i < 20; i++) {
            db.prepare(`INSERT INTO memory_events (project, type, summary, importance, created_at)
         VALUES (?, 'edit', ?, 3, datetime('now'))`).run('alerts-test', `Edit ${i}`);
        }
        const alerts = (0, proactive_insights_1.generateProactiveAlerts)('alerts-test');
        expect(alerts.some(a => a.type === 'low_verification')).toBe(true);
    });
    it('detects decision gap', () => {
        const db = (0, database_1.getDb)();
        for (let i = 0; i < 35; i++) {
            db.prepare(`INSERT INTO memory_events (project, type, summary, importance, created_at)
         VALUES (?, 'edit', ?, 3, datetime('now'))`).run('alerts-test', `Event ${i}`);
        }
        const alerts = (0, proactive_insights_1.generateProactiveAlerts)('alerts-test');
        expect(alerts.some(a => a.type === 'decision_gap')).toBe(true);
    });
});
//# sourceMappingURL=proactive-insights.test.js.map