import { describe, it, expect } from "vitest";
import { render, screen } from "@testing-library/react";
import { CaseOverviewGrid } from "@/components/dashboard/CaseOverviewGrid";
import type { CaseSummary } from "@/lib/types";

describe("CaseOverviewGrid", () => {
  const defaultData: CaseSummary = {
    active_count: 15,
    new_this_month: 4,
    closed_count: 8,
  };

  it("renders all three case categories", () => {
    render(<CaseOverviewGrid data={defaultData} />);

    expect(screen.getByText("Aktive Akten")).toBeInTheDocument();
    expect(screen.getByText("Neu (Monat)")).toBeInTheDocument();
    expect(screen.getByText("Abgeschlossen")).toBeInTheDocument();
  });

  it("displays correct counts", () => {
    render(<CaseOverviewGrid data={defaultData} />);

    expect(screen.getByText("15")).toBeInTheDocument();
    expect(screen.getByText("4")).toBeInTheDocument();
    expect(screen.getByText("8")).toBeInTheDocument();
  });

  it("renders the section header", () => {
    render(<CaseOverviewGrid data={defaultData} />);

    expect(screen.getByText("Aktenübersicht")).toBeInTheDocument();
  });

  it("handles zero counts", () => {
    const zeroData: CaseSummary = {
      active_count: 0,
      new_this_month: 0,
      closed_count: 0,
    };

    render(<CaseOverviewGrid data={zeroData} />);

    const zeros = screen.getAllByText("0");
    expect(zeros).toHaveLength(3);
  });
});
