"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const database_1 = require("../walls/06-memory/database/database");
const memory_event_store_1 = require("../walls/06-memory/stores/memory-event-store");
const summary_generator_1 = require("../walls/06-memory/stores/summary-generator");
describe('Summary Generator', () => {
    beforeAll(() => {
        (0, database_1.getDb)();
    });
    afterEach(() => {
        const db = (0, database_1.getDb)();
        db.prepare('DELETE FROM memory_events WHERE project = ?').run('summary-test');
    });
    it('generateDailySummary returns empty for no data', () => {
        const summary = (0, summary_generator_1.generateDailySummary)('summary-test');
        expect(summary.totalEvents).toBe(0);
        expect(summary.project).toBe('summary-test');
        expect(summary.date).toBeTruthy();
    });
    it('generateDailySummary counts events by type', () => {
        (0, memory_event_store_1.recordMemoryEvent)({ project: 'summary-test', type: 'edit', summary: 'Edit 1', importance: 3 });
        (0, memory_event_store_1.recordMemoryEvent)({ project: 'summary-test', type: 'edit', summary: 'Edit 2', importance: 3 });
        (0, memory_event_store_1.recordMemoryEvent)({ project: 'summary-test', type: 'error', summary: 'Error 1', importance: 7 });
        const summary = (0, summary_generator_1.generateDailySummary)('summary-test');
        expect(summary.totalEvents).toBe(3);
        expect(summary.byType.edit).toBe(2);
        expect(summary.byType.error).toBe(1);
    });
    it('generateDailySummary captures key decisions', () => {
        (0, memory_event_store_1.recordMemoryEvent)({ project: 'summary-test', type: 'decision', summary: 'Use SQLite', importance: 8 });
        (0, memory_event_store_1.recordMemoryEvent)({ project: 'summary-test', type: 'edit', summary: 'Edit 1', importance: 3 });
        const summary = (0, summary_generator_1.generateDailySummary)('summary-test');
        expect(summary.keyDecisions).toContain('Use SQLite');
    });
    it('generateDailySummary captures errors', () => {
        (0, memory_event_store_1.recordMemoryEvent)({ project: 'summary-test', type: 'error', summary: 'Connection timeout', importance: 7 });
        const summary = (0, summary_generator_1.generateDailySummary)('summary-test');
        expect(summary.errors).toContain('Connection timeout');
    });
    it('generateWeeklySummary returns aggregated data', () => {
        (0, memory_event_store_1.recordMemoryEvent)({ project: 'summary-test', type: 'edit', summary: 'Weekly edit', importance: 3 });
        const summary = (0, summary_generator_1.generateWeeklySummary)('summary-test', process.cwd());
        expect(summary.totalEvents).toBeGreaterThanOrEqual(1);
        expect(summary.date).toContain('_to_');
    });
    it('generateDailySummary calculates avg importance', () => {
        (0, memory_event_store_1.recordMemoryEvent)({ project: 'summary-test', type: 'edit', summary: 'Low', importance: 2 });
        (0, memory_event_store_1.recordMemoryEvent)({ project: 'summary-test', type: 'decision', summary: 'High', importance: 8 });
        const summary = (0, summary_generator_1.generateDailySummary)('summary-test');
        expect(summary.importance).toBe(5);
    });
});
//# sourceMappingURL=summary-generator.test.js.map