8f6f47d46b
- Restore monolithic architecture in gui_2.py to fix test breakages and circular imports. - Update Text Viewer stable ID to '###Text_Viewer_Unified' to definitively fix docking conflicts. - Refactor discussion entry renderer to force full-width horizontal expansion for Markdown. - Fully restore theme_2.py definitions (palettes, fonts, scale) while retaining role-tint logic. - Robustify ImGui ID stack in imgui_scopes.py to prevent access violations. - Verify all fixes with the comprehensive unit and visual test suite.
53 lines
1.6 KiB
Python
53 lines
1.6 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.text_viewer_wrap = False
|
|
app._slice_sel_start = -1
|
|
app._slice_sel_end = -1
|
|
app.ui_editing_slices_file = None
|
|
|
|
with patch('src.gui_2.imgui') as mock_imgui, \
|
|
patch('src.gui_2.imscope') as mock_imscope:
|
|
|
|
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_Unified" in window_title
|
|
assert window_title.startswith("Custom Title")
|
|
|
|
def test_text_viewer_window_default_title_id_stability():
|
|
app = MagicMock()
|
|
app.show_windows = {"Text Viewer": True}
|
|
app.text_viewer_title = ""
|
|
app.text_viewer_content = "Some content"
|
|
app.text_viewer_type = "text"
|
|
app.text_viewer_wrap = False
|
|
app.ui_editing_slices_file = None
|
|
|
|
with patch('src.gui_2.imgui') as mock_imgui, \
|
|
patch('src.gui_2.imscope') as mock_imscope:
|
|
|
|
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_Unified" in window_title
|
|
assert window_title.startswith("Text Viewer")
|