test: regression coverage for error mapping and client error extraction

- handlers: pgx.ErrNoRows→404, InputError→400 with message preserved,
  pgconn 23505→409 without constraint/SQLSTATE leak, unknown→500
- services: export NewInputError so error construction is testable
- frontend: vitest for errorMessage helper — server reason preferred,
  status text and fallbacks verified

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
This commit is contained in:
Tomas DvorakandDevin committed 2026-09-24 22:58:55 +02:00
1 parent 89f3d84234
commit a71baa49cd
3 files changed
+78

No files matched your search

@@ -0,0 +1,29 @@
import { describe, expect, it } from "vitest";
import { errorMessage } from "../api";
describe("errorMessage", () => {
it("prefers the server's reason over the HTTP status text", () => {
const apiError = {
message: "Bad Request",
body: { error: { message: "webhook url must be https (http allowed only for private/self-hosted targets)" } },
};
expect(errorMessage(apiError)).toBe(
"webhook url must be https (http allowed only for private/self-hosted targets)",
);
});
it("falls back to error.message when no body reason exists", () => {
expect(errorMessage(new Error("network down"))).toBe("network down");
});
it("uses the fallback for non-error values", () => {
expect(errorMessage(null, "Nope")).toBe("Nope");
expect(errorMessage(undefined)).toBe("Request failed");
expect(errorMessage("string failure")).toBe("Request failed");
});
it("ignores empty body and message strings", () => {
expect(errorMessage({ message: "", body: { error: { message: "" } } }, "Empty")).toBe("Empty");
});
});