import { render, screen } from "@testing-library/react";
import { DescriptionOutlined } from "@mui/icons-material";
import PanelEmptyState, { SchemeQueryEmptyState } from "./PanelEmptyState";

describe("PanelEmptyState", () => {
  it("renders an accessible panel instruction", () => {
    render(
      <PanelEmptyState
        icon={<DescriptionOutlined />}
        title="尚未选择分析方案"
        description="请在方案查询中打开一个方案。"
      />,
    );

    expect(screen.getByRole("status")).toHaveAttribute("aria-live", "polite");
    expect(screen.getByText("尚未选择分析方案")).toBeInTheDocument();
    expect(screen.getByText("请在方案查询中打开一个方案。")).toBeInTheDocument();
  });

  it("distinguishes initial query guidance from an empty result", () => {
    const { rerender } = render(
      <SchemeQueryEmptyState hasQueried={false} />,
    );

    expect(screen.getByText("尚未查询历史方案")).toBeInTheDocument();

    rerender(<SchemeQueryEmptyState hasQueried />);

    expect(screen.getByText("未找到符合条件的方案")).toBeInTheDocument();
    expect(
      screen.getByText("请调整查询条件后重新查询，或先创建一个新方案。"),
    ).toBeInTheDocument();
  });

  it("supports compact selection guidance", () => {
    render(
      <PanelEmptyState
        variant="compact"
        title="尚未选择阀门"
        description="点击“选择阀门”，然后在地图上添加。"
      />,
    );

    expect(screen.getByText("尚未选择阀门")).toBeInTheDocument();
  });
});
