from __future__ import annotations

from grantflow.api.public_views_preflight import public_job_preflight_payload


def _sanitize(value):
    return value


def test_public_job_preflight_payload_reads_top_level() -> None:
    payload = public_job_preflight_payload({"generate_preflight": {"ok": True}}, sanitize=_sanitize)
    assert payload == {"ok": True}


def test_public_job_preflight_payload_reads_state_fallback() -> None:
    payload = public_job_preflight_payload(
        {"state": {"generate_preflight": {"ok": True, "source": "state"}}}, sanitize=_sanitize
    )
    assert payload == {"ok": True, "source": "state"}
