2026-08-24 04:12:03 -03:00
|
|
|
"""Executable and static quality gates for the isolated HUX-06 frontend."""
|
|
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
import json
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
2026-08-24 05:22:01 -03:00
|
|
|
from hux_node_gate import run_node_coverage
|
|
|
|
|
|
2026-08-24 04:12:03 -03:00
|
|
|
|
|
|
|
|
ROOT = Path(__file__).resolve().parents[2]
|
|
|
|
|
MODES = ROOT / "dockerfiles" / "hermes-webui-hux" / "modes"
|
|
|
|
|
|
|
|
|
|
|
2026-08-24 05:22:01 -03:00
|
|
|
|
2026-08-24 04:12:03 -03:00
|
|
|
def test_hux_modes_model_node_suite_and_coverage():
|
|
|
|
|
"""Mode intent validation is covered above the repository threshold."""
|
|
|
|
|
|
2026-08-24 05:22:01 -03:00
|
|
|
run_node_coverage(
|
|
|
|
|
[
|
|
|
|
|
"dockerfiles/hermes-webui-hux/modes/model.ts",
|
|
|
|
|
],
|
2026-08-24 04:12:03 -03:00
|
|
|
[
|
|
|
|
|
"testing/tests/test_hermes_hux_ui_modes.mjs",
|
|
|
|
|
],
|
2026-08-24 05:22:01 -03:00
|
|
|
{"functions": 95, "lines": 95},
|
|
|
|
|
strip_types=True,
|
2026-08-24 04:12:03 -03:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_hux_modes_component_is_flagged_accessible_and_provider_neutral():
|
|
|
|
|
"""Static UI guardrails preserve keyboard access and neutral routing."""
|
|
|
|
|
|
|
|
|
|
component = (MODES / "FriendlyModeSelector.tsx").read_text(encoding="utf-8")
|
|
|
|
|
model = (MODES / "model.ts").read_text(encoding="utf-8")
|
|
|
|
|
styles = (MODES / "styles.css").read_text(encoding="utf-8")
|
|
|
|
|
assert "if (!enabled) return null" in component
|
|
|
|
|
assert "friendlyModesEnabled(flags)" in component
|
|
|
|
|
assert "<fieldset" in component and "<legend" in component
|
|
|
|
|
assert 'type="radio"' in component and "aria-describedby" in component
|
|
|
|
|
assert "<details" in component and "<summary" in component
|
|
|
|
|
assert "<select" in component and 'aria-live="polite"' in component
|
|
|
|
|
assert "Automatic — use all allowed pools" in component
|
|
|
|
|
assert "codex" in model and "claude" in model and "local" in model
|
|
|
|
|
assert "preferred_provider" not in model
|
|
|
|
|
assert "default_provider" not in model
|
|
|
|
|
assert "dangerouslySetInnerHTML" not in component
|
|
|
|
|
assert ".hux-modes" in styles
|
|
|
|
|
assert "body" not in styles and ":root" not in styles
|
|
|
|
|
assert "focus-visible" in styles and "prefers-reduced-motion" in styles
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_hux_modes_matches_contract_and_stays_inert_and_bounded():
|
|
|
|
|
"""HUX-06 uses the declared schema without entering the live build."""
|
|
|
|
|
|
|
|
|
|
schema = json.loads(
|
|
|
|
|
(ROOT / "services/hermes/contracts/hux/mode.schema.json").read_text(
|
|
|
|
|
encoding="utf-8"
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
model = (MODES / "model.ts").read_text(encoding="utf-8")
|
|
|
|
|
assert schema["properties"]["schema"]["const"] == "hux.mode.v1"
|
|
|
|
|
for mode in schema["properties"]["mode"]["enum"]:
|
|
|
|
|
assert f'"{mode}"' in model
|
|
|
|
|
assert "hux.mode.v1" in model and "hux.v1" in model
|
|
|
|
|
assert {path.name for path in MODES.iterdir()} == {
|
|
|
|
|
"FriendlyModeSelector.tsx",
|
|
|
|
|
"index.ts",
|
|
|
|
|
"model.ts",
|
|
|
|
|
"styles.css",
|
|
|
|
|
"types.ts",
|
|
|
|
|
}
|
|
|
|
|
for path in MODES.iterdir():
|
|
|
|
|
assert len(path.read_text(encoding="utf-8").splitlines()) <= 500
|
|
|
|
|
assert "hermes-webui-hux/modes" not in (
|
|
|
|
|
ROOT / "dockerfiles/Dockerfile.hermes-webui"
|
|
|
|
|
).read_text(encoding="utf-8")
|