import { describe, it, expect } from 'vitest'; import { linkColor, workerStateLabel, workerStatus, workerColor, workerTitle } from './statusVisual'; describe('statusVisual', () => { it('maps link status to theme colors', () => { expect(linkColor('healthy')).toBe('#00d4ff'); expect(linkColor('paused')).toBe('#fbbf24'); expect(linkColor('degraded')).toBe('#fb923c'); expect(linkColor('down')).toBe('#f43f5e'); expect(linkColor('???')).toBe('#4a5572'); }); it('labels a dead worker offline', () => { expect(workerStateLabel({ alive: false })).toBe('오프라인'); expect(workerStateLabel(null)).toBe('오프라인'); }); it('labels alive workers by state', () => { expect(workerStateLabel({ alive: true, state: 'idle' })).toBe('대기'); expect(workerStateLabel({ alive: true, state: 'busy' })).toBe('처리 중'); expect(workerStateLabel({ alive: true, state: 'paused' })).toBe('일시정지'); expect(workerStateLabel({ alive: true, state: 'market_open' })).toBe('장중'); }); it('derives worker status with dead-letter and paused precedence', () => { expect(workerStatus({ alive: false })).toBe('down'); expect(workerStatus({ alive: true, state: 'paused' })).toBe('paused'); expect(workerStatus({ alive: true, state: 'idle', dead_letter: 3 })).toBe('degraded'); expect(workerStatus({ alive: true, state: 'idle', dead_letter: 0 })).toBe('healthy'); }); it('workerColor follows workerStatus', () => { expect(workerColor({ alive: false })).toBe('#f43f5e'); expect(workerColor({ alive: true, state: 'idle' })).toBe('#00d4ff'); }); it('humanizes worker names', () => { expect(workerTitle('insta-render')).toBe('Insta Render'); expect(workerTitle('ai_trade')).toBe('AI Trade'); expect(workerTitle('unknown-x')).toBe('unknown-x'); }); });