fix(sidebar): preserve searched database children
This commit is contained in:
parent
47ec339d5a
commit
d64074dbc2
|
|
@ -1,7 +1,7 @@
|
|||
import type { TreeNode } from "@/types/database";
|
||||
import { matchSidebarLabel } from "@/lib/sidebarSearch";
|
||||
|
||||
const preserveMatchedSubtreeTypes = new Set(["table", "view"]);
|
||||
const preserveMatchedSubtreeTypes = new Set(["database", "schema", "table", "view"]);
|
||||
|
||||
const normalizedLabelCache = new WeakMap<TreeNode, { label: string; normalized: string }>();
|
||||
|
||||
|
|
|
|||
|
|
@ -53,3 +53,33 @@ test("preserves loaded table children when the table itself matches search", ()
|
|||
assert.equal(table?.children?.[0]?.label, "tree.columns");
|
||||
assert.equal(table?.children?.[0]?.children?.[0]?.label, "id");
|
||||
});
|
||||
|
||||
test("preserves loaded schema children when the database itself matches search", () => {
|
||||
const nodes: TreeNode[] = [
|
||||
{
|
||||
id: "conn:hdi",
|
||||
label: "hdi",
|
||||
type: "database",
|
||||
connectionId: "conn",
|
||||
database: "hdi",
|
||||
isExpanded: true,
|
||||
children: [
|
||||
{
|
||||
id: "conn:hdi:public",
|
||||
label: "public",
|
||||
type: "schema",
|
||||
connectionId: "conn",
|
||||
database: "hdi",
|
||||
schema: "public",
|
||||
isExpanded: false,
|
||||
children: [],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const filtered = filterSidebarTree(nodes, "hdi", new Set());
|
||||
|
||||
assert.equal(filtered[0]?.label, "hdi");
|
||||
assert.equal(filtered[0]?.children?.[0]?.label, "public");
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in New Issue