diff --git a/l4d2web/tests/e2e/test_files_overlay.py b/l4d2web/tests/e2e/test_files_overlay.py index 2dbd3bc..ca19ec4 100644 --- a/l4d2web/tests/e2e/test_files_overlay.py +++ b/l4d2web/tests/e2e/test_files_overlay.py @@ -453,3 +453,50 @@ def test_modal_close_on_escape_preserves_no_state(page: Page, files_overlay_serv _wait_for_routed_editor(page) reopened = page.evaluate("() => window.__filesEditor.getValue()") assert reopened == original_content + + +def test_drag_row_to_folder_moves_file(page: Page, files_overlay_server) -> None: + """Drag the server.cfg row from the overlay root onto the cfg/ + folder row. Asserts the file actually moved on disk AND the tree + reflects the move after the debounced HTMX refresh. + + Exercises the internal-drag path in uploads.js:332-366 — the + `dataTransfer.setData("application/x-files-overlay", path)` → + `getData` round-trip → POST /files/move → schedule refresh of + both parents. Playwright's `locator.drag_to()` synthesizes the + `setData/getData` contract that this path relies on (it does NOT + require `webkitGetAsEntry`, which Playwright cannot fake). + + Tree DOM gotcha: the cfg folder is collapsed by default, so its + children div is `hidden`. `scheduleRefresh("cfg")` still swaps + HTML into the hidden div — the new row exists in the DOM, just + not visible to a `to_be_visible` assertion. Using `to_have_count` + instead of `to_be_visible` accommodates this. + """ + base = files_overlay_server["base_url"] + overlay_id = files_overlay_server["overlay_id"] + overlay_root = files_overlay_server["overlay_root"] + original_content = (overlay_root / "server.cfg").read_text() + _open_overlay(page, base, overlay_id) + + # Scope to the row