fix(mongodb): offer rename collection on legacy agent connections

This commit is contained in:
Loc Nguyen authored and GitHub committed 2026-09-22 11:05:35 +08:00
1 parent 9fa61d53b6
commit 808317e0e7
5 files changed
+33 -23

No files matched your search

@@ -277,7 +277,8 @@ describe("MongoDB sidebar mutation runtime", () => {
activeNode.value = mongoCollectionNode();
expect(feature.canDropMongoCollection.value).toBe(true);
expect(feature.canDropAllMongoIndexes.value).toBe(false);
expect(feature.canRenameMongoCollection.value).toBe(false);
// The Legacy Agent supports renameCollection (capability-gated in the backend).
expect(feature.canRenameMongoCollection.value).toBe(true);
expect(feature.canCloneMongoCollection.value).toBe(true);
expect(feature.canCreateMongoIndex.value).toBe(false);
activeNode.value = mongoIndexesGroupNode();
@@ -177,6 +177,33 @@ function milvusCollectionNode(): TreeNode {
};
}
describe("MongoDB collection rename availability", () => {
beforeEach(() => {
setActivePinia(createPinia());
vi.clearAllMocks();
});
it("offers rename on both the native driver and the Legacy Agent", () => {
// The Agent has renameCollection (capability-gated in the backend), so the menu no longer
// hides the action on legacy connections; a read-only connection still gets nothing.
for (const driver_profile of [undefined, "mongodb-native", "mongodb-legacy"]) {
mocks.getConfig.mockReturnValue({ id: "conn-1", name: "Mongo", db_type: "mongodb", host: "localhost", port: 27017, username: "op", password: "", driver_profile });
const activeNode = shallowRef(collectionNode());
const { canRenameMongoCollection } = useSidebarDatabaseSpecificMutationRuntime({
activeNode,
connectionStore: { getConfig: mocks.getConfig, ensureConnected: mocks.ensureConnected, loadMongoCollections: mocks.loadMongoCollections, treeNodes: [] } as any,
});
expect(canRenameMongoCollection.value, `driver_profile=${driver_profile}`).toBe(true);
}
mocks.getConfig.mockReturnValue({ id: "conn-1", name: "Mongo", db_type: "mongodb", host: "localhost", port: 27017, username: "op", password: "", driver_profile: "mongodb-legacy", read_only: true });
const { canRenameMongoCollection } = useSidebarDatabaseSpecificMutationRuntime({
activeNode: shallowRef(collectionNode()),
connectionStore: { getConfig: mocks.getConfig, ensureConnected: mocks.ensureConnected, loadMongoCollections: mocks.loadMongoCollections, treeNodes: [] } as any,
});
expect(canRenameMongoCollection.value).toBe(false);
});
});
describe("Milvus collection rename", () => {
beforeEach(() => {
setActivePinia(createPinia());