from pathlib import Path


def test_workflow_guard_accepts_legacy_invoice_task_text():
    source = Path('app/workflow_guard.py').read_text()
    assert 'def _task_looks_like_invoice_sent' in source
    assert 'ENVIAR FATURA' in source
    assert "action ILIKE '%fatura%'" in source
    assert 'SEND_FISCAL_INVOICE' in source


def test_delivered_guard_still_requires_invoice_sent():
    source = Path('app/workflow_guard.py').read_text()
    assert 'Concluir oportunidade exige evidência de fatura enviada ao cliente.' in source
    assert 'physical_closed and payment and invoice and invoice_sent' in source
