File size: 2,280 Bytes
5e0b58b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from pathlib import Path

# fmt: off
STATIC = Path(__file__).parents[1] / "src" / "dashboard" / "static"
TABS = (
    "overview",
    "network",
    "control",
    "research",
    "gate",
    "settings",
    "embodiment",
)


def test_dashboard_shell_covers_every_primary_tab() -> None:
    source = (STATIC / "dashboard-shell.js").read_text(encoding="utf-8")
    for tab in TABS:
        assert f"{tab}:" in source
    assert "tab-${tabName}" in source


def test_dashboard_shell_is_full_width_and_responsive() -> None:
    css = (STATIC / "dashboard-shell.css").read_text(encoding="utf-8")
    assert "max-width: none !important" in css
    assert "grid-template-columns: repeat(7, minmax(0, 1fr))" in css
    assert "@media (max-width: 1180px)" in css
    assert "@media (max-width: 820px)" in css
    assert "@media (max-width: 520px)" in css
    assert "prefers-reduced-motion" in css


def test_dashboard_shell_has_dark_and_light_design_contracts() -> None:
    css = (STATIC / "dashboard-shell.css").read_text(encoding="utf-8")
    assert ":root {" in css
    assert "data-theme" in css
    assert "light" in css
    assert "--shell-surface" in css
    assert "--shell-text" in css
    assert "--shell-accent" in css


def test_dashboard_shell_does_not_issue_runtime_commands() -> None:
    source = (STATIC / "dashboard-shell.js").read_text(encoding="utf-8")
    assert "fetch(" not in source
    assert "XMLHttpRequest" not in source


def test_dashboard_shell_is_loaded_from_main_dashboard_module_graph() -> None:
    console_log = (STATIC / "console-log.js").read_text(encoding="utf-8")
    app = (STATIC / "app.js").read_text(encoding="utf-8")
    assert "dashboard-shell.js" in console_log
    assert "console-log.js" in app


def test_dashboard_tabs_are_hidden_before_external_styles_load() -> None:
    html = (STATIC / "index.html").read_text(encoding="utf-8")
    assert ".tab-content { display: none; }" in html
    assert ".tab-content.active { display: block; }" in html


def test_print_styles_do_not_capture_screen_rules() -> None:
    css = (STATIC / "styles.css").read_text(encoding="utf-8")
    assert "color: black !important;\n  }\n}\n\n/* ============================================================================\n   BIBTEX VIEWER" in css
# fmt: on