import { describe, it, expect, beforeEach } from 'vitest'
import { screen, waitFor } from '@testing-library/react'
import { renderWithProviders } from '@/test/utils'
import { ImportPage } from '@/pages/ImportPage'

describe('ImportPage', () => {
  beforeEach(() => {
    localStorage.setItem('access_token', 'test-token')
  })

  it('renders the page title', async () => {
    renderWithProviders(<ImportPage />, { initialRoute: '/import' })

    await waitFor(() => {
      expect(screen.getByText('Import')).toBeInTheDocument()
    })
  })

  it('shows CSV and ICD import tabs', async () => {
    renderWithProviders(<ImportPage />, { initialRoute: '/import' })

    await waitFor(() => {
      expect(screen.getByText('CSV-Import')).toBeInTheDocument()
    })

    expect(screen.getByText('ICD-Import')).toBeInTheDocument()
    expect(screen.getByText('Import-Verlauf')).toBeInTheDocument()
  })

  it('shows the CSV upload drop zone by default', async () => {
    renderWithProviders(<ImportPage />, { initialRoute: '/import' })

    await waitFor(() => {
      expect(screen.getByText('CSV-Datei hierhin ziehen')).toBeInTheDocument()
    })

    expect(screen.getByText('oder klicken zum Auswählen')).toBeInTheDocument()
  })
})
