feat(milvus): add database and collection deletion

This commit is contained in:
onenewcode authored and GitHub committed 2026-08-20 18:25:12 +08:00
1 parent db8f262c14
commit 439f2c2617
14 files changed
+309 -12

No files matched your search

@@ -40,6 +40,18 @@ function connectionGroupNode(groupId: string): TreeNode {
};
}
function vectorDatabaseNode(database: string): TreeNode {
return {
id: `conn-1:${database}`,
label: database,
type: "vector-database",
connectionId: "conn-1",
database,
isExpanded: false,
children: [],
};
}
function connectionStore(selectedTreeNodeIds: string[]) {
const lastSelectedTreeNodeId = selectedTreeNodeIds[selectedTreeNodeIds.length - 1] ?? null;
return {
@@ -57,6 +69,7 @@ function connectionStore(selectedTreeNodeIds: string[]) {
disconnect: vi.fn().mockResolvedValue(undefined),
isTreeNodeChildrenLoaded: vi.fn(() => false),
getConfig: vi.fn(() => undefined),
isDefaultDatabase: vi.fn(() => false),
};
}
@@ -73,6 +86,22 @@ function runtime(activeNode: TreeNode, store: ReturnType<typeof connectionStore>
});
}
describe("sidebar default database state", () => {
beforeEach(() => {
vi.clearAllMocks();
sidebarFormTarget.value = null;
});
it("recognizes the configured Milvus vector database as default", () => {
const store = connectionStore([]);
store.isDefaultDatabase.mockReturnValue(true);
const { isNodeDefaultDatabase } = runtime(vectorDatabaseNode("analytics"), store);
expect(isNodeDefaultDatabase.value).toBe(true);
expect(store.isDefaultDatabase).toHaveBeenCalledWith("conn-1", "analytics");
});
});
describe("sidebar connection move selection", () => {
beforeEach(() => {
vi.clearAllMocks();
@@ -89,6 +89,31 @@ function mongoConfig(driverProfile?: string, production = false) {
};
}
function milvusConfig(database?: string) {
return {
id: "conn-1",
name: "Milvus",
db_type: "milvus" as const,
host: "localhost",
port: 19530,
username: "",
password: "",
database,
};
}
function milvusDatabaseNode(database: string): TreeNode {
return {
id: `conn-1:${database}`,
label: database,
type: "vector-database",
connectionId: "conn-1",
database,
isExpanded: false,
children: [],
};
}
function mongoDatabaseNode(): TreeNode {
return {
id: "conn-1:app",
@@ -209,6 +234,29 @@ describe("MongoDB sidebar mutation runtime", () => {
cloneMongoCollectionLoading.value = false;
});
it("protects the built-in and configured Milvus databases from deletion", () => {
mocks.getConfig.mockReturnValue(milvusConfig("analytics"));
const activeNode = shallowRef(milvusDatabaseNode("default"));
const feature = useSidebarDatabaseSpecificMutationRuntime({
activeNode,
connectionStore: {
getConfig: mocks.getConfig,
} as any,
});
expect(feature.canDropMilvusDatabase.value).toBe(false);
activeNode.value = milvusDatabaseNode("analytics");
expect(feature.canDropMilvusDatabase.value).toBe(false);
activeNode.value = milvusDatabaseNode("archive");
expect(feature.canDropMilvusDatabase.value).toBe(true);
mocks.getConfig.mockReturnValue(mongoConfig());
activeNode.value = milvusDatabaseNode("archive-2");
expect(feature.canDropMilvusDatabase.value).toBe(false);
});
it("keeps Legacy MongoDB mutations available while limiting index actions to the Indexes group", () => {
mocks.getConfig.mockReturnValue(mongoConfig("mongodb-legacy"));
const activeNode = shallowRef(mongoDatabaseNode());