test(#3899): re-anchor 5 brittle source-window tests displaced by the idle-reset block

#3899's new idle-reset added an EARLIER if(INFLIGHT[sid]){ block in loadSession, so
4 test_regressions tests' src.find('if(INFLIGHT[sid]){') grabbed the wrong (idle-cleanup)
occurrence instead of the Phase-2 restore branch → switched to rfind (the substantive
branch). And the idle-cleanup comment changed from 'discard any browser-side inflight'
to 'reset browser-side streaming flags' → re-anchored test_frontend_drops_inflight_cache
on the new comment + nested if(!activeStreamId){...if(INFLIGHT[sid]){ form (behavior
preserved + enhanced). No production code changed.
This commit is contained in:
nesquena-hermes
2026-06-13 06:48:21 +00:00
parent 5bbddbad1e
commit 5f3e0ab8d9
2 changed files with 26 additions and 8 deletions

View File

@@ -426,7 +426,10 @@ def test_loadSession_inflight_restores_live_tool_cards(cleanup_test_sessions):
"""
src = (REPO_ROOT / "static/sessions.js").read_text()
# INFLIGHT branch must call appendLiveToolCard
inflight_idx = src.find("if(INFLIGHT[sid]){")
# Anchor on the Phase-2 INFLIGHT restore branch (the later occurrence); #3899
# added an earlier if(INFLIGHT[sid]){ idle-reset block, so .find() would
# grab the wrong one. (rfind = the substantive restore branch.)
inflight_idx = src.rfind("if(INFLIGHT[sid]){")
assert inflight_idx >= 0, "INFLIGHT branch not found in loadSession"
inflight_block = src[inflight_idx:inflight_idx+4200]
assert "appendLiveToolCard" in inflight_block, "loadSession INFLIGHT branch must restore live tool cards via appendLiveToolCard"
@@ -647,7 +650,10 @@ def test_loadSession_inflight_sets_busy_before_renderMessages(cleanup_test_sessi
session switch.
"""
src = (REPO_ROOT / "static/sessions.js").read_text()
inflight_idx = src.find("if(INFLIGHT[sid]){")
# Anchor on the Phase-2 INFLIGHT restore branch (the later occurrence); #3899
# added an earlier if(INFLIGHT[sid]){ idle-reset block, so .find() would
# grab the wrong one. (rfind = the substantive restore branch.)
inflight_idx = src.rfind("if(INFLIGHT[sid]){")
assert inflight_idx >= 0, "INFLIGHT branch not found in loadSession"
inflight_block = src[inflight_idx:inflight_idx+4200]
busy_pos = inflight_block.find("S.busy=true;")
@@ -662,7 +668,10 @@ def test_loadSession_inflight_sets_busy_before_renderMessages(cleanup_test_sessi
def test_loadSession_inflight_merges_tail_with_persisted_transcript(cleanup_test_sessions):
src = (REPO_ROOT / "static/sessions.js").read_text()
inflight_idx = src.find("if(INFLIGHT[sid]){")
# Anchor on the Phase-2 INFLIGHT restore branch (the later occurrence); #3899
# added an earlier if(INFLIGHT[sid]){ idle-reset block, so .find() would
# grab the wrong one. (rfind = the substantive restore branch.)
inflight_idx = src.rfind("if(INFLIGHT[sid]){")
assert inflight_idx >= 0, "INFLIGHT branch not found in loadSession"
inflight_block = src[inflight_idx:inflight_idx+1200]
@@ -756,7 +765,10 @@ def test_loadSession_inflight_sets_active_stream_before_replaying_live_tool_card
counter drops the previously-seen tools after a focus change.
"""
src = (REPO_ROOT / "static/sessions.js").read_text()
inflight_idx = src.find("if(INFLIGHT[sid]){")
# Anchor on the Phase-2 INFLIGHT restore branch (the later occurrence); #3899
# added an earlier if(INFLIGHT[sid]){ idle-reset block, so .find() would
# grab the wrong one. (rfind = the substantive restore branch.)
inflight_idx = src.rfind("if(INFLIGHT[sid]){")
assert inflight_idx >= 0, "INFLIGHT branch not found in loadSession"
inflight_block = src[inflight_idx:inflight_idx+4200]
active_pos = inflight_block.find("S.activeStreamId=activeStreamId;")

View File

@@ -398,13 +398,19 @@ def test_stale_stream_cleanup_does_not_clobber_concurrent_chat_start(monkeypatch
def test_frontend_drops_inflight_cache_when_server_session_is_idle():
marker = "If the server says the session is idle, discard any browser-side inflight"
# #3900/#3899 generalized this block: on an idle server session it now resets
# the streaming flags (S.busy/S.activeStreamId) AND drops the inflight cache,
# before the async message-load gap. Anchor on the current comment + assert the
# (preserved) cache-drop behavior in the now-nested form.
marker = "If the server says the session is idle, reset browser-side streaming flags"
marker_pos = SESSIONS_SRC.index(marker)
window = SESSIONS_SRC[marker_pos:marker_pos + 500]
assert "if(!activeStreamId&&INFLIGHT[sid])" in window
window = SESSIONS_SRC[marker_pos:marker_pos + 900]
assert "if(!activeStreamId){" in window
assert "S.busy=false" in window
assert "S.activeStreamId=null" in window
assert "if(INFLIGHT[sid]){" in window
assert "delete INFLIGHT[sid]" in window
assert "clearInflightState" in window
assert "S.busy=false" in window
def test_service_worker_cache_bumped_for_frontend_fix_delivery():