import React from 'react'; import { describe, expect, it, vi } from 'vitest'; import { render, screen } from '@testing-library/react'; const navigateMock = vi.fn(); const selectEventMock = vi.fn(); const refetchMock = vi.fn(); const activeEventMock = { slug: 'demo-event', settings: { guest_upload_visibility: 'review', control_room: {} } }; vi.mock('react-router-dom', () => ({ useNavigate: () => navigateMock, useLocation: () => ({ search: '', pathname: '/event-admin/mobile/events/demo-event/control-room' }), useParams: () => ({ slug: 'demo-event' }), })); const tMock = (key: string, fallback?: string | Record, options?: Record) => { if (typeof fallback === 'string') { return fallback; } if (fallback && typeof fallback === 'object' && typeof fallback.defaultValue === 'string') { return fallback.defaultValue; } if (options?.defaultValue) { return String(options.defaultValue); } return key; }; vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: tMock, }), })); vi.mock('../../auth/context', () => ({ useAuth: () => ({ user: { role: 'tenant_admin' } }), })); vi.mock('../../context/EventContext', () => ({ useEventContext: () => ({ activeEvent: activeEventMock, selectEvent: selectEventMock, refetch: refetchMock, }), })); vi.mock('../hooks/useOnlineStatus', () => ({ useOnlineStatus: () => true, })); vi.mock('../hooks/useBackNavigation', () => ({ useBackNavigation: () => undefined, })); vi.mock('../components/MobileShell', () => ({ MobileShell: ({ children }: { children: React.ReactNode }) =>
{children}
, HeaderActionButton: ({ children }: { children: React.ReactNode }) =>
{children}
, })); vi.mock('../components/Primitives', () => ({ MobileCard: ({ children }: { children: React.ReactNode }) =>
{children}
, CTAButton: ({ label, onPress }: { label: string; onPress?: () => void }) => ( ), SkeletonCard: () =>
Loading...
, ContentTabs: ({ header, tabs }: { header?: React.ReactNode; tabs: Array<{ value: string; content: React.ReactNode }> }) => (
{header} {tabs.map((tab) => (
{tab.content}
))}
), })); vi.mock('../components/FormControls', () => ({ MobileField: ({ label, children }: { label: string; children: React.ReactNode }) => ( ), MobileSelect: (props: React.SelectHTMLAttributes) =>