fix(collector): restore direct DLC drag imports

Resolve dropped file paths through Electron webUtils, send dragged DLC containers directly to Downloads, and keep explicit collector imports bounded so metadata enrichment cannot leave the interface permanently busy.
This commit is contained in:
Sucukdeluxe
2026-08-22 20:17:58 +02:00
parent 340d6597cc
commit 2f031dc350
9 changed files with 128 additions and 12 deletions
+35
View File
@@ -0,0 +1,35 @@
import { describe, expect, it, vi } from "vitest";
import { importDroppedDlcFiles, resolveDroppedDlcPaths } from "../src/renderer/collector-drop";
describe("collector DLC drop", () => {
it("resolves DLC paths through the preload bridge instead of File.path", () => {
const first = { name: "first.dlc" } as File;
const ignored = { name: "notes.txt" } as File;
const second = { name: "SECOND.DLC" } as File;
const getPath = vi.fn((file: File) => file === first ? "C:\\Drops\\first.dlc" : "C:\\Drops\\second.dlc");
expect(resolveDroppedDlcPaths([first, ignored, second], getPath)).toEqual([
"C:\\Drops\\first.dlc",
"C:\\Drops\\second.dlc"
]);
expect(getPath.mock.calls.map(([file]) => file)).toEqual([first, second]);
});
it("ignores files whose native path cannot be resolved", () => {
const file = { name: "broken.dlc" } as File;
expect(resolveDroppedDlcPaths([file], () => "")).toEqual([]);
expect(resolveDroppedDlcPaths([file], () => { throw new Error("unavailable"); })).toEqual([]);
});
it("imports dropped DLC files directly into Downloads without collector analysis", async () => {
const file = { name: "package.dlc" } as File;
const addContainers = vi.fn(async () => ({ addedPackages: 2, addedLinks: 16 }));
await expect(importDroppedDlcFiles([file], () => "C:\\Drops\\package.dlc", addContainers)).resolves.toEqual({
addedPackages: 2,
addedLinks: 16
});
expect(addContainers).toHaveBeenCalledWith(["C:\\Drops\\package.dlc"]);
});
});