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