From fbb21964a9c2ef0a966912e41d05c1e1d654a97e Mon Sep 17 00:00:00 2001 From: allenliang2022 Date: Thu, 2 Jul 2026 00:08:51 +0800 Subject: [PATCH] test(chat): update 6 post-render tests orphaned by the _postProcessWithAnchorSuppression refactor (#5338) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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). --- tests/test_csv_table_rendering.py | 11 ++++++++++- tests/test_excalidraw_inline_embed.py | 8 +++++++- tests/test_issue347.py | 8 +++++++- tests/test_issue483_inline_diff_viewer.py | 8 +++++++- tests/test_issue484_json_tree_viewer.py | 8 +++++++- tests/test_pdf_html_preview.py | 10 +++++++++- 6 files changed, 47 insertions(+), 6 deletions(-) diff --git a/tests/test_csv_table_rendering.py b/tests/test_csv_table_rendering.py index b86c413f..57cbbe9b 100644 --- a/tests/test_csv_table_rendering.py +++ b/tests/test_csv_table_rendering.py @@ -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" diff --git a/tests/test_excalidraw_inline_embed.py b/tests/test_excalidraw_inline_embed.py index 677aac07..73c83f87 100644 --- a/tests/test_excalidraw_inline_embed.py +++ b/tests/test_excalidraw_inline_embed.py @@ -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, ( diff --git a/tests/test_issue347.py b/tests/test_issue347.py index 489e8d7e..1b94ec4a 100644 --- a/tests/test_issue347.py +++ b/tests/test_issue347.py @@ -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 diff --git a/tests/test_issue483_inline_diff_viewer.py b/tests/test_issue483_inline_diff_viewer.py index 215d20ce..06e819fc 100644 --- a/tests/test_issue483_inline_diff_viewer.py +++ b/tests/test_issue483_inline_diff_viewer.py @@ -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 diff --git a/tests/test_issue484_json_tree_viewer.py b/tests/test_issue484_json_tree_viewer.py index 1b0978e3..7e46436a 100644 --- a/tests/test_issue484_json_tree_viewer.py +++ b/tests/test_issue484_json_tree_viewer.py @@ -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 diff --git a/tests/test_pdf_html_preview.py b/tests/test_pdf_html_preview.py index 51be6a2d..c0a3c8ca 100644 --- a/tests/test_pdf_html_preview.py +++ b/tests/test_pdf_html_preview.py @@ -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 ────────────────────────────────────────────────────────────