Files
cimtechniques-service-suite/tests/core/test_theme.py

49 lines
1.7 KiB
Python

"""Stylesheet generation: both themes compile, legacy palette gone, hooks intact."""
import re
import pytest
from cim_suite.core.ui.theme.fonts import MONO, SANS
from cim_suite.core.ui.theme.stylesheet import build_qss
from cim_suite.core.ui.theme.tokens import DARK, LIGHT
@pytest.mark.parametrize("tokens", [LIGHT, DARK], ids=["light", "dark"])
def test_qss_builds_clean(tokens):
qss = build_qss(tokens, SANS, MONO)
assert "None" not in qss # no missed token interpolation
assert qss.count("{") == qss.count("}")
assert "#0096FF" not in qss # old SmartScan azure is gone
@pytest.mark.parametrize("tokens", [LIGHT, DARK], ids=["light", "dark"])
def test_qss_keeps_existing_widget_hooks(tokens):
qss = build_qss(tokens, SANS, MONO)
for hook in (
"PrimaryAction", "BrandTitle",
"FooterDot", "FooterFieldValue",
"RebootBanner", "LauncherPage", "WhatsNewButton", "ModuleCard",
"CablePanel", "SubnetPreview", "LoadingOverlay", "HelpText",
"ChromeTitleBar", "TitleBarBrand", "ThemeToggle", "CloseButton",
"CellEditor",
):
assert hook in qss, f"missing QSS hook: {hook}"
def test_status_bar_is_instrument_footer_in_both_themes():
# Spec §4: the footer stays dark chrome in light AND dark theme.
for tokens in (LIGHT, DARK):
qss = build_qss(tokens, SANS, MONO)
assert tokens.footer in qss
def test_themes_produce_different_css():
assert build_qss(LIGHT, SANS, MONO) != build_qss(DARK, SANS, MONO)
def test_radius_capped_at_4px():
qss = build_qss(LIGHT, SANS, MONO)
for r in re.findall(r"border(?:-\w+)*-radius:\s*(\d+)px", qss):
assert int(r) <= 4, f"radius {r}px exceeds the spec cap"