/ src / lib / server / session-note.test.ts
session-note.test.ts
 1  import assert from 'node:assert/strict'
 2  import test from 'node:test'
 3  
 4  import { buildSessionNoteMessage } from './session-note'
 5  
 6  test('buildSessionNoteMessage defaults to assistant/system note metadata', () => {
 7    const result = buildSessionNoteMessage({
 8      text: 'Live test passed',
 9    })
10  
11    assert.ok(result)
12    assert.equal(result?.role, 'assistant')
13    assert.equal(result?.kind, 'system')
14    assert.equal(result?.text, 'Live test passed')
15    assert.equal(typeof result?.time, 'number')
16  })
17  
18  test('buildSessionNoteMessage trims text and preserves explicit role/kind', () => {
19    const result = buildSessionNoteMessage({
20      text: '  Visible smoke report  ',
21      role: 'user',
22      kind: 'chat',
23      time: 123,
24    })
25  
26    assert.deepEqual(result, {
27      role: 'user',
28      kind: 'chat',
29      text: 'Visible smoke report',
30      time: 123,
31    })
32  })
33  
34  test('buildSessionNoteMessage returns null for empty text', () => {
35    assert.equal(buildSessionNoteMessage({ text: '   ' }), null)
36  })