test(palette): add live_gui integration tests via toggle custom_callback
This commit is contained in:
@@ -170,6 +170,8 @@ class App:
|
||||
self.controller._predefined_callbacks['set_ui_screenshot_paths'] = lambda p: setattr(self, 'ui_screenshot_paths', p)
|
||||
self.controller._predefined_callbacks['set_context_files_for_test'] = lambda files: setattr(self, 'context_files', [models.FileItem(path=f) for f in files])
|
||||
self.controller._predefined_callbacks['set_screenshots_for_test'] = lambda ss: setattr(self, 'screenshots', ss)
|
||||
self.controller._predefined_callbacks['_toggle_command_palette'] = self._toggle_command_palette
|
||||
self.controller._gettable_fields['show_command_palette'] = 'show_command_palette'
|
||||
|
||||
def _save_context_preset_force(name: str):
|
||||
if not name: return
|
||||
@@ -727,6 +729,16 @@ class App:
|
||||
def ui_screenshot_paths(self, paths: list[str]) -> None:
|
||||
self.screenshots = paths
|
||||
|
||||
def _toggle_command_palette(self) -> None:
|
||||
"""Toggle the Command Palette visibility. Used as a custom_callback for tests
|
||||
since the keyboard shortcut (Ctrl+Shift+P) cannot be simulated via the hook API."""
|
||||
self.show_command_palette = not self.show_command_palette
|
||||
if self.show_command_palette:
|
||||
if hasattr(self, '_command_palette_query'):
|
||||
self._command_palette_query = ""
|
||||
if hasattr(self, '_command_palette_selected'):
|
||||
self._command_palette_selected = 0
|
||||
|
||||
def _test_callback_func_write_to_file(self, data: str) -> None:
|
||||
"""A dummy function that a custom_callback would execute for testing."""
|
||||
# Ensure the directory exists if running from a different cwd
|
||||
|
||||
Reference in New Issue
Block a user