from app.workflow_guard import _completed_send_invoice_task_evidence


def test_completed_send_invoice_task_evidence_accepts_legacy_without_invoice_rows():
    tasks = [
        {
            "action_code": "SEND_INVOICE",
            "action": "Enviar fatura FA.FA2026.143 ao cliente",
            "note": "PDF/anexo disponível para envio automático.",
            "status": "done",
            "metadata": {},
        }
    ]
    assert _completed_send_invoice_task_evidence(tasks, []) is True


def test_completed_send_invoice_task_evidence_still_rejects_non_invoice_followup():
    tasks = [
        {
            "action_code": "FOLLOW_UP_PAYMENT",
            "action": "Fazer follow-up de pagamento/fatura",
            "note": "Confirmar pendência de pagamento.",
            "status": "done",
            "metadata": {},
        }
    ]
    assert _completed_send_invoice_task_evidence(tasks, []) is False
