Files
openidea/e2e/clickhouse-source.spec.ts
T
kkmihaiandkkMihai e04e5dd57d feat(database): add ClickHouse data sources (#865)
Adds ClickHouse to Data Sources over its HTTP interface (HTTP/HTTPS, SSH tunnels, session settings, server-side cancellation): browse databases, tables and columns, inspect DDL, run queries and EXPLAIN plans, with ClickHouse dialect completion. Table data stays read-only and manual transactions are rejected, since ClickHouse keys are not unique and HTTP has no transactions.

Results are streamed as JSONCompactEachRowWithNamesAndTypes and parsing stops at the row limit, because result_overflow_mode=break still returns a whole block; errors show only the server's "Code: …" message, including failures raised mid-stream.

Fixes #862

Co-authored-by: kkMihai <59262001+kkMihai@users.noreply.github.com>
2026-11-04 12:21:03 +08:00

43 lines
2.2 KiB
TypeScript

import { expect, test } from "./fixtures";
test("configures a ClickHouse HTTP source and keeps transaction controls unavailable", async ({
workbench: page,
}, info) => {
await page.evaluate(async () => {
const storePath = "/src/features/database/store.ts";
const bindingsPath = "/src/bindings.ts";
const { useDatabase } = await import(storePath);
const { commands } = await import(bindingsPath);
commands.dbTest = async (source: unknown) => {
document.documentElement.dataset.testedSource = JSON.stringify(source);
return { status: "ok", data: "ClickHouse" };
};
useDatabase.setState({ dialog: { kind: "source", source: null } });
});
const dialog = page.getByRole("dialog", { name: "New Data Source", exact: true });
await dialog.getByRole("button", { name: "Data source type", exact: true }).click();
await page.getByRole("option", { name: "ClickHouse", exact: true }).click();
await expect(dialog.locator("#db-port")).toHaveValue("8123");
await expect(dialog.locator("#db-user")).toHaveValue("default");
await expect(dialog.locator("#db-database")).toHaveValue("default");
await expect(dialog.locator("#db-url")).toHaveValue("http://localhost:8123/default");
await dialog.locator("#db-url").fill("https://reader@db.example:8443/analytics");
await expect(dialog.locator("#db-host")).toHaveValue("db.example");
await expect(dialog.locator("#db-port")).toHaveValue("8443");
await expect(dialog.locator("#db-user")).toHaveValue("reader");
await expect(dialog.locator("#db-database")).toHaveValue("analytics");
await dialog.getByRole("button", { name: "Test Connection", exact: true }).click();
await expect(dialog.getByRole("status")).toHaveText("Succeeded: ClickHouse");
expect(await page.evaluate(() => JSON.parse(document.documentElement.dataset.testedSource!))).toMatchObject({
driver: "clickhouse",
host: "db.example",
port: 8443,
user: "reader",
database: "analytics",
ssl: "verifyFull",
});
await dialog.screenshot({ path: info.outputPath("clickhouse-source.png") });
await dialog.getByRole("tab", { name: "Options", exact: true }).click();
await expect(dialog.getByRole("button", { name: "Transaction control", exact: true })).toBeDisabled();
});