Files
hermes-webui/tests/test_issue2554_workspace_tree_file_indent.py
T
nesquena-hermesandRod Boev 53adcfc33f feat(#4226): display symlinks in workspace file tree (#4228)
Render symlinks in the workspace file tree with a distinct chain-link
icon (vs regular file/folder icons), and show "Symlink → {target}" on
hover with long targets middle-elided. Directory and file symlinks are
both handled; regular entries keep their normal icons.

Rebased onto master (v0.51.466) and code-diff verified byte-identical to
the contributor's PR head before staging.

Co-authored-by: Rod Boev <rod.boev@gmail.com>
2026-06-16 23:24:15 +00:00

52 lines
2.2 KiB
Python

"""Regression coverage for #2554 — workspace tree file rows align with directories."""
from pathlib import Path
REPO_ROOT = Path(__file__).resolve().parents[1]
UI_JS = (REPO_ROOT / "static" / "ui.js").read_text(encoding="utf-8")
STYLE_CSS = (REPO_ROOT / "static" / "style.css").read_text(encoding="utf-8")
def _render_tree_item_toggle_block() -> str:
# After the symlink PR, the guard changed from ``if(item.type==='dir')``
# to ``if(isDirLike)`` (covers real dirs and directory-symlinks).
try:
start = UI_JS.index("if(isDirLike){\n // Toggle arrow for directories")
except ValueError:
start = UI_JS.index("if(item.type==='dir'){\n // Toggle arrow for directories")
end = UI_JS.index("\n\n // Icon", start)
return UI_JS[start:end]
def test_file_rows_get_toggle_placeholder_before_icon():
block = _render_tree_item_toggle_block()
assert "spacer=document.createElement('span')" in block
assert "spacer.className='file-tree-toggle-placeholder'" in block
assert "spacer.setAttribute('aria-hidden','true')" in block
assert "el.appendChild(spacer);" in block
spacer_idx = UI_JS.index("spacer.className='file-tree-toggle-placeholder'")
icon_idx = UI_JS.index("const iconEl=document.createElement('span');", spacer_idx)
assert spacer_idx < icon_idx, "file-row spacer must be appended before the file icon"
def test_placeholder_matches_directory_toggle_slot_width():
assert ".file-tree-toggle{" in STYLE_CSS
assert ".file-tree-toggle-placeholder{" in STYLE_CSS
assert "--file-tree-toggle-width:10px" in STYLE_CSS
toggle_start = STYLE_CSS.index(".file-tree-toggle{")
toggle_end = STYLE_CSS.index("}", toggle_start)
toggle = STYLE_CSS[toggle_start:toggle_end]
placeholder_start = STYLE_CSS.index(".file-tree-toggle-placeholder{")
placeholder_end = STYLE_CSS.index("}", placeholder_start)
placeholder = STYLE_CSS[placeholder_start:placeholder_end]
assert "width:var(--file-tree-toggle-width)" in toggle
assert "width:var(--file-tree-toggle-width)" in placeholder
assert "flex:0 0 var(--file-tree-toggle-width)" in placeholder
assert "display:inline-block" in placeholder