import { describe, it, expect } from 'vitest'
import { setActivePinia, createPinia } from 'pinia'
import { useOperationsStore } from '../src/stores/operations'

describe('operations store', () => {
  it('initializes with safe fallback structure', () => {
    setActivePinia(createPinia())
    const store = useOperationsStore()
    // Fallback provides a valid structure even when API is down
    expect(store.snapshot).toBeDefined()
    expect(store.snapshot.runtime.runtime).toBe('OpenClaw')
    expect(store.snapshot.metrics).toBeDefined()
    expect(Array.isArray(store.snapshot.projects)).toBe(true)
    expect(Array.isArray(store.snapshot.tasks)).toBe(true)
    expect(Array.isArray(store.snapshot.activity)).toBe(true)
    expect(Array.isArray(store.snapshot.models)).toBe(true)
  })

  it('initializes routing as empty array', () => {
    setActivePinia(createPinia())
    const store = useOperationsStore()
    expect(Array.isArray(store.routing)).toBe(true)
    expect(store.routing.length).toBe(0)
  })
})
