The sidebar already supports multi-select, so deletion now resolves the context-clicked selected connection set before confirming. Connection removal gained a batched path to persist once while pruning sidebar layout, pins, active state, connection errors, and stale selection for every removed connection. Constraint: No new dependencies and existing single-connection delete behavior must remain available.\nRejected: Delete every selected tree item regardless of type | mixed tree selections could unexpectedly remove connections while table/object deletion has separate SQL confirmation behavior.\nConfidence: high\nScope-risk: narrow\nTested: pnpm fmt; pnpm test; pnpm typecheck; pnpm lint; pnpm build\nNot-tested: Manual desktop UI interaction against a running Tauri window Co-authored-by: caisin <caisin@caisins-Mac-mini.local>
39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
import { strict as assert } from "node:assert";
|
|
import { test } from "node:test";
|
|
import { selectedConnectionDeleteTargets } from "../../apps/desktop/src/lib/sidebarConnectionSelection.ts";
|
|
import type { TreeNode } from "../../apps/desktop/src/types/database.ts";
|
|
|
|
function node(id: string, type: TreeNode["type"] = "connection"): TreeNode {
|
|
return { id, label: id, type, connectionId: type === "connection" ? id : "conn-1" };
|
|
}
|
|
|
|
test("deletes all selected connections when the context-clicked connection is selected", () => {
|
|
const first = node("conn-1");
|
|
const second = node("conn-2");
|
|
|
|
assert.deepEqual(
|
|
selectedConnectionDeleteTargets(first, [first, second]).map((target) => target.connectionId),
|
|
["conn-1", "conn-2"],
|
|
);
|
|
});
|
|
|
|
test("falls back to only the current connection for mixed selections", () => {
|
|
const connection = node("conn-1");
|
|
const table = node("table-1", "table");
|
|
|
|
assert.deepEqual(
|
|
selectedConnectionDeleteTargets(connection, [connection, table]).map((target) => target.connectionId),
|
|
["conn-1"],
|
|
);
|
|
});
|
|
|
|
test("falls back to only the current connection when right-clicking outside the selection", () => {
|
|
const current = node("conn-1");
|
|
const selected = node("conn-2");
|
|
|
|
assert.deepEqual(
|
|
selectedConnectionDeleteTargets(current, [selected]).map((target) => target.connectionId),
|
|
["conn-1"],
|
|
);
|
|
});
|