Private
Public Access
0
0
Files
manual_slop/tests/test_gui_text_viewer_docking.py
T
ed 4d8e949720 fix(gui): Force newline in discussion entries to prevent squashed layout
- Insert imgui.new_line() before rendering discussion content.
- Ensures the Markdown renderer inherits the full horizontal width of the panel.
- Definitively fixes vertical squashing of tables and long text blocks.
2026-06-02 15:42:04 -04:00

55 lines
1.8 KiB
Python

import pytest
from unittest.mock import patch, MagicMock
from src.gui_2 import render_text_viewer_window
def test_text_viewer_window_id_stability():
# Setup a mock app with necessary state
app = MagicMock()
app.show_windows = {"Text Viewer": True}
app.text_viewer_title = "Custom Title"
app.text_viewer_content = "Some content"
app.text_viewer_type = "text"
app.ui_editing_slices_file = None
# Patch all dependencies
with patch('src.gui_2.imgui') as mock_imgui, \
patch('src.gui_2.markdown_helper') as mock_md, \
patch('src.gui_2.imscope') as mock_scope:
# Setup mock returns
mock_imgui.begin.return_value = (True, True)
mock_imgui.checkbox.return_value = (False, True)
render_text_viewer_window(app)
# Verify imgui.begin was called with the stable ID suffix
args, _ = mock_imgui.begin.call_args
window_title = args[0]
assert "###Text_Viewer_Stable" in window_title
assert window_title.startswith("Custom Title")
def test_text_viewer_window_default_title_id_stability():
# Setup a mock app with default title (None)
app = MagicMock()
app.show_windows = {"Text Viewer": True}
app.text_viewer_title = None
app.text_viewer_content = "Some content"
app.text_viewer_type = "text"
app.ui_editing_slices_file = None
with patch('src.gui_2.imgui') as mock_imgui, \
patch('src.gui_2.markdown_helper') as mock_md, \
patch('src.gui_2.imscope') as mock_scope:
# Setup mock returns
mock_imgui.begin.return_value = (True, True)
mock_imgui.checkbox.return_value = (False, True)
render_text_viewer_window(app)
# Verify imgui.begin was called with the stable ID suffix
args, _ = mock_imgui.begin.call_args
window_title = args[0]
assert "###Text_Viewer_Stable" in window_title
assert window_title.startswith("Text Viewer")