import { test } from 'node:test' import assert from 'node:assert/strict' import { buildNotification, parseNotifyTargets } from '../src/notify.mjs' test('parseNotifyTargets splits a list and drops blanks', () => { assert.deepEqual(parseNotifyTargets('https://a, https://b https://c'), ['https://a', 'https://b', 'https://c']) assert.deepEqual(parseNotifyTargets(['x', ' y ']), ['x', 'y']) assert.deepEqual(parseNotifyTargets(''), []) }) test('buildNotification produces a titled body with the event payload', () => { const note = buildNotification('verify-failed', { runId: 'r1', goal: 'G', iteration: 3, stage: 'Phase 2', verify: 'pnpm test', detail: 'exit 1', }) assert.match(note.title, /Verify failed/) assert.match(note.body, /Run: r1/) assert.match(note.body, /Verify: pnpm test/) assert.match(note.body, /Detail: exit 1/) }) test('buildNotification lists pending questions', () => { const note = buildNotification('question', { questions: [{ text: 'Proceed?' }, 'Or stop?'] }) assert.match(note.body, /Questions: Proceed\? \| Or stop\?/) })