import { describe, test, expect } from "bun:test";
import { CLONE, DEFAULT_IGNORED_COMMENT_LOGINS, OBSERVABILITY } from "@/core/constants.js";

describe("CLONE", () => {
  test("prewarm timeout is bounded and positive", () => {
    expect(CLONE.PREWARM_TIMEOUT_MS).toBeGreaterThan(0);
    // Must sit under the container health-check startPeriod (300s, the ECS max)
    // so prewarm fails-open before failed /health checks count toward a kill.
    expect(CLONE.PREWARM_TIMEOUT_MS).toBeLessThan(300_000);
  });
});

describe("DEFAULT_IGNORED_COMMENT_LOGINS", () => {
  test("includes cursor[bot]", () => {
    expect(DEFAULT_IGNORED_COMMENT_LOGINS).toContain("cursor[bot]");
  });

  test("includes hu-reviewer[bot]", () => {
    expect(DEFAULT_IGNORED_COMMENT_LOGINS).toContain("hu-reviewer[bot]");
  });

  test("has no duplicates", () => {
    const set = new Set(DEFAULT_IGNORED_COMMENT_LOGINS);
    expect(set.size).toBe(DEFAULT_IGNORED_COMMENT_LOGINS.length);
  });
});

describe("OBSERVABILITY", () => {
  test("AUTH_CHECK_INTERVAL_MS is 5 minutes", () => {
    expect(OBSERVABILITY.AUTH_CHECK_INTERVAL_MS).toBe(5 * 60 * 1000);
  });

  test("SKIP_LOG_THROTTLE_MS is 1 minute", () => {
    expect(OBSERVABILITY.SKIP_LOG_THROTTLE_MS).toBe(60 * 1000);
  });

  test("FAILURE_ESCALATION_THRESHOLD is 3", () => {
    expect(OBSERVABILITY.FAILURE_ESCALATION_THRESHOLD).toBe(3);
  });

  test("QUEUE_SAMPLE_INTERVAL_MS is 30 seconds", () => {
    expect(OBSERVABILITY.QUEUE_SAMPLE_INTERVAL_MS).toBe(30 * 1000);
  });
});
