from pathlib import Path

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


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


def test_reply_assistant_version_159_marker():
    tasks = read("app/admin_ui/pages/tasks.py")
    assert "v4928.1.5.9" in tasks or "v4928.1.5.10" in tasks or "v4928.1.5.11" in tasks or "v4928.1.5.12" in tasks or "v4928.1.5.13" in tasks


def test_empty_technical_blocks_are_hidden():
    tasks = read("app/admin_ui/pages/tasks.py")
    assert "_has_useful_technical_data" in tasks
    assert "technical_details_html" in tasks
    assert "if technical_blocks else" in tasks


def test_reclassify_block_moved_to_right_column_under_completion():
    tasks = read("app/admin_ui/pages/tasks.py")
    assert "Corrigir classificação" in tasks
    assert "{task_management_html}" in tasks
    assert tasks.index("{task_management_html}") > tasks.index('<h2 class="cf-section-title mb-3">Concluir</h2>')


def test_openrouter_uses_formal_preferred_greeting():
    llm = read("app/llm_reply_generator.py")
    assert "preferred_greeting" in llm
    assert "Boa tarde" in llm
    assert "Sra." in llm
    assert "_apply_preferred_greeting" in llm


def test_email_agent_prompt_prefers_formal_greeting():
    service = read("app/email_reply_agent_service.py")
    assert "Preferir cumprimento formal" in service
    assert "Boa tarde" in service
    assert "Sr./Sra." in service
