import { describe, expect, it } from "vitest"; import { blockText, stripHtml } from "../version-text"; describe("version-text (T-150/T-151 preview extraction)", () => { it("extracts the API canonical { text } shape", () => { expect(blockText({ text: "Standup notes" })).toBe("Standup notes"); }); it("extracts the legacy { title } shape", () => { expect(blockText({ title: "Legacy title" })).toBe("Legacy title"); }); it("strips tags from a raw HTML string payload (untrusted — never rendered)", () => { expect(blockText("

Objectives

")).toBe("Objectives"); // Payloads are escaped by the renderer (textContent), not re-parsed: expect(blockText('

x

')).not.toContain("onerror=alert"); }); it("walks a serialized Tiptap doc object", () => { expect( blockText({ type: "doc", content: [ { type: "paragraph", content: [{ type: "text", text: "hello " }] }, { type: "paragraph", content: [{ type: "text", text: "world" }] } ] }) ).toBe("hello world"); }); it("returns '' for empty / unknown content", () => { expect(blockText(null)).toBe(""); expect(blockText(undefined)).toBe(""); expect(blockText({ databaseId: "db_123" })).toBe(""); expect(blockText(42)).toBe(""); }); it("stripHtml removes tags (regex fallback, jsdom-free)", () => { expect(stripHtml("bold and italic")).toBe("bold and italic"); }); });