mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-06-15 17:25:26 -04:00
2e37d72155
Render streamed markdown incrementally (freeze finalized blocks, re-render only the growing tail) instead of re-rendering the whole message every token, which recreated every <pre> and dropped CSS :hover.
39 lines
1.3 KiB
Python
39 lines
1.3 KiB
Python
"""Runs the Node-based streaming-render segmenter suite (tests/streaming/*.test.mjs).
|
|
|
|
Covers the pure incremental-render segmenter (static/js/streamingSegmenter.js):
|
|
unit boundaries plus a streaming-invariant fuzz that feeds a markdown corpus in
|
|
token-by-token and asserts the freeze/tail split always matches a single full
|
|
render. Pure JS — no DOM, no extra dependencies. Skipped when node is
|
|
unavailable, mirroring tests/test_markdown_rendering_js.py.
|
|
|
|
The renderer's DOM behavior (streamingRenderer.js) is exercised against a running
|
|
app, not here, consistent with how this project tests browser-coupled code.
|
|
"""
|
|
|
|
import shutil
|
|
import subprocess
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
_REPO = Path(__file__).resolve().parent.parent
|
|
_HAS_NODE = shutil.which("node") is not None
|
|
|
|
|
|
@pytest.mark.skipif(not _HAS_NODE, reason="node binary not on PATH")
|
|
def test_streaming_segmenter_suite():
|
|
test_files = sorted(str(p) for p in (_REPO / "tests" / "streaming").glob("*.test.mjs"))
|
|
assert test_files, "no streaming test files found"
|
|
|
|
result = subprocess.run(
|
|
["node", "--test", *test_files],
|
|
cwd=_REPO,
|
|
capture_output=True,
|
|
timeout=180,
|
|
text=True,
|
|
)
|
|
if result.returncode != 0:
|
|
raise AssertionError(
|
|
f"node --test failed:\nSTDOUT:\n{result.stdout}\nSTDERR:\n{result.stderr}"
|
|
)
|