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_email_agent_prompt_requires_readable_commercial_format():
    service = read("app/email_reply_agent_service.py")
    assert "Formato visual e legibilidade" in service
    assert "Estrutura para pedidos de preço/proposta" in service
    assert "Usar listas com travessão" in service
    assert "Com os melhores cumprimentos" in service
    assert "Sérgio Araújo" in service
    assert "Blif" in service


def test_email_agent_does_not_invent_names_or_references():
    service = read("app/email_reply_agent_service.py")
    assert "não inventar nomes" in service.lower() or "Não inventar nomes" in service
    assert "não inventar referências" in service.lower() or "Não inventar referências" in service
    assert "disponível no email ou no CRM" in service


def test_schema_description_requests_readable_response():
    service = read("app/email_reply_agent_service.py")
    assert "parágrafos curtos" in service
    assert "funcionalidades, prazos" in service
    assert "resposta_sugerida" in service


def test_prompt_version_updated_to_readability():
    service = read("app/email_reply_agent_service.py")
    assert ("blif-email-agent-phase1-readability-20260613" in service or "blif-email-agent-phase1-readability-ui-20260613" in service or "blif-email-agent-phase1-readability-ui-formal-20260613" in service)


def test_ui_shows_new_version_marker():
    tasks = read("app/admin_ui/pages/tasks.py")
    assert "v4928.1.5.7" in tasks or "v4928.1.5.8" in tasks or "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
