test(api): cover notification broadcast reference errors

This commit is contained in:
2026-03-31 21:57:02 +02:00
parent 4111b7b661
commit 7585a76c11
2 changed files with 115 additions and 0 deletions
@@ -82,6 +82,24 @@ describe("notification procedure support", () => {
}
});
it("rewrites broadcast source foreign-key errors to a not found TRPC error", () => {
const error = {
code: "P2003",
meta: { field_name: "Notification_sourceId_fkey" },
};
try {
rethrowNotificationReferenceError(error);
throw new Error("expected notification reference error");
} catch (caught) {
expect(caught).toBeInstanceOf(TRPCError);
expect(caught).toMatchObject<Partial<TRPCError>>({
code: "NOT_FOUND",
message: "Notification broadcast not found",
});
}
});
it("rethrows unrelated errors unchanged", () => {
const error = new Error("boom");