feat(xugu): expose public synonyms in an isolated scope

This commit is contained in:
Elias authored and GitHub committed 2026-08-12 18:24:01 +08:00
1 parent ab46f3fc72
commit ea9a27ce11
11 files changed
+678 -39

No files matched your search

@@ -1,6 +1,7 @@
import { createPinia, setActivePinia } from "pinia";
import { beforeEach, describe, expect, it, vi } from "vitest";
import type { ConnectionConfig, TreeNode } from "@/types/database";
import { XUGU_PUBLIC_SYNONYM_SCOPE } from "@/lib/sidebar/xuguPublicSynonyms";
function installLocalStorage() {
const data = new Map<string, string>();
@@ -24,6 +25,18 @@ function postgresConnection(): ConnectionConfig {
};
}
function xuguConnection(): ConnectionConfig {
return {
...postgresConnection(),
id: "xugu-1",
name: "Xugu",
db_type: "xugu",
port: 5138,
username: "SYSDBA",
database: "SYSTEM",
};
}
describe("connectionStore default schema", () => {
beforeEach(() => {
vi.resetModules();
@@ -86,4 +99,26 @@ describe("connectionStore default schema", () => {
expect(schemaLabels()).toEqual(["archive", "public"]);
expect(saveConnections).toHaveBeenLastCalledWith([expect.objectContaining({ id: connection.id, default_schema: undefined })]);
});
it("does not persist the synthetic Xugu public-synonym scope as a default schema", async () => {
const saveConnections = vi.fn().mockResolvedValue(undefined);
vi.doMock("@/lib/backend/tauriRuntime", () => ({ isTauriRuntime: () => false }));
vi.doMock("@/lib/backend/api", () => ({
deleteSchemaCachePrefix: vi.fn().mockResolvedValue(undefined),
loadSchemaCache: vi.fn().mockResolvedValue(null),
saveConnections,
saveSchemaCache: vi.fn().mockResolvedValue(undefined),
saveSidebarLayout: vi.fn().mockResolvedValue(undefined),
}));
const { useConnectionStore } = await import("@/stores/connectionStore");
const store = useConnectionStore();
const connection = xuguConnection();
store.addEphemeralConnection(connection);
await store.setDefaultSchema(connection.id, XUGU_PUBLIC_SYNONYM_SCOPE);
expect(store.getConfig(connection.id)?.default_schema).toBeUndefined();
expect(saveConnections).not.toHaveBeenCalled();
});
});