// frontend/tests/Topbar.test.tsx
import { render, screen } from "@testing-library/react";
import { describe, it, expect, vi } from "vitest";
import { Topbar } from "@/components/Topbar";

vi.mock("next/navigation", () => ({ usePathname: () => "/tasks" }));

describe("Topbar", () => {
  it("13개 메인 내비 항목을 렌더한다", () => {
    render(<Topbar />);
    [
      "대시보드",
      "인박스",
      "결재함",
      "자동화",
      "여정",
      "일정",
      "작업",
      "메일",
      "알림",
      "리서치",
      "여행",
      "라이프",
      "하루 마감",
    ].forEach((label) => expect(screen.getByText(label)).toBeInTheDocument());
  });

  it("현재 경로(/tasks=작업)가 active 클래스 + aria-current=page", () => {
    render(<Topbar />);
    const active = screen.getByRole("link", { name: /작업/ });
    expect(active).toHaveClass("active");
    expect(active).toHaveAttribute("aria-current", "page");
  });

  it("결재함=3, 작업=4, 알림=6 배지가 표시된다", () => {
    render(<Topbar />);
    expect(screen.getByText("3")).toBeInTheDocument();
    expect(screen.getByText("4")).toBeInTheDocument();
    expect(screen.getByText("6")).toBeInTheDocument();
  });

  it("브랜드/아바타 텍스트와 우측 액션 aria-label", () => {
    render(<Topbar />);
    expect(screen.getByText("아리")).toBeInTheDocument();
    expect(screen.getByText("AI LIFE OS")).toBeInTheDocument();
    expect(screen.getByText("지")).toBeInTheDocument(); // user.initial
    expect(screen.getByLabelText("검색")).toBeInTheDocument();
    expect(screen.getByLabelText("알림")).toBeInTheDocument();
    expect(screen.getByLabelText("테마 전환")).toBeInTheDocument();
  });
});
