from pathlib import Path

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


def test_send_info_default_is_customer_facing_equipment_list():
    src = (ROOT / "app" / "message_templates.py").read_text()
    assert '"SEND_INFO": "SEND_INFO_EQUIPMENT_LIST"' in src


def test_manual_review_draft_can_be_normalized_for_send_info_send():
    src = (ROOT / "app" / "reply_assistant_service.py").read_text()
    assert "_safe_customer_template_for_manual_send" in src
    assert "MANUAL_CUSTOMER_SEND_ACTIONS" in src
    assert "SEND_INFO_EQUIPMENT_LIST" in src
    assert "template = _safe_customer_template_for_manual_send(task, template, message_body)" in src
    assert "triagem interna" in src


def test_task_ui_uses_effective_conversation_and_normalized_template():
    src = (ROOT / "app" / "admin_ui" / "pages" / "tasks.py").read_text()
    assert "_task_effective_conversation_id" in src
    assert "_customer_send_template_code_for_task" in src
    assert "send_conversation_id = _task_effective_conversation_id(task)" in src
    assert "if send_conversation_id else" in src
