From 406d3267af868659b77b43a34f991741e165e1b6 Mon Sep 17 00:00:00 2001 From: Abhay Singh Date: Thu, 11 Jun 2026 17:45:43 -0400 Subject: [PATCH] fix(admin): use the custom element tag the vendored bundle registers @andypf/json-viewer registers , not ; the unknown tag rendered as an empty element so detail pages showed only the label. Also drop show-toolbar (not an attribute in 2.1.1) for show-copy. Regression test extracts the customElements.define tag from the vendored bundle and asserts the formatter emits exactly that tag. Co-Authored-By: Claude Fable 5 --- app/console/admin_ui.py | 5 +++-- tests/test_admin_ui.py | 22 +++++++++++++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/app/console/admin_ui.py b/app/console/admin_ui.py index 4dbdaf3..9863445 100644 --- a/app/console/admin_ui.py +++ b/app/console/admin_ui.py @@ -56,8 +56,9 @@ def _fmt_meta_detail(m: object, a: str) -> Markup: payload = json.dumps(val, sort_keys=True, default=str) blocks.append( Markup( - '
{}
' - '' + "
{}
" + '' + "" ).format(label, payload) ) else: diff --git a/tests/test_admin_ui.py b/tests/test_admin_ui.py index 467aeca..6e3713e 100644 --- a/tests/test_admin_ui.py +++ b/tests/test_admin_ui.py @@ -1,5 +1,7 @@ import base64 import os +import re +from pathlib import Path import pytest from fastapi import FastAPI @@ -95,13 +97,31 @@ class Row: # Dict values become a collapsible json-viewer component fed escaped JSON. assert isinstance(rendered, Markup) assert "/console/static/json_viewer.js" in rendered - assert " 0.42" in rendered +def test_meta_formatter_tag_matches_vendored_custom_element() -> None: + """The emitted tag must be the one the vendored bundle registers — an + unknown tag silently renders as an empty element (prod regression).""" + bundle = ( + Path(__file__).parent.parent / "app" / "console" / "static" / "json_viewer.js" + ).read_text() + match = re.search(r'customElements\.define\("([^"]+)"', bundle) + assert match, "vendored bundle no longer registers a custom element?" + tag = match.group(1) + + class Row: + meta = {"texet_generation": {"query": "hi"}} + + rendered = _fmt_meta_detail(Row(), "meta") + assert f"<{tag} " in rendered + assert f"" in rendered + + def test_meta_formatter_escapes_user_content() -> None: class Row: meta = {"texet_generation": {"query": ''}}