import { describe, it, expect } from "vitest";
import { render, screen } from "@testing-library/react";
import { SelectionOverlay } from "./selection-overlay";

describe("SelectionOverlay", () => {
  it("renders nothing when rect is null (no selection)", () => {
    render(<SelectionOverlay rect={null} />);
    expect(screen.queryByTestId("selection-overlay")).not.toBeInTheDocument();
  });

  it("positions the ring from the agent-reported rect", () => {
    render(
      <SelectionOverlay rect={{ x: 24, y: 12, width: 320, height: 48 }} />,
    );
    const overlay = screen.getByTestId("selection-overlay");
    expect(overlay).toHaveStyle({
      position: "absolute",
      left: "24px",
      top: "12px",
      width: "320px",
      height: "48px",
    });
  });

  it("is chrome, not content: hidden from a11y and inert to pointers (ADR-028)", () => {
    render(<SelectionOverlay rect={{ x: 0, y: 0, width: 10, height: 10 }} />);
    const overlay = screen.getByTestId("selection-overlay");
    expect(overlay).toHaveAttribute("aria-hidden", "true");
    expect(overlay).toHaveStyle({ pointerEvents: "none" });
  });
});
