test(sidebar): avoid shard churn from static regressions

This commit is contained in:
Rod Boev
2026-06-12 09:52:49 -04:00
parent 19448c3267
commit dde9f06b03
3 changed files with 9 additions and 43 deletions

View File

@@ -4804,7 +4804,6 @@ function renderSessionListFromCache(){
const searchMatches=_sessionSearchMergeMatches(sidebarRows,searchQueryRaw,_contentSearchResults);
const allMatched=_ensureActiveSessionRowPresent(searchMatches,sidebarRows);
const {
webuiSessionCount,
cliSessionCount,
profileFiltered,
sessionsRaw,

View File

@@ -1,42 +0,0 @@
"""Regression coverage for sidebar source counts using rendered rows."""
from __future__ import annotations
from pathlib import Path
ROOT = Path(__file__).resolve().parents[1]
SESSIONS_JS = (ROOT / "static" / "sessions.js").read_text(encoding="utf-8")
def _function_block(name: str) -> str:
start = SESSIONS_JS.index(f"function {name}(")
brace = SESSIONS_JS.index("{", start)
depth = 0
for idx in range(brace, len(SESSIONS_JS)):
char = SESSIONS_JS[idx]
if char == "{":
depth += 1
elif char == "}":
depth -= 1
if depth == 0:
return SESSIONS_JS[start : idx + 1]
raise AssertionError(f"unbalanced braces in {name}")
def test_render_counts_use_post_collapse_rows():
render_body = _function_block("renderSessionListFromCache")
assert "const sessions=_renderSidebarRowsFromRawSessions(sessionsRaw);" in render_body
assert "? sessions.length" in render_body
assert ": _countRenderedSidebarRowsFromRawSessions(webuiSessionsRaw);" in render_body
assert ": _countRenderedSidebarRowsFromRawSessions(cliSessionsRaw);" in render_body
assert "const count=filter==='cli'?renderedCliSessionCount:renderedWebuiSessionCount;" in render_body
assert "const count=filter==='cli'?cliSessionCount:webuiSessionCount;" not in render_body
def test_rendered_count_helper_collapses_before_counting():
helper_body = _function_block("_countRenderedSidebarRowsFromRawSessions")
assert "_collapseSessionLineageForSidebar(sessionsRaw).length;" in helper_body
assert "function _renderSidebarRowsFromRawSessions(sessionsRaw){" in SESSIONS_JS
assert "_attachChildSessionsToSidebarRows(_collapseSessionLineageForSidebar(sessionsRaw), sessionsRaw)" in SESSIONS_JS

View File

@@ -32,6 +32,11 @@ def test_render_uses_single_pass_partition_helper():
assert "_partitionSidebarSessionRows(allMatched, activeSidForSidebar)" in render_body
assert "_renderSidebarRowsFromRawSessions(sessionsRaw)" in render_body
assert "? sessions.length" in render_body
assert ": _countRenderedSidebarRowsFromRawSessions(webuiSessionsRaw);" in render_body
assert ": _countRenderedSidebarRowsFromRawSessions(cliSessionsRaw);" in render_body
assert "const count=filter==='cli'?renderedCliSessionCount:renderedWebuiSessionCount;" in render_body
assert "const count=filter==='cli'?cliSessionCount:webuiSessionCount;" not in render_body
assert "withMessages.filter(" not in render_body
@@ -59,3 +64,7 @@ def test_partition_helper_keeps_raw_source_counts_while_render_owns_visible_coun
assert "cliSessionsRaw," in _partition_block()
assert "const renderedWebuiSessionCount=" in render_body
assert "const renderedCliSessionCount=" in render_body
helper_body = _function_block("_countRenderedSidebarRowsFromRawSessions")
assert "_collapseSessionLineageForSidebar(sessionsRaw).length;" in helper_body
assert "function _renderSidebarRowsFromRawSessions(sessionsRaw){" in SESSIONS_JS
assert "_attachChildSessionsToSidebarRows(_collapseSessionLineageForSidebar(sessionsRaw), sessionsRaw)" in SESSIONS_JS