"""Phase 6A — editorial_text slot on the empty_state partial.

The shared empty_state partial supports a 3-sentence editorial paragraph
that downstream RIMS templates use for the system/filter/constraint voice
([[project_rims_t4_editorial_2026_05_17]]). The slot is optional; callers
that pass only heading + subtext must render unchanged.
"""
from __future__ import annotations

import pytest
from django.template import Context, Template


def _render(**context: object) -> str:
    return Template(
        "{% include 'components/empty_state.html' %}"
    ).render(Context(context))


@pytest.mark.django_db
def test_renders_heading_only():
    html = _render(heading="No reforecasts yet")
    assert "No reforecasts yet" in html


@pytest.mark.django_db
def test_renders_with_subtext():
    html = _render(heading="No bank statements", subtext="Upload a CSV to get started.")
    assert "Upload a CSV to get started." in html


@pytest.mark.django_db
def test_renders_editorial_text_slot():
    """The editorial 3-sentence variant should appear as its own paragraph."""
    html = _render(
        heading="No flagged GL entries",
        editorial_text=(
            "Every posted ledger row passes validation today. "
            "When the daily reconcile beat flags a row, it lands here. "
            "Voiding an entry leaves an audit trail rather than removing the record."
        ),
    )
    assert "Every posted ledger row passes validation today" in html
    assert "leading-relaxed" in html  # the editorial paragraph styling


@pytest.mark.django_db
def test_editorial_slot_absent_when_unset():
    """Backward-compat: callers that omit editorial_text get no extra paragraph."""
    html = _render(heading="Empty", subtext="Nothing here.")
    assert "leading-relaxed" not in html
