Files
hermes-webui/tests/test_issue3411_workspace_tree_os_drop.py
T
nesquena-hermesandnesquena-hermes 9374e66855 Release v0.51.228 — Release GV (stage-p12 — workspace tree-drop #3411 + large-markdown preview #3378) (#3463)
* Release v0.51.228 (stage-p12): workspace tree-drop #3411 + large-markdown preview #3378

#3411 (@pamnard): stopPropagation on workspace file-tree OS-file dragenter/dragover/drop
so a tree drop uploads to the workspace WITHOUT also attaching to the composer.
#3378 (@starGazerK): raise md rich-render ceiling 64KB/1500L->256KB/5000L + backend
file read 200KB->400KB, add 'Render as markdown anyway' force button (reuses cached
raw content, no extra fetch).

* fix(workspace): force-render uses fresh path-scoped cache, blocked while dirty (#3378 Codex follow-up)

Codex review of #3378 found the markdown force-render path had two SILENT bugs:
(1) saving a md file from the plain-text fallback didn't update _previewRawContent,
so a later force-render showed stale pre-save content; (2) the cache-reuse check
'path===_previewCurrentPath' was tautological (var just assigned), so a force-render
after a file switch could render the previous file's cached content. Fixes: track
_previewRawContentPath (set on fetch AND save), reuse cache only when it matches the
requested path, and block force-render while the editor is dirty/open. +3 regression
tests. (#3411 was cleared clean by Codex.)

---------

Co-authored-by: nesquena-hermes <[email protected]>
2026-06-02 20:58:22 -07:00

56 lines
2.4 KiB
Python

"""Tests for #3411 — OS file drop on workspace tree must not attach to composer."""
import re
def _src(name: str) -> str:
with open(f"static/{name}") as f:
return f.read()
def _tree_os_drop_block(src: str) -> str:
"""Extract the file-tree OS upload DnD init block in workspace.js."""
m = re.search(r"tree\.addEventListener\('drop', async \(e\) => \{", src)
assert m, "fileTree drop handler must exist in workspace.js"
return src[m.start():m.start() + 1200]
class TestIssue3411WorkspaceTreeOsDrop:
"""OS Files drops on #fileTree must not bubble to the composer handler."""
def test_tree_drop_stops_propagation_for_os_files(self):
block = _tree_os_drop_block(_src("workspace.js"))
assert "e.stopPropagation()" in block, (
"fileTree drop must stopPropagation so document drop does not call addFiles"
)
prevent = block.index("e.preventDefault()")
stop = block.index("e.stopPropagation()")
assert prevent < stop, "stopPropagation must run after preventDefault on OS file drop"
def test_tree_dragover_stops_propagation_for_os_files(self):
src = _src("workspace.js")
m = re.search(r"tree\.addEventListener\('dragover', \(e\) => \{", src)
assert m, "fileTree dragover handler must exist in workspace.js"
block = src[m.start():m.start() + 400]
assert "e.stopPropagation()" in block, (
"fileTree dragover must stopPropagation so composer drag-over does not highlight"
)
def test_tree_dragenter_stops_propagation_for_os_files(self):
src = _src("workspace.js")
m = re.search(r"tree\.addEventListener\('dragenter', \(e\) => \{", src)
assert m, "fileTree dragenter handler must exist in workspace.js"
block = src[m.start():m.start() + 300]
assert "e.stopPropagation()" in block, (
"fileTree dragenter must stopPropagation so composer drag-over does not highlight"
)
def test_composer_os_drop_still_works_outside_tree(self):
"""Document-level addFiles path must remain for drops outside the tree."""
src = _src("panels.js")
m = re.search(r"document\.addEventListener\('drop'", src)
assert m, "Global drop listener must exist"
after = src[m.start():m.start() + 2000]
assert "addFiles(files)" in after, (
"Composer must still attach OS files dropped outside the workspace tree"
)