feat: add AI catalog description generation
This commit is contained in:
@@ -143,6 +143,27 @@ test("keeps only a known safe bounded JSON error payload", async () => {
|
||||
}
|
||||
});
|
||||
|
||||
test.each([
|
||||
["description_generation_target_ids_duplicate", "Description generation target IDs must be unique."],
|
||||
["description_generation_no_eligible_targets", "No eligible catalog tables or columns need description generation."],
|
||||
["catalog_table_not_found", "One or more selected catalog tables were not found."],
|
||||
])("maps the description-generation error code %s to safe local copy", async (code, message) => {
|
||||
const fetchSpy = vi.spyOn(globalThis, "fetch").mockResolvedValue(
|
||||
new Response(JSON.stringify({ code, message: "provider detail must not be trusted" }), {
|
||||
status: 400,
|
||||
headers: { "content-type": "application/json" },
|
||||
}),
|
||||
);
|
||||
|
||||
try {
|
||||
const failure = await apiFetch<unknown>("/description-generation-error")
|
||||
.catch((error: unknown) => error) as ApiError;
|
||||
expect(failure).toMatchObject({ code, message, payload: { code } });
|
||||
} finally {
|
||||
fetchSpy.mockRestore();
|
||||
}
|
||||
});
|
||||
|
||||
test("derives local messages without retaining a malicious known-code message", async () => {
|
||||
const fetchSpy = vi.spyOn(globalThis, "fetch").mockResolvedValue(
|
||||
new Response(JSON.stringify({
|
||||
|
||||
Reference in New Issue
Block a user