27 lines
1.4 KiB
TypeScript
27 lines
1.4 KiB
TypeScript
import { strict as assert } from "node:assert";
|
|
import { readFileSync } from "node:fs";
|
|
import { test } from "vitest";
|
|
|
|
const treeItem = readFileSync("apps/desktop/src/components/sidebar/TreeItem.vue", "utf8");
|
|
const runtimeHost = readFileSync("apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vue", "utf8");
|
|
const connectionTree = readFileSync("apps/desktop/src/components/sidebar/ConnectionTree.vue", "utf8");
|
|
|
|
test("sidebar rows retain database-specific node affordances", () => {
|
|
for (const nodeType of ["connection", "database", "schema", "table", "column", "mongo-db", "mongo-collection", "redis-db", "nacos-namespace", "mq-tenant"]) {
|
|
const sources = `${treeItem}\n${runtimeHost}`;
|
|
assert.ok(sources.includes(`node.type === "${nodeType}"`) || sources.includes(`node.type === '${nodeType}'`), nodeType);
|
|
}
|
|
assert.match(treeItem, /@dblclick="onDoubleClick"/);
|
|
assert.match(treeItem, /@keydown="onKeydown"/);
|
|
assert.match(treeItem, /@mousedown="onRowMouseDown"/);
|
|
assert.match(treeItem, /@contextmenu="onTreeItemContextMenu"/);
|
|
});
|
|
|
|
test("complex tree changes retain the full rebuild fallback", () => {
|
|
assert.match(connectionTree, /const filteredNodes = computed/);
|
|
assert.match(connectionTree, /filterSidebarTree\(/);
|
|
assert.match(connectionTree, /const flatNodes = computed<FlatTreeNode\[]>/);
|
|
assert.match(connectionTree, /flattenTree\(filteredNodes\.value\)/);
|
|
assert.match(connectionTree, /watch\(flatNodes,/);
|
|
});
|