fix(mysql): support compatible explain formats

This commit is contained in:
t8y2 committed 2026-07-26 16:24:15 +08:00
1 parent 6a796ae97e
commit 000bb907e3
5 files changed
+163 -21

No files matched your search

@@ -0,0 +1,18 @@
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
const viewerSource = readFileSync(new URL("../ExplainPlanViewer.vue", import.meta.url), "utf8");
describe("ExplainPlanViewer MySQL fallback", () => {
it("selects the table only after loading finishes without a visual plan", () => {
expect(viewerSource).toContain("const hasTableView = computed(() => !!props.tableResult || !!props.tableError);");
expect(viewerSource).toContain("[hasTableView, () => !!props.tableResult, () => !!props.plan, () => props.loading]");
expect(viewerSource).toContain('if (!loading && hasTableResult && !hasPlan) activeView.value = "table";');
expect(viewerSource).toContain("{ immediate: true },");
});
it("keeps the regular tree default when the visual plan arrives", () => {
expect(viewerSource).toContain('if (!loading && hasTableResult && !hasPlan) activeView.value = "table";');
expect(viewerSource).toContain('if (!available && activeView.value === "table") activeView.value = "tree";');
});
});