from __future__ import annotations

from pathlib import Path

from tools.render_graph import render_mermaid
from tools.validate_config import validate_config


ROOT = Path(__file__).resolve().parents[2]
CFG_PATH = ROOT / "sync_state_machine" / "config" / "node_state_machine.yaml"


def test_validate_config_has_no_errors() -> None:
    problems, _cfg = validate_config(CFG_PATH)
    errors = [p for p in problems if p.level == "ERROR"]
    assert not errors


def test_render_mermaid_contains_core_edges() -> None:
    problems, cfg = validate_config(CFG_PATH)
    errors = [p for p in problems if p.level == "ERROR"]
    assert not errors

    mermaid = render_mermaid(cfg)
    assert "flowchart LR" in mermaid
    assert "S02 -- \"E16" in mermaid
    assert "S06 -- \"E40" in mermaid
