from pathlib import Path

ROOT = Path(__file__).resolve().parents[1]


def read(path: str) -> str:
    return (ROOT / path).read_text(encoding="utf-8")


def test_v453_ui_alignment_styles_are_present():
    admin = read("app/admin_dashboard.py")
    styles = read("app/admin_ui/styles.py")
    layout = read("app/admin_ui/layout.py")
    navigation = read("app/admin_ui/navigation.py")
    components = read("app/admin_ui/components.py")
    assert "ADMIN_UI_V451_CSS" in admin
    assert "--cf-sidebar-width:284px" in styles
    assert "background:linear-gradient(180deg,#fff 0,#f8fbff 100%)" in styles
    assert "cf-global-search" in layout
    assert "v4.7 Operator Workbench" in navigation
    assert "cf-kpi-icon" in components
    assert "kpi_icon_for" in components


def test_v452_nav_matches_operational_information_architecture():
    navigation = read("app/admin_ui/navigation.py")
    for label in [
        "Dashboard",
        "Centro de trabalho",
        "Oportunidades",
        "Clientes",
        "Produtos",
        "Encomendas",
        "Financeiro",
        "Integrações",
        "Admin",
        "Comunicações",
        "Outbox",
        "Configuração",
    ]:
        assert label in navigation


def test_ui_css_endpoint_uses_v451_css():
    admin = read("app/admin_dashboard.py")
    assert "return Response(ADMIN_UI_V451_CSS" in admin
