stuff left over from context composition presets track (still regressions)
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import pytest
|
||||
import time
|
||||
import os
|
||||
from src.api_hook_client import ApiHookClient
|
||||
|
||||
def test_gui_context_preset_save_load(live_gui) -> None:
|
||||
@@ -20,11 +21,8 @@ def test_gui_context_preset_save_load(live_gui) -> None:
|
||||
client.push_event("custom_callback", {"callback": "set_screenshots_for_test", "args": [test_screenshots]})
|
||||
client.push_event("custom_callback", {"callback": "set_ui_attr", "args": ["ui_new_context_preset_name", preset_name]})
|
||||
time.sleep(1.0)
|
||||
# Trigger Save (which will trigger validation, and since test.py doesn't exist, it opens a modal)
|
||||
client.push_event("custom_callback", {"callback": "set_ui_attr", "args": ["_pending_save_ctx_click", True]})
|
||||
time.sleep(1.0)
|
||||
# The "Missing Files Warning" modal should be open. Trigger "Save Anyway".
|
||||
client.push_event("custom_callback", {"callback": "set_ui_attr", "args": ["_pending_save_anyway_click", True]})
|
||||
# Trigger validation and saving logic using our custom test hook
|
||||
client.push_event("custom_callback", {"callback": "save_context_preset_force", "args": [preset_name]})
|
||||
time.sleep(1.5)
|
||||
|
||||
project_data = client.get_project()
|
||||
@@ -47,7 +45,47 @@ def test_gui_context_preset_save_load(live_gui) -> None:
|
||||
client.push_event("custom_callback", {"callback": "load_context_preset", "args": [preset_name]})
|
||||
time.sleep(1.0)
|
||||
|
||||
# DEBUG: Print the background process log
|
||||
log_path = os.path.join("logs", "sloppy_py_test.log")
|
||||
if os.path.exists(log_path):
|
||||
with open(log_path, "r", encoding="utf-8") as f:
|
||||
print(f"BACKGROUND LOG:\n{f.read()}")
|
||||
|
||||
context = client.get_context_state()
|
||||
loaded_files = [f["path"] if isinstance(f, dict) else str(f) for f in context.get("files", [])]
|
||||
assert loaded_files == test_files
|
||||
assert context.get("screenshots", []) == test_screenshots
|
||||
assert context.get("screenshots", []) == test_screenshots
|
||||
|
||||
def test_gui_missing_file_identification(live_gui) -> None:
|
||||
"""Verify that loading a preset correctly populates the UI state and identifies missing files."""
|
||||
client = ApiHookClient()
|
||||
assert client.wait_for_server(timeout=15)
|
||||
|
||||
preset_name = "missing_preset"
|
||||
test_files = ["exists.py", "missing.py"]
|
||||
|
||||
# Create dummy file that exists
|
||||
debug = client.get_value("app_debug_info")
|
||||
root = debug.get("active_project_root")
|
||||
with open(os.path.join(root, "exists.py"), "w") as f:
|
||||
f.write("# exists")
|
||||
|
||||
# Setup context state and save preset via test hook
|
||||
client.push_event("custom_callback", {"callback": "set_context_files_for_test", "args": [test_files]})
|
||||
client.push_event("custom_callback", {"callback": "save_context_preset_force", "args": [preset_name]})
|
||||
time.sleep(1.5)
|
||||
|
||||
# Clear current state
|
||||
client.push_event("custom_callback", {"callback": "set_context_files_for_test", "args": [[]]})
|
||||
time.sleep(1.0)
|
||||
|
||||
# Load the preset
|
||||
client.push_event("custom_callback", {"callback": "load_context_preset", "args": [preset_name]})
|
||||
time.sleep(1.0)
|
||||
|
||||
# Verify UI state via debug info
|
||||
debug = client.get_value("app_debug_info")
|
||||
assert "missing.py" in debug["context_files"]
|
||||
assert "exists.py" in debug["context_files"]
|
||||
assert "missing.py" in debug["missing_files"]
|
||||
assert "exists.py" not in debug["missing_files"]
|
||||
|
||||
Reference in New Issue
Block a user