From 75016c99f6879a1df9434b03ea07f280ce270764 Mon Sep 17 00:00:00 2001 From: Rod Boev Date: Tue, 23 Jun 2026 11:46:37 -0400 Subject: [PATCH] test(sidebar): align legacy list checks with visible-session filtering (#4775) --- tests/test_gateway_sync.py | 23 +++++++++++++++++++ tests/test_regressions.py | 20 ++++++++++++++++ .../test_session_import_cli_fallback_model.py | 2 ++ tests/test_session_summary_redaction.py | 2 +- tests/test_sprint12.py | 12 +++++++++- tests/test_sprint15.py | 12 +++++++++- tests/test_sprint23.py | 20 ++++++++++++++++ 7 files changed, 88 insertions(+), 3 deletions(-) diff --git a/tests/test_gateway_sync.py b/tests/test_gateway_sync.py index bcb002c3..a5c164c6 100644 --- a/tests/test_gateway_sync.py +++ b/tests/test_gateway_sync.py @@ -2330,6 +2330,29 @@ def test_importing_older_gateway_session_preserves_original_timestamps_and_order {'session_id': newer_webui_sid, 'title': 'Newer WebUI Session'}, ) assert rename_status == 200, rename + from api.models import Session + from tests.conftest import TEST_WORKSPACE + newer_webui_session = Session( + session_id=newer_webui_sid, + title='Newer WebUI Session', + workspace=str(TEST_WORKSPACE), + model='openai/gpt-5', + created_at=newer_webui['session']['created_at'], + updated_at=time.time(), + profile='default', + messages=[{ + 'role': 'user', + 'content': 'newer visible row', + 'timestamp': time.time(), + }], + tool_calls=[], + ) + newer_webui_session.save(touch_updated_at=False) + rename_refresh, rename_refresh_status = post( + '/api/session/rename', + {'session_id': newer_webui_sid, 'title': 'Newer WebUI Session'}, + ) + assert rename_refresh_status == 200, rename_refresh _insert_gateway_session( conn, diff --git a/tests/test_regressions.py b/tests/test_regressions.py index 3fc3ffcb..84376955 100644 --- a/tests/test_regressions.py +++ b/tests/test_regressions.py @@ -42,6 +42,24 @@ def make_session(created_list): return sid +def _make_session_visible(sid): + from api.models import Session + from tests.conftest import TEST_WORKSPACE + + session = Session( + session_id=sid, + title="regression-test-delete-R8", + workspace=str(TEST_WORKSPACE), + model="test", + created_at=time.time(), + updated_at=time.time(), + profile="default", + messages=[{"role": "user", "content": "visible row", "timestamp": time.time()}], + tool_calls=[], + ) + session.save(touch_updated_at=False) + + def _make_auth_json_with_credential_pool( provider_id: str, pool_entries: list[dict], tmp_dir: pathlib.Path ) -> pathlib.Path: @@ -296,6 +314,8 @@ def test_deleted_session_does_not_appear_in_list(cleanup_test_sessions): d, _ = post("/api/session/new", {}) sid = d["session"]["session_id"] post("/api/session/rename", {"session_id": sid, "title": "regression-test-delete-R8"}) + _make_session_visible(sid) + post("/api/session/rename", {"session_id": sid, "title": "regression-test-delete-R8"}) # Verify it appears sessions, _ = get("/api/sessions") diff --git a/tests/test_session_import_cli_fallback_model.py b/tests/test_session_import_cli_fallback_model.py index a053eb87..a43e0eb5 100644 --- a/tests/test_session_import_cli_fallback_model.py +++ b/tests/test_session_import_cli_fallback_model.py @@ -338,6 +338,7 @@ def test_sessions_endpoint_suppresses_duplicate_webui_state_projection(monkeypat "session_id": "visible_tip", "title": "Long Conversation", "profile": "default", + "message_count": 1, "updated_at": 20, "last_message_at": 20, "source_tag": "webui", @@ -362,6 +363,7 @@ def test_sessions_endpoint_suppresses_duplicate_webui_state_projection(monkeypat "session_id": "telegram_tip", "title": "External Thread", "profile": "default", + "message_count": 1, "updated_at": 10, "last_message_at": 10, "source_tag": "telegram", diff --git a/tests/test_session_summary_redaction.py b/tests/test_session_summary_redaction.py index e6a2c80f..7a07b456 100644 --- a/tests/test_session_summary_redaction.py +++ b/tests/test_session_summary_redaction.py @@ -34,7 +34,7 @@ def _write_session_with_secret_title(): created_at=now, updated_at=now, profile="default", - messages=[], + messages=[{"role": "user", "content": "visible row", "timestamp": now}], tool_calls=[], ) # Save through the model layer so the sidebar index is updated just like a diff --git a/tests/test_sprint12.py b/tests/test_sprint12.py index 2c7f3afe..b0dc4a79 100644 --- a/tests/test_sprint12.py +++ b/tests/test_sprint12.py @@ -29,6 +29,15 @@ def make_session(created_list): return sid +def _make_session_visible(sid): + from api.models import Session + + session = Session.load(sid) + assert session is not None + session.messages = [{"role": "user", "content": "visible row", "timestamp": 1.0}] + session.save() + + # ── Settings API ────────────────────────────────────────────────────────── def test_settings_get_returns_defaults(): @@ -121,8 +130,9 @@ def test_pinned_in_session_list(): created = [] try: sid = make_session(created) - # Pin it and give it a title so it shows in the list + # Give it one real message so the default sidebar route keeps it visible. post("/api/session/rename", {"session_id": sid, "title": "Pinned Test"}) + _make_session_visible(sid) post("/api/session/pin", {"session_id": sid, "pinned": True}) d, _ = get("/api/sessions") match = [s for s in d['sessions'] if s['session_id'] == sid] diff --git a/tests/test_sprint15.py b/tests/test_sprint15.py index 8fb06788..0b291f34 100644 --- a/tests/test_sprint15.py +++ b/tests/test_sprint15.py @@ -29,6 +29,15 @@ def make_session(created_list): return sid, d["session"] +def _make_session_visible(sid): + from api.models import Session + + session = Session.load(sid) + assert session is not None + session.messages = [{"role": "user", "content": "visible row", "timestamp": 1.0}] + session.save() + + def make_project(created_list, name="Test Project", color=None): body = {"name": name} if color: @@ -196,8 +205,9 @@ def test_session_project_in_list(): try: pid, _ = make_project(pids, "Listed") sid, _ = make_session(sids) - # Give it a title so it shows in list (non-empty Untitled sessions are hidden) + # Give it one real message so the default sidebar route keeps it visible. post("/api/session/rename", {"session_id": sid, "title": "Project Test Session"}) + _make_session_visible(sid) post("/api/session/move", {"session_id": sid, "project_id": pid}) dl, _ = get("/api/sessions") match = [s for s in dl["sessions"] if s["session_id"] == sid] diff --git a/tests/test_sprint23.py b/tests/test_sprint23.py index 43909d53..d0f088be 100644 --- a/tests/test_sprint23.py +++ b/tests/test_sprint23.py @@ -30,6 +30,24 @@ def make_session(created_list): return sid, d["session"] +def _make_session_visible(sid): + from api.models import Session + from tests.conftest import TEST_WORKSPACE + + session = Session( + session_id=sid, + title="Compact Usage", + workspace=str(TEST_WORKSPACE), + model="test", + created_at=1.0, + updated_at=1.0, + profile="default", + messages=[{"role": "user", "content": "visible row", "timestamp": 1.0}], + tool_calls=[], + ) + session.save(touch_updated_at=False) + + # ── Session usage fields ───────────────────────────────────────────────── def test_new_session_has_usage_fields(): @@ -57,6 +75,8 @@ def test_session_compact_has_usage_fields(): try: sid, _ = make_session(created) post("/api/session/rename", {"session_id": sid, "title": "Compact Usage"}) + _make_session_visible(sid) + post("/api/session/rename", {"session_id": sid, "title": "Compact Usage"}) d, status = get("/api/sessions") assert status == 200 match = [s for s in d["sessions"] if s["session_id"] == sid]