mirror of
https://github.com/pewdiepie-archdaemon/odysseus.git
synced 2026-10-16 03:42:20 +02:00
Preserve preview harness, editor, email and task improvements
Snapshot current maintainer-preview application changes and regression fixtures for integration into lab. Excludes local runtime data, evaluation outputs and source backups. Focused Python regression selection: 140 passed; full suite not certified.
This commit is contained in:
@@ -7,9 +7,36 @@ But valid_toggles omitted "rag", so `toggle rag on` returned an "Unknown
|
||||
toggle" error - the advertised capability was dead.
|
||||
"""
|
||||
import asyncio
|
||||
import json
|
||||
import pytest
|
||||
|
||||
from src.ai_interaction import do_ui_control
|
||||
from routes import prefs_routes
|
||||
from src.tool_schemas import function_call_to_tool_block
|
||||
|
||||
|
||||
@pytest.mark.parametrize('name', ['Dark Red', "Artist's Night", 'Night "Sky"', 'minimal'])
|
||||
def test_theme_native_adapter_preserves_name_and_colors(monkeypatch, name):
|
||||
stores = {}
|
||||
monkeypatch.setattr(prefs_routes, '_load_for_user', lambda owner: dict(stores))
|
||||
monkeypatch.setattr(prefs_routes, '_save_for_user', lambda owner, prefs: stores.update(prefs))
|
||||
colors = dict(bg='#1a0505', fg='#f5e6e6', panel='#2b0a0a', border='#4a1515', accent='#d93025')
|
||||
block = function_call_to_tool_block('ui_control', json.dumps(dict(
|
||||
action='create_theme', name=name, colors=colors)))
|
||||
result = asyncio.run(do_ui_control(block.content, owner='fixture'))
|
||||
assert 'error' not in result
|
||||
assert result['theme_name'] == name.lower().replace(' ', '-')
|
||||
assert result['colors']['bg'] == colors['bg']
|
||||
assert result['colors']['red'] == colors['accent']
|
||||
|
||||
|
||||
def test_failed_theme_cannot_claim_success():
|
||||
from src.clean_agent_preview import failed_ui_completion
|
||||
failed = dict(tool='ui_control', error=True, execution_attempted=True,
|
||||
output=json.dumps({'error': 'Invalid hex color'}))
|
||||
assert 'Invalid hex color' in failed_ui_completion('Dark Red theme created.', [failed])
|
||||
assert not failed_ui_completion('Could not create the theme.', [failed])
|
||||
assert not failed_ui_completion('Dark Red theme created.', [failed, dict(tool='ui_control', error=False)])
|
||||
|
||||
|
||||
def test_toggle_rag_on_is_accepted():
|
||||
@@ -78,11 +105,48 @@ def test_set_theme_persists_owner_scoped_name_for_later_verification(monkeypatch
|
||||
|
||||
assert changed.get("ui_event") == "set_theme"
|
||||
assert stores["alice"]["theme"] == {"name": "dark"}
|
||||
assert current == {
|
||||
"results": "Current theme: dark",
|
||||
"current_theme": "dark",
|
||||
"theme_known": True,
|
||||
}
|
||||
assert current['current_theme'] == 'dark'
|
||||
assert current['theme_known'] is True
|
||||
assert 'dark' in current['presets']
|
||||
assert 'ascii-fireflies' in current['background_patterns']
|
||||
|
||||
|
||||
@pytest.mark.parametrize('pattern', ['none', 'embers', 'ascii-fireflies', 'starfield-depth', 'random'])
|
||||
def test_minimal_theme_palette_and_background_survive_storage(monkeypatch, pattern):
|
||||
stores = {}
|
||||
monkeypatch.setattr(prefs_routes, '_load_for_user', lambda owner: dict(stores))
|
||||
monkeypatch.setattr(prefs_routes, '_save_for_user', lambda owner, prefs: stores.update(prefs))
|
||||
block = function_call_to_tool_block('ui_control', json.dumps({
|
||||
'action': 'create_theme', 'name': 'Night Sky',
|
||||
'colors': {'bg': '#123', 'accent': 'e34b50'},
|
||||
'background': {'pattern': pattern, 'speed': .5}}))
|
||||
result = asyncio.run(do_ui_control(block.content, owner='fixture'))
|
||||
assert 'error' not in result
|
||||
assert result['colors']['bg'] == '#112233'
|
||||
assert result['colors']['fg'] == '#ffffff'
|
||||
assert result['bg']['effectSpeed'] == .5
|
||||
chosen = result['bg']['pattern']
|
||||
assert chosen != 'random'
|
||||
assert chosen == pattern or pattern == 'random'
|
||||
assert stores['custom-themes']['night-sky']['bgPattern'] == chosen
|
||||
current = asyncio.run(do_ui_control('get_theme', owner='fixture'))
|
||||
assert current['background']['bgPattern'] == chosen
|
||||
assert current['colors']['bg'] == '#112233'
|
||||
assert current['custom_themes'] == ['night-sky']
|
||||
assert asyncio.run(do_ui_control('set_theme Night Sky', owner='fixture'))['theme_name'] == 'night-sky'
|
||||
|
||||
|
||||
def test_theme_invalid_palette_and_storage_failure_are_not_success(monkeypatch):
|
||||
result = asyncio.run(do_ui_control(json.dumps({'action': 'create_theme', 'name': 'Bad',
|
||||
'colors': {'bg': 'potato', 'accent': '#fff'}})))
|
||||
assert 'colors.bg' in result['error']
|
||||
def fail(*args):
|
||||
raise OSError('storage unavailable')
|
||||
monkeypatch.setattr(prefs_routes, '_load_for_user', fail)
|
||||
result = asyncio.run(do_ui_control(json.dumps({'action': 'create_theme', 'name': 'Good',
|
||||
'colors': {'bg': '#fff', 'accent': '#123'}})))
|
||||
assert 'Could not save' in result['error']
|
||||
assert 'ui_event' not in result
|
||||
|
||||
|
||||
def test_get_theme_does_not_invent_unsynchronized_client_state(monkeypatch):
|
||||
|
||||
Reference in New Issue
Block a user