// @vitest-environment happy-dom
import { describe, it, expect } from 'vitest'

import QueueStatusBar from '../../src/components/settings/QueueStatusBar.vue'
import { useSystemActivityStore } from '../../src/stores/systemActivity.js'
import { freshPinia, mountComponent } from '../support/mountComponent.js'

describe('QueueStatusBar', () => {
  it('shows the pending count when the queue is busy', () => {
    const pinia = freshPinia()
    useSystemActivityStore().queues = { queues: { ml: 3 }, fetched_at: '' }
    const w = mountComponent(QueueStatusBar, {
      props: { queue: 'ml', queueLabel: 'ML' }, pinia,
    })
    expect(w.text()).toContain('3 pending')
  })

  it('reads idle when the queue is empty', () => {
    const pinia = freshPinia()
    useSystemActivityStore().queues = { queues: { ml: 0 }, fetched_at: '' }
    const w = mountComponent(QueueStatusBar, {
      props: { queue: 'ml', queueLabel: 'ML' }, pinia,
    })
    expect(w.text().toLowerCase()).toContain('idle')
  })
})
