test: update loadSession source-assertion tests for #3326 conditional renderMessages arg
#3326 changed loadSession's INFLIGHT + idle render calls from bare renderMessages() to renderMessages(sameSessionForceReload?{preserveScroll:true}:undefined), and added reload-width-hint handling inside _ensureMessagesLoaded. Updated 5 source-pinning tests to match the new (behaviorally-equivalent) call form: - test_regressions / test_issue2341: match 'renderMessages(' call form - test_parallel_session_switch: match call form + widen 600->850 block window - test_issue1690: assert the CONDITIONAL preserveScroll (cross-session still bottom-pins) - test_issue3162: widen _ensureMessagesLoaded slice 2000->2600
This commit is contained in:
@@ -72,5 +72,13 @@ def test_session_switch_and_idle_session_load_keep_default_bottom_pin_behavior()
|
||||
load_session = _function_body(SESSIONS_JS, "loadSession")
|
||||
idle_branch = load_session[load_session.index("}else{\n S.busy=false;") : load_session.index("// Sync context usage indicator")]
|
||||
|
||||
assert "syncTopbar();renderMessages();" in idle_branch
|
||||
assert "preserveScroll:true" not in idle_branch
|
||||
# #3326: the idle branch now renders with a CONDITIONAL preserveScroll —
|
||||
# `renderMessages(sameSessionForceReload?{preserveScroll:true}:undefined)`.
|
||||
# For a normal cross-session idle load (currentSid!==sid) sameSessionForceReload
|
||||
# is false, so the arg is undefined and the default bottom-pin behavior (#1690)
|
||||
# is unchanged. preserveScroll only applies to a same-session external
|
||||
# force-refresh (#3239), which is a different code path from #1690's scenario.
|
||||
assert "syncTopbar();renderMessages(sameSessionForceReload?{preserveScroll:true}:undefined);" in idle_branch
|
||||
# The idle path must NOT unconditionally preserveScroll — it stays bottom-pinned
|
||||
# for cross-session loads. Guard against a regression to an always-on preserve.
|
||||
assert "renderMessages({preserveScroll:true})" not in idle_branch
|
||||
|
||||
@@ -25,7 +25,9 @@ def test_load_session_inflight_reattach_merges_pending_user_message_before_rende
|
||||
block = _load_session_inflight_branch()
|
||||
|
||||
merge_pos = block.find("_mergePendingSessionMessage")
|
||||
render_pos = block.find("renderMessages();")
|
||||
# #3326 added an optional {preserveScroll} arg to the INFLIGHT-branch render
|
||||
# call; match the call form rather than the bare `renderMessages();`.
|
||||
render_pos = block.find("renderMessages(")
|
||||
|
||||
assert merge_pos != -1, (
|
||||
"loadSession's INFLIGHT reattach branch must merge pending_user_message "
|
||||
|
||||
@@ -15,7 +15,9 @@ SESSIONS_JS = (REPO / "static" / "sessions.js").read_text(encoding="utf-8")
|
||||
|
||||
def _ensure_messages_loaded_body() -> str:
|
||||
start = SESSIONS_JS.index("async function _ensureMessagesLoaded")
|
||||
return SESSIONS_JS[start: start + 2000]
|
||||
# Window widened (#3326 added reload-width-hint handling inside this function,
|
||||
# pushing the carry-forward reassignment further down).
|
||||
return SESSIONS_JS[start: start + 2600]
|
||||
|
||||
|
||||
def test_ensure_messages_loaded_declares_msgs_with_let():
|
||||
|
||||
@@ -80,9 +80,14 @@ class TestLoadSessionIdleOverlap:
|
||||
|
||||
found = False
|
||||
for pos in positions:
|
||||
block = SESSIONS_JS[pos : pos + 600]
|
||||
# Window widened 600→850 (#3326 added a reload-width-hint comment +
|
||||
# conditional preserveScroll arg in the idle branch, pushing the
|
||||
# _dirP.catch line further from the S.busy=false anchor).
|
||||
block = SESSIONS_JS[pos : pos + 850]
|
||||
has_loaddir = "loadDir('.')" in block
|
||||
has_render = "renderMessages()" in block
|
||||
# #3326 added an optional {preserveScroll} arg to the idle-path render
|
||||
# call; match the call form rather than the bare `renderMessages()`.
|
||||
has_render = "renderMessages(" in block
|
||||
if has_loaddir and has_render:
|
||||
found = True
|
||||
assert "highlightCode()" not in block, (
|
||||
|
||||
@@ -620,7 +620,9 @@ def test_loadSession_inflight_sets_busy_before_renderMessages(cleanup_test_sessi
|
||||
assert inflight_idx >= 0, "INFLIGHT branch not found in loadSession"
|
||||
inflight_block = src[inflight_idx:inflight_idx+1600]
|
||||
busy_pos = inflight_block.find("S.busy=true;")
|
||||
render_pos = inflight_block.find("renderMessages();")
|
||||
# #3326 added an optional {preserveScroll} arg to the INFLIGHT-branch render
|
||||
# call, so match the call form rather than the bare `renderMessages();`.
|
||||
render_pos = inflight_block.find("renderMessages(")
|
||||
assert busy_pos >= 0, "loadSession INFLIGHT branch must set S.busy=true"
|
||||
assert render_pos >= 0, "loadSession INFLIGHT branch must call renderMessages()"
|
||||
assert busy_pos < render_pos, \
|
||||
|
||||
Reference in New Issue
Block a user