from pathlib import Path

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


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


def test_v494_external_sync_defaults_to_three_day_window():
    script = read("scripts/sync_external_reconciliation.py")
    service = read("app/external_reconciliation_sync.py")

    assert 'parser.add_argument("--days", type=int, default=3' in script
    assert "sync_all_external_reconciliation_candidates(*, limit: int = 100, days: int = 3)" in service
    assert "sync_odoo_reconciliation_candidates(*, limit: int = 100, days: int = 3)" in service
    assert "sync_packlink_reconciliation_candidates(*, limit: int = 100, days: int = 3)" in service


def test_v494_reconciliation_ui_has_cleanup_window_action():
    ui = read("app/admin_ui/pages/reconciliation.py")
    service = read("app/reconciliation_service.py")

    assert "/reconciliation/cleanup-window" in ui
    assert "Limpar fora dos 3 dias" in ui
    assert "cleanup_reconciliation_outside_window" in service
    assert "fora da janela operacional" in service
