learning_ai_notes/web/src/lib/context-pack.test.ts
Saravana Achu Mac a697752d15 feat: implement WEB_AI_FAST_ROADMAP (web + backend + docs)
Phase 1: Command palette (⌘K), editor autosave with quiet auto-saves, dashboard
saved views from API + quick links + onboarding seed CTA, explicit task scan panel.

Phase 2: Context pack formatter with YAML frontmatter, copy on note + workspace .md export.

Phase 3: ADR for hybrid search without embeddings; POST /notes/search (lexical +
ranked hybrid); search UI mode toggle.

Phase 4: POST copilot + suggest-title; in-editor copilot actions; /chat retrieval
answers with citations (backend chat.rag_enabled).

Phase 5: Settings MCP snippet, offline queue note, API token deferral; DEEP_LINKS.md.

Phase 6: Note shares + public GET; share page; POST onboarding-seed.

Phase 7: note_versions on PATCH; version panel; create-note templates; PWA manifest.

Flags: search.hybrid_enabled, copilot.enabled, chat.rag_enabled, onboarding.seed_enabled.
Made-with: Cursor
2026-03-31 13:00:36 -07:00

39 lines
1.4 KiB
TypeScript

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: "<p>Body <strong>text</strong></p>",
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");
});
});