from __future__ import annotations import base64 from pathlib import Path import re import shutil import subprocess import pytest ROOT = Path(__file__).resolve().parents[1] STORE = ROOT / "plugins" / "_agent_editor" / "webui" / "agent-editor-store.js" MODAL = ROOT / "plugins" / "_agent_editor" / "webui" / "main.html" TOOL_ROW = MODAL.with_name("tool-policy-row.html") TOOLTIP_STORE = ROOT / "webui" / "components" / "tooltips" / "tooltip-store.js" SWITCHER = ( ROOT / "plugins" / "_model_config" / "extensions" / "webui" / "chat-input-progress-start" / "model-switcher.html" ) SWITCHER_MIXIN = ROOT / "plugins" / "_model_config" / "webui" / "switcher-mixin.js" def test_agent_editor_surface_has_normative_entry_points_and_accessible_controls() -> None: modal = MODAL.read_text(encoding="utf-8") tool_row = TOOL_ROW.read_text(encoding="utf-8") store = STORE.read_text(encoding="utf-8") switcher = SWITCHER.read_text(encoding="utf-8") tool_section = re.search( r'data-agent-editor-section="3".*?(?=
Edit" in switcher assert "profile.customized" not in switcher assert 'class="model-switcher-item agent-profile-edit"' not in switcher assert "min-height: 24px" in re.search( r"\.agent-profile-row-edit\s*\{([^}]*)\}", switcher ).group(1) assert "createAgentProfileChat" not in switcher assert all( label in modal for label in ( "Identity", "Prompt files", "Tools", "MCPs", "Skills", "Review", "Save & test", ) ) assert 'aria-label="Editor mode"' in modal assert "Allow selected" not in modal and "Block selected" not in modal assert "No optional tools" not in modal assert 'class="agent-model-preset-picker"' in modal assert modal.count('x-model="$store.agentEditor.draft.modelPreset"') == 2 assert modal.count('$el.value = $store.agentEditor.draft.modelPreset') == 2 assert 'id="agent-editor-easy-model-preset"' in easy_surface easy_identity = easy_surface[easy_surface.index('
'):easy_surface.index('
')] assert easy_identity.index('id="agent-editor-name"') < easy_identity.index('id="agent-editor-easy-model-preset"') assert easy_surface.index('id="agent-editor-easy-model-preset"') < easy_surface.index('id="agent-editor-instructions"') assert '`Use current preset (${$store.agentEditor.state.model_preset.effective})`' in modal assert 'x-for="preset in $store.agentEditor.state.model_presets"' in modal assert modal.count("Edit Presets") == 2 assert "Manage presets" not in modal assert "model-preset-row" not in modal assert easy_surface.count('
') == 3 assert '