import { describe, it, expect } from "vitest";
import { runScaleAssessment, quickBottleneckScan, discoverProfiles, generateSampleProfile, detectBottlenecks, calculateBottleneckScore, estimateCapacity, calculateCapacityScore, detectLoadTool, isK6Available, } from "../../../scanners/scale/index.js";
describe("scale module exports", () => {
    it("exports runScaleAssessment", () => {
        expect(typeof runScaleAssessment).toBe("function");
    });
    it("exports quickBottleneckScan", () => {
        expect(typeof quickBottleneckScan).toBe("function");
    });
    it("exports discoverProfiles", () => {
        expect(typeof discoverProfiles).toBe("function");
    });
    it("exports generateSampleProfile", () => {
        expect(typeof generateSampleProfile).toBe("function");
    });
    it("exports detectBottlenecks", () => {
        expect(typeof detectBottlenecks).toBe("function");
    });
    it("exports calculateBottleneckScore", () => {
        expect(typeof calculateBottleneckScore).toBe("function");
    });
    it("exports estimateCapacity", () => {
        expect(typeof estimateCapacity).toBe("function");
    });
    it("exports calculateCapacityScore", () => {
        expect(typeof calculateCapacityScore).toBe("function");
    });
    it("exports detectLoadTool", () => {
        expect(typeof detectLoadTool).toBe("function");
    });
    it("exports isK6Available", () => {
        expect(typeof isK6Available).toBe("function");
    });
});
describe("scale integration", () => {
    describe("quickBottleneckScan", () => {
        it("returns score and bottlenecks", async () => {
            const result = await quickBottleneckScan(".");
            expect(result).toHaveProperty("score");
            expect(result).toHaveProperty("bottlenecks");
            expect(typeof result.score).toBe("number");
            expect(Array.isArray(result.bottlenecks)).toBe(true);
        });
    });
    describe("estimateCapacity", () => {
        it("returns conservative estimates without load test", async () => {
            const estimate = await estimateCapacity();
            expect(estimate.maxConcurrentUsers).toBe(100);
            expect(estimate.maxRequestsPerSecond).toBe(50);
            expect(estimate.recommendations).toContain("Run load tests to get accurate capacity estimates");
        });
    });
    describe("calculateCapacityScore", () => {
        it("returns 100 for 5x headroom", () => {
            const estimate = {
                maxConcurrentUsers: 500,
                maxRequestsPerSecond: 1000,
                estimatedBreakpoint: { vus: 500, confidence: 0.8 },
                recommendations: [],
            };
            const score = calculateCapacityScore(estimate, 100);
            expect(score).toBe(100);
        });
        it("returns lower score for tight capacity", () => {
            const estimate = {
                maxConcurrentUsers: 120,
                maxRequestsPerSecond: 200,
                estimatedBreakpoint: { vus: 120, confidence: 0.6 },
                recommendations: [],
            };
            const score = calculateCapacityScore(estimate, 100);
            expect(score).toBeLessThan(100);
            expect(score).toBeGreaterThanOrEqual(50);
        });
        it("returns low score when below target", () => {
            const estimate = {
                maxConcurrentUsers: 50,
                maxRequestsPerSecond: 100,
                estimatedBreakpoint: { vus: 50, confidence: 0.5 },
                recommendations: [],
            };
            const score = calculateCapacityScore(estimate, 100);
            expect(score).toBeLessThan(50);
        });
    });
});
//# sourceMappingURL=index.test.js.map