Private
Public Access
0
0
Files
manual_slop/tests/test_log_management_first_open.py
T
ed df7bda6e0d fix(gui): explicit child size for comms_scroll and prior_scroll prevents early clipping
ROOT CAUSE: When child windows used ImVec2(0, 0) for auto-fill, the
child's reported height was unstable inside tab items (especially when
the parent tab was inside a tab_bar inside a window). Result: the
scrollable child rendered with a fixed smaller height, showing only the
first half of the content, with empty space below.

FIX: Use imgui.get_content_region_avail() to compute explicit dimensions
and pass them to begin_child. Now the child fills the full available area
inside the tab content.

- render_comms_history_panel: avail.x, avail.y
- render_prior_session_view: same, plus added entry count indicator next
  to the Exit Prior Session button ({N} entries) for at-a-glance info

Tests:
- test_comms_scroll_no_clipping.py: verifies comms_scroll child uses
  explicit (non-zero) size
- test_prior_session_no_clipping.py: same for prior_scroll child
- test_log_management_first_open.py: minor cleanup
- 42/42 broad regression pass
2026-06-03 13:47:08 -04:00

35 lines
1.8 KiB
Python

import os, tempfile, tomli_w
from unittest.mock import patch, MagicMock
from src.gui_2 import render_log_management
def test_log_management_populates_registry_on_first_open(app_instance):
with tempfile.TemporaryDirectory() as tmp:
reg_path = os.path.join(tmp, "log_registry.toml")
tomli_w.dump({"s1": {"start_time": "2026-06-03T10:00:00", "path": "C:/x/s1", "whitelisted": False}}, open(reg_path, "wb"))
app_instance._log_registry = None
app_instance.show_windows = {"Log Management": True}
app_instance.perf_profiling_enabled = False
with patch("src.gui_2.paths") as mock_paths, \
patch("src.gui_2.imgui") as mock_imgui, \
patch("src.gui_2.imscope") as mock_imscope:
mock_paths.get_logs_dir.return_value = MagicMock()
mock_paths.get_logs_dir.return_value.__truediv__ = lambda self, x: reg_path
mock_imgui.collapsing_header = MagicMock(return_value=True)
mock_imgui.TableFlags_ = type("T", (), {"borders": 1, "row_bg": 2, "resizable": 4})()
mock_imgui.TableColumnFlags_ = type("C", (), {"width_fixed": 1, "width_stretch": 2})()
mock_imgui.begin_table.return_value = True
mock_imgui.button.return_value = False
mock_imgui.table_next_row = lambda: None
mock_imgui.table_next_column = lambda: None
mock_imgui.text = lambda *a, **k: None
mock_imgui.text_colored = lambda *a, **k: None
mock_imgui.text_disabled = lambda *a, **k: None
mock_imgui.end_table = lambda: None
mock_imscope.window.return_value.__enter__.return_value = (True, True)
app_instance.cb_load_prior_log = MagicMock()
app_instance.controller = MagicMock()
del app_instance.controller._log_registry
render_log_management(app_instance)
assert app_instance._log_registry is not None
assert "s1" in app_instance._log_registry.data, f"Registry should be populated on first open. Got: {list(app_instance._log_registry.data.keys())}"