import React from 'react'; import { describe, expect, it, vi } from 'vitest'; import { render, screen } from '@testing-library/react'; const navigateMock = vi.fn(); vi.mock('react-router-dom', () => ({ useNavigate: () => navigateMock, useParams: () => ({}), useLocation: () => ({ search: '' }), })); vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string, fallback?: string | Record) => { if (typeof fallback === 'string') { return fallback; } if (fallback && typeof fallback === 'object' && typeof fallback.defaultValue === 'string') { return fallback.defaultValue; } return key; }, }), })); vi.mock('../../api', () => ({ listNotificationLogs: vi.fn().mockResolvedValue([]), markNotificationLogs: vi.fn(), getEvents: vi.fn().mockResolvedValue([]), })); vi.mock('../../auth/tokens', () => ({ isAuthError: () => false, })); vi.mock('../../lib/apiError', () => ({ getApiErrorMessage: () => 'error', })); vi.mock('../lib/notificationGrouping', () => ({ groupNotificationsByScope: () => [], })); vi.mock('../lib/notificationUnread', () => ({ collectUnreadIds: () => [], })); vi.mock('../lib/relativeTime', () => ({ formatRelativeTime: () => 'now', })); vi.mock('../lib/haptics', () => ({ triggerHaptic: () => undefined, })); vi.mock('../hooks/useBackNavigation', () => ({ useBackNavigation: () => undefined, })); vi.mock('framer-motion', () => ({ motion: { div: ({ children }: { children: React.ReactNode }) =>
{children}
, }, useAnimationControls: () => ({ start: vi.fn() }), })); vi.mock('@tamagui/react-native-web-lite', () => ({ Pressable: ({ children, onPress }: { children: React.ReactNode; onPress?: () => void }) => ( ), })); 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('../components/MobileShell', () => ({ MobileShell: ({ children }: { children: React.ReactNode }) =>
{children}
, HeaderActionButton: ({ children }: { children: React.ReactNode }) =>
{children}
, })); vi.mock('../components/Primitives', () => ({ MobileCard: ({ children }: { children: React.ReactNode }) =>
{children}
, PillBadge: ({ children }: { children: React.ReactNode }) =>
{children}
, SkeletonCard: () =>
Loading...
, CTAButton: ({ label }: { label: string }) => , })); vi.mock('../components/FormControls', () => ({ MobileSelect: ({ children }: { children: React.ReactNode }) => , })); vi.mock('../components/Sheet', () => ({ MobileSheet: ({ children }: { children: React.ReactNode }) =>
{children}
, })); vi.mock('../theme', () => ({ useAdminTheme: () => ({ textStrong: '#111827', text: '#111827', muted: '#6b7280', subtle: '#94a3b8', border: '#e5e7eb', primary: '#ff5a5f', danger: '#dc2626', successBg: '#dcfce7', successText: '#166534', infoBg: '#e0e7ff', infoText: '#3730a3', }), })); import MobileNotificationsPage from '../NotificationsPage'; describe('MobileNotificationsPage', () => { it('shows empty state when no notifications are available', async () => { render(); expect(await screen.findByText('All caught up')).toBeInTheDocument(); }); });