fix: refresh sidebar after SQL file import

This commit is contained in:
t8y2
2026-05-16 12:38:53 +08:00
parent e97e965ea1
commit 70e324989c
4 changed files with 79 additions and 0 deletions
+36
View File
@@ -0,0 +1,36 @@
import assert from "node:assert/strict";
import test from "node:test";
import { findDatabaseTreeNode } from "../src/lib/treeRefreshTarget.ts";
import type { TreeNode } from "../src/types/database.ts";
test("finds database refresh targets inside grouped sidebar trees", () => {
const target: TreeNode = {
id: "conn-1:app",
label: "app",
type: "database",
connectionId: "conn-1",
database: "app",
};
const nodes: TreeNode[] = [
{
id: "group-1",
label: "Production",
type: "connection-group",
children: [
{
id: "conn-1",
label: "mysql",
type: "connection",
connectionId: "conn-1",
children: [target],
},
],
},
];
assert.equal(findDatabaseTreeNode(nodes, "conn-1", "app"), target);
});
test("returns null when the target database node is not loaded", () => {
assert.equal(findDatabaseTreeNode([], "conn-1", "app"), null);
});