import { describe, it, expect, vi, beforeEach } from 'vitest'
import { mount } from '@vue/test-utils'
import { createPinia, setActivePinia } from 'pinia'

vi.mock('@/api/acp', () => ({
  acpApi: {
    sessions: {
      list: vi.fn().mockResolvedValue([]),
      get: vi.fn(),
      create: vi.fn(),
      terminate: vi.fn(),
      events: vi.fn(),
    },
    agentKinds: {
      list: vi.fn().mockResolvedValue([]),
      get: vi.fn(),
      create: vi.fn(),
      update: vi.fn(),
      remove: vi.fn(),
    },
  },
  isAgentKindAdmin: () => false,
}))

vi.mock('vue-router', () => ({
  useRoute: () => ({ params: { slug: 'p', wsSlug: 'w' } }),
  useRouter: () => ({ push: vi.fn() }),
}))

import AcpSessionListView from './AcpSessionListView.vue'

beforeEach(() => {
  setActivePinia(createPinia())
})

describe('AcpSessionListView', () => {
  it('mounts without error and shows empty state', async () => {
    const wrapper = mount(AcpSessionListView)
    await new Promise((r) => setTimeout(r, 20))
    const html = wrapper.html()
    expect(html).toContain('ACP Sessions')
    expect(html).toContain('No sessions yet')
  })
})
