import { describe, expect, mock, test } from 'claude-code/testing' import { boardHtml, parseCsv, tasksFrom } from '../hooks/band/board' import type { Band } from '../hooks/band/types' import { NO_TOKENS, addTokens, addedLines, callsIn, defsIn, duration, elapsed, fmtTokens, inProject, isTestCommand, mainModel, markdown, metricsSvg, parseDefs, percent, resume, sessionTitle, snapshot, testCounts, totalTokens, upsertCsv, CSV_HEADER, webhookRequest, } from '../hooks/band/metrics' describe('board', () => { const CSV = 'key,started,project,name,cost_usd,turns,agent_minutes,tokens_total,tokens_output,reuse_pct,reused,new,callers_open,tests,level\n' + 'a-1,2026-10-15 12:00,shop,"Fix ""cart"", totals\nand tax",3.10,6,26.0,1200000,85000,83,5,1,0,14 passed,full\n' + 'b-2,2026-10-14 09:30,shop,,0.50,2,1.5,40000,900,,0,0,0,not run,lite\n' test('reads quoted CSV fields with commas, quotes and line breaks', () => { const rows = parseCsv(CSV) expect(rows.length).toBe(3) expect(rows[1]?.[3]).toBe('Fix "cart", totals\nand tax') const tasks = tasksFrom(CSV) expect(tasks[0]).toEqual({ started: '2026-10-15 12:00', project: 'shop', name: 'Fix "cart", totals\nand tax', cost: 3.1, turns: 6, agentMinutes: 26, tokens: 1_200_000, reuse: 83, tests: '14 passed', level: 'full', model: '' }) expect(tasks[1]?.reuse).toBeNull() expect(tasksFrom('not,a,ledger\n1,2,3')).toEqual([]) }) const dataOf = (html: string) => JSON.parse(/') expect(html).not.toContain('