import { describe, expect, it } from 'vitest'
import type { StateResponse } from './collector-types'
import { sidebarBadgesFromState } from './sidebar-badges'

describe('sidebarBadgesFromState', () => {
  it('uses the live bot fleet count instead of static mockup values', () => {
    const state: StateResponse = {
      panels: [{
        id: 'bots',
        ts: '2026-08-04T00:00:00.000Z',
        data: {
          bots: [
            { id: 'a', name: 'HetziBot', status: 'down', messages24h: 0, errors: null, cost: null },
            { id: 'b', name: 'ZyncBot', status: 'live', messages24h: 3, errors: 0, cost: 1.2 },
          ],
        },
      }],
      adapters: [],
    }

    expect(sidebarBadgesFromState(state)['/bots']).toEqual({ label: '2', hot: true })
  })

  it('derives inbox and decision badges from collector items', () => {
    const state: StateResponse = { panels: [], adapters: [] }
    const items = [
      { kind: 'decision' },
      { kind: 'alert' },
    ] as Parameters<typeof sidebarBadgesFromState>[1]

    const badges = sidebarBadgesFromState(state, items)
    expect(badges['/inbox']).toEqual({ label: '2', hot: true })
    expect(badges['/decisions']).toEqual({ label: '1', hot: true })
  })
})
