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 }) =>
{children}
, XStack: ({ children }: { children: React.ReactNode }) =>
{children}
, })); vi.mock('@tamagui/text', () => ({ SizableText: ({ children }: { children: React.ReactNode }) => {children}, })); vi.mock('@tamagui/button', () => ({ Button: ({ children, ...rest }: { children: React.ReactNode }) => ( ), })); vi.mock('lucide-react', () => ({ Camera: () => camera, Sparkles: () => sparkles, Image: () => image, Star: () => star, Trophy: () => trophy, })); vi.mock('../components/AppShell', () => ({ default: ({ children }: { children: React.ReactNode }) =>
{children}
, })); vi.mock('../services/uploadApi', () => ({ useUploadQueue: () => ({ items: [], loading: false, refresh: vi.fn() }), })); vi.mock('../services/tasksApi', () => ({ fetchTasks: vi.fn().mockResolvedValue([ { id: 12, title: 'Capture the dancefloor', description: 'Find the happiest crew.', instructions: 'Look for the brightest smiles.', duration: 5, emotion: { slug: 'freude', name: 'Joy' }, }, ]), })); vi.mock('../services/emotionsApi', () => ({ fetchEmotions: vi.fn().mockResolvedValue([{ slug: 'freude', name: 'Joy' }]), })); vi.mock('../services/photosApi', () => ({ fetchGallery: vi.fn().mockResolvedValue({ data: [] }), })); vi.mock('@/guest/i18n/useTranslation', () => ({ useTranslation: () => ({ t: (key: string, fallback?: string) => fallback ?? key, locale: 'de' }), })); vi.mock('@/guest/i18n/LocaleContext', () => ({ useLocale: () => ({ locale: 'de' }), })); vi.mock('@/hooks/use-appearance', () => ({ useAppearance: () => ({ resolved: 'light' }), })); vi.mock('@/guest/hooks/useGuestTaskProgress', () => ({ useGuestTaskProgress: () => ({ isCompleted: () => false }), })); import HomeScreen from '../screens/HomeScreen'; describe('HomeScreen', () => { it('shows task hero content when tasks are enabled', async () => { render( ); expect(await screen.findByText('Capture the dancefloor')).toBeInTheDocument(); expect(screen.getByText("Let's go!")).toBeInTheDocument(); }); it('shows capture-ready content when tasks are disabled', () => { render( ); expect(screen.getByText('Capture ready')).toBeInTheDocument(); expect(screen.getByText('Upload / Take photo')).toBeInTheDocument(); }); });