Skip to content

Private AI meeting notes that stay on your computer. No meeting bot. Free and open source for Mac, Windows and Linux. An alternative to Granola, Otter and Fireflies.

4.4 KB
Raw Blame
import { describe, expect, it } from 'vitest'
import { validateCatalog } from '../src/catalog-schema'
import real from '../../../catalog/catalog.json'
import licenses from '../../../catalog/licenses.json'
import { models } from './fixtures'

const shipped = real as Record<string, unknown>
const sha = /^[a-f0-9]{64}$/

describe('validateCatalog', () => {
  it('accepts the shipped catalog', () => {
    const r = validateCatalog(real, licenses)
    expect(r.ok ? [] : r.errors).toEqual([])
  })
  it('the 26B notes model needs a graphics card (#32)', () => {
    const r = validateCatalog(real, licenses)
    if (!r.ok) throw new Error(r.errors.join('; '))
    expect(r.catalog.models.find((m) => m.id === 'gemma-4-26b-a4b')?.gpuOnly).toBe(true)
  })
  it('pins Parakeet like the other speech models: a URL at a fixed revision, a sha256, its size, an allowed licence with its credit', () => {
    const r = validateCatalog(real, licenses)
    if (!r.ok) throw new Error(r.errors.join('; '))
    const p = r.catalog.parakeet!
    expect(p.url).toMatch(/^https:\/\/huggingface\.co\/ggml-org\/parakeet-GGUF\/resolve\/[a-f0-9]{40}\/ggml-parakeet-tdt-0\.6b-v3-q8_0\.bin$/)
    expect(p.sha256).toMatch(sha)
    expect(p.bytes / 1e9).toBeCloseTo(p.sizeGB, 1)
    expect(p.license).toBe('CC-BY-4.0')
    expect(p.attribution).toMatch(/NVIDIA/)
    expect(r.catalog.asr.some((a) => a.id === p.languageId)).toBe(true)
    expect(r.catalog.parakeetServer).toMatchObject({ bundled: true })
  })
  it('a catalog without Parakeet is still a catalog (whisper reads everything)', () => {
    const { parakeet: _p, parakeetServer: _s, ...rest } = shipped
    expect(validateCatalog(rest, licenses).ok).toBe(true)
  })
  it('pins every ASR model with a sha256', () => {
    const r = validateCatalog(real, licenses)
    if (!r.ok) throw new Error(r.errors.join('; '))
    expect(r.catalog.asr.length).toBeGreaterThanOrEqual(2)
    for (const a of r.catalog.asr) expect(a.sha256).toMatch(sha)
  })
  it('takes a whisper-server entry that is bundled in the app: nothing to download', () => {
    const r = validateCatalog(real, licenses)
    if (!r.ok) throw new Error(r.errors.join('; '))
    expect(r.catalog.whisperServer.bundled).toBe(true)
    expect(r.catalog.whisperServer.url).toBeUndefined()
  })
  it('rejects a whisper-server entry that is neither pending nor bundled and has no sha256', () => {
    const bad = { ...shipped, whisperServer: { id: 'whisper-server', tag: 'v1.9.5' } }
    expect(validateCatalog(bad, licenses).ok).toBe(false)
  })
  it('pins the embedding model (meaning search across meetings) with a sha256, its size and its vector length', () => {
    const r = validateCatalog(real, licenses)
    if (!r.ok) throw new Error(r.errors.join('; '))
    expect(r.catalog.embedding.sha256).toMatch(sha)
    expect(r.catalog.embedding.url).toMatch(/\/resolve\/[a-f0-9]{40}\//)
    expect(r.catalog.embedding.dims).toBeGreaterThan(0)
  })
  it('rejects an embedding model without a sha256, or with a disallowed license', () => {
    const embedding = shipped.embedding as Record<string, unknown>
    expect(validateCatalog({ ...shipped, embedding: { ...embedding, sha256: '' } }, licenses).ok).toBe(false)
    expect(validateCatalog({ ...shipped, embedding: { ...embedding, license: 'CC-BY-NC-4.0' } }, licenses).ok).toBe(false)
  })
  it('rejects an ASR model without a sha256', () => {
    const asr = (shipped.asr as Record<string, unknown>[]).map((a) => ({ ...a, sha256: '' }))
    expect(validateCatalog({ ...shipped, asr }, licenses).ok).toBe(false)
  })
  it('rejects disallowed licenses', () => {
    const r = validateCatalog({ ...shipped, models: [{ ...models[0], license: 'CC-BY-NC-4.0' }] }, licenses)
    expect(r.ok).toBe(false)
  })
  it('rejects a disallowed ASR license', () => {
    const asr = (shipped.asr as Record<string, unknown>[]).map((a) => ({ ...a, license: 'CC-BY-NC-4.0' }))
    expect(validateCatalog({ ...shipped, asr }, licenses).ok).toBe(false)
  })
  it('rejects duplicate ids', () => {
    const r = validateCatalog({ ...shipped, models: [models[0], models[0]] }, licenses)
    expect(r.ok).toBe(false)
  })
  it('rejects missing sha256', () => {
    const bad = { ...models[0], builds: [{ ...models[0].builds[0], sha256: '' }] }
    expect(validateCatalog({ ...shipped, models: [bad] }, licenses).ok).toBe(false)
  })
  it('requires at least one starter model', () => {
    expect(validateCatalog({ ...shipped, models: [models[3]] }, licenses).ok).toBe(false)
  })
})