feat(xugu): expose programmable object metadata
This commit is contained in:
1 parent
d3887c9936
commit
08cd8903f4
36 files changed
+431
-62
No files matched your search
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { doubleClickRowAction, resolveRowClickAction, shouldDeferSingleClick, singleClickRowAction } from "@/lib/table/objectBrowserRowAction";
|
||||
import { doubleClickRowAction, isSourceOnlyObjectBrowserRow, resolveRowClickAction, shouldDeferSingleClick, singleClickRowAction } from "@/lib/table/objectBrowserRowAction";
|
||||
import type { ObjectBrowserRow } from "@/lib/table/objectBrowserRows";
|
||||
|
||||
function row(type: ObjectBrowserRow["type"], name = "test"): ObjectBrowserRow {
|
||||
@@ -39,6 +39,10 @@ describe("singleClickRowAction", () => {
|
||||
expect(singleClickRowAction(row("PACKAGE_BODY", "pkg_body_test"))).toBe("open-source");
|
||||
});
|
||||
|
||||
it.each(["TRIGGER", "TYPE", "TYPE_BODY"] as const)("returns open-source for %s", (type) => {
|
||||
expect(singleClickRowAction(row(type, "programmable_test"))).toBe("open-source");
|
||||
});
|
||||
|
||||
it("returns none for null/undefined", () => {
|
||||
expect(singleClickRowAction(null)).toBe("none");
|
||||
expect(singleClickRowAction(undefined)).toBe("none");
|
||||
@@ -63,6 +67,17 @@ describe("doubleClickRowAction", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("isSourceOnlyObjectBrowserRow", () => {
|
||||
it.each(["TRIGGER", "TYPE", "TYPE_BODY"] as const)("marks %s as source-only", (type) => {
|
||||
expect(isSourceOnlyObjectBrowserRow(row(type))).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps procedure and function mutation menus separate", () => {
|
||||
expect(isSourceOnlyObjectBrowserRow(row("PROCEDURE"))).toBe(false);
|
||||
expect(isSourceOnlyObjectBrowserRow(row("FUNCTION"))).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe("resolveRowClickAction", () => {
|
||||
const tableRow = row("TABLE", "users");
|
||||
const viewRow = row("VIEW", "v_users");
|
||||
|
||||
@@ -29,6 +29,22 @@ describe("PostgreSQL overloaded routines", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("programmable database objects", () => {
|
||||
it("keeps Xugu trigger/type nodes distinct and preserves an invalid status", () => {
|
||||
const objects: ObjectInfo[] = [
|
||||
{ name: "TRG_AUDIT", object_type: "TRIGGER", schema: "APP", valid: false },
|
||||
{ name: "ADDRESS_T", object_type: "TYPE", schema: "APP", valid: true },
|
||||
{ name: "ADDRESS_T", object_type: "TYPE_BODY", schema: "APP", valid: true },
|
||||
];
|
||||
|
||||
const nodes = buildSimpleObjectTreeNodes({ ...context, schema: "APP", objects });
|
||||
|
||||
expect(nodes).toEqual(
|
||||
expect.arrayContaining([expect.objectContaining({ type: "trigger", objectName: "TRG_AUDIT", valid: false }), expect.objectContaining({ type: "type", objectName: "ADDRESS_T", valid: true }), expect.objectContaining({ type: "type-body", objectName: "ADDRESS_T", valid: true })]),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe("PostgreSQL table hierarchy", () => {
|
||||
it("keeps schema pagination visible at the table-group root when a page ends inside nested partitions", () => {
|
||||
const nodes = buildTableTreeNodes({
|
||||
|
||||
Reference in new issue
Block a user