import React from 'react'; import { describe, expect, it, vi } from 'vitest'; import { render, screen } from '@testing-library/react'; const useEventDataMock = vi.fn(); vi.mock('react-router-dom', () => ({ useNavigate: () => vi.fn(), })); vi.mock('../context/EventDataContext', () => ({ useEventData: () => useEventDataMock(), })); 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, Timer: () => timer, RefreshCw: () => refresh, Trophy: () => trophy, X: () => x, })); vi.mock('../components/AppShell', () => ({ default: ({ children }: { children: React.ReactNode }) =>
{children}
, })); vi.mock('../components/TaskHeroCard', () => ({ default: ({ task }: { task: { title?: string } | null }) => (
{task?.title} Let's go!
), })); vi.mock('../components/PhotoFrameTile', () => ({ default: ({ children }: { children: React.ReactNode }) =>
{children}
, })); vi.mock('@/guest/context/EventBrandingContext', () => ({ useEventBranding: () => ({ branding: { welcomeMessage: '' }, isCustom: false, }), useOptionalEventBranding: () => ({ branding: { welcomeMessage: '' }, isCustom: false, }), })); 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: [] }), })); const translate = (key: string, fallback?: string) => fallback ?? key; vi.mock('@/guest/i18n/useTranslation', () => ({ useTranslation: () => ({ t: translate, locale: 'de' }), })); vi.mock('@/guest/i18n/LocaleContext', () => ({ useLocale: () => ({ locale: 'de' }), })); vi.mock('../hooks/usePollStats', () => ({ usePollStats: () => ({ stats: { onlineGuests: 0, tasksSolved: 0, guestCount: 0, likesCount: 0, latestPhotoAt: null }, }), })); vi.mock('../lib/useStaggeredReveal', () => ({ useStaggeredReveal: () => 5, })); 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 () => { useEventDataMock.mockReturnValue({ tasksEnabled: true, token: 'demo', event: { name: 'Demo Event' }, }); 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', () => { useEventDataMock.mockReturnValue({ tasksEnabled: false, token: 'demo', event: { name: 'Demo Event' }, }); render(); expect(screen.getByText('Capture ready')).toBeInTheDocument(); expect(screen.getByText('Upload / Take photo')).toBeInTheDocument(); }); });