import React from 'react';
import { describe, expect, it, vi } from 'vitest';
import { render, screen } from '@testing-library/react';
import { EventDataProvider } from '../context/EventDataContext';

vi.mock('react-router-dom', () => ({
  useNavigate: () => vi.fn(),
}));

vi.mock('@tamagui/stacks', () => ({
  YStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
  XStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));

vi.mock('@tamagui/text', () => ({
  SizableText: ({ children }: { children: React.ReactNode }) => <span>{children}</span>,
}));

vi.mock('@tamagui/button', () => ({
  Button: ({ children, ...rest }: { children: React.ReactNode }) => (
    <button type="button" {...rest}>
      {children}
    </button>
  ),
}));

vi.mock('lucide-react', () => ({
  Camera: () => <span>camera</span>,
  Sparkles: () => <span>sparkles</span>,
  Image: () => <span>image</span>,
  Star: () => <span>star</span>,
  Trophy: () => <span>trophy</span>,
}));

vi.mock('../components/AppShell', () => ({
  default: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));

vi.mock('../services/uploadApi', () => ({
  useUploadQueue: () => ({ items: [], loading: false, refresh: vi.fn() }),
}));

vi.mock('@/guest/i18n/useTranslation', () => ({
  useTranslation: () => ({ t: (key: string, fallback?: string) => fallback ?? key, locale: 'de' }),
}));

vi.mock('@/hooks/use-appearance', () => ({
  useAppearance: () => ({ resolved: 'light' }),
}));

import HomeScreen from '../screens/HomeScreen';

describe('HomeScreen', () => {
  it('shows prompt quest content when tasks are enabled', () => {
    render(
      <EventDataProvider tasksEnabledFallback>
        <HomeScreen />
      </EventDataProvider>
    );

    expect(screen.getByText('Prompt quest')).toBeInTheDocument();
    expect(screen.getByText('Start prompt')).toBeInTheDocument();
  });

  it('shows capture-ready content when tasks are disabled', () => {
    render(
      <EventDataProvider tasksEnabledFallback={false}>
        <HomeScreen />
      </EventDataProvider>
    );

    expect(screen.getByText('Capture ready')).toBeInTheDocument();
    expect(screen.getByText('Upload / Take photo')).toBeInTheDocument();
  });
});
