import { describe, it, expect } from "vitest";
import { render, screen } from "@testing-library/react";
import { QueueSummary } from "@/components/QueueSummary";
import { makeFocusItem } from "../helpers/fixtures";

describe("QueueSummary", () => {
  it("shows empty queue message when no items", () => {
    render(<QueueSummary queue={[]} />);
    expect(screen.getByText(/queue is empty/i)).toBeInTheDocument();
  });

  it("shows review count", () => {
    const queue = [
      makeFocusItem({ id: "a", type: "mr_review" }),
      makeFocusItem({ id: "b", type: "mr_review" }),
    ];
    render(<QueueSummary queue={queue} />);
    expect(screen.getByText(/2 reviews/)).toBeInTheDocument();
  });

  it("shows singular for 1 item", () => {
    const queue = [makeFocusItem({ id: "a", type: "issue" })];
    render(<QueueSummary queue={queue} />);
    expect(screen.getByText(/1 issue(?!s)/)).toBeInTheDocument();
  });

  it("shows mixed counts separated by dots", () => {
    const queue = [
      makeFocusItem({ id: "a", type: "mr_review" }),
      makeFocusItem({ id: "b", type: "issue" }),
      makeFocusItem({ id: "c", type: "issue" }),
      makeFocusItem({ id: "d", type: "manual" }),
    ];
    render(<QueueSummary queue={queue} />);
    const text = screen.getByText(/Queue:/);
    expect(text.textContent).toContain("1 review");
    expect(text.textContent).toContain("2 issues");
    expect(text.textContent).toContain("1 task");
  });
});
