"""Documentation validation for Hospitality Phase 12.2."""
from pathlib import Path

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


def _read(rel: str) -> str:
    return (ROOT / rel).read_text(encoding="utf-8")


def test_phase_docs_exist_and_mention_db():
    text = _read("docs/hospitality-phase-12-2.md")
    assert "hospitality_db" in text
    assert "12.2" in text
    assert "Torbat Food" in text
    assert "QR" in text


def test_handover_exists():
    text = _read("docs/phase-handover/phase-12-2.md")
    assert "hospitality" in text.lower()
    assert "12.2" in text
    assert "hospitality_db" in text


def test_phase_12_3_docs_exist_and_mention_db():
    text = _read("docs/hospitality-phase-12-3.md")
    assert "hospitality_db" in text
    assert "12.3" in text
    assert "Torbat Food" in text
    assert "Reservation" in text or "reservation" in text


def test_phase_12_3_handover_exists():
    text = _read("docs/phase-handover/phase-12-3.md")
    assert "hospitality" in text.lower()
    assert "12.3" in text
    assert "hospitality_db" in text


def test_phase_12_4_docs_exist_and_mention_db():
    text = _read("docs/hospitality-phase-12-4.md")
    assert "hospitality_db" in text
    assert "12.4" in text
    assert "Torbat Food" in text
    assert "POS" in text


def test_phase_12_4_handover_exists():
    text = _read("docs/phase-handover/phase-12-4.md")
    assert "hospitality" in text.lower()
    assert "12.4" in text
    assert "hospitality_db" in text


def test_phase_12_5_docs_exist_and_mention_db():
    text = _read("docs/hospitality-phase-12-5.md")
    assert "hospitality_db" in text
    assert "12.5" in text
    assert "Torbat Food" in text
    assert "POS" in text


def test_phase_12_5_handover_exists():
    text = _read("docs/phase-handover/phase-12-5.md")
    assert "hospitality" in text.lower()
    assert "12.5" in text
    assert "hospitality_db" in text


def test_phase_12_6_docs_exist_and_mention_db():
    text = _read("docs/hospitality-phase-12-6.md")
    assert "hospitality_db" in text
    assert "12.6" in text
    assert "Torbat Food" in text
    assert "Kitchen" in text or "kitchen" in text


def test_phase_12_6_handover_exists():
    text = _read("docs/phase-handover/phase-12-6.md")
    assert "hospitality" in text.lower()
    assert "12.6" in text
    assert "hospitality_db" in text


def test_phase_12_7_docs_exist_and_mention_db():
    text = _read("docs/hospitality-phase-12-7.md")
    assert "hospitality_db" in text
    assert "12.7" in text
    assert "Torbat Food" in text
    assert "Connector" in text or "connector" in text


def test_phase_12_7_handover_exists():
    text = _read("docs/phase-handover/phase-12-7.md")
    assert "hospitality" in text.lower()
    assert "12.7" in text
    assert "hospitality_db" in text


def test_phase_12_8_docs_exist_and_mention_db():
    text = _read("docs/hospitality-phase-12-8.md")
    assert "hospitality_db" in text
    assert "12.8" in text
    assert "Torbat Food" in text
    assert "Analytics" in text or "analytics" in text


def test_phase_12_8_handover_exists():
    text = _read("docs/phase-handover/phase-12-8.md")
    assert "hospitality" in text.lower()
    assert "12.8" in text
    assert "hospitality_db" in text


def test_module_registry_updated():
    text = _read("docs/module-registry.md")
    assert "hospitality" in text.lower()
    assert "hospitality_db" in text
    assert "0.12.8.0" in text or "12.8" in text


def test_service_readme():
    text = _read("backend/services/hospitality/README.md")
    assert "hospitality_db" in text
    assert "8009" in text
    assert "12.8" in text


def test_adr_017_exists():
    text = _read("docs/architecture/adr/ADR-017.md")
    assert "Hospitality" in text
    assert "hospitality_db" in text
