from pathlib import Path

TASKS = Path('app/admin_ui/pages/tasks.py').read_text(encoding='utf-8')


def test_external_channel_completion_ui_present():
    assert 'manual_external_done' in TASKS
    assert 'Marcar como enviado externamente' in TASKS
    assert 'WhatsApp' in TASKS
    assert 'Sem email/Chatwoot nesta tarefa' in TASKS


def test_external_document_sent_bypasses_fiscal_completion_guard_only_when_explicit():
    assert 'external_document_sent = manual_external_done and _task_has_available_document_for_action' in TASKS
    assert "Cliente fiscal/dados de envio incompletos" in TASKS
    assert '_external_channel_completion_note(action_for_guard' in TASKS


def test_document_availability_helper_covers_proforma_and_invoice():
    assert 'def _task_has_available_document_for_action' in TASKS
    assert 'SEND_PROFORMA' in TASKS
    assert 'document_kind' in TASKS
    assert 'invoice' in TASKS
    assert 'quotation' in TASKS
