Loading source
Pulling the file list, source metadata, and syntax-aware rendering for this listing.
Source from repo
AI-powered design system generator that produces complete, tailored design systems from project requirements.
Files
Skill
Size
Entrypoint
Format
Open file
Syntax-highlighted preview of this file as included in the skill package.
scripts/tests/test_validate_tokens.py
1"""Regression tests for validate-tokens.cjs.23The validator used to skip any line containing ``var(--`` outright, so a4hardcoded value sharing a line with a token reference (extremely common in5real CSS, and universal in minified CSS where everything is one line) went6undetected. These tests drive the CLI via ``node`` and assert it flags such7cases. They are pytest-based so the repository's existing pytest CI runs them.8"""910import shutil11import subprocess12from pathlib import Path1314import pytest1516SCRIPT = Path(__file__).resolve().parent.parent / "validate-tokens.cjs"171819def _run(tmp_path: Path, css: str) -> subprocess.CompletedProcess:20node = shutil.which("node")21if not node:22pytest.skip("node not available")23(tmp_path / "sample.css").write_text(css)24return subprocess.run(25[node, str(SCRIPT), "--dir", str(tmp_path)],26capture_output=True,27text=True,28)293031def test_flags_hardcoded_hex_sharing_line_with_token(tmp_path):32"""A hardcoded hex on the same line as a var() token is still a violation."""33result = _run(34tmp_path,35".btn { background: #FF6B6B; color: var(--color-primary); }\n",36)37assert "#FF6B6B" in result.stdout, result.stdout38assert result.returncode == 1394041def test_token_only_line_reports_no_violation(tmp_path):42"""A line that references only tokens produces no false positives."""43result = _run(44tmp_path,45".btn { background: var(--color-bg); color: var(--color-primary); }\n",46)47assert "No token violations" in result.stdout, result.stdout48assert result.returncode == 049