import fs from "node:fs"; import path from "node:path"; import { describe, expect, test } from "vitest"; import { resolveRepoPath } from "~/utils/testing/repoPaths"; const servicePath = path.join(resolveRepoPath("apps/web/app"), "modules/booking/services/BookingSubmitService.server.ts"); describe("booking post-booking server wiring", () => { test("public booking creates and links a typed InboxLead when no contact matches", () => { const source = fs.readFileSync(servicePath, "utf8"); expect(source).toContain('import { createLead } from "~/utils/integrations/leads/leadService.server"'); expect(source).toContain("if (!kontaktId)"); expect(source).toContain("const lead = await createLead"); expect(source).toContain('quelle: "form"'); expect(source).toContain('kind: "booking"'); expect(source).toContain("appointmentId"); expect(source).toContain("data: { leadId }"); expect(source).toContain('type: "lead" as const'); }); test("public booking persists a FormSubmission when an intake form is configured", () => { const source = fs.readFileSync(servicePath, "utf8"); expect(source).toContain("page.intakeFormId"); expect(source).toContain("tx.formSubmission.create"); expect(source).toContain("formId: page.intakeFormId"); expect(source).toContain("formSubmissionId: formSubmission?.id ?? null"); expect(source).toContain('target: "booking_intake"'); }); });