import { describe, it, expect, vi, beforeEach } from "vitest"; import { render, screen, waitFor, within } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; import type { CmsPageView } from "@/app/lib/cmsPages"; // add-cms-forms Task 11: the Form block in the page editor (specs/admin-portal-cms-forms-ui "The Page // Editor Offers A Form Block"). const router = vi.hoisted(() => ({ replace: vi.fn(), push: vi.fn(), search: new URLSearchParams() })); vi.mock("next/navigation", () => ({ useRouter: () => router, useSearchParams: () => router.search })); const pages = vi.hoisted(() => ({ getPage: vi.fn(), savePage: vi.fn(), deletePage: vi.fn(), uploadPageImage: vi.fn(), listPages: vi.fn(), })); vi.mock("@/app/lib/services/adminPages", () => pages); const collections = vi.hoisted(() => ({ listCollections: vi.fn() })); vi.mock("@/app/lib/services/adminCollections", () => collections); const forms = vi.hoisted(() => ({ listForms: vi.fn() })); vi.mock("@/app/lib/services/adminForms", () => forms); vi.mock("@/app/components/products/RichTextEditor", () => ({ RichTextEditor: ({ id, value, onChange }: { id?: string; value: string; onChange: (v: string) => void }) => (