fix(file-manager): accept OS file drops over existing rows (#1484)

* fix(file-manager): accept OS file drops over existing rows

* test(file-manager): target the file label in drop tests

* test(css): exercise the configured PostCSS plugin chain

* test(identity): preserve full Ed25519 public keys in fixtures

* test(remote-desktop): always mutate ciphertext in tamper test
This commit is contained in:
ZacharyZcR authored and GitHub committed 2026-09-27 00:38:55 -05:00
1 parent 4423c4c8ef
commit 98cf62547f
2 files changed
+54 -1

No files matched your search

@@ -458,6 +458,9 @@ export function FileManagerGrid({
};
const handleFileDrop = (e: React.DragEvent, targetFile: FileItem) => {
// OS drops belong to the pane's upload handler, even over an existing row.
if (dragState.type !== "internal" && !isLocalFilesDrag(e.dataTransfer))
return;
e.preventDefault();
e.stopPropagation();
@@ -1,4 +1,4 @@
import { afterEach, describe, expect, it, vi } from "vitest";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { cleanup, fireEvent, render, screen } from "@testing-library/react";
import "@testing-library/jest-dom/vitest";
import { FileManagerGrid } from "../../src/frontend/FileManagerGrid";
@@ -44,6 +44,7 @@ const props = {
afterEach(() => {
cleanup();
vi.restoreAllMocks();
vi.unstubAllGlobals();
});
describe("remote file rename", () => {
@@ -89,3 +90,52 @@ describe("remote file rename", () => {
expect(screen.getByText(file.modified!)).toBeInTheDocument();
});
});
describe("external file drops", () => {
beforeEach(() => {
vi.stubGlobal(
"ResizeObserver",
class {
observe() {}
disconnect() {}
},
);
});
it.each(["list", "grid"] as const)(
"uploads dropped folders over a file in %s view",
(viewMode) => {
const onUploadItems = vi.fn();
render(
<FileManagerGrid
{...props}
viewMode={viewMode}
onUploadItems={onUploadItems}
/>,
);
const folder = {
name: "logs",
isDirectory: true,
isFile: false,
} as FileSystemEntry;
fireEvent.drop(screen.getByText(file.name), {
dataTransfer: {
types: ["Files"],
files: [],
getData: () => "",
items: [{ webkitGetAsEntry: () => folder }],
},
});
expect(onUploadItems).toHaveBeenCalledExactlyOnceWith([folder]);
},
);
it("uploads a plain OS file dropped over a row", () => {
const onUpload = vi.fn();
render(<FileManagerGrid {...props} onUpload={onUpload} />);
const files = [new File(["log"], "app.log")];
fireEvent.drop(screen.getByText(file.name), {
dataTransfer: { types: ["Files"], files, items: [], getData: () => "" },
});
expect(onUpload).toHaveBeenCalledExactlyOnceWith(files);
});
});