import { describe, it, expect, beforeEach, afterEach } from "vitest";
import { join } from "path";
import { mkdir, rm, readFile } from "fs/promises";
import { tmpdir } from "os";
import { runDeployVerification, quickDeployCheck, loadDeployConfig, generateDeployConfig, detectProvider, checkAllHealth, runAllSmokeTests, calculateHealthScore, calculateSmokeTestScore, isVercelAvailable, createDefaultSmokeTests, } from "../../../scanners/deploy/index.js";
describe("deploy module exports", () => {
    it("exports runDeployVerification", () => {
        expect(typeof runDeployVerification).toBe("function");
    });
    it("exports quickDeployCheck", () => {
        expect(typeof quickDeployCheck).toBe("function");
    });
    it("exports loadDeployConfig", () => {
        expect(typeof loadDeployConfig).toBe("function");
    });
    it("exports generateDeployConfig", () => {
        expect(typeof generateDeployConfig).toBe("function");
    });
    it("exports detectProvider", () => {
        expect(typeof detectProvider).toBe("function");
    });
    it("exports checkAllHealth", () => {
        expect(typeof checkAllHealth).toBe("function");
    });
    it("exports runAllSmokeTests", () => {
        expect(typeof runAllSmokeTests).toBe("function");
    });
    it("exports calculateHealthScore", () => {
        expect(typeof calculateHealthScore).toBe("function");
    });
    it("exports calculateSmokeTestScore", () => {
        expect(typeof calculateSmokeTestScore).toBe("function");
    });
    it("exports isVercelAvailable", () => {
        expect(typeof isVercelAvailable).toBe("function");
    });
});
describe("deploy integration", () => {
    let testDir;
    beforeEach(async () => {
        testDir = join(tmpdir(), `deploy-integration-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`);
        await mkdir(testDir, { recursive: true });
    });
    afterEach(async () => {
        await rm(testDir, { recursive: true, force: true });
    });
    describe("generateDeployConfig", () => {
        it("creates config file", async () => {
            const configPath = await generateDeployConfig(testDir, "vercel");
            expect(configPath).toContain("deploy.yaml");
            const content = await readFile(configPath, "utf-8");
            expect(content).toContain("healthEndpoints");
            expect(content).toContain("smokeTests");
            expect(content).toContain("canary");
        });
    });
    describe("loadDeployConfig", () => {
        it("returns null for non-existent config", async () => {
            const config = await loadDeployConfig(testDir);
            expect(config).toBeNull();
        });
        it("loads generated config", async () => {
            await generateDeployConfig(testDir);
            const config = await loadDeployConfig(testDir);
            expect(config).not.toBeNull();
            expect(config?.healthEndpoints).toBeDefined();
        });
    });
    describe("createDefaultSmokeTests", () => {
        it("returns default smoke tests", () => {
            const tests = createDefaultSmokeTests();
            expect(tests.length).toBeGreaterThan(0);
            expect(tests[0].name).toBe("Homepage loads");
            expect(tests[0].endpoint).toBe("/");
        });
    });
    describe("isVercelAvailable", () => {
        it("returns boolean", () => {
            const result = isVercelAvailable();
            expect(typeof result).toBe("boolean");
        });
    });
});
//# sourceMappingURL=index.test.js.map