"""Documentation validation for Delivery Phase 10.1."""
from pathlib import Path

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


def test_phase_docs_exist():
    assert (ROOT / "docs" / "delivery-phase-10-0.md").exists()
    assert (ROOT / "docs" / "delivery-phase-10-1.md").exists()
    assert (ROOT / "docs" / "phase-handover" / "phase-10-0.md").exists()
    assert (ROOT / "docs" / "phase-handover" / "phase-10-1.md").exists()
    assert (ROOT / "docs" / "phases" / "Delivery" / "README.md").exists()
    assert (ROOT / "docs" / "architecture" / "adr" / "ADR-015.md").exists()
    assert (ROOT / "docs" / "delivery-roadmap.md").exists()


def test_module_registry_mentions_delivery():
    text = (ROOT / "docs" / "module-registry.md").read_text(encoding="utf-8")
    assert "## delivery" in text.lower()
    assert "delivery_db" in text
    assert "delivery." in text
    assert "10.1" in text or "0.10.1" in text
    assert "delivery.drivers" in text


def test_progress_mentions_phase_10_1():
    text = (ROOT / "docs" / "progress.md").read_text(encoding="utf-8")
    assert "10.1" in text
    assert "Driver Management" in text or "drivers" in text.lower()


def test_service_readme_documents_boundaries():
    text = (ROOT / "backend" / "services" / "delivery" / "README.md").read_text(
        encoding="utf-8"
    )
    assert "delivery_db" in text
    assert "8007" in text
    assert "drivers" in text.lower()
    assert "dispatch" in text.lower() or "Accounting" in text
