/** * HTML Block Conversion Tests (admin editor seam) * * Tests the Portable Text ↔ ProseMirror conversion for `htmlBlock` through * the seams the admin rich-text editor actually exercises. Mirrors the core * converter round-trip test against the in-file converters. */ import { describe, it, expect } from "vitest"; import { _prosemirrorToPortableText as prosemirrorToPortableText, _portableTextToProsemirror as portableTextToProsemirror, } from "../../src/components/PortableTextEditor"; describe("HTML block round-trip (admin editor seam)", () => { it("preserves html content through PT → PM → PT", () => { const htmlBlock = { _type: "htmlBlock", _key: "html001", html: '
Hello world
Injected
" }, { _type: "block", _key: "txt002", style: "normal", children: [{ _type: "span", _key: "s2", text: "After" }], }, ]; const pm = portableTextToProsemirror(blocks); expect(pm.content).toHaveLength(3); const middle = pm.content?.[1] as { type: string } | undefined; expect(middle?.type).toBe("htmlBlock"); const pt = prosemirrorToPortableText(pm); expect(pt).toHaveLength(3); expect(pt[1]!._type).toBe("htmlBlock"); expect((pt[1] as { html?: string }).html).toBe("Injected
"); }); });