99 lines
2.9 KiB
Python
99 lines
2.9 KiB
Python
from pathlib import Path
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
WEB = ROOT / "apps" / "web-console"
|
|
|
|
|
|
def source(name: str) -> str:
|
|
return (WEB / name).read_text(encoding="utf-8")
|
|
|
|
|
|
def test_spatial_ui_contract_is_loaded_last_and_cached() -> None:
|
|
html = source("index.html")
|
|
service_worker = source("service-worker.js")
|
|
asset = "/ui-consistency.css?v=spatial-ui-4"
|
|
|
|
assert asset in html
|
|
assert f'"{asset}"' in service_worker
|
|
assert html.index("/energy-monitor.css") < html.index(asset)
|
|
|
|
|
|
def test_same_kind_surfaces_share_geometry_tokens() -> None:
|
|
styles = source("ui-consistency.css")
|
|
|
|
for token in (
|
|
"--ui-control-height-compact:",
|
|
"--ui-control-height:",
|
|
"--ui-radius-control:",
|
|
"--ui-radius-item:",
|
|
"--ui-radius-section:",
|
|
"--ui-radius-panel:",
|
|
"--ui-radius-modal:",
|
|
"--ui-shadow-item:",
|
|
"--ui-shadow-panel:",
|
|
"--ui-shadow-modal:",
|
|
):
|
|
assert token in styles
|
|
|
|
for selector in (
|
|
".v2-operation-shell",
|
|
".joint-twin-shell > .twin-band",
|
|
"#v2DevicePanel",
|
|
"#v2ExtensionPanel .v2-extension-sync-mount",
|
|
".mode-gallery",
|
|
".mode-editor",
|
|
".energy-monitor-page",
|
|
".v2-synced-device",
|
|
".v2-extension-gateway",
|
|
".mode-gallery-card",
|
|
".energy-kpi",
|
|
):
|
|
assert selector in styles
|
|
|
|
|
|
def test_same_kind_controls_share_sizes_and_focus_treatment() -> None:
|
|
styles = source("ui-consistency.css")
|
|
|
|
for selector in (
|
|
"#v2PanelControlDock > .v2-panel-control-button",
|
|
".v2-mode-rail .mode-rail-actions > button",
|
|
".v2-device-adjust-toggle",
|
|
".v2-extension-nfc-launch",
|
|
".energy-trend-tabs button",
|
|
".mode-gallery-close",
|
|
".mode-editor-header > button",
|
|
"#energyMonitorClose",
|
|
):
|
|
assert selector in styles
|
|
|
|
assert "box-shadow: var(--ui-focus-ring)" in styles
|
|
assert "outline: none" in styles
|
|
|
|
|
|
def test_compact_sidebar_overrides_cannot_break_shared_geometry() -> None:
|
|
styles = source("ui-consistency.css")
|
|
|
|
assert ".v2-sync-execution-field," in styles
|
|
assert ".v2-can-command-panel" in styles
|
|
assert "border-radius: var(--ui-radius-item) !important" in styles
|
|
assert ".v2-sync-log {" in styles
|
|
assert "border-radius: var(--ui-radius-section) !important" in styles
|
|
|
|
|
|
def test_assistant_composer_hint_stays_inside_narrow_input() -> None:
|
|
styles = source("ui-consistency.css")
|
|
|
|
assert ".v2-request-form .composer-hint" in styles
|
|
assert "left: 16px !important" in styles
|
|
assert "right: auto !important" in styles
|
|
assert "max-width: calc(100% - 132px)" in styles
|
|
|
|
|
|
def test_failed_delivery_uses_one_semantic_status_treatment() -> None:
|
|
styles = source("ui-consistency.css")
|
|
|
|
assert '[data-delivery-state="blocked"]' in styles
|
|
assert '[data-delivery-state="failed"]' in styles
|
|
assert "color: var(--destructive)" in styles
|