2026-08-24 04:12:03 -03:00
|
|
|
"""Executable and static quality gates for isolated HUX-07 multimodal chat."""
|
|
|
|
|
|
|
|
|
|
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]
|
|
|
|
|
MULTIMODAL = ROOT / "dockerfiles" / "hermes-webui-hux" / "multimodal"
|
|
|
|
|
|
|
|
|
|
|
2026-08-24 05:22:01 -03:00
|
|
|
|
2026-08-24 04:12:03 -03:00
|
|
|
def test_hux_multimodal_model_node_suite_and_coverage():
|
2026-08-24 05:22:01 -03:00
|
|
|
run_node_coverage(
|
|
|
|
|
[
|
|
|
|
|
"dockerfiles/hermes-webui-hux/multimodal/model.ts",
|
|
|
|
|
"dockerfiles/hermes-webui-hux/multimodal/security.ts",
|
|
|
|
|
"dockerfiles/hermes-webui-hux/multimodal/endpoints.ts",
|
|
|
|
|
],
|
2026-08-24 04:12:03 -03:00
|
|
|
[
|
|
|
|
|
"testing/tests/test_hermes_hux_ui_multimodal.mjs",
|
|
|
|
|
],
|
2026-08-24 05:22:01 -03:00
|
|
|
{"branches": 95, "functions": 95, "lines": 95},
|
|
|
|
|
strip_types=True,
|
2026-08-24 04:12:03 -03:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_hux_multimodal_component_is_flagged_accessible_safe_and_inert():
|
|
|
|
|
component = (MULTIMODAL / "MultimodalChat.tsx").read_text(encoding="utf-8")
|
|
|
|
|
model = (MULTIMODAL / "model.ts").read_text(encoding="utf-8")
|
|
|
|
|
endpoints = (MULTIMODAL / "endpoints.ts").read_text(encoding="utf-8")
|
|
|
|
|
styles = (MULTIMODAL / "styles.css").read_text(encoding="utf-8")
|
|
|
|
|
assert "if (!enabled || !page) return null" in component
|
|
|
|
|
assert "multimodalEnabled(props.flags)" in component
|
|
|
|
|
for flag in (
|
|
|
|
|
"FOUNDATION_FLAG",
|
|
|
|
|
"PROJECTS_FLAG",
|
|
|
|
|
"ARTIFACTS_FLAG",
|
|
|
|
|
"AUTONOMY_FLAG",
|
|
|
|
|
"MULTIMODAL_FLAG",
|
|
|
|
|
):
|
|
|
|
|
assert flag in model
|
|
|
|
|
assert 'aria-label="Multimodal chat"' in component
|
|
|
|
|
assert 'aria-live="polite"' in component
|
|
|
|
|
assert 'aria-label="Live media permissions"' in component
|
|
|
|
|
assert "Ask to use" in component and "Ask before uploading" in component
|
|
|
|
|
assert "Create linked variant" in component
|
|
|
|
|
assert "Correct transcript" in component
|
|
|
|
|
assert "Content is not executed" in component
|
|
|
|
|
assert "dangerouslySetInnerHTML" not in component
|
|
|
|
|
assert "<iframe" not in component and "<object" not in component and "<embed" not in component
|
|
|
|
|
assert "getUserMedia" not in component and "getDisplayMedia" not in component
|
|
|
|
|
assert "fetch(" not in endpoints and "axios" not in endpoints
|
|
|
|
|
assert '"PATCH"' not in endpoints and '"DELETE"' not in endpoints
|
|
|
|
|
assert ".hux-multimodal" in styles
|
|
|
|
|
assert "body" not in styles and ":root" not in styles
|
|
|
|
|
assert "prefers-reduced-motion" in styles
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_hux_multimodal_sources_are_bounded_and_isolated():
|
|
|
|
|
sources = sorted(MULTIMODAL.glob("*"))
|
|
|
|
|
assert {path.name for path in sources} == {
|
|
|
|
|
"MultimodalChat.tsx",
|
|
|
|
|
"endpoints.ts",
|
|
|
|
|
"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/multimodal" not in (
|
|
|
|
|
ROOT / "dockerfiles" / "Dockerfile.hermes-agent"
|
|
|
|
|
).read_text(encoding="utf-8")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_hux_multimodal_forbids_inline_and_executable_media():
|
|
|
|
|
security = (MULTIMODAL / "security.ts").read_text(encoding="utf-8")
|
|
|
|
|
component = (MULTIMODAL / "MultimodalChat.tsx").read_text(encoding="utf-8")
|
|
|
|
|
assert "image/svg+xml" not in security
|
|
|
|
|
assert "text/html" not in security
|
|
|
|
|
assert "data:" not in component
|
|
|
|
|
assert "URL.createObjectURL" not in component
|
|
|
|
|
assert "blob:" in security
|