import { describe, expect, it } from "vitest";

import {
  aiToolItems,
  primaryAiToolItems,
  secondaryAiToolItems,
} from "./ai-tools";

describe("aiToolItems", () => {
  it("returns 5 items", () => {
    expect(aiToolItems("p1")).toHaveLength(5);
  });

  it("leads with 写本章 (primary, key write)", () => {
    const [first] = aiToolItems("p1");
    expect(first?.label).toBe("写本章");
    expect(first?.primary).toBe(true);
    expect(first?.key).toBe("write");
  });

  it("scopes every href under the project path", () => {
    for (const item of aiToolItems("abc")) {
      expect(item.href.startsWith("/projects/abc/")).toBe(true);
    }
  });

  it("maps 审稿 to the review page and key", () => {
    const review = aiToolItems("p1").find((item) => item.label === "审稿");
    expect(review?.href).toBe("/projects/p1/review");
    expect(review?.key).toBe("review");
  });

  it("keeps high-frequency tools outside the mobile more menu", () => {
    expect(primaryAiToolItems("p1").map((item) => item.key)).toEqual([
      "write",
      "review",
    ]);
    expect(secondaryAiToolItems("p1").map((item) => item.key)).toEqual([
      "outline",
      "codex",
      "toolbox",
    ]);
  });
});
