Files
Jyotisha/frontend/tests/safe-error-reason.test.ts
T
Jesse_Chen b466a6fc8c fix(report): stop listing reports via PostgREST JSON paths (BUG-574)
Staging PostgREST rejects the executiveSummary JSON-path alias, so GET /api/reports 500s. Persist a plain card_summary column from the Markdown excerpt instead.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-09-07 11:08:00 +08:00

22 lines
828 B
TypeScript

import assert from "node:assert/strict";
import test from "node:test";
import { sanitizedErrorReason } from "../src/lib/safe-error-reason.ts";
test("sanitizedErrorReason reads PostgREST code/hint from non-Error objects", () => {
assert.equal(sanitizedErrorReason("boom"), "UnknownError");
assert.equal(sanitizedErrorReason(new Error("secret row")), "Error");
assert.equal(
sanitizedErrorReason({ code: "42703", hint: "column does not exist" }),
"UnknownError code=42703 hint=column does not exist",
);
assert.equal(
sanitizedErrorReason({ name: "PostgrestError", code: "PGRST204", hint: "" }),
"PostgrestError code=PGRST204 hint=none",
);
assert.doesNotMatch(
sanitizedErrorReason({ code: "42703", message: "row body must not be logged", details: "secret" }),
/row body|secret/,
);
});