feat(viewer): schema linking renders a Mermaid erDiagram (tables + relations)
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import { render, screen, waitFor } from "@testing-library/react";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { SchemaLinkingViewer } from "./SchemaLinkingViewer";
|
||||
import { SchemaLinkingViewer, buildErDiagram } from "./SchemaLinkingViewer";
|
||||
|
||||
vi.mock("./mermaid", () => ({
|
||||
renderMermaid: vi.fn().mockResolvedValue('<svg data-testid="mm"></svg>'),
|
||||
@@ -82,3 +82,18 @@ test("(d) ~10 promoted + ~50 excluded does NOT cap; graph is available", async (
|
||||
// Grafico (mermaid) view is the default and renders the mocked svg.
|
||||
await waitFor(() => expect(screen.getByTestId("mm")).toBeInTheDocument());
|
||||
});
|
||||
|
||||
test("(e) buildErDiagram emits entities, attributes and a relation", () => {
|
||||
const def = buildErDiagram(
|
||||
[
|
||||
{ kind: "table", name: "orders", decision: "promoted" },
|
||||
{ kind: "column", name: "orders.id", decision: "promoted" },
|
||||
{ kind: "table", name: "customers", decision: "promoted" },
|
||||
],
|
||||
[{ from: "orders.customer_id", to: "customers.id" }],
|
||||
);
|
||||
expect(def.startsWith("erDiagram")).toBe(true);
|
||||
expect(def).toContain("orders {");
|
||||
expect(def).toContain("col id");
|
||||
expect(def).toContain("orders }o--o{ customers : join");
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user