test(chat): update 6 post-render tests orphaned by the _postProcessWithAnchorSuppression refactor (#5338)

Commit 7536f6f1 routed the deferred post-render dispatches through
_postProcessWithAnchorSuppression() (holds overflow-anchor suppression across
the async media/layout settle frame, then calls postProcessRenderedMessages).
Six pre-existing tests string-matched the old
'requestAnimationFrame(()=>postProcessRenderedMessages(inner))' literal and
failed on the rename — behavior is preserved (the wrapper still invokes
postProcessRenderedMessages), so this is a test-fix not a code-fix.

Per the gate-cert recommendation, the tests now assert the BEHAVIOR chain
(post-render is scheduled via _postProcessWithAnchorSuppression, and that
wrapper calls postProcessRenderedMessages) rather than the exact rAF literal, so
a future wrapper rename can't re-orphan them.

Files: test_csv_table_rendering, test_excalidraw_inline_embed,
test_issue483_inline_diff_viewer, test_issue484_json_tree_viewer, test_issue347,
test_pdf_html_preview. Verified: the 6 updated assertions pass locally (the only
local failures are the pre-existing Windows-only WinError 206 command-line-too-long
in Node-harness tests, unrelated, green on Linux CI).
This commit is contained in:
allenliang2022 authored and nesquena-hermes committed 2026-07-01 17:46:03 +00:00
1 parent 7db6fd8650
commit fbb21964a9
6 files changed
+47 -6

No files matched your search

+10 -1
View File
@@ -112,7 +112,16 @@ def test_csv_loadCsvInline_called_after_render():
"""Verify loadCsvInline is called by the consolidated post-render pass."""
with open('static/ui.js') as f:
src = f.read()
assert 'requestAnimationFrame(()=>postProcessRenderedMessages(inner))' in src
# Behavior assertion (not a brittle rAF-literal match): the post-render pass
# is scheduled a frame later, now routed through _postProcessWithAnchorSuppression
# (which holds overflow-anchor suppression across the media/layout reflow, then
# calls postProcessRenderedMessages). Assert the behavior chain, so a future
# wrapper rename doesn't re-orphan this test. (#5338)
assert 'requestAnimationFrame(()=>_postProcessWithAnchorSuppression(' in src
wrap_idx = src.find('function _postProcessWithAnchorSuppression')
assert wrap_idx != -1, "post-render should be wrapped by _postProcessWithAnchorSuppression"
assert 'postProcessRenderedMessages(container)' in src[wrap_idx:wrap_idx + 500], \
"the wrapper must still invoke postProcessRenderedMessages"
idx = src.find('function postProcessRenderedMessages')
body = src[idx:idx + 500]
assert 'loadCsvInline(container)' in body, "post-process should call loadCsvInline once per render"
+7 -1
View File
@@ -123,7 +123,13 @@ def test_excalidraw_called_after_render():
"""Verify loadExcalidrawInline is called by the consolidated post-render pass."""
with open('static/ui.js') as f:
src = f.read()
assert 'requestAnimationFrame(()=>postProcessRenderedMessages(inner))' in src
# Behavior assertion (#5338): post-render is now scheduled through
# _postProcessWithAnchorSuppression (which still calls postProcessRenderedMessages).
assert 'requestAnimationFrame(()=>_postProcessWithAnchorSuppression(' in src
_wrap = src.find('function _postProcessWithAnchorSuppression')
assert _wrap != -1, "post-render should be wrapped by _postProcessWithAnchorSuppression"
assert 'postProcessRenderedMessages(container)' in src[_wrap:_wrap + 500], \
"the wrapper must still invoke postProcessRenderedMessages"
idx = src.find('function postProcessRenderedMessages')
body = src[idx:idx + 500]
assert 'loadExcalidrawInline(container)' in body, (
+7 -1
View File
@@ -204,8 +204,14 @@ def test_katex_throw_on_error_false():
def test_render_katex_blocks_wired_into_raf():
"""renderKatexBlocks() must run from the post-render requestAnimationFrame pass."""
raf_call = 'requestAnimationFrame(()=>postProcessRenderedMessages(inner))'
# Behavior assertion (#5338): post-render is scheduled through
# _postProcessWithAnchorSuppression, which still calls postProcessRenderedMessages.
raf_call = 'requestAnimationFrame(()=>_postProcessWithAnchorSuppression('
assert raf_call in UI_JS, 'post-render requestAnimationFrame pass not found'
_wrap = UI_JS.find('function _postProcessWithAnchorSuppression')
assert _wrap != -1, "post-render should be wrapped by _postProcessWithAnchorSuppression"
assert 'postProcessRenderedMessages(container)' in UI_JS[_wrap:_wrap + 500], \
"the wrapper must still invoke postProcessRenderedMessages"
idx = UI_JS.find('function postProcessRenderedMessages')
body = UI_JS[idx:idx + 500]
assert 'renderMermaidBlocks(container)' in body
+7 -1
View File
@@ -62,7 +62,13 @@ class TestMediaDiffInline:
"""loadDiffInline() should be called by the consolidated post-render pass."""
with open("static/ui.js", "r", encoding="utf-8") as f:
content = f.read()
assert "requestAnimationFrame(()=>postProcessRenderedMessages(inner))" in content
# Behavior assertion (#5338): post-render scheduled via
# _postProcessWithAnchorSuppression, which still calls postProcessRenderedMessages.
assert "requestAnimationFrame(()=>_postProcessWithAnchorSuppression(" in content
_wrap = content.find('function _postProcessWithAnchorSuppression')
assert _wrap != -1, "post-render should be wrapped by _postProcessWithAnchorSuppression"
assert 'postProcessRenderedMessages(container)' in content[_wrap:_wrap + 500], \
"the wrapper must still invoke postProcessRenderedMessages"
start = content.find("function postProcessRenderedMessages")
body = content[start:start + 500]
assert "addCopyButtons(container)" in body
+7 -1
View File
@@ -55,7 +55,13 @@ class TestTreeRenderer:
def test_initTreeViews_called_in_post_render(self):
with open("static/ui.js", "r", encoding="utf-8") as f:
content = f.read()
assert "requestAnimationFrame(()=>postProcessRenderedMessages(inner))" in content
# Behavior assertion (#5338): post-render scheduled via
# _postProcessWithAnchorSuppression, which still calls postProcessRenderedMessages.
assert "requestAnimationFrame(()=>_postProcessWithAnchorSuppression(" in content
_wrap = content.find('function _postProcessWithAnchorSuppression')
assert _wrap != -1, "post-render should be wrapped by _postProcessWithAnchorSuppression"
assert 'postProcessRenderedMessages(container)' in content[_wrap:_wrap + 500], \
"the wrapper must still invoke postProcessRenderedMessages"
start = content.find("function postProcessRenderedMessages")
body = content[start:start + 500]
assert "initTreeViews(container)" in body
+9 -1
View File
@@ -242,7 +242,15 @@ class TestRAFIntegration:
def test_message_render_uses_single_post_process_raf(self):
ui = _read_js('ui.js')
assert ui.count('requestAnimationFrame(()=>postProcessRenderedMessages(inner))') == 2
# Behavior assertion (#5338): the two `(inner)` post-render dispatches are
# now routed through _postProcessWithAnchorSuppression (which still calls
# postProcessRenderedMessages). Assert on the wrapper's `(inner)` dispatch
# count rather than the old literal so a future rename doesn't re-orphan this.
assert ui.count('requestAnimationFrame(()=>_postProcessWithAnchorSuppression(inner))') == 2
_wrap = ui.find('function _postProcessWithAnchorSuppression')
assert _wrap != -1, "post-render should be wrapped by _postProcessWithAnchorSuppression"
assert 'postProcessRenderedMessages(container)' in ui[_wrap:_wrap + 500], \
"the wrapper must still invoke postProcessRenderedMessages"
# ── CSS classes ────────────────────────────────────────────────────────────