from pathlib import Path

from app.skill_loader import load_skill_catalog


def test_load_skill_catalog_reads_index_and_skill_files() -> None:
    skills = load_skill_catalog(Path("skills") / "GJB438C-2021_prd_skills")

    assert len(skills) >= 30
    skill_names = {skill.slug for skill in skills}
    assert "gjb438c-software-requirements-spec-structure" in skill_names
    target = next(skill for skill in skills if skill.slug == "gjb438c-software-requirements-spec-structure")
    assert "软件需求规格说明" in target.content
    assert target.path.name == "SKILL.md"


def test_load_skill_catalog_reads_gjb438b_collection() -> None:
    skills = load_skill_catalog(Path("skills") / "GJB438B-2009_prd_skills")

    assert len(skills) > 0
    assert any(skill.slug.startswith("gjb438b-") for skill in skills)
