fix(objects): guard system source edits
This commit is contained in:
1 parent
57dea3cb6d
commit
17bc2e66d4
13 files changed
+291
-27
No files matched your search
@@ -0,0 +1,54 @@
|
||||
import { strict as assert } from "node:assert";
|
||||
import test from "node:test";
|
||||
import { shouldShowQueryOutputPane } from "../../apps/desktop/src/lib/contentAreaLayout.ts";
|
||||
|
||||
test("object source tabs hide the query output pane while idle", () => {
|
||||
assert.equal(
|
||||
shouldShowQueryOutputPane({
|
||||
mode: "query",
|
||||
objectSource: { objectType: "PROCEDURE", name: "refresh_cache" },
|
||||
isExecuting: false,
|
||||
isExplaining: false,
|
||||
}),
|
||||
false,
|
||||
);
|
||||
});
|
||||
|
||||
test("object source tabs show the query output pane after execution starts or returns feedback", () => {
|
||||
assert.equal(
|
||||
shouldShowQueryOutputPane({
|
||||
mode: "query",
|
||||
objectSource: { objectType: "FUNCTION", name: "calc_total" },
|
||||
isExecuting: true,
|
||||
isExplaining: false,
|
||||
}),
|
||||
true,
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
shouldShowQueryOutputPane({
|
||||
mode: "query",
|
||||
objectSource: { objectType: "PROCEDURE", name: "refresh_cache" },
|
||||
isExecuting: false,
|
||||
isExplaining: false,
|
||||
result: {
|
||||
columns: ["Error"],
|
||||
rows: [["syntax error"]],
|
||||
affected_rows: 0,
|
||||
execution_time_ms: 2,
|
||||
},
|
||||
}),
|
||||
true,
|
||||
);
|
||||
});
|
||||
|
||||
test("regular query tabs keep the output pane visible before execution", () => {
|
||||
assert.equal(
|
||||
shouldShowQueryOutputPane({
|
||||
mode: "query",
|
||||
isExecuting: false,
|
||||
isExplaining: false,
|
||||
}),
|
||||
true,
|
||||
);
|
||||
});
|
||||
@@ -3,6 +3,7 @@ import test from "node:test";
|
||||
import {
|
||||
buildExecutableObjectSourceSql,
|
||||
buildExecutableObjectSourceStatements,
|
||||
objectSourceReadOnlyReason,
|
||||
objectSourceSaveExecutionMode,
|
||||
} from "../../apps/desktop/src/lib/objectSourceEditor.ts";
|
||||
|
||||
@@ -104,3 +105,37 @@ test("object source SQL joins generated save statements for previews", () => {
|
||||
'CREATE OR REPLACE PROCEDURE "public"."refresh_cache_v2"(mode text)\nLANGUAGE SQL\nAS $$ SELECT 1 $$;\nDROP PROCEDURE IF EXISTS "public"."refresh_cache"(mode text);',
|
||||
);
|
||||
});
|
||||
|
||||
test("system schemas open object source as read-only", () => {
|
||||
assert.equal(
|
||||
objectSourceReadOnlyReason({
|
||||
databaseType: "oracle",
|
||||
schema: "SYS",
|
||||
name: "DBMS_STATS",
|
||||
objectType: "PROCEDURE",
|
||||
}),
|
||||
"system-object",
|
||||
);
|
||||
});
|
||||
|
||||
test("Dameng built-in maintenance routines open as read-only without blocking user SP names", () => {
|
||||
assert.equal(
|
||||
objectSourceReadOnlyReason({
|
||||
databaseType: "dameng",
|
||||
schema: "SYSDBA",
|
||||
name: "SP_TS_BAKSET_REMOVE_BATCH",
|
||||
objectType: "PROCEDURE",
|
||||
}),
|
||||
"system-object",
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
objectSourceReadOnlyReason({
|
||||
databaseType: "dameng",
|
||||
schema: "SYSDBA",
|
||||
name: "SP_HELLO",
|
||||
objectType: "PROCEDURE",
|
||||
}),
|
||||
null,
|
||||
);
|
||||
});
|
||||
Reference in new issue
Block a user