import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";

const appSource = readFileSync(
  new URL("../../../app/App.tsx", import.meta.url),
  "utf8",
);

describe("F3 capabilities retained during F4", () => {
  it("分类树仍具备加载、空状态、错误重试和真实管理操作", () => {
    for (const marker of [
      "useCategoryTree",
      "DATA_VERSION_CONFLICT",
      "CATEGORY_IN_USE",
      "rowVersion",
      "onAddChild={admin ?",
    ]) expect(appSource).toContain(marker);
    expect(appSource).not.toContain("const CATEGORY_TREE");
  });

  it("ADMIN 保留分类管理，文档浏览分类选择驱动真实查询", () => {
    expect(appSource).toContain("<LeftPanel admin");
    expect(appSource).toContain("selectedCategoryId={categoryId}");
    expect(appSource).toContain("categoryId: categoryId ?? undefined");
  });

  it("权限目录仍来自 F3 真实组织和人员接口", () => {
    expect(appSource).toContain("useOrganizationTree");
    expect(appSource).toContain("useUserDirectory");
    expect(appSource).toContain("includeDescendants");
  });
});
