import { describe, expect, it } from "vitest"; import { buildFrontmatter, buildNoteContextPack, NOTELETT_CONTEXT_VERSION } from "@/lib/context-pack"; import type { NoteDetail } from "@/lib/types"; const sampleNote: NoteDetail = { id: "n1", workspaceId: "w1", title: "Hello", excerpt: "Hi", status: "active", tags: ["a", "b"], updatedAt: "2026-03-31T00:00:00.000Z", updatedBy: "u1", body: "

Body text

", metadata: { owner: "u1", source: "manual", reviewState: "none", taskCount: 0, artifactCount: 0 }, linkedNotes: [{ id: "n2", title: "Other", relationship: "see_also" }], tasks: [{ id: "t1", title: "Do thing", status: "todo", source: "manual" }], artifacts: [], timeline: [], }; describe("context-pack", () => { it("builds stable frontmatter", () => { const fm = buildFrontmatter("ws-1", "2026-03-31T12:00:00.000Z"); expect(fm).toContain(`notelett_version: "${NOTELETT_CONTEXT_VERSION}"`); expect(fm).toContain('workspace_id: "ws-1"'); expect(fm).toContain("exported_at:"); }); it("includes title, stripped body, links, and tasks", () => { const pack = buildNoteContextPack(sampleNote, { workspaceId: "w1", exportedAt: "2026-03-31T12:00:00.000Z" }); expect(pack).toContain("# Hello"); expect(pack).toContain("Body text"); expect(pack).toContain("Linked notes"); expect(pack).toContain("/notes/n2"); expect(pack).toContain("Do thing"); }); });