"""系统说明 Markdown 加载与目录."""
from __future__ import annotations

from lib.instance.instance_system_guide_lib import (
    load_system_guide_payload,
    system_guide_md_path,
    system_guide_template_context,
)


def test_system_guide_md_exists():
    assert system_guide_md_path().is_file()


def test_system_guide_payload_has_toc_and_html():
    payload = load_system_guide_payload()
    assert payload["html"]
    assert "系统说明" in payload["html"] or "总览" in payload["html"]
    toc = payload["toc"]
    assert isinstance(toc, list)
    assert len(toc) >= 3
    assert all(item.get("id") and item.get("title") for item in toc)
    assert any("总览" in (item.get("title") or "") for item in toc)
    assert any("期权" in (item.get("title") or "") for item in toc)
    assert any("对冲" in (item.get("title") or "") for item in toc)


def test_system_guide_template_context():
    ctx = system_guide_template_context()
    assert ctx["system_guide_html"]
    assert ctx["system_guide_toc"]
