2026-08-24 04:12:03 -03:00
|
|
|
"""Executable and static quality gates for the isolated HUX-03 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]
|
|
|
|
|
ORGANIZATION = ROOT / "dockerfiles" / "hermes-webui-hux" / "organization"
|
|
|
|
|
|
|
|
|
|
|
2026-08-24 05:22:01 -03:00
|
|
|
|
2026-08-24 04:12:03 -03:00
|
|
|
def test_hux_organization_node_suite_and_line_branch_coverage():
|
2026-08-24 05:22:01 -03:00
|
|
|
run_node_coverage(
|
|
|
|
|
[
|
|
|
|
|
"dockerfiles/hermes-webui-hux/organization/client.ts",
|
|
|
|
|
"dockerfiles/hermes-webui-hux/organization/model.ts",
|
|
|
|
|
"dockerfiles/hermes-webui-hux/organization/security.ts",
|
|
|
|
|
],
|
2026-08-24 04:12:03 -03:00
|
|
|
[
|
|
|
|
|
"testing/tests/test_hermes_hux_ui_organization.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_organization_component_is_flagged_accessible_and_scope_safe():
|
|
|
|
|
component = (ORGANIZATION / "OrganizationWorkspace.tsx").read_text(encoding="utf-8")
|
|
|
|
|
model = (ORGANIZATION / "model.ts").read_text(encoding="utf-8")
|
|
|
|
|
client = (ORGANIZATION / "client.ts").read_text(encoding="utf-8")
|
|
|
|
|
contracts = (ORGANIZATION / "contracts.ts").read_text(encoding="utf-8")
|
|
|
|
|
styles = (ORGANIZATION / "styles.css").read_text(encoding="utf-8")
|
|
|
|
|
assert "if (!enabled) return null" in component
|
|
|
|
|
assert "projectsEnabled(props.flags)" in component
|
|
|
|
|
assert "FOUNDATION_FLAG" in model and "PROJECTS_FLAG" in model
|
|
|
|
|
assert 'role="search"' in component
|
|
|
|
|
assert 'role="status"' in component and 'aria-live="polite"' in component
|
|
|
|
|
assert 'aria-label="Project folders"' in component
|
|
|
|
|
assert 'aria-label="Conversations"' in component
|
|
|
|
|
assert 'aria-labelledby="hux-org-lineage-title"' in component
|
|
|
|
|
assert 'aria-labelledby="hux-org-attachments-title"' in component
|
|
|
|
|
assert "Edit tags" in component and 'role="alert"' in component
|
|
|
|
|
assert "encodeURIComponent(conversation.id)" in component
|
|
|
|
|
assert "dangerouslySetInnerHTML" not in component
|
|
|
|
|
assert all(token not in client for token in ("localStorage", "sessionStorage", "indexedDB", "document.cookie"))
|
|
|
|
|
assert 'credentials: "same-origin"' in client and 'cache: "no-store"' in client
|
|
|
|
|
assert "expected_updated_at" in client and "preservesConversation" in client
|
|
|
|
|
assert "tenant_ref" in contracts and "MUST NOT be accepted" in contracts
|
|
|
|
|
assert ".hux-organization" in styles
|
|
|
|
|
assert "body" not in styles and ":root" not in styles
|
|
|
|
|
assert "prefers-reduced-motion" in styles
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_hux_organization_sources_respect_size_and_scope_boundaries():
|
|
|
|
|
sources = sorted(ORGANIZATION.glob("*"))
|
|
|
|
|
assert {path.name for path in sources} == {
|
|
|
|
|
"OrganizationWorkspace.tsx",
|
|
|
|
|
"client.ts",
|
|
|
|
|
"contracts.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/organization" not in (
|
|
|
|
|
ROOT / "dockerfiles" / "Dockerfile.hermes-agent"
|
|
|
|
|
).read_text(encoding="utf-8")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_hux_organization_declares_exact_backend_contracts():
|
|
|
|
|
contracts = (ORGANIZATION / "contracts.ts").read_text(encoding="utf-8")
|
|
|
|
|
expected = (
|
|
|
|
|
"GET /hux/v1/projects?cursor=&limit=",
|
|
|
|
|
"GET /hux/v1/projects/{prj_id}/conversations?cursor=&limit=",
|
|
|
|
|
"GET /hux/v1/conversations/search?q=&project_id=&tag=&pinned=&cursor=&limit=",
|
|
|
|
|
"PATCH /hux/v1/projects/{prj_id}",
|
|
|
|
|
"PATCH /hux/v1/conversations/{conv_id}",
|
|
|
|
|
'api_version="hux.v1"',
|
|
|
|
|
"next_cursor",
|
|
|
|
|
"expected_updated_at",
|
|
|
|
|
"branch",
|
|
|
|
|
"artifact_ids",
|
|
|
|
|
"409",
|
|
|
|
|
)
|
|
|
|
|
for value in expected:
|
|
|
|
|
assert value in contracts
|