feat: complete catalog fleet management workflow
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
import { http, HttpResponse } from "msw";
|
||||
import { expect, test } from "vitest";
|
||||
import { server } from "../test/msw";
|
||||
import { getCatalogMetrics, type CatalogMetrics } from "./catalog-databases";
|
||||
|
||||
const databaseId = "d4baf0f5-b9c3-4dc5-aad2-2f5676a36e64";
|
||||
|
||||
const globalMetrics: CatalogMetrics = {
|
||||
scope: "global",
|
||||
databaseId: null,
|
||||
tables: 163,
|
||||
columns: 2_275,
|
||||
sensitiveColumns: 5,
|
||||
relationships: 21,
|
||||
descriptionTargets: 2_438,
|
||||
describedTargets: 1_829,
|
||||
descriptionCoverage: 75.02,
|
||||
updatedAt: "2026-08-31T08:45:00.000Z",
|
||||
};
|
||||
|
||||
test("loads global catalog metrics without a database filter", async () => {
|
||||
let requestedUrl: URL | undefined;
|
||||
server.use(http.get("/api/catalog/metrics", ({ request }) => {
|
||||
requestedUrl = new URL(request.url);
|
||||
return HttpResponse.json(globalMetrics);
|
||||
}));
|
||||
|
||||
await expect(getCatalogMetrics()).resolves.toEqual(globalMetrics);
|
||||
expect(requestedUrl?.pathname).toBe("/api/catalog/metrics");
|
||||
expect(requestedUrl?.searchParams.has("databaseId")).toBe(false);
|
||||
});
|
||||
|
||||
test("loads metrics scoped to the requested database", async () => {
|
||||
const databaseMetrics: CatalogMetrics = {
|
||||
...globalMetrics,
|
||||
scope: "database",
|
||||
databaseId,
|
||||
tables: 42,
|
||||
columns: 508,
|
||||
sensitiveColumns: 3,
|
||||
relationships: 8,
|
||||
descriptionTargets: 550,
|
||||
describedTargets: 413,
|
||||
descriptionCoverage: 75.09,
|
||||
};
|
||||
let requestedDatabaseId: string | null = null;
|
||||
server.use(http.get("/api/catalog/metrics", ({ request }) => {
|
||||
requestedDatabaseId = new URL(request.url).searchParams.get("databaseId");
|
||||
return HttpResponse.json(databaseMetrics);
|
||||
}));
|
||||
|
||||
await expect(getCatalogMetrics(databaseId)).resolves.toEqual(databaseMetrics);
|
||||
expect(requestedDatabaseId).toBe(databaseId);
|
||||
});
|
||||
|
||||
test("propagates an unsuccessful catalog metrics response", async () => {
|
||||
server.use(http.get("/api/catalog/metrics", () => new HttpResponse(null, { status: 503 })));
|
||||
|
||||
await expect(getCatalogMetrics()).rejects.toMatchObject({ status: 503 });
|
||||
});
|
||||
Reference in New Issue
Block a user