46 lines
1.7 KiB
TypeScript
46 lines
1.7 KiB
TypeScript
import { describe, expect, it } from "vitest";
|
|
import fs from "node:fs";
|
|
import path from "node:path";
|
|
|
|
import { sanitizeNotificationPayloadForDisplay } from "./NotificationMessagesTable";
|
|
|
|
describe("NotificationMessagesTable", () => {
|
|
it("redacts sensitive notification payload fields before display", () => {
|
|
const payload = JSON.stringify({
|
|
token: "secret-token",
|
|
authorization: "Bearer abc123",
|
|
nested: { email: "user@example.com", message: "ok" },
|
|
});
|
|
|
|
const redacted = sanitizeNotificationPayloadForDisplay(payload);
|
|
|
|
expect(redacted).not.toContain("secret-token");
|
|
expect(redacted).not.toContain("Bearer abc123");
|
|
expect(redacted).toContain("[REDACTED]");
|
|
expect(redacted).toContain("user@example.com");
|
|
});
|
|
|
|
it("stringifies object payloads before redaction", () => {
|
|
const redacted = sanitizeNotificationPayloadForDisplay({
|
|
token: "secret-token",
|
|
nested: { authorization: "Bearer abc123", message: "ok" },
|
|
});
|
|
|
|
expect(redacted).not.toContain("secret-token");
|
|
expect(redacted).not.toContain("Bearer abc123");
|
|
expect(redacted).toContain("[REDACTED]");
|
|
expect(redacted).toContain("ok");
|
|
});
|
|
|
|
it("keeps notification table dates on locale-aware formatters", () => {
|
|
const componentsRoot = path.resolve(process.cwd(), "apps/web/app/modules/notifications/components");
|
|
const source = ["NotificationMessagesTable.tsx", "NotificationSubscribersTable.tsx"]
|
|
.map((file) => fs.readFileSync(path.join(componentsRoot, file), "utf8"))
|
|
.join("\n");
|
|
|
|
expect(source).toContain("useLocaleFormatters");
|
|
expect(source).toContain("formatters.relativeDate");
|
|
expect(source).not.toContain("DateUtils");
|
|
});
|
|
});
|