fix(gui): Implement correct UX for discussion takes tabs and combo box
This commit is contained in:
@@ -11,22 +11,26 @@ def mock_gui():
|
||||
'active': 'main',
|
||||
'discussions': {
|
||||
'main': {'history': []},
|
||||
'take_1': {'history': []},
|
||||
'take_2': {'history': []}
|
||||
'main_take_1': {'history': []},
|
||||
'other_topic': {'history': []}
|
||||
}
|
||||
}
|
||||
}
|
||||
gui.active_discussion = 'main'
|
||||
# Mock some required state
|
||||
gui.perf_profiling_enabled = False
|
||||
gui.is_viewing_prior_session = False
|
||||
gui._get_discussion_names = lambda: ['main', 'take_1', 'take_2']
|
||||
gui._get_discussion_names = lambda: ['main', 'main_take_1', 'other_topic']
|
||||
return gui
|
||||
|
||||
def test_discussion_tabs_rendered(mock_gui):
|
||||
with patch('src.gui_2.imgui') as mock_imgui, \
|
||||
patch('src.app_controller.AppController.active_project_root', new_callable=PropertyMock, return_value='.'):
|
||||
# We expect a tab bar to be used instead of a combo box
|
||||
|
||||
# We expect a combo box for base discussion
|
||||
mock_imgui.begin_combo.return_value = True
|
||||
mock_imgui.selectable.return_value = (False, False)
|
||||
|
||||
# We expect a tab bar for takes
|
||||
mock_imgui.begin_tab_bar.return_value = True
|
||||
mock_imgui.begin_tab_item.return_value = (True, True)
|
||||
mock_imgui.input_text.return_value = (False, "")
|
||||
@@ -34,16 +38,16 @@ def test_discussion_tabs_rendered(mock_gui):
|
||||
mock_imgui.checkbox.return_value = (False, False)
|
||||
mock_imgui.input_int.return_value = (False, 0)
|
||||
|
||||
# Prevent infinite loop in ListClipper
|
||||
mock_clipper = MagicMock()
|
||||
mock_clipper.step.return_value = False
|
||||
mock_imgui.ListClipper.return_value = mock_clipper
|
||||
|
||||
mock_gui._render_discussion_panel()
|
||||
|
||||
mock_imgui.begin_combo.assert_called_once_with("##disc_sel", 'main')
|
||||
mock_imgui.begin_tab_bar.assert_called_once_with('discussion_takes_tabs')
|
||||
# Check that begin_tab_item was called for each take
|
||||
|
||||
calls = [c[0][0] for c in mock_imgui.begin_tab_item.call_args_list]
|
||||
assert 'main' in calls
|
||||
assert 'take_1' in calls
|
||||
assert 'take_2' in calls
|
||||
assert 'Original###main' in calls
|
||||
assert 'Take 1###main_take_1' in calls
|
||||
assert 'Synthesis###Synthesis' in calls
|
||||
|
||||
Reference in New Issue
Block a user