import { describe, it, beforeEach, afterEach } from 'node:test'; import assert from 'node:assert/strict'; import fs from 'node:fs'; import os from 'node:os'; import path from 'node:path'; import { loadExclusions, applyExclusions } from './findings.js'; import { EXCLUSIONS_PATH } from './config.js'; describe('findings exclusions', () => { let workspace; beforeEach(() => { workspace = fs.mkdtempSync(path.join(os.tmpdir(), 'findings-test-')); }); afterEach(() => { fs.rmSync(workspace, { recursive: true, force: true }); }); it('loads excluded_findings wrapper format', () => { const fullPath = path.join(workspace, EXCLUSIONS_PATH); fs.mkdirSync(path.dirname(fullPath), { recursive: true }); fs.writeFileSync(fullPath, JSON.stringify({ excluded_findings: [ { location: 'entrypoint.sh:180', title: 'fetch_package_versions jq overhead' }, ], }, null, 2)); const exclusions = loadExclusions(workspace); assert.equal(exclusions.length, 1); assert.equal(exclusions[0].location, 'entrypoint.sh:180'); assert.equal(exclusions[0].title, 'fetch_package_versions jq overhead'); }); it('applies exclusions loaded from wrapper format', () => { const findings = [ { location: 'entrypoint.sh:180', role: 'Maya', suggestion: 'keep' }, { location: 'README.md:12', role: 'Maya', suggestion: 'keep' }, ]; const exclusions = [ { location: 'entrypoint.sh:180', title: 'fetch_package_versions jq overhead' }, ]; const filtered = applyExclusions(findings, exclusions); assert.equal(filtered.length, 1); assert.equal(filtered[0].location, 'README.md:12'); }); });