fix(history): remove selections atomically

This commit is contained in:
Sucukdeluxe
2026-08-21 00:59:45 +02:00
parent 3a95136ef1
commit 869dbc25be
11 changed files with 107 additions and 20 deletions
+11 -1
View File
@@ -6,6 +6,7 @@ import type { HistoryEntry } from "../src/shared/types";
const electron = vi.hoisted(() => ({
api: undefined as ElectronApi | undefined,
listeners: new Map<string, (...args: unknown[]) => void>(),
invoke: vi.fn<(...args: unknown[]) => Promise<unknown>>(async () => undefined),
on: vi.fn((channel: string, listener: (...args: unknown[]) => void) => {
electron.listeners.set(channel, listener);
}),
@@ -23,7 +24,7 @@ vi.mock("electron", () => ({
}
},
ipcRenderer: {
invoke: vi.fn(),
invoke: electron.invoke,
on: electron.on,
removeListener: electron.removeListener,
send: vi.fn()
@@ -48,4 +49,13 @@ describe("history preload contract", () => {
unsubscribe?.();
expect(electron.removeListener).toHaveBeenCalledWith(IPC_CHANNELS.HISTORY_ENTRY_ADDED, listener);
});
it("forwards a history selection through one bulk removal channel", async () => {
electron.invoke.mockClear();
await electron.api?.removeHistoryEntries(["history-a", "history-b"]);
expect(electron.invoke).toHaveBeenCalledTimes(1);
expect(electron.invoke).toHaveBeenCalledWith(IPC_CHANNELS.REMOVE_HISTORY_ENTRIES, ["history-a", "history-b"]);
});
});