"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 fs = __importStar(require("fs"));
const os = __importStar(require("os"));
const path = __importStar(require("path"));
describe('EnhancedBlindSpots (Phase 8)', () => {
    let tmpDir;
    let testHome;
    let originalUserProfile;
    beforeAll(() => {
        originalUserProfile = process.env.USERPROFILE;
        testHome = path.join(os.tmpdir(), 'fivo-cell-bs-' + Date.now());
        process.env.USERPROFILE = testHome;
    });
    afterAll(async () => {
        process.env.USERPROFILE = originalUserProfile;
        const { closeDb } = await Promise.resolve().then(() => __importStar(require('../walls/06-memory/database/database')));
        closeDb();
        if (fs.existsSync(testHome)) {
            try {
                fs.rmSync(testHome, { recursive: true, force: true });
            }
            catch { }
        }
    });
    beforeEach(() => {
        tmpDir = path.join(os.tmpdir(), 'fivo-cell-bs-test-' + Date.now() + '-' + Math.random().toString(36).slice(2, 8));
        fs.mkdirSync(tmpDir, { recursive: true });
    });
    afterEach(() => {
        if (fs.existsSync(tmpDir)) {
            try {
                fs.rmSync(tmpDir, { recursive: true, force: true });
            }
            catch { }
        }
    });
    describe('detectPromisesWithoutCatch', () => {
        it('detects .then() without .catch()', async () => {
            const f = path.join(tmpDir, 'p1.ts');
            fs.writeFileSync(f, 'fetch("/x").then(r => r.json());');
            const { scanFileForBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = scanFileForBlindSpots(f);
            expect(spots.some(s => s.message.includes('.then() without .catch()'))).toBe(true);
        });
        it('does not flag .then() followed by .catch()', async () => {
            const f = path.join(tmpDir, 'p2.ts');
            fs.writeFileSync(f, 'fetch("/x").then(r => r.json()).catch(e => console.error(e));');
            const { scanFileForBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = scanFileForBlindSpots(f);
            expect(spots.some(s => s.message.includes('.then() without .catch()'))).toBe(false);
        });
    });
    describe('detectApiCallsWithoutErrorState', () => {
        it('detects fetch() without try/catch', async () => {
            const f = path.join(tmpDir, 'api1.ts');
            fs.writeFileSync(f, 'const r = await fetch("/api");');
            const { scanFileForBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = scanFileForBlindSpots(f);
            expect(spots.some(s => s.message.includes('API call without error handling'))).toBe(true);
        });
        it('does not flag fetch inside try/catch', async () => {
            const f = path.join(tmpDir, 'api2.ts');
            fs.writeFileSync(f, 'try {\n  const r = await fetch("/api");\n} catch (e) { console.error(e); }');
            const { scanFileForBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = scanFileForBlindSpots(f);
            expect(spots.some(s => s.message.includes('API call without error handling'))).toBe(false);
        });
    });
    describe('detectApiWithoutTimeout', () => {
        it('detects axios without timeout', async () => {
            const f = path.join(tmpDir, 'ax1.ts');
            fs.writeFileSync(f, 'axios.get("/x");');
            const { scanFileForBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = scanFileForBlindSpots(f);
            expect(spots.some(s => s.message.includes('without timeout'))).toBe(true);
        });
        it('does not flag axios with timeout', async () => {
            const f = path.join(tmpDir, 'ax2.ts');
            fs.writeFileSync(f, 'axios.get("/x", { timeout: 5000 });');
            const { scanFileForBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = scanFileForBlindSpots(f);
            expect(spots.some(s => s.message.includes('without timeout'))).toBe(false);
        });
    });
    describe('detectDbOperationsWithoutRollback', () => {
        it('detects prisma call without transaction', async () => {
            const f = path.join(tmpDir, 'db1.ts');
            fs.writeFileSync(f, 'await prisma.user.create({ data: { name: "x" } });');
            const { scanFileForBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = scanFileForBlindSpots(f);
            expect(spots.some(s => s.message.includes('transaction'))).toBe(true);
        });
    });
    describe('detectFileOpsWithoutErrorHandling', () => {
        it('detects readFile without try/catch', async () => {
            const f = path.join(tmpDir, 'fs1.ts');
            fs.writeFileSync(f, 'const data = await readFile("x.txt", "utf-8");');
            const { scanFileForBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = scanFileForBlindSpots(f);
            expect(spots.some(s => s.message.includes('File operation without error handling'))).toBe(true);
        });
    });
    describe('detectAwaitWithoutNullCheck', () => {
        it('detects await without null check on next lines', async () => {
            const f = path.join(tmpDir, 'n1.ts');
            fs.writeFileSync(f, 'const data = await fetchData();\nconsole.log(data.name);');
            const { scanFileForBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = scanFileForBlindSpots(f);
            expect(spots.some(s => s.message.includes("used without null check"))).toBe(true);
        });
        it('does not flag when null check is present', async () => {
            const f = path.join(tmpDir, 'n2.ts');
            fs.writeFileSync(f, 'const data = await fetchData();\nif (!data) return;\nconsole.log(data.name);');
            const { scanFileForBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = scanFileForBlindSpots(f);
            expect(spots.some(s => s.message.includes("used without null check"))).toBe(false);
        });
    });
    describe('detectArrayAccessWithoutLengthCheck', () => {
        it('detects [0] without length check', async () => {
            const f = path.join(tmpDir, 'a1.ts');
            fs.writeFileSync(f, 'const first = arr[0];');
            const { scanFileForBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = scanFileForBlindSpots(f);
            expect(spots.some(s => s.message.includes('Array index'))).toBe(true);
        });
    });
    describe('detectProcessEnvWithoutFallback', () => {
        it('detects process.env without fallback', async () => {
            const f = path.join(tmpDir, 'e1.ts');
            fs.writeFileSync(f, 'const port = process.env.PORT;');
            const { scanFileForBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = scanFileForBlindSpots(f);
            expect(spots.some(s => s.message.includes('without fallback'))).toBe(true);
        });
        it('does not flag with || fallback', async () => {
            const f = path.join(tmpDir, 'e2.ts');
            fs.writeFileSync(f, 'const port = process.env.PORT || 3000;');
            const { scanFileForBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = scanFileForBlindSpots(f);
            expect(spots.some(s => s.message.includes('without fallback'))).toBe(false);
        });
    });
    describe('detectN1QueryPattern', () => {
        it('detects await DB call inside for-loop', async () => {
            const f = path.join(tmpDir, 'n11.ts');
            fs.writeFileSync(f, 'for (const u of users) {\n  await prisma.order.findMany({ where: { userId: u.id } });\n}');
            const { scanFileForBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = scanFileForBlindSpots(f);
            expect(spots.some(s => s.message.includes('N+1 query pattern'))).toBe(true);
        });
    });
    describe('detectSyncOpsInAsyncCode', () => {
        it('detects readFileSync in async function', async () => {
            const f = path.join(tmpDir, 's1.ts');
            fs.writeFileSync(f, 'async function load() {\n  const d = readFileSync("x.txt");\n}');
            const { scanFileForBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = scanFileForBlindSpots(f);
            expect(spots.some(s => s.message.includes('Sync file/exec operation'))).toBe(true);
        });
    });
    describe('detectAnyUsage', () => {
        it('detects : any', async () => {
            const f = path.join(tmpDir, 'a1.ts');
            fs.writeFileSync(f, 'const x: any = 1;');
            const { scanFileForBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = scanFileForBlindSpots(f);
            expect(spots.some(s => s.message.includes('`any` type'))).toBe(true);
        });
        it('detects as any', async () => {
            const f = path.join(tmpDir, 'a2.ts');
            fs.writeFileSync(f, 'const x = foo as any;');
            const { scanFileForBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = scanFileForBlindSpots(f);
            expect(spots.some(s => s.message.includes('`any` type'))).toBe(true);
        });
    });
    describe('detectConsoleLogInProduction', () => {
        it('flags files with console.log', async () => {
            const f = path.join(tmpDir, 'c1.ts');
            fs.writeFileSync(f, 'console.log("debug");\nconsole.log("more debug");');
            const { scanFileForBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = scanFileForBlindSpots(f);
            expect(spots.some(s => s.message.includes('console.log in source'))).toBe(true);
        });
    });
    describe('detectMissingPagination', () => {
        it('detects findMany() without take/skip', async () => {
            const f = path.join(tmpDir, 'pg1.ts');
            fs.writeFileSync(f, 'const users = await prisma.user.findMany({});');
            const { scanFileForBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = scanFileForBlindSpots(f);
            expect(spots.some(s => s.message.includes('pagination'))).toBe(true);
        });
        it('does not flag findMany with take', async () => {
            const f = path.join(tmpDir, 'pg2.ts');
            fs.writeFileSync(f, 'const users = await prisma.user.findMany({ take: 50 });');
            const { scanFileForBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = scanFileForBlindSpots(f);
            expect(spots.some(s => s.message.includes('pagination'))).toBe(false);
        });
    });
    describe('detectMissingReactErrorBoundaries', () => {
        it('flags .tsx without ErrorBoundary', async () => {
            const f = path.join(tmpDir, 'r1.tsx');
            fs.writeFileSync(f, 'export default function App() { return (<div>Hi</div>); }');
            const { scanFileForBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = scanFileForBlindSpots(f);
            expect(spots.some(s => s.message.includes('ErrorBoundary'))).toBe(true);
        });
    });
    describe('summarizeBlindSpots', () => {
        it('counts by severity and category', async () => {
            const { summarizeBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = [
                { id: '1', category: 'error_handling', severity: 'high', message: '', filePath: 'a.ts', lineNumber: 1, codeSnippet: '', recommendation: '', detectedAt: '' },
                { id: '2', category: 'null_safety', severity: 'medium', message: '', filePath: 'b.ts', lineNumber: 1, codeSnippet: '', recommendation: '', detectedAt: '' },
                { id: '3', category: 'error_handling', severity: 'critical', message: '', filePath: 'a.ts', lineNumber: 5, codeSnippet: '', recommendation: '', detectedAt: '' },
            ];
            const s = summarizeBlindSpots(spots);
            expect(s.total).toBe(3);
            expect(s.critical).toBe(1);
            expect(s.high).toBe(1);
            expect(s.medium).toBe(1);
            expect(s.low).toBe(0);
            expect(s.byCategory['error_handling']).toBe(2);
            expect(s.byFile['a.ts']).toBe(2);
        });
    });
    describe('formatBlindSpotReport', () => {
        it('returns success message when no spots', async () => {
            const { formatBlindSpotReport } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const r = formatBlindSpotReport([]);
            expect(r).toContain('No blind spots');
        });
        it('groups spots by severity in output', async () => {
            const { formatBlindSpotReport } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = [
                { id: '1', category: 'x', severity: 'critical', message: 'm1', filePath: 'a.ts', lineNumber: 1, codeSnippet: '', recommendation: '', detectedAt: '' },
                { id: '2', category: 'x', severity: 'low', message: 'm2', filePath: 'b.ts', lineNumber: 2, codeSnippet: '', recommendation: '', detectedAt: '' },
            ];
            const r = formatBlindSpotReport(spots);
            expect(r).toContain('CRITICAL');
            expect(r).toContain('LOW');
            expect(r).toContain('Total');
        });
    });
    describe('scanDirectoryForBlindSpots', () => {
        it('walks directory and returns combined results', async () => {
            fs.writeFileSync(path.join(tmpDir, 'a.ts'), 'const x: any = 1;');
            fs.writeFileSync(path.join(tmpDir, 'b.ts'), 'fetch("/x").then(r => r.json());');
            fs.mkdirSync(path.join(tmpDir, 'sub'), { recursive: true });
            fs.writeFileSync(path.join(tmpDir, 'sub', 'c.ts'), 'await readFileSync("x");');
            const { scanDirectoryForBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = scanDirectoryForBlindSpots(tmpDir, 50);
            expect(spots.length).toBeGreaterThan(0);
        });
        it('ignores node_modules and .git', async () => {
            fs.mkdirSync(path.join(tmpDir, 'node_modules'), { recursive: true });
            fs.writeFileSync(path.join(tmpDir, 'node_modules', 'x.ts'), 'const x: any = 1;');
            const { scanDirectoryForBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = scanDirectoryForBlindSpots(tmpDir, 50);
            const hasNodeModules = spots.some(s => s.filePath.includes('node_modules'));
            expect(hasNodeModules).toBe(false);
        });
    });
    describe('detectAsyncWithoutTryCatch', () => {
        it('detects async function with await but no try/catch', async () => {
            const f = path.join(tmpDir, 'a.ts');
            fs.writeFileSync(f, 'async function fetchPayment() {\n  const result = await db.query();\n  return result;\n}');
            const { scanFileForBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = scanFileForBlindSpots(f);
            expect(spots.some(s => s.message.includes('await') && s.message.includes('try/catch'))).toBe(true);
        });
        it('does not flag async with try/catch', async () => {
            const f = path.join(tmpDir, 'b.ts');
            fs.writeFileSync(f, 'async function safe() {\n  try {\n    const r = await db.query();\n    return r;\n  } catch (e) {\n    return null;\n  }\n}');
            const { scanFileForBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = scanFileForBlindSpots(f);
            expect(spots.some(s => s.message.includes('try/catch'))).toBe(false);
        });
    });
    describe('detectChainedPropertyAccess', () => {
        it('detects result.data.items without null check after await', async () => {
            const f = path.join(tmpDir, 'c.ts');
            fs.writeFileSync(f, 'async function get() {\n  const result = await fetch("/x");\n  return result.data.items;\n}');
            const { scanFileForBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = scanFileForBlindSpots(f);
            expect(spots.some(s => s.message.includes('Chained access'))).toBe(true);
        });
        it('does not flag with optional chaining', async () => {
            const f = path.join(tmpDir, 'd.ts');
            fs.writeFileSync(f, 'async function get() {\n  const result = await fetch("/x");\n  return result?.data?.items;\n}');
            const { scanFileForBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = scanFileForBlindSpots(f);
            expect(spots.some(s => s.message.includes('Chained access'))).toBe(false);
        });
    });
    describe('scanFileForBlindSpots cap', () => {
        it('caps output at 25 spots per file', async () => {
            // Generate a file with many any usages
            const lines = ['const x: any = 1;'];
            for (let i = 0; i < 60; i++)
                lines.push(`const y${i}: any = ${i};`);
            const f = path.join(tmpDir, 'e.ts');
            fs.writeFileSync(f, lines.join('\n'));
            const { scanFileForBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = scanFileForBlindSpots(f);
            expect(spots.length).toBeLessThanOrEqual(25);
        });
    });
    describe('Phase 1 — Priority Scoring', () => {
        it('rankBlindSpots assigns priorityScore', async () => {
            const { rankBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = [
                { id: '1', category: 'error_handling', severity: 'high', message: 'Missing try/catch', filePath: 'a.ts', lineNumber: 1, codeSnippet: '', recommendation: '', detectedAt: '', priorityScore: 0 },
                { id: '2', category: 'quality', severity: 'low', message: 'console.log', filePath: 'b.ts', lineNumber: 2, codeSnippet: '', recommendation: '', detectedAt: '', priorityScore: 0 },
                { id: '3', category: 'error_handling', severity: 'critical', message: 'Missing try/catch', filePath: 'c.ts', lineNumber: 3, codeSnippet: '', recommendation: '', detectedAt: '', priorityScore: 0 },
            ];
            const ranked = rankBlindSpots(spots);
            expect(ranked.length).toBe(3);
            for (const s of ranked) {
                expect(s.priorityScore).toBeGreaterThan(0);
            }
        });
        it('rankBlindSpots sorts by priority descending', async () => {
            const { rankBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = [
                { id: '1', category: 'quality', severity: 'low', message: 'console.log', filePath: 'a.ts', lineNumber: 1, codeSnippet: '', recommendation: '', detectedAt: '', priorityScore: 0 },
                { id: '2', category: 'error_handling', severity: 'high', message: 'Missing try/catch', filePath: 'b.ts', lineNumber: 2, codeSnippet: '', recommendation: '', detectedAt: '', priorityScore: 0 },
            ];
            const ranked = rankBlindSpots(spots);
            expect(ranked[0].severity).toBe('high');
            expect(ranked[1].severity).toBe('low');
            expect(ranked[0].priorityScore).toBeGreaterThan(ranked[1].priorityScore);
        });
        it('getTopFixes returns correct count', async () => {
            const { getTopFixes } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = [
                { id: '1', category: 'error_handling', severity: 'high', message: 'err1', filePath: 'a.ts', lineNumber: 1, codeSnippet: '', recommendation: '', detectedAt: '' },
                { id: '2', category: 'error_handling', severity: 'high', message: 'err2', filePath: 'b.ts', lineNumber: 2, codeSnippet: '', recommendation: '', detectedAt: '' },
                { id: '3', category: 'quality', severity: 'low', message: 'err3', filePath: 'c.ts', lineNumber: 3, codeSnippet: '', recommendation: '', detectedAt: '' },
                { id: '4', category: 'null_safety', severity: 'high', message: 'err4', filePath: 'd.ts', lineNumber: 4, codeSnippet: '', recommendation: '', detectedAt: '' },
                { id: '5', category: 'performance', severity: 'medium', message: 'err5', filePath: 'e.ts', lineNumber: 5, codeSnippet: '', recommendation: '', detectedAt: '' },
                { id: '6', category: 'validation', severity: 'medium', message: 'err6', filePath: 'f.ts', lineNumber: 6, codeSnippet: '', recommendation: '', detectedAt: '' },
            ];
            const top3 = getTopFixes(spots, 3);
            expect(top3.length).toBe(3);
            for (const s of top3) {
                expect(s.priorityScore).toBeGreaterThan(0);
            }
            expect(top3[0].priorityScore).toBeGreaterThanOrEqual(top3[1].priorityScore);
        });
        it('getTopFixes returns empty for empty input', async () => {
            const { getTopFixes } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            expect(getTopFixes([], 5)).toEqual([]);
        });
        it('repeated issues get higher priority score', async () => {
            const { rankBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = [
                { id: '1', category: 'error_handling', severity: 'high', message: 'same issue', filePath: 'a.ts', lineNumber: 1, codeSnippet: '', recommendation: '', detectedAt: '' },
                { id: '2', category: 'error_handling', severity: 'high', message: 'same issue', filePath: 'b.ts', lineNumber: 2, codeSnippet: '', recommendation: '', detectedAt: '' },
                { id: '3', category: 'error_handling', severity: 'high', message: 'unique issue', filePath: 'c.ts', lineNumber: 3, codeSnippet: '', recommendation: '', detectedAt: '' },
            ];
            const ranked = rankBlindSpots(spots);
            const sameScore = ranked.filter(s => s.message === 'same issue')[0].priorityScore;
            const uniqueScore = ranked.filter(s => s.message === 'unique issue')[0].priorityScore;
            expect(sameScore).toBeGreaterThan(uniqueScore);
        });
        it('getCategorySummary groups and counts correctly', async () => {
            const { getCategorySummary } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const spots = [
                { id: '1', category: 'error_handling', severity: 'high', message: 'err', filePath: 'a.ts', lineNumber: 1, codeSnippet: '', recommendation: '', detectedAt: '' },
                { id: '2', category: 'error_handling', severity: 'critical', message: 'err2', filePath: 'b.ts', lineNumber: 2, codeSnippet: '', recommendation: '', detectedAt: '' },
                { id: '3', category: 'quality', severity: 'low', message: 'err3', filePath: 'c.ts', lineNumber: 3, codeSnippet: '', recommendation: '', detectedAt: '' },
            ];
            const summary = getCategorySummary(spots);
            expect(summary.length).toBe(2);
            const eh = summary.find(c => c.category === 'error_handling');
            expect(eh.count).toBe(2);
            expect(eh.topSeverity).toBe('critical');
            const q = summary.find(c => c.category === 'quality');
            expect(q.count).toBe(1);
        });
        it('getCategorySummary returns empty for empty input', async () => {
            const { getCategorySummary } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            expect(getCategorySummary([])).toEqual([]);
        });
        it('priorityScore is added to scanDirectoryForBlindSpots via getTopFixes', async () => {
            const { getTopFixes, scanDirectoryForBlindSpots } = await Promise.resolve().then(() => __importStar(require('../core/enhanced-blind-spots')));
            const f = path.join(tmpDir, 'priority-test.ts');
            fs.writeFileSync(f, 'async function noTry() {\n  const x = await fetch("/");\n  return x;\n}\nconst y: any = 1;');
            const spots = scanDirectoryForBlindSpots(tmpDir, 50);
            const top = getTopFixes(spots, 5);
            if (top.length > 0) {
                expect(top[0].priorityScore).toBeGreaterThan(0);
            }
        });
    });
});
//# sourceMappingURL=enhanced-blind-spots.test.js.map