import { describe, test, expect, beforeAll } from "vitest"; import { resolveAuditCatalog, type RuleMeta } from "./catalog"; import { renderHtml, type AuditSnapshot } from "./report-html"; import type { AuditFinding } from "./core"; const CI = `name: CI on: pull_request_target: permissions: write-all jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 `; const FINDINGS: AuditFinding[] = [ { checkId: "GHA033", severity: "warning", message: "write-all permissions.", file: ".github/workflows/ci.yml", lexicon: "github" }, { checkId: "GHA035", severity: "error", message: "elevated token on pull_request_target.", file: ".github/workflows/ci.yml", lexicon: "github" }, { checkId: "GHA022", severity: "info", message: "no timeout.", file: ".github/workflows/ci.yml", lexicon: "github" }, ]; const SNAPSHOT: AuditSnapshot = { target: "https://github.com/owner/repo", host: "github.com", repo: "owner/repo", commit: "11bd71901bbe5b1630ceea73d27597364c9af683", files: [".github/workflows/ci.yml"], generatedAt: "2026-06-16T00:00:00.000Z", toolVersion: "0.4.0", }; let CATALOG: Record; beforeAll(async () => { CATALOG = await resolveAuditCatalog(["github", "gitlab"]); }); /** renderHtml with the migrated github/gitlab catalog injected (#687). */ const html2 = (findings: AuditFinding[], opts: Parameters[1] = {}) => renderHtml(findings, { ...opts, catalog: CATALOG }); describe("renderHtml", () => { test("produces a self-contained HTML document with sections and snapshot", () => { const html = html2(FINDINGS, { files: [{ path: ".github/workflows/ci.yml", content: CI }], snapshot: SNAPSHOT }); expect(html.startsWith("")).toBe(true); expect(html).toContain("