25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
import { describe, expect, it } from "vitest";
import type { TreeNode } from "@/types/database";
import { sidebarNodeSupportsStructureEdit } from "@/lib/sidebar/sidebarTreeStructureShortcut";
function node(type: TreeNode["type"], extra: Partial<TreeNode> = {}): TreeNode {
return { id: "n", label: "n", type, connectionId: "c", database: "db", ...extra };
}
describe("sidebar tree structure shortcut", () => {
it("supports table nodes on databases that support table structure editing", () => {
expect(sidebarNodeSupportsStructureEdit(node("table"), "mysql")).toBe(true);
expect(sidebarNodeSupportsStructureEdit(node("table"), "postgres")).toBe(true);
expect(sidebarNodeSupportsStructureEdit(node("table"), "redis")).toBe(false);
});
it("supports column and index nodes that have a tableName", () => {
expect(sidebarNodeSupportsStructureEdit(node("column", { tableName: "users" }), "mysql")).toBe(true);
expect(sidebarNodeSupportsStructureEdit(node("index", { tableName: "users" }), "mysql")).toBe(true);
expect(sidebarNodeSupportsStructureEdit(node("column"), "mysql")).toBe(false);
expect(sidebarNodeSupportsStructureEdit(node("index"), "mysql")).toBe(false);
});
it("rejects nodes without connection or database", () => {
expect(sidebarNodeSupportsStructureEdit({ id: "n", label: "n", type: "table" }, "mysql")).toBe(false);
expect(sidebarNodeSupportsStructureEdit({ id: "n", label: "n", type: "table", connectionId: "c" }, "mysql")).toBe(false);
});
it("rejects non-table nodes", () => {
expect(sidebarNodeSupportsStructureEdit(node("connection"), "mysql")).toBe(false);
expect(sidebarNodeSupportsStructureEdit(node("database"), "mysql")).toBe(false);
expect(sidebarNodeSupportsStructureEdit(node("schema"), "mysql")).toBe(false);
expect(sidebarNodeSupportsStructureEdit(node("procedure"), "mysql")).toBe(false);
expect(sidebarNodeSupportsStructureEdit(node("view"), "mysql")).toBe(false);
});
it("rejects SQL Server linked server nodes", () => {
expect(sidebarNodeSupportsStructureEdit(node("table", { linkedServer: "REMOTE" }), "sqlserver")).toBe(false);
});
});