fix(connection): restore New Connection dialog after RabbitMQ
New connection dialog crashed on open after rabbitmq was added without a category entry. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
a6dfec6724
commit
80bd53b4c2
2 files changed
+22
-1
No files matched your search
@@ -2202,7 +2202,7 @@ const dbCategoryDefinitions: Array<{
|
|||||||
{
|
{
|
||||||
key: "mq",
|
key: "mq",
|
||||||
titleKey: "connection.databaseCategoryMq",
|
titleKey: "connection.databaseCategoryMq",
|
||||||
optionValues: ["mq", "kafka", "rocketmq"],
|
optionValues: ["mq", "kafka", "rocketmq", "rabbitmq"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
key: "registry_config",
|
key: "registry_config",
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
import assert from "node:assert/strict";
|
import assert from "node:assert/strict";
|
||||||
|
import { readFileSync } from "node:fs";
|
||||||
|
import { fileURLToPath } from "node:url";
|
||||||
|
import { dirname, join } from "node:path";
|
||||||
import { test } from "vitest";
|
import { test } from "vitest";
|
||||||
import { assertCompleteDatabaseCategories, databaseSelectionForCategory } from "../../apps/desktop/src/lib/connection/databaseCategoryOptions.ts";
|
import { assertCompleteDatabaseCategories, databaseSelectionForCategory } from "../../apps/desktop/src/lib/connection/databaseCategoryOptions.ts";
|
||||||
|
|
||||||
@@ -14,3 +17,21 @@ test("database category changes keep only visible selections", () => {
|
|||||||
assert.equal(databaseSelectionForCategory("mysql", ["questdb", "tdengine"]), "questdb");
|
assert.equal(databaseSelectionForCategory("mysql", ["questdb", "tdengine"]), "questdb");
|
||||||
assert.equal(databaseSelectionForCategory("mysql", []), undefined);
|
assert.equal(databaseSelectionForCategory("mysql", []), undefined);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test("ConnectionDialog database categories stay exhaustive", () => {
|
||||||
|
const dialogPath = join(dirname(fileURLToPath(import.meta.url)), "../../apps/desktop/src/components/connection/ConnectionDialog.vue");
|
||||||
|
const source = readFileSync(dialogPath, "utf8");
|
||||||
|
const optionsMatch = source.match(/const dbOptions: DbOption\[] = \[([\s\S]*?)\];/);
|
||||||
|
const categoriesMatch = source.match(/const dbCategoryDefinitions: Array<\{[\s\S]*?\}> = \[([\s\S]*?)\];/);
|
||||||
|
assert.ok(optionsMatch, "dbOptions not found");
|
||||||
|
assert.ok(categoriesMatch, "dbCategoryDefinitions not found");
|
||||||
|
|
||||||
|
const optionValues = [...optionsMatch[1].matchAll(/value:\s*"([^"]+)"/g)].map((match) => match[1]);
|
||||||
|
const categoryBlocks = [...categoriesMatch[1].matchAll(/optionValues:\s*\[([^\]]*)\]/g)].map((match) =>
|
||||||
|
[...match[1].matchAll(/"([^"]+)"/g)].map((valueMatch) => valueMatch[1]),
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.doesNotThrow(() => assertCompleteDatabaseCategories(optionValues, categoryBlocks));
|
||||||
|
assert.ok(optionValues.includes("rabbitmq"), "rabbitmq must remain in dbOptions");
|
||||||
|
assert.ok(categoryBlocks.some((values) => values.includes("rabbitmq")), "rabbitmq must remain categorized");
|
||||||
|
});
|
||||||
Reference in new issue
Block a user