2026-08-24 04:12:03 -03:00
|
|
|
"""Executable and static quality gates for the isolated HUX-01 frontend."""
|
|
|
|
|
|
|
|
|
|
from __future__ import annotations
|
|
|
|
|
|
|
|
|
|
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]
|
|
|
|
|
ACTIVITY = ROOT / "dockerfiles" / "hermes-webui-hux" / "activity"
|
|
|
|
|
|
|
|
|
|
|
2026-08-24 05:22:01 -03:00
|
|
|
|
2026-08-24 04:12:03 -03:00
|
|
|
def test_hux_activity_model_node_suite_and_coverage():
|
2026-08-24 05:22:01 -03:00
|
|
|
run_node_coverage(
|
|
|
|
|
[
|
|
|
|
|
"dockerfiles/hermes-webui-hux/activity/model.ts",
|
|
|
|
|
"dockerfiles/hermes-webui-hux/activity/security.ts",
|
|
|
|
|
],
|
2026-08-24 04:12:03 -03:00
|
|
|
[
|
|
|
|
|
"testing/tests/test_hermes_hux_ui_activity.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_activity_component_is_flagged_accessible_and_payload_safe():
|
|
|
|
|
component = (ACTIVITY / "ActivityTimeline.tsx").read_text(encoding="utf-8")
|
|
|
|
|
model = (ACTIVITY / "model.ts").read_text(encoding="utf-8")
|
|
|
|
|
styles = (ACTIVITY / "styles.css").read_text(encoding="utf-8")
|
|
|
|
|
assert "if (!enabled) return null" in component
|
|
|
|
|
assert "activityTimelineEnabled(flags)" in component
|
|
|
|
|
assert "FOUNDATION_FLAG" in model and "ACTIVITY_TIMELINE_FLAG" in model
|
|
|
|
|
assert 'role="log"' in component and 'aria-live="polite"' in component
|
|
|
|
|
assert 'aria-busy={reconnecting}' in component
|
|
|
|
|
assert "dangerouslySetInnerHTML" not in component
|
|
|
|
|
assert ".detail" not in component
|
|
|
|
|
assert "JSON.stringify" not in component
|
|
|
|
|
assert "evidence.uri" not in component and "evidence.id" not in component
|
|
|
|
|
assert ".hux-activity" in styles
|
|
|
|
|
assert "body" not in styles and ":root" not in styles
|
|
|
|
|
assert "prefers-reduced-motion" in styles
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_hux_activity_sources_respect_size_and_scope_boundaries():
|
|
|
|
|
sources = sorted(ACTIVITY.glob("*"))
|
|
|
|
|
assert {path.name for path in sources} == {
|
|
|
|
|
"ActivityTimeline.tsx",
|
|
|
|
|
"index.ts",
|
|
|
|
|
"model.ts",
|
|
|
|
|
"security.ts",
|
|
|
|
|
"styles.css",
|
|
|
|
|
"types.ts",
|
|
|
|
|
}
|
|
|
|
|
for path in sources:
|
|
|
|
|
assert len(path.read_text(encoding="utf-8").splitlines()) <= 500
|
|
|
|
|
assert "dockerfiles/hermes-webui-hux/activity" not in (
|
|
|
|
|
ROOT / "dockerfiles" / "Dockerfile.hermes-agent"
|
|
|
|
|
).read_text(encoding="utf-8")
|