import re from pathlib import Path ROOT = Path(__file__).resolve().parents[1] INDEX = (ROOT / "static" / "index.html").read_text(encoding="utf-8") APP_JS = (ROOT / "static" / "app.js").read_text(encoding="utf-8") MEMORY_JS = (ROOT / "static" / "js" / "memory.js").read_text(encoding="utf-8") CHAT_STREAM_JS = (ROOT / "static" / "js" / "chatStream.js").read_text(encoding="utf-8") INIT_JS = (ROOT / "static" / "js" / "init.js").read_text(encoding="utf-8") TOOL_ORDER = [ "tool-calendar-btn", "tool-compare-btn", "tool-cookbook-btn", "tool-research-btn", "tool-gallery-btn", "tool-library-btn", "tool-memory-btn", "tool-notes-btn", "tool-skills-btn", "tool-tasks-btn", "tool-theme-btn", ] RAIL_ORDER = [ "rail-calendar", "rail-compare", "rail-cookbook", "rail-research", "rail-email", "rail-gallery", "rail-archive", "rail-memory", "rail-notes", "rail-skills", "rail-tasks", "rail-theme", ] def _element_by_id(source: str, tag: str, element_id: str) -> str: match = re.search( rf"<{tag}\b(?=[^>]*\bid=\"{re.escape(element_id)}\")[\s\S]*?", source, ) assert match, f"missing <{tag}>#{element_id}" return match.group(0) def test_memory_modal_and_sidebar_are_renamed_from_brain(): assert 'role="dialog" aria-label="Memory"' in INDEX assert 'id="memory-modal-title-text">Memory' in INDEX memory_row = _element_by_id(INDEX, "div", "tool-memory-btn") assert "Memory" in memory_row assert "Brain" not in memory_row assert 'id="rail-memory" title="Memory"' in INDEX def test_skills_has_its_own_sidebar_and_rail_launcher(): skills_row = _element_by_id(INDEX, "div", "tool-skills-btn") assert "Skills" in skills_row assert "' in INDEX assert '
' in INDEX def test_sidebar_tools_and_icon_rail_are_alphabetically_ordered(): tool_positions = [INDEX.index(f'id="{tool_id}"') for tool_id in TOOL_ORDER] assert tool_positions == sorted(tool_positions) rail_positions = [INDEX.index(f'id="{rail_id}"') for rail_id in RAIL_ORDER] assert rail_positions == sorted(rail_positions)