from pathlib import Path


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


def test_task_reply_audit_script_exists_and_is_read_only_by_default():
    script = read("scripts/audit_task_reply_suggestions.py")
    assert "audit_task_reply_suggestions" in script
    assert "generate_reply_draft(task_id, persist=persist_drafts)" in script
    assert "CLIENTFLOW_REPLY_LLM_ENABLED" in script
    assert "false" in script
    assert "--persist-drafts" in script
    assert "não persiste rascunhos" in script


def test_task_reply_audit_outputs_request_and_suggested_reply():
    script = read("scripts/audit_task_reply_suggestions.py")
    assert "Pedido do cliente" in script
    assert "Resposta sugerida" in script
    assert "knowledge_topics" in script
    assert "blockers" in script
    assert "warnings" in script
    assert "render_markdown" in script
    assert "render_csv" in script
    assert "render_json" in script


def test_task_reply_audit_release_documentation_exists():
    doc = read("docs/CLIENTFLOW_V4928_1_5_1_TASK_REPLY_AUDIT.md")
    release = read("RELEASE_NOTES_v4928_1_5_1.md")
    assert "Task Reply Audit" in doc
    assert "scripts/audit_task_reply_suggestions.py" in doc
    assert "read-only" in doc
    assert "v4928.1.5.1" in release
