from pathlib import Path

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


def test_jasmin_invoice_candidates_are_actionable_downstream_documents():
    src = (ROOT / "app" / "jasmin_backfill_service.py").read_text(encoding="utf-8")
    assert 'external_type == "jasmin_invoice"' in src
    assert 'or (is_invoice and not invalid_reasons)' in src
    assert 'not_open_or_not_quotation' not in src
    assert 'cancelled_or_void_invoice' in src


def test_invoice_candidates_are_not_shown_as_replacements_in_ui():
    src = (ROOT / "app" / "admin_dashboard.py").read_text(encoding="utf-8")
    assert "is_invoice_candidate" in src
    assert "Associar fatura" in src
    assert "não substituir o orçamento" in src
