"""Compatibility smoke tests for docs refresh autogen markers."""

from __future__ import annotations

from typing import TYPE_CHECKING

from dopetask.docs.refresh_llm import AUTOGEN_END, AUTOGEN_START, inject_autogen

if TYPE_CHECKING:
    from pathlib import Path


def test_inject_autogen_preserves_prefix_suffix(tmp_path: Path) -> None:
    path = tmp_path / "AGENTS.md"
    before = (
        "prefix\n"
        f"{AUTOGEN_START}\n"
        "old\n"
        f"{AUTOGEN_END}\n"
        "suffix\n"
    )
    path.write_text(before, encoding="utf-8")

    updated, markers_created, modified = inject_autogen(path, "## dopeTask Command Surface (Autogenerated)", check=False)

    assert markers_created is False
    assert modified is True
    assert updated.startswith("prefix\n")
    assert updated.endswith("suffix\n")
