chore(conductor): Mark track 'Saved System Prompt Presets' as complete

This commit is contained in:
2026-03-09 22:35:52 -04:00
parent e2a403a187
commit 95381c258c
9 changed files with 1729 additions and 158 deletions

View File

@@ -3,9 +3,39 @@ import time
import tomli_w
import os
import json
import shutil
from pathlib import Path
from src.api_hook_client import ApiHookClient
@pytest.fixture(scope="session", autouse=True)
def test_env_setup():
temp_workspace = Path("tests/artifacts/live_gui_workspace")
if temp_workspace.exists():
try: shutil.rmtree(temp_workspace)
except: pass
temp_workspace.mkdir(parents=True, exist_ok=True)
config_path = temp_workspace / "config.toml"
manual_slop_path = temp_workspace / "manual_slop.toml"
# Create minimal project file
manual_slop_path.write_text("[project]\nname = 'TestProject'\n", encoding="utf-8")
# Create local config.toml
config_path.write_text(tomli_w.dumps({
"projects": {
"paths": [str(manual_slop_path.absolute())],
"active": str(manual_slop_path.absolute())
},
"ai": {
"provider": "gemini",
"model": "gemini-2.5-flash-lite"
}
}))
yield
# Cleanup handled by live_gui fixture usually, but we can be explicit
if config_path.exists(): config_path.unlink()
def test_preset_switching(live_gui):
client = ApiHookClient()
@@ -58,10 +88,6 @@ def test_preset_switching(live_gui):
})
time.sleep(2) # Wait for processing
# Verify where it thinks the project is
state = client.get_gui_state()
print(f"DEBUG: ui_files_base_dir={state.get('files_base_dir')}")
# Apply Global Preset (should use override from project if available in merged list)
client.push_event("custom_callback", {
"callback": "_apply_preset",
@@ -86,6 +112,7 @@ def test_preset_switching(live_gui):
assert state["project_preset_name"] == "TestProject"
assert state["project_system_prompt"] == "Project Prompt"
assert state["temperature"] == 0.3
# Select "None"
client.push_event("custom_callback", {
"callback": "_apply_preset",
@@ -97,7 +124,45 @@ def test_preset_switching(live_gui):
# Prompt remains from previous application
assert state["global_system_prompt"] == "Overridden Prompt"
finally:
# Cleanup
if global_presets_path.exists(): global_presets_path.unlink()
if project_presets_path.exists(): project_presets_path.unlink()
def test_preset_manager_modal(live_gui):
client = ApiHookClient()
temp_workspace = Path("tests/artifacts/live_gui_workspace")
global_presets_path = temp_workspace / "presets.toml"
project_presets_path = temp_workspace / "project_presets.toml"
# Open Modal
client.set_value("show_preset_manager_modal", True)
time.sleep(1)
# Create New Preset via Modal Logic (triggering the callback directly for reliability in headless)
client.push_event("custom_callback", {
"callback": "_cb_save_preset",
"args": ["ModalPreset", "Modal Content", 0.9, 1.0, 4096, "global"]
})
time.sleep(2)
# Verify file exists
assert global_presets_path.exists()
with open(global_presets_path, "rb") as f:
import tomllib
data = tomllib.load(f)
assert "ModalPreset" in data["presets"]
assert data["presets"]["ModalPreset"]["temperature"] == 0.9
# Delete Preset via Modal Logic
client.push_event("custom_callback", {
"callback": "_cb_delete_preset",
"args": ["ModalPreset", "global"]
})
time.sleep(2)
# Verify file content
with open(global_presets_path, "rb") as f:
data = tomllib.load(f)
assert "ModalPreset" not in data["presets"]