import { describe, expect, test } from "bun:test"; import { readFileSync } from "node:fs"; import { getEventFormValuesFromEvent } from "@/lib/event-form"; describe("EventDialog public modes", () => { test("accepts AI-prefilled editable initial values through its public props", () => { const initialValues = getEventFormValuesFromEvent({ title: "AI Draft", start: "2026-04-09T10:00:00.000Z", recurrenceRule: "FREQ=WEEKLY;INTERVAL=1;BYDAY=TH", }); expect(initialValues.title).toBe("AI Draft"); expect(initialValues.start).toBe("2026-04-09T10:00:00.000Z"); expect(initialValues.recurrenceRule).toBe("FREQ=WEEKLY;INTERVAL=1;BYDAY=TH"); }); test("dialog content uses console surface classes instead of generic border and shadow", () => { const source = readFileSync("src/components/ui/dialog.tsx", "utf8"); expect(source).toContain("rounded-[10px]"); expect(source).toContain("shadow-xl"); expect(source).not.toContain("rounded-lg border p-6 shadow-lg"); }); test("dialog source uses console section labels and grouped field regions", () => { const source = readFileSync("src/components/event-dialog.tsx", "utf8"); expect(source).toContain("Event details"); expect(source).toContain("Schedule"); expect(source).toContain("Recurrence"); }); test("event-dialog imports Drawer for mobile branch", () => { const source = readFileSync("src/components/event-dialog.tsx", "utf8"); expect(source).toContain('from "@/components/ui/drawer"'); }); test("event-dialog renders three step components", () => { const source = readFileSync("src/components/event-dialog.tsx", "utf8"); expect(source).toContain("DetailsStep"); expect(source).toContain("ScheduleStep"); expect(source).toContain("RecurrenceStep"); }); test("event-dialog includes step progress bars", () => { const source = readFileSync("src/components/event-dialog.tsx", "utf8"); expect(source).toContain("grid-cols-3"); }); test("event-dialog includes step counter badge", () => { const source = readFileSync("src/components/event-dialog.tsx", "utf8"); expect(source).toContain("/ 3"); }); test("drawer footer shows Cancel on step 1 and Back on steps 2 and 3", () => { const source = readFileSync("src/components/event-dialog.tsx", "utf8"); expect(source).toContain("Cancel"); expect(source).toContain("Back"); }); test("drawer footer shows Save only on step 3", () => { const source = readFileSync("src/components/event-dialog.tsx", "utf8"); expect(source).toContain("Save"); expect(source).toContain("Next"); }); test("event-dialog resets step to 1 on close", () => { const source = readFileSync("src/components/event-dialog.tsx", "utf8"); expect(source).toContain("setStep(1)"); }); test("dialog.tsx no longer forks on isMobile in DialogContent", () => { const source = readFileSync("src/components/ui/dialog.tsx", "utf8"); expect(source).not.toContain('isMobile ? undefined : "max-w-lg"'); }); test("dialog.tsx no longer forks on isMobile in DialogFooter", () => { const source = readFileSync("src/components/ui/dialog.tsx", "utf8"); expect(source).not.toContain('isMobile\n\t\t\t\t? "flex flex-col-reverse gap-2"'); }); });