Files
windmill/ai_evals/core/previewFailureDetails.test.ts
7f8765c171 fix: surface backend preview logs in AI eval failures (#9383)
* Surface backend preview logs in AI eval failures

* fix: keep the tail of preview job logs in eval failure details

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: lead a failed preview's result excerpt with its error message

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix: keep line breaks in failed preview log and result excerpts

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Ruben Fiszel <ruben@windmill.dev>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-19 10:51:57 +01:00

56 lines
1.9 KiB
TypeScript

import { describe, expect, it } from "bun:test";
import { formatPreviewFailureDetails } from "./previewFailureDetails";
describe("formatPreviewFailureDetails", () => {
it("includes runtime logs and result excerpts for failed preview jobs", () => {
const details = formatPreviewFailureDetails({
workspaceId: "ai-evals-crud-a1",
jobId: "job-123",
logs: "\nTypeError: Cannot read properties of undefined\n at listRecipes\n",
result: { error: "frontend called missing backend runnable" },
});
expect(details).toContain("workspace=ai-evals-crud-a1");
expect(details).toContain("job=job-123");
expect(details).toContain("TypeError: Cannot read properties of undefined");
expect(details).toContain("frontend called missing backend runnable");
});
it("bounds noisy logs so check summaries stay readable", () => {
const details = formatPreviewFailureDetails({
workspaceId: "workspace",
jobId: "job",
logs: "x".repeat(100),
maxCharacters: 20,
});
expect(details).toContain(`logs:\n…${"x".repeat(19)}`);
expect(details.length).toBeLessThan(80);
});
it("keeps the error at the end of a log after long install output", () => {
const installOutput = Array.from(
{ length: 150 },
(_, i) => `+ package-${i}@1.0.${i} installed from the registry`,
).join("\n");
const details = formatPreviewFailureDetails({
workspaceId: "workspace",
jobId: "job",
logs: `${installOutput}\nerror: Cannot find module 'missing'\n at main (/tmp/main.ts:3:9)\n`,
result: {
error: {
name: "Error",
stack: "x".repeat(2000),
message: "Cannot find module",
},
},
});
expect(details).toContain(
"error: Cannot find module 'missing'\n at main (/tmp/main.ts:3:9)",
);
expect(details).not.toContain("package-0@");
expect(details).toContain("result:\nError: Cannot find module\nxxx");
});
});