mirror of
https://github.com/t8y2/dbx.git
synced 2026-10-28 16:09:17 +00:00
feat(sidebar): add node-type search scopes for tree filtering
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { strict as assert } from "node:assert";
|
||||
import test from "node:test";
|
||||
|
||||
const source = readFileSync("apps/desktop/src/components/sidebar/ConnectionTree.vue", "utf8");
|
||||
|
||||
test("connection tree exposes node search scopes instead of driver profile filters", () => {
|
||||
assert.match(source, /type SearchScope = "connection" \| "database" \| "schema" \| "table" \| "view"/);
|
||||
assert.match(source, /const selectedSearchScopes = ref<SearchScope\[]>\(\[\]\)/);
|
||||
assert.match(source, /filterSidebarTree\(nodes, q, searchCollapsedIds\.value, searchableNodeTypes\.value\)/);
|
||||
});
|
||||
|
||||
test("connection tree filter menu uses sidebar search scope i18n labels", () => {
|
||||
assert.match(source, /t\("sidebar\.searchScopeConnection"\)/);
|
||||
assert.match(source, /t\("sidebar\.searchScopeDatabase"\)/);
|
||||
assert.match(source, /t\("sidebar\.searchScopeTable"\)/);
|
||||
});
|
||||
@@ -83,3 +83,38 @@ test("preserves loaded schema children when the database itself matches search",
|
||||
assert.equal(filtered[0]?.label, "hdi");
|
||||
assert.equal(filtered[0]?.children?.[0]?.label, "public");
|
||||
});
|
||||
|
||||
test("search scope excludes non-selected node self matches", () => {
|
||||
const nodes: TreeNode[] = [
|
||||
{
|
||||
id: "conn:1",
|
||||
label: "orders-conn",
|
||||
type: "connection",
|
||||
connectionId: "conn",
|
||||
isExpanded: true,
|
||||
children: [
|
||||
{
|
||||
id: "conn:1:db",
|
||||
label: "orders_db",
|
||||
type: "database",
|
||||
connectionId: "conn",
|
||||
database: "orders_db",
|
||||
isExpanded: true,
|
||||
children: [
|
||||
{
|
||||
id: "conn:1:db:table",
|
||||
label: "customers",
|
||||
type: "table",
|
||||
connectionId: "conn",
|
||||
database: "orders_db",
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
|
||||
const filtered = filterSidebarTree(nodes, "orders", new Set(), new Set(["table"]));
|
||||
|
||||
assert.equal(filtered.length, 0);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user