fix(tests): Resolve access violation in phase4 tests and auto-approval logic in cli integration tests

This commit is contained in:
2026-03-03 01:35:37 -05:00
parent 6b2270f811
commit 5401fc770b
3 changed files with 9 additions and 3 deletions

View File

@@ -325,6 +325,7 @@ class App:
self.is_viewing_prior_session = False self.is_viewing_prior_session = False
self.prior_session_entries: list[dict[str, Any]] = [] self.prior_session_entries: list[dict[str, Any]] = []
self.test_hooks_enabled = ("--enable-test-hooks" in sys.argv) or (os.environ.get("SLOP_TEST_HOOKS") == "1") self.test_hooks_enabled = ("--enable-test-hooks" in sys.argv) or (os.environ.get("SLOP_TEST_HOOKS") == "1")
self.ui_manual_approve = False
self.perf_monitor = PerformanceMonitor() self.perf_monitor = PerformanceMonitor()
self.perf_history = {"frame_time": [0.0]*100, "fps": [0.0]*100, "cpu": [0.0]*100, "input_lag": [0.0]*100} self.perf_history = {"frame_time": [0.0]*100, "fps": [0.0]*100, "cpu": [0.0]*100, "input_lag": [0.0]*100}
self._perf_last_update = 0.0 self._perf_last_update = 0.0
@@ -421,7 +422,8 @@ class App:
'mma_status': 'mma_status', 'mma_status': 'mma_status',
'mma_active_tier': 'active_tier', 'mma_active_tier': 'active_tier',
'ui_new_track_name': 'ui_new_track_name', 'ui_new_track_name': 'ui_new_track_name',
'ui_new_track_desc': 'ui_new_track_desc' 'ui_new_track_desc': 'ui_new_track_desc',
'manual_approve': 'ui_manual_approve'
} }
self._clickable_actions: dict[str, Callable[..., Any]] = { self._clickable_actions: dict[str, Callable[..., Any]] = {
'btn_reset': self._handle_reset_session, 'btn_reset': self._handle_reset_session,
@@ -1424,8 +1426,8 @@ class App:
def _confirm_and_run(self, script: str, base_dir: str, qa_callback: Optional[Callable[[str], str]] = None) -> str | None: def _confirm_and_run(self, script: str, base_dir: str, qa_callback: Optional[Callable[[str], str]] = None) -> str | None:
print(f"[DEBUG] _confirm_and_run triggered for script length: {len(script)}") print(f"[DEBUG] _confirm_and_run triggered for script length: {len(script)}")
if self.test_hooks_enabled: if self.test_hooks_enabled and not getattr(self, "ui_manual_approve", False):
print(f"[DEBUG] test_hooks_enabled is True; AUTO-APPROVING script execution in {base_dir}") print(f"[DEBUG] test_hooks_enabled is True and ui_manual_approve is False; AUTO-APPROVING script execution in {base_dir}")
self.ai_status = "running powershell..." self.ai_status = "running powershell..."
output = shell_runner.run_powershell(script, base_dir, qa_callback=qa_callback) output = shell_runner.run_powershell(script, base_dir, qa_callback=qa_callback)
self._append_tool_log(script, output) self._append_tool_log(script, output)

View File

@@ -15,6 +15,7 @@ def test_gemini_cli_full_integration(live_gui: Any) -> None:
client.click("btn_reset") client.click("btn_reset")
time.sleep(1.5) time.sleep(1.5)
client.set_value("auto_add_history", True) client.set_value("auto_add_history", True)
client.set_value("manual_approve", True)
# Switch to manual_slop project explicitly # Switch to manual_slop project explicitly
client.select_list_item("proj_files", "manual_slop") client.select_list_item("proj_files", "manual_slop")
# 1. Setup paths and configure the GUI # 1. Setup paths and configure the GUI
@@ -81,6 +82,7 @@ def test_gemini_cli_rejection_and_history(live_gui: Any) -> None:
client.click("btn_reset") client.click("btn_reset")
time.sleep(1.5) time.sleep(1.5)
client.set_value("auto_add_history", True) client.set_value("auto_add_history", True)
client.set_value("manual_approve", True)
client.select_list_item("proj_files", "manual_slop") client.select_list_item("proj_files", "manual_slop")
mock_script = os.path.abspath("tests/mock_gemini_cli.py") mock_script = os.path.abspath("tests/mock_gemini_cli.py")
cli_cmd = f'"{sys.executable}" "{mock_script}"' cli_cmd = f'"{sys.executable}" "{mock_script}"'

View File

@@ -40,6 +40,7 @@ def test_add_ticket_logic(mock_app: App):
mock_imgui.button.side_effect = button_side_effect mock_imgui.button.side_effect = button_side_effect
# Mock other necessary imgui calls to avoid errors # Mock other necessary imgui calls to avoid errors
mock_imgui.begin_child.return_value = True mock_imgui.begin_child.return_value = True
mock_imgui.get_window_draw_list.return_value.add_rect_filled = MagicMock()
# We also need to mock _push_mma_state_update # We also need to mock _push_mma_state_update
with patch.object(mock_app, '_push_mma_state_update') as mock_push: with patch.object(mock_app, '_push_mma_state_update') as mock_push:
@@ -76,6 +77,7 @@ def test_delete_ticket_logic(mock_app: App):
return label == "Delete##T-001" return label == "Delete##T-001"
mock_imgui.button.side_effect = button_side_effect mock_imgui.button.side_effect = button_side_effect
mock_imgui.tree_node_ex.return_value = True mock_imgui.tree_node_ex.return_value = True
mock_imgui.get_window_draw_list.return_value.add_rect_filled = MagicMock()
with patch.object(mock_app, '_push_mma_state_update') as mock_push: with patch.object(mock_app, '_push_mma_state_update') as mock_push:
# Render T-001 # Render T-001