"""Unit tests for the consumer-facing objects — no browser."""

from __future__ import annotations

from mgf.uitest_web import ConsoleLaunch, Viewport
from mgf.uitest_web.console import _slug


def test_slug_makes_filesystem_safe_tokens() -> None:
    assert _slug("Overview Page") == "overview-page"
    assert _slug("a/b\\c:d") == "a-b-c-d"
    assert _slug("  Trim Me  ") == "trim-me"
    assert _slug("keeps.dots_and-dashes") == "keeps.dots_and-dashes"
    assert _slug("!!!") == "shot"  # nothing survives → the documented fallback


def test_viewport_size_is_a_playwright_mapping() -> None:
    vp = Viewport("mobile", 390, 844)
    assert vp.size == {"width": 390, "height": 844}


def test_console_launch_defaults() -> None:
    cl = ConsoleLaunch(command=["x"])
    assert cl.ready_path == "/"
    assert cl.timeout == 30.0
    assert cl.env == {}
    assert cl.cwd is None
    assert cl.name == "console"
