From 4ffa40282fe0b73d3865277c6da13ea48055010c Mon Sep 17 00:00:00 2001 From: nesquena-hermes Date: Thu, 7 May 2026 20:42:55 +0000 Subject: [PATCH] =?UTF-8?q?test:=20tighten=20smd=20import=20shape=20?= =?UTF-8?q?=E2=80=94=20forbid=20bare=20AND=20root-absolute,=20require=20'.?= =?UTF-8?q?/'=20relative?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The two tests that pin streaming-markdown's import shape were updated to require the './' relative form and forbid BOTH the bare specifier (broken by ES spec, #1849) AND the root-absolute form (broken under subpath deployments like /hermes/). The original tests only forbade root-absolute, which let the bare-specifier regression land unnoticed. --- tests/test_streaming_markdown.py | 16 ++++++++++++++-- tests/test_subpath_frontend_routes.py | 11 ++++++++++- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/tests/test_streaming_markdown.py b/tests/test_streaming_markdown.py index e86d4872..76e1db7d 100644 --- a/tests/test_streaming_markdown.py +++ b/tests/test_streaming_markdown.py @@ -108,9 +108,21 @@ class TestIndexHtmlSmdScript: ) def test_smd_vendor_import_is_mount_agnostic(self): - assert "static/vendor/smd.min.js" in INDEX_HTML, ( - "index.html must load the vendored streaming-markdown module" + """Import must resolve relative to current document, not a bare + specifier (rejected by ES module spec, #1849) and not root-absolute + (escapes /hermes/-style subpath mounts). The `./` form is the only + shape that satisfies both: ES-spec-valid AND mount-agnostic. + """ + assert "from './static/vendor/smd.min.js'" in INDEX_HTML, ( + "index.html must use the './static/vendor/smd.min.js' form — " + "bare specifiers are rejected by the ES module spec (#1849) and " + "leading-/ paths break subpath deployments such as /hermes/" ) + # Forbid the bare form (#1849 broke streaming-markdown silently) + assert "import * as smd from 'static/vendor/smd.min.js'" not in INDEX_HTML, ( + "bare specifier is rejected by the ES module spec — use './static/...'" + ) + # Forbid the root-absolute form (subpath deployments escape the mount) assert "from '/static/vendor/smd.min.js'" not in INDEX_HTML, ( "streaming-markdown import must not be root-absolute; root-absolute " "static paths break subpath deployments such as /hermes/" diff --git a/tests/test_subpath_frontend_routes.py b/tests/test_subpath_frontend_routes.py index 8bb15b78..c04e8914 100644 --- a/tests/test_subpath_frontend_routes.py +++ b/tests/test_subpath_frontend_routes.py @@ -56,6 +56,15 @@ def test_direct_frontend_event_sources_are_relative_to_current_mount(): def test_static_vendor_import_is_relative_to_current_mount(): + """Import must use `./static/vendor/smd.min.js` form so the URL resolves + relative to the document URL. Bare specifier (no leading `./` or `/`) + is invalid per ES module spec and breaks markdown streaming silently + (#1849). Root-absolute (`/static/...`) escapes subpath mounts like + `/hermes/`. The `./` form satisfies both constraints. + """ src = read("static/index.html") - assert "import * as smd from 'static/vendor/smd.min.js'" in src + assert "import * as smd from './static/vendor/smd.min.js'" in src + # Bare specifier — broken per ES module spec (#1849) + assert "import * as smd from 'static/vendor/smd.min.js'" not in src + # Root-absolute — breaks /hermes/ subpath mounts assert "import * as smd from '/static/vendor/smd.min.js'" not in src