feat: A toggles the sessions column between active and archived
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
+40
-1
@@ -310,7 +310,7 @@ async def test_new_session_on_dismiss_sequential_create_then_refresh():
|
||||
session=MagicMock(), spawn_ok=True, spawn_error=""
|
||||
)
|
||||
|
||||
async def fake_list(project_id):
|
||||
async def fake_list(project_id, archived=False):
|
||||
call_order.append("list")
|
||||
return []
|
||||
|
||||
@@ -2088,3 +2088,42 @@ async def test_archive_session_action_calls_service_and_refreshes():
|
||||
|
||||
mock_service.archive_session.assert_awaited_once_with(sess_id)
|
||||
mock_service.list_sessions.assert_awaited()
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_toggle_archived_binding_exists():
|
||||
bindings = {b.key: b for b in HqtApp.BINDINGS}
|
||||
assert bindings["A"].action == "toggle_archived"
|
||||
|
||||
|
||||
@pytest.mark.asyncio
|
||||
async def test_toggle_archived_switches_list_and_header():
|
||||
app = HqtApp()
|
||||
async with app.run_test(size=(120, 40)) as pilot:
|
||||
from hqt.tui.widgets.session_list import SessionList
|
||||
from textual.widgets import Label
|
||||
|
||||
proj_id = 42
|
||||
app._selected_project_id = proj_id
|
||||
|
||||
mock_service = MagicMock()
|
||||
mock_service.list_sessions = AsyncMock(return_value=[])
|
||||
mock_service.sync_window_labels = AsyncMock(return_value=[])
|
||||
app._session_service = mock_service
|
||||
|
||||
assert app._show_archived is False
|
||||
|
||||
await app.run_action("toggle_archived")
|
||||
await pilot.pause()
|
||||
|
||||
assert app._show_archived is True
|
||||
mock_service.list_sessions.assert_awaited_with(proj_id, archived=True)
|
||||
header = app.query_one(SessionList).query_one("#session-header", Label)
|
||||
assert "archived" in str(header.render()).lower()
|
||||
|
||||
await app.run_action("toggle_archived")
|
||||
await pilot.pause()
|
||||
|
||||
assert app._show_archived is False
|
||||
mock_service.list_sessions.assert_awaited_with(proj_id, archived=False)
|
||||
assert str(header.render()) == "Sessions"
|
||||
|
||||
Reference in New Issue
Block a user