import * as React from 'react';
import { describe, it, expect, vi } from 'vitest';
import { render } from '@testing-library/react';
import { AISearchResults } from './AISearchResults';

// Mock lucide-react
vi.mock('lucide-react', () => ({
  ArrowUp: () => <div data-testid="arrow-up" />,
  X: () => <div data-testid="close-icon" />,
  Sparkles: () => <div data-testid="sparkles" />,
  ChevronRight: () => <div data-testid="chevron-right" />,
  RotateCcw: () => <div data-testid="rotate-ccw" />,
  Copy: () => <div data-testid="copy" />,
  Check: () => <div data-testid="check" />,
}));

// Mock next/link
vi.mock('next/link', () => ({
  default: ({ children, href }: any) => <a href={href}>{children}</a>,
}));

// Mock useAnalytics
vi.mock('../analytics/useAnalytics', () => ({
  useAnalytics: () => ({
    trackEvent: vi.fn(),
  }),
}));

// Mock react-markdown
vi.mock('react-markdown', () => ({
  default: ({ children }: any) => <div>{children}</div>,
}));

// Mock remark-gfm
vi.mock('remark-gfm', () => ({
  default: {},
}));

// Mock next-intl
vi.mock('next-intl', () => ({
  useTranslations: () => {
    const translate = (key: string) => key;
    translate.raw = (key: string) => {
      if (key === 'loadingTexts') return ['Lade...', 'Denke nach...'];
      if (key === 'prompts') return ['Prompt 1', 'Prompt 2'];
      return [];
    };
    return translate;
  },
  useLocale: () => 'en',
}));

describe('AISearchResults Component Test (TDD)', () => {
  it('renders correctly when open', () => {
    const handleClose = vi.fn();
    const { container } = render(
      <AISearchResults isOpen={true} onClose={handleClose} />
    );
    expect(container).toBeTruthy();
  });
});
