Refresh HiveGrid Cloud reference snapshot

This commit is contained in:
david committed 2026-08-03 15:31:14 +02:00
1 parent 5e99e14772
commit 7f88026f79
5955 files changed
+1177325 -188362

No files matched your search

@@ -22,6 +22,8 @@ describe("admin notification channels i18n", () => {
expect(source).toContain("notifications.admin.channels.title");
expect(source).toContain("notifications.admin.channels.setup.instructions");
expect(source).toContain("notifications.admin.templates.previewMessage");
expect(source).toContain("notifications.admin.templates.errors.deleteFailed");
expect(source).toContain("notifications.admin.templates.errors.previewFailed");
expect(source).toContain("notifications.admin.nav.overview");
expect(source).toContain("notifications.admin.nav.subscribers");
expect(source).toContain("notifications.admin.nav.messages");
@@ -40,5 +42,6 @@ describe("admin notification channels i18n", () => {
expect(source).not.toContain('name: "Channels"');
expect(source).not.toContain(">Messages<");
expect(source).not.toContain('title: "Channel"');
expect(source).not.toContain("redactNotificationDiagnosticText");
});
});
@@ -15,6 +15,10 @@ vi.mock("~/utils/db/users.db.server", () => ({
getUser: vi.fn(async () => ({ id: "user_123", email: "user@example.com" })),
}));
vi.mock("~/locale/i18next.server", () => ({
getTranslations: vi.fn(async () => ({ t: (key: string) => key })),
}));
vi.mock("~/modules/notifications/services/.server/NotificationService", () => ({
default: {
deleteNotificationTemplate: vi.fn(async () => null),
@@ -24,11 +28,13 @@ vi.mock("~/modules/notifications/services/.server/NotificationService", () => ({
}));
import { verifyUserHasPermission } from "~/utils/helpers/.server/PermissionsService";
import NotificationService from "~/modules/notifications/services/.server/NotificationService";
import { action } from "./channels";
function callAction() {
function callAction(actionName = "create", fields: Record<string, string> = {}) {
const form = new FormData();
form.set("action", "create");
form.set("action", actionName);
for (const [key, value] of Object.entries(fields)) form.set(key, value);
return action({
request: new Request("https://admin.example.test/notifications/channels", {
method: "POST",
@@ -49,4 +55,22 @@ describe("admin notification channels action", () => {
await callAction();
expect(verifyUserHasPermission).toHaveBeenCalledWith(expect.any(Request), "admin.notifications.manage");
});
it("does not expose provider diagnostics when deletion fails", async () => {
vi.mocked(NotificationService.deleteNotificationTemplate).mockRejectedValueOnce(new Error("provider token expired"));
const response = await callAction("delete", { id: "template_123" });
expect(response).toBeInstanceOf(Response);
await expect((response as Response).json()).resolves.toEqual({ error: "notifications.admin.templates.errors.deleteFailed" });
});
it("does not expose provider diagnostics when preview delivery fails", async () => {
vi.mocked(NotificationService.send).mockRejectedValueOnce(new Error("provider request leaked details"));
const response = await callAction("send-preview", { channel: "in_app" });
expect(response).toBeInstanceOf(Response);
await expect((response as Response).json()).resolves.toEqual({ error: "notifications.admin.templates.errors.previewFailed" });
});
});
@@ -8,19 +8,22 @@ import ServerError from "~/components/ui/errors/ServerError";
import NotificationTemplatesTable from "~/modules/notifications/components/NotificationTemplatesTable";
import { NotificationChannelDto, NotificationChannels } from "~/modules/notifications/services/NotificationChannels";
import NotificationService, { IGetTemplatesData } from "~/modules/notifications/services/.server/NotificationService";
import { redactNotificationDiagnosticText } from "@hivegrid/db/notifications.server";
import { getUser } from "~/utils/db/users.db.server";
import { getPaginationFromCurrentUrl } from "~/utils/helpers/RowPaginationHelper";
import { getUserInfo, validateCSRFToken } from "~/utils/session.server";
import toast from "react-hot-toast";
import { toast } from "sonner";
import { verifyUserHasPermission } from "~/utils/helpers/.server/PermissionsService";
import { appendCSRFToken } from "~/utils/csrf";
import { getTranslations } from "~/locale/i18next.server";
import { createScopedLogger } from "~/utils/logger.server";
import { toSafeErrorLog } from "~/utils/safeErrorLog.server";
const logger = createScopedLogger("admin.notification-channels");
type LoaderData = {
items: IGetTemplatesData | null;
};
export const loader = async ({ request, params }: LoaderFunctionArgs) => {
export const loader = async ({ request, params: _params }: LoaderFunctionArgs) => {
await verifyUserHasPermission(request, "admin.notifications.view");
const urlSearchParams = new URL(request.url).searchParams;
const currentPagination = getPaginationFromCurrentUrl(urlSearchParams);
@@ -52,8 +55,9 @@ export const action: ActionFunction = async ({ request }) => {
return Response.json({
success: t("notifications.admin.templates.deleted"),
});
} catch (e: any) {
return Response.json({ error: redactNotificationDiagnosticText(e instanceof Error ? e.message : String(e)) }, { status: 500 });
} catch (error: unknown) {
logger.error({ event: "admin.notification_template.delete_failed", ...toSafeErrorLog(error) }, "Notification template deletion failed");
return Response.json({ error: t("notifications.admin.templates.errors.deleteFailed") }, { status: 500 });
}
} else if (action === "create") {
// const name = form.get("name")?.toString() ?? "";
@@ -69,8 +73,9 @@ export const action: ActionFunction = async ({ request }) => {
// critical: false,
// });
return Response.json({ success: t("shared.created") });
} catch (e: any) {
return Response.json({ error: redactNotificationDiagnosticText(e instanceof Error ? e.message : String(e)) }, { status: 500 });
} catch (error: unknown) {
logger.error({ event: "admin.notification_template.create_failed", ...toSafeErrorLog(error) }, "Notification template creation failed");
return Response.json({ error: t("notifications.admin.templates.errors.createFailed") }, { status: 500 });
}
} else if (action === "send-preview") {
const channel = form.get("channel")?.toString() ?? "";
@@ -84,10 +89,12 @@ export const action: ActionFunction = async ({ request }) => {
required: true,
});
return Response.json({ success: t("notifications.admin.templates.previewSent", { channel }) });
} catch (e: any) {
return Response.json({ error: redactNotificationDiagnosticText(e instanceof Error ? e.message : String(e)) }, { status: 500 });
} catch (error: unknown) {
logger.error({ event: "admin.notification_template.preview_failed", ...toSafeErrorLog(error) }, "Notification template preview failed");
return Response.json({ error: t("notifications.admin.templates.errors.previewFailed") }, { status: 500 });
}
}
return Response.json({ error: t("notifications.errors.invalidAction") }, { status: 400 });
};
export default function () {
@@ -147,7 +154,7 @@ export default function () {
}
return (
<>
<div className="mx-auto w-full max-w-5xl space-y-3 px-4 py-2 pb-6 sm:px-6 sm:pt-3 lg:px-8 xl:max-w-full">
<div className="w-full space-y-3 px-6 py-2 pb-6 mobile:px-4 sm:pt-3">
<div className="md:border-border md:border-b md:py-2">
<div className="flex items-center justify-between">
<h3 className="text-foreground text-lg font-medium leading-6">{t("notifications.admin.channels.title")}</h3>
@@ -29,7 +29,7 @@ export default function () {
const formatters = useLocaleFormatters();
const data = useLoaderData<LoaderData>();
return (
<div className="mx-auto mb-12 max-w-5xl space-y-5 px-4 py-4 sm:px-6 lg:px-8 xl:max-w-7xl">
<div className="mb-12 w-full space-y-5 px-6 py-6 mobile:px-4">
<div className="border-border border-b pb-5">
<h3 className="text-foreground text-lg leading-6 font-medium">{t("shared.overview")}</h3>
</div>
@@ -1,5 +1,5 @@
import { LoaderFunctionArgs, useLoaderData } from "react-router";
import { t as i18nT } from "i18next";
import { requestScopedT as i18nT } from "~/locale/request-scoped-t";
import { useTranslation } from "react-i18next";
import { FilterablePropertyDto } from "~/application/dtos/data/FilterablePropertyDto";
import ServerError from "~/components/ui/errors/ServerError";
@@ -45,7 +45,7 @@ export default function () {
const data = useLoaderData<LoaderData>();
return (
<>
<div className="mx-auto w-full max-w-5xl space-y-3 px-4 py-2 pb-6 sm:px-6 sm:pt-3 lg:px-8 xl:max-w-full">
<div className="w-full space-y-3 px-6 py-2 pb-6 mobile:px-4 sm:pt-3">
<div className="md:border-border md:border-b md:py-2">
<div className="flex items-center justify-between">
<h3 className="text-foreground text-lg font-medium leading-6">{t("notifications.admin.messages.title")}</h3>
@@ -26,7 +26,7 @@ export default function () {
const data = useLoaderData<LoaderData>();
return (
<>
<div className="mx-auto w-full max-w-5xl space-y-3 px-4 py-2 pb-6 sm:px-6 sm:pt-3 lg:px-8 xl:max-w-full">
<div className="w-full space-y-3 px-6 py-2 pb-6 mobile:px-4 sm:pt-3">
<div className="md:border-border md:border-b md:py-2">
<div className="flex items-center justify-between">
<h3 className="text-foreground text-lg font-medium leading-6">{t("notifications.admin.subscribers.title")}</h3>