"""Documentation presence tests for Sports Center phases."""
from pathlib import Path

ROOT = Path(__file__).resolve().parents[5]


def test_phase_doc_exists():
    path = ROOT / "docs" / "sports-center-phase-9-0.md"
    assert path.exists()
    text = path.read_text(encoding="utf-8")
    assert "Phase 9.0" in text
    assert "sports_center_db" in text


def test_phase_91_doc_exists():
    path = ROOT / "docs" / "sports-center-phase-9-1.md"
    assert path.exists()
    text = path.read_text(encoding="utf-8")
    assert "Phase 9.1" in text


def test_phase_92_doc_exists():
    path = ROOT / "docs" / "sports-center-phase-9-2.md"
    assert path.exists()
    text = path.read_text(encoding="utf-8")
    assert "Phase 9.2" in text
    assert "Member Management" in text


def test_handover_doc_exists():
    path = ROOT / "docs" / "phase-handover" / "phase-9-0.md"
    assert path.exists()
    text = path.read_text(encoding="utf-8")
    assert "Phase 9.1" in text


def test_handover_91_doc_exists():
    path = ROOT / "docs" / "phase-handover" / "phase-9-1.md"
    assert path.exists()
    text = path.read_text(encoding="utf-8")
    assert "9.2" in text


def test_phase_96_doc_exists():
    path = ROOT / "docs" / "sports-center-phase-9-6.md"
    assert path.exists()
    text = path.read_text(encoding="utf-8")
    assert "Phase 9.6" in text
    assert "Training Management" in text


def test_handover_96_doc_exists():
    path = ROOT / "docs" / "phase-handover" / "phase-9-6.md"
    assert path.exists()
    text = path.read_text(encoding="utf-8")
    assert "9.7" in text


def test_phase_97_doc_exists():
    path = ROOT / "docs" / "sports-center-phase-9-7.md"
    assert path.exists()
    text = path.read_text(encoding="utf-8")
    assert "Phase 9.7" in text
    assert "Competition" in text


def test_handover_97_doc_exists():
    path = ROOT / "docs" / "phase-handover" / "phase-9-7.md"
    assert path.exists()
    text = path.read_text(encoding="utf-8")
    assert "9.8" in text


def test_module_registry_mentions_sports_center():
    path = ROOT / "docs" / "module-registry.md"
    text = path.read_text(encoding="utf-8")
    assert "sports-center" in text or "sports_center" in text
    assert "sports_center_db" in text


def test_service_readme_exists():
    path = Path(__file__).resolve().parents[2] / "README.md"
    assert path.exists()
    text = path.read_text(encoding="utf-8")
    assert "sports_center_db" in text
