import { render, screen } from '@testing-library/react'
import { describe, it, expect, vi, beforeEach } from 'vitest'
import { App } from './App'

vi.mock('./api', () => ({
  api: {
    getPosts: vi.fn().mockResolvedValue([]),
    getSettings: vi.fn().mockResolvedValue({ api_url: '', api_key: '', connected: false }),
  },
}))

describe('App', () => {
  beforeEach(() => {
    vi.clearAllMocks()
  })

  it('renders the title', async () => {
    render(<App />)
    expect(await screen.findByText('Supan Content')).toBeInTheDocument()
  })

  it('renders all five tabs', async () => {
    render(<App />)
    await screen.findByText('Supan Content')
    expect(screen.getByText('Link Graph')).toBeInTheDocument()
    expect(screen.getByText('Suggestions')).toBeInTheDocument()
    expect(screen.getByText('clusters')).toBeInTheDocument()
    expect(screen.getByText('duplicates')).toBeInTheDocument()
    expect(screen.getByText('settings')).toBeInTheDocument()
  })
})
