This commit is contained in:
1 parent
8efd032cc6
commit
df38dccbf1
735 files changed
+128321
-120870
No files matched your search
+27
-25
@@ -2,30 +2,32 @@ import { describe, expect, it } from "vitest";
|
||||
import { serverErrorRecord } from "@/lib/server-log";
|
||||
|
||||
describe("serverErrorRecord", () => {
|
||||
it("keeps operational context while redacting sensitive fields", () => {
|
||||
expect(
|
||||
serverErrorRecord("paypal.capture_failed", new Error("gateway timeout"), {
|
||||
orderId: "ORDER-123",
|
||||
userId: 42,
|
||||
authorization: "Bearer secret",
|
||||
apiToken: "secret-token",
|
||||
}),
|
||||
).toEqual({
|
||||
level: "error",
|
||||
event: "paypal.capture_failed",
|
||||
message: "gateway timeout",
|
||||
context: {
|
||||
orderId: "ORDER-123",
|
||||
userId: 42,
|
||||
authorization: "[REDACTED]",
|
||||
apiToken: "[REDACTED]",
|
||||
},
|
||||
});
|
||||
});
|
||||
it("keeps operational context while redacting sensitive fields", () => {
|
||||
expect(
|
||||
serverErrorRecord("paypal.capture_failed", new Error("gateway timeout"), {
|
||||
orderId: "ORDER-123",
|
||||
userId: 42,
|
||||
authorization: "Bearer secret",
|
||||
apiToken: "secret-token",
|
||||
}),
|
||||
).toEqual({
|
||||
level: "error",
|
||||
event: "paypal.capture_failed",
|
||||
message: "gateway timeout",
|
||||
context: {
|
||||
orderId: "ORDER-123",
|
||||
userId: 42,
|
||||
authorization: "[REDACTED]",
|
||||
apiToken: "[REDACTED]",
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it("normalizes non-Error failures without serializing arbitrary objects", () => {
|
||||
expect(serverErrorRecord("admin.update_failed", { password: "secret" })).toMatchObject({
|
||||
message: "Unknown server error",
|
||||
});
|
||||
});
|
||||
it("normalizes non-Error failures without serializing arbitrary objects", () => {
|
||||
expect(
|
||||
serverErrorRecord("admin.update_failed", { password: "secret" }),
|
||||
).toMatchObject({
|
||||
message: "Unknown server error",
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user