Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

1.8 KB
Raw Blame
const test = require("node:test");
const assert = require("node:assert/strict");

const { tagEventAttendeesJson } = require("../../src/helpers/eventAttendees.js");

test("tagEventAttendeesJson tags every guest with the event that added them, but not the user", () => {
  const attendees = [
    { email: "[email protected]", displayName: "Dana", responseStatus: "accepted", self: false },
    { email: "[email protected]", displayName: "Me", responseStatus: "accepted", self: true },
  ];

  assert.deepEqual(
    JSON.parse(tagEventAttendeesJson(JSON.stringify(attendees), "evt-1")),
    [{ ...attendees[0], addedByEvent: "evt-1" }, attendees[1]],
    "the user recorded the note, so removing the event keeps their own row"
  );
});

test("tagEventAttendeesJson leaves rooms and declined guests off the note, never the user", () => {
  const dana = { email: "[email protected]", displayName: "Dana", responseStatus: null, self: false };
  const attendees = [
    dana,
    {
      email: "[email protected]",
      displayName: "Room 4",
      self: false,
      resource: true,
    },
    { email: "[email protected]", displayName: "Kim", responseStatus: "declined", self: false },
    // The user records the note even when their RSVP says no.
    { email: "[email protected]", displayName: "Me", responseStatus: "declined", self: true },
  ];

  assert.deepEqual(JSON.parse(tagEventAttendeesJson(JSON.stringify(attendees), "evt-1")), [
    { ...dana, addedByEvent: "evt-1" },
    attendees[3],
  ]);
});

test("tagEventAttendeesJson leaves missing or unreadable attendees as they are", () => {
  assert.equal(tagEventAttendeesJson(null, "evt-1"), null);
  assert.equal(tagEventAttendeesJson("[]", null), "[]");
  assert.equal(tagEventAttendeesJson("not json", "evt-1"), "not json");
  assert.equal(tagEventAttendeesJson('{"email":"[email protected]"}', "evt-1"), '{"email":"[email protected]"}');
});