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

@@ -1,4 +1,5 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
import { getRlsExecutionContext } from "@hivegrid/db/rls-context.server";
import { action } from "./forms.$id";
import { db } from "~/utils/db.server";
import { validateCSRFToken } from "~/utils/session.server";
@@ -76,10 +77,13 @@ function validSaveForm(overrides: Record<string, string> = {}) {
const form = new FormData();
form.set("op", "save");
form.set("name", "Contact");
form.set("definition", JSON.stringify({
title: "Kontakt",
fields: [{ key: "email", type: "email", label: "E-Mail", required: true }],
}));
form.set(
"definition",
JSON.stringify({
title: "Kontakt",
fields: [{ key: "email", type: "email", label: "E-Mail", required: true }],
})
);
form.set("theme", "{}");
form.set("fieldMapping", "{}");
form.set("targetType", "generic");
@@ -99,6 +103,14 @@ describe("form detail action", () => {
});
it("persists localized definition defaults during save", async () => {
vi.mocked(db.form.findFirst).mockImplementationOnce(async () => {
expect(getRlsExecutionContext()).toMatchObject({
tenantId: "tenant_1",
userId: "user_1",
});
return { id: "form_1" } as never;
});
const result = await action({
request: postRequest(validSaveForm({ targetType: "unsupported-target" })),
params: { tenant: "acme", id: "form_1" },
@@ -148,4 +160,39 @@ describe("form detail action", () => {
expect(result).toEqual({ error: "Webhook URL is invalid." });
expect(db.form.update).not.toHaveBeenCalled();
});
it("persists start-double-opt-in post-submit actions", async () => {
const result = await action({
request: postRequest(
validSaveForm({
actions: JSON.stringify([
{
actionType: "start_double_opt_in",
name: "Double opt-in",
enabled: true,
fieldMapping: { email: "email" },
actionConfig: { subject: "Bitte bestätigen" },
},
]),
})
),
params: { tenant: "acme", id: "form_1" },
context: {},
unstable_pattern: "app.$tenant/forms.$id",
});
expect(result).toEqual({ success: "Saved." });
expect(db.formAction.createMany).toHaveBeenCalledWith({
data: [
expect.objectContaining({
formId: "form_1",
tenantId: "tenant_1",
actionType: "start_double_opt_in",
name: "Double opt-in",
fieldMapping: { email: "email" },
actionConfig: { subject: "Bitte bestätigen" },
}),
],
});
});
});