/**
 * Tests for Tactics Registry
 */
import { describe, it, expect } from "vitest";
import { getAllTactics, getTactic } from "../../../../agents/adversary/tactics/index.js";
// Import all tactics to ensure they're registered
import "../../../../agents/adversary/tactics/injection.js";
import "../../../../agents/adversary/tactics/auth.js";
import "../../../../agents/adversary/tactics/api.js";
describe("Tactics Registry", () => {
    it("registers all expected tactics", () => {
        const tactics = getAllTactics();
        const focusAreas = tactics.map((t) => t.focusArea);
        expect(focusAreas).toContain("injection");
        expect(focusAreas).toContain("auth");
        expect(focusAreas).toContain("api");
    });
    it("can retrieve API tactic by focus area", () => {
        const apiTactic = getTactic("api");
        expect(apiTactic).toBeDefined();
        expect(apiTactic?.name).toBe("API Security");
        expect(apiTactic?.focusArea).toBe("api");
    });
    it("can retrieve injection tactic by focus area", () => {
        const injectionTactic = getTactic("injection");
        expect(injectionTactic).toBeDefined();
        expect(injectionTactic?.name).toBe("Injection");
        expect(injectionTactic?.focusArea).toBe("injection");
    });
    it("can retrieve auth tactic by focus area", () => {
        const authTactic = getTactic("auth");
        expect(authTactic).toBeDefined();
        expect(authTactic?.name).toBe("Authentication");
        expect(authTactic?.focusArea).toBe("auth");
    });
    it("returns undefined for unregistered tactic", () => {
        const unknownTactic = getTactic("unknown");
        expect(unknownTactic).toBeUndefined();
    });
    it("all registered tactics have required properties", () => {
        const tactics = getAllTactics();
        for (const tactic of tactics) {
            expect(tactic.focusArea).toBeDefined();
            expect(tactic.name).toBeDefined();
            expect(tactic.description).toBeDefined();
            expect(tactic.patterns).toBeDefined();
            expect(Array.isArray(tactic.patterns)).toBe(true);
            expect(typeof tactic.analyzeFile).toBe("function");
            expect(typeof tactic.generatePoC).toBe("function");
            expect(typeof tactic.getPromptEnhancement).toBe("function");
            expect(typeof tactic.getRelevantFilePatterns).toBe("function");
        }
    });
    it("all tactics have at least one pattern", () => {
        const tactics = getAllTactics();
        for (const tactic of tactics) {
            expect(tactic.patterns.length).toBeGreaterThan(0);
        }
    });
    it("all patterns have required fields", () => {
        const tactics = getAllTactics();
        for (const tactic of tactics) {
            for (const pattern of tactic.patterns) {
                expect(pattern.id).toBeDefined();
                expect(pattern.name).toBeDefined();
                expect(pattern.description).toBeDefined();
                expect(pattern.cwe).toBeDefined();
                expect(pattern.cwe).toMatch(/^CWE-\d+$/);
                expect(pattern.severity).toMatch(/^(critical|high|medium|low)$/);
            }
        }
    });
});
//# sourceMappingURL=registry.test.js.map