Skip to content

armgit / clipy

Public Imported from GitHub
0

The AI-native screen recorder. Record your screen and talk; the people you share it with and your AI agents both get it.

3.0 KB
Raw Blame
import { describe, expect, it } from "vitest";
import { boldSpans, notesBlocks, speakerColour } from "../src/lib/meetingNotes";

const MARKDOWN = [
  "## Summary",
  "The team set Q3 goals.",
  "",
  "## Decisions",
  "- None recorded.",
  "",
  "## Action items",
  "- [ ] **Maya**: Share the numbers (due Friday)",
  "- [x] **Unassigned**: Book the review",
  "",
  "## Discussion",
  "### Onboarding",
  "- Only a third share a recording in week one.",
].join("\n");

// What Rust's `notes::parse(..).lines` gives for the same Markdown.
const LINES = [
  { text: "The team set Q3 goals.", action: null, done: false },
  { text: "**Maya**: Share the numbers (due Friday)", action: 0, done: false },
  { text: "**Unassigned**: Book the review", action: 1, done: true },
  { text: "Only a third share a recording in week one.", action: null, done: false },
];

describe("notesBlocks", () => {
  it("ties lines to their index and takes action items from Rust", () => {
    const blocks = notesBlocks(MARKDOWN, LINES);
    expect(blocks.map((b) => b.kind)).toEqual([
      "section",
      "paragraph",
      "section",
      "item",
      "section",
      "item",
      "item",
      "section",
      "topic",
      "item",
    ]);
    const lines = blocks.flatMap((b) => ("line" in b ? [b.line] : []));
    expect(lines).toEqual([0, null, 1, 2, 3]);
    const actions = blocks.flatMap((b) => ("action" in b && b.action !== null ? [[b.action, b.done]] : []));
    expect(actions).toEqual([
      [0, false],
      [1, true],
    ]);
  });

  it("does not make a checkbox Rust did not count an action item", () => {
    const blocks = notesBlocks("## Decisions and action items\n- [ ] **A**: one", [
      { text: "**A**: one", action: null, done: false },
    ]);
    expect(blocks[1]).toMatchObject({ kind: "item", line: 0, action: null });
  });

  it("leaves a line the parser did not list unlinked", () => {
    const blocks = notesBlocks("## Summary\nSomething new.", []);
    expect(blocks[1]).toMatchObject({ kind: "paragraph", line: null });
  });
  it("keeps the checkbox of an item whose text holds a Unicode line or paragraph separator", () => {
    for (const sep of ["
", "
"]) {
      const text = `**Maya**: Share the numbers${sep}and include the chart`;
      const blocks = notesBlocks(`## Action items\n- [x] ${text}`, [{ text, action: 0, done: true }]);
      expect(blocks[1]).toEqual({ kind: "item", text, line: 0, action: 0, done: true });
    }
  });
});

describe("boldSpans", () => {
  it("splits paired bold markers and leaves an unpaired one as text", () => {
    expect(boldSpans("**Maya**: ship")).toEqual([
      { text: "Maya", bold: true },
      { text: ": ship", bold: false },
    ]);
    expect(boldSpans("2 ** 3")).toEqual([{ text: "2 ** 3", bold: false }]);
  });
});

describe("speakerColour", () => {
  it("is stable per speaker", () => {
    expect(speakerColour("p1")).toBe(speakerColour("p1"));
    expect(speakerColour("p1")).not.toBe(speakerColour("p2"));
    expect(speakerColour("you")).not.toBe(speakerColour("p1"));
  });
});