21 lines
752 B
TypeScript
21 lines
752 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
|
|
import { formatRawAssistantErrorForUi } from "./pi-embedded-helpers.js";
|
|
|
|
describe("formatRawAssistantErrorForUi", () => {
|
|
it("renders HTTP code + type + message from Anthropic payloads", () => {
|
|
const text = formatRawAssistantErrorForUi(
|
|
'429 {"type":"error","error":{"type":"rate_limit_error","message":"Rate limited."},"request_id":"req_123"}',
|
|
);
|
|
|
|
expect(text).toContain("HTTP 429");
|
|
expect(text).toContain("rate_limit_error");
|
|
expect(text).toContain("Rate limited.");
|
|
expect(text).toContain("req_123");
|
|
});
|
|
|
|
it("renders a generic unknown error message when raw is empty", () => {
|
|
expect(formatRawAssistantErrorForUi("")).toContain("unknown error");
|
|
});
|
|
});
|