feat(web): support driver management

This commit is contained in:
t8y2
2026-05-18 18:16:25 +08:00
parent af16ac219c
commit b01c17e709
13 changed files with 766 additions and 49 deletions
@@ -0,0 +1,39 @@
import { readFileSync } from "node:fs";
import { strict as assert } from "node:assert";
import test from "node:test";
const apiSource = readFileSync("apps/desktop/src/lib/api.ts", "utf8");
const httpSource = readFileSync("apps/desktop/src/lib/http.ts", "utf8");
const tauriSource = readFileSync("apps/desktop/src/lib/tauri.ts", "utf8");
const webMainSource = readFileSync("crates/dbx-web/src/main.rs", "utf8");
const webRoutesSource = readFileSync("crates/dbx-web/src/routes/mod.rs", "utf8");
const agentFunctions = [
"listInstalledAgentsLocal",
"listInstalledAgents",
"installAgent",
"upgradeAllAgents",
"uninstallAgent",
"getAgentJavaRuntimeConfig",
"setAgentJavaRuntimeConfig",
"invalidateAgentRegistryCache",
"reinstallJre",
"uninstallJre",
"listenAgentInstallProgress",
];
test("shared frontend API exposes agent driver management functions", () => {
for (const name of agentFunctions) {
assert.match(apiSource, new RegExp(`export const ${name} = forward\\("${name}"\\)`));
assert.match(httpSource, new RegExp(`export async function ${name}\\b`));
assert.match(tauriSource, new RegExp(`export async function ${name}\\b`));
}
});
test("web backend exposes agent driver management routes", () => {
assert.match(webRoutesSource, /pub mod agents;/);
assert.match(webMainSource, /\/agents\/installed-local/);
assert.match(webMainSource, /\/agents\/install/);
assert.match(webMainSource, /\/agents\/progress\/\{operationId\}/);
assert.match(webMainSource, /\/agents\/java-runtime/);
});
@@ -0,0 +1,24 @@
import { readFileSync } from "node:fs";
import { strict as assert } from "node:assert";
import test from "node:test";
const appSource = readFileSync("apps/desktop/src/App.vue", "utf8");
const connectionDialogSource = readFileSync("apps/desktop/src/components/connection/ConnectionDialog.vue", "utf8");
const driverStoreSource = readFileSync("apps/desktop/src/components/config/DriverStoreDialog.vue", "utf8");
test("web runtime handles driver store open events", () => {
assert.match(appSource, /showDriverStore\.value = true;/);
assert.doesNotMatch(appSource, /if \(!isDesktop\) return;\s+showDriverStore\.value = true;/);
});
test("web runtime can show driver install hints", () => {
assert.match(connectionDialogSource, /showAgentDriverInstallHint\(form\.value\.db_type, agentDrivers\.value\)/);
assert.doesNotMatch(connectionDialogSource, /isDesktop &&\s+showAgentDriverInstallHint/);
});
test("driver store uses the shared API instead of direct Tauri calls", () => {
assert.doesNotMatch(driverStoreSource, /@tauri-apps\/api\/core/);
assert.doesNotMatch(driverStoreSource, /@tauri-apps\/api\/event/);
assert.match(driverStoreSource, /api\.listInstalledAgents/);
assert.match(driverStoreSource, /api\.listenAgentInstallProgress/);
});