feat(connection): add dedicated ssh tunnel test button
This commit is contained in:
18 files changed
+228
-21
No files matched your search
@@ -0,0 +1,25 @@
|
||||
import { readFileSync } from "node:fs";
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
const dialogSource = readFileSync(new URL("../../../components/connection/ConnectionDialog.vue", import.meta.url), "utf8");
|
||||
|
||||
describe("ConnectionDialog SSH tunnel test", () => {
|
||||
it("exposes a dedicated SSH tunnel test without running the database test", () => {
|
||||
expect(dialogSource).toContain("async function testSshTunnel()");
|
||||
expect(dialogSource).toContain("await api.testSshTunnel(config)");
|
||||
expect(dialogSource).toContain('@click="testSshTunnel"');
|
||||
expect(dialogSource).toContain('t("connection.sshTunnelTest")');
|
||||
});
|
||||
|
||||
it("builds the tunnel probe config without database-specific validation", () => {
|
||||
const start = dialogSource.indexOf("function connectionConfigForSshTunnelTest");
|
||||
const end = dialogSource.indexOf("function connectionConfigForSubmit", start);
|
||||
const helperSource = dialogSource.slice(start, end);
|
||||
|
||||
expect(start).toBeGreaterThan(-1);
|
||||
expect(end).toBeGreaterThan(start);
|
||||
expect(helperSource).toContain("normalizeTransportLayersForSubmit(config)");
|
||||
expect(helperSource).not.toContain("kingbaseDatabaseRequired");
|
||||
expect(helperSource).not.toContain("dynamodbCredentialsRequired");
|
||||
});
|
||||
});
|
||||
@@ -52,6 +52,7 @@ function forward<K extends keyof Backend>(name: K): Backend[K] {
|
||||
|
||||
// Connection
|
||||
export const testConnection = forward("testConnection");
|
||||
export const testSshTunnel = forward("testSshTunnel");
|
||||
export const testConnectionWithInfo = forward("testConnectionWithInfo");
|
||||
export const connectDb = forward("connectDb");
|
||||
export const connectionDatabaseInfo = forward("connectionDatabaseInfo");
|
||||
|
||||
@@ -374,6 +374,10 @@ export async function testConnection(config: ConnectionConfig): Promise<string>
|
||||
return post("/api/connection/test", { config });
|
||||
}
|
||||
|
||||
export async function testSshTunnel(config: ConnectionConfig): Promise<string> {
|
||||
return post("/api/connection/test-ssh-tunnel", { config });
|
||||
}
|
||||
|
||||
export async function testConnectionWithInfo(config: ConnectionConfig): Promise<ConnectionTestResult> {
|
||||
const response = await fetch(apiUrl("/api/connection/test-info"), {
|
||||
method: "POST",
|
||||
|
||||
@@ -1068,6 +1068,10 @@ export async function testConnection(config: ConnectionConfig): Promise<string>
|
||||
return invokeBackend("test_connection", { config });
|
||||
}
|
||||
|
||||
export async function testSshTunnel(config: ConnectionConfig): Promise<string> {
|
||||
return invokeBackend("test_ssh_tunnel", { config });
|
||||
}
|
||||
|
||||
export async function testConnectionWithInfo(config: ConnectionConfig): Promise<ConnectionTestResult> {
|
||||
try {
|
||||
const result = await invoke<unknown>("test_connection_with_info", {
|
||||
|
||||
Reference in new issue
Block a user