import React from 'react';
import { describe, expect, it, vi } from 'vitest';
import { render, screen } from '@testing-library/react';
import { LocaleProvider } from '@/guest/i18n/LocaleContext';

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('@tamagui/input', () => ({
  Input: ({ ...rest }: { [key: string]: unknown }) => <input {...rest} />,
}));

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

vi.mock('html5-qrcode', () => ({
  Html5Qrcode: vi.fn().mockImplementation(() => ({
    start: vi.fn(),
    stop: vi.fn(),
  })),
}));

vi.mock('lucide-react', () => ({
  QrCode: () => <span>qr</span>,
  ArrowRight: () => <span>arrow</span>,
}));

import LandingScreen from '../screens/LandingScreen';

describe('LandingScreen', () => {
  it('renders join panel copy', () => {
    render(
      <LocaleProvider>
        <LandingScreen />
      </LocaleProvider>
    );

    expect(screen.getByRole('button', { name: 'Event beitreten' })).toBeInTheDocument();
    expect(screen.getAllByText('Event beitreten').length).toBeGreaterThan(1);
    expect(screen.getByPlaceholderText('Event-Code eingeben')).toBeInTheDocument();
  });
});
