import type { EvidenceBundle } from "@/lib/applicationEvidenceApi";
import { describe, expect, it } from "vitest";
import { recommendCouncilRankFromEvidence } from "@/components/admin/review/evaluationCategoryRecommendation";

const bundleWithResearch: EvidenceBundle = {
  research: {
    kind: "research",
    originalName: "a.pdf",
    byteSize: 10,
    storageKey: "initiatives/x/research.pdf",
    downloadUrl: null,
    uploadedAt: "2026-01-01T00:00:00Z",
  },
  textbook: null,
  technical: null,
};

const bundleWithTextbook: EvidenceBundle = {
  research: null,
  textbook: {
    kind: "textbook",
    originalName: "t.pdf",
    byteSize: 10,
    storageKey: "initiatives/x/textbook.pdf",
    downloadUrl: null,
    uploadedAt: "2026-01-01T00:00:00Z",
  },
  technical: null,
};

describe("recommendCouncilRankFromEvidence", () => {
  it("suggests Xuất sắc when textbook draft is Xuất sắc — Sách, giáo trình and textbook slot has a file on kho", () => {
    const r = recommendCouncilRankFromEvidence({
      application: {
        initiativeClassification: "textbook",
        textbookEvidenceKind: "book",
      },
      bundle: bundleWithTextbook,
      evidencePhase: "ready",
    });
    expect(r.rank).toContain("Xuất sắc");
    expect(r.detail).toContain("Sách, giáo trình");
  });

  it("suggests Trung bình when research draft is 2.1.4 and research slot has a file on kho", () => {
    const r = recommendCouncilRankFromEvidence({
      application: {
        initiativeClassification: "research",
        researchEvidenceKind: "poster-without-review",
      },
      bundle: bundleWithResearch,
      evidencePhase: "ready",
    });
    expect(r.rank).toContain("Trung bình");
    expect(r.detail).toContain("2.1.4");
  });
});
