import React from 'react'; import { describe, expect, it, vi } from 'vitest'; import { render, screen } from '@testing-library/react'; const logoutMock = vi.fn(); const navigateMock = vi.fn(); vi.mock('react-router-dom', () => ({ useNavigate: () => navigateMock, })); 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('../../i18n', () => ({ default: { language: 'de', changeLanguage: vi.fn(), }, })); vi.mock('../../auth/context', () => ({ useAuth: () => ({ user: { name: 'Demo User', email: 'demo@example.com', role: 'tenant_admin' }, logout: logoutMock, }), })); vi.mock('../../api', () => ({ fetchTenantProfile: vi.fn().mockResolvedValue({ name: 'Demo User', email: 'demo@example.com', role: 'tenant_admin', }), })); vi.mock('@/hooks/use-appearance', () => ({ useAppearance: () => ({ appearance: 'system', updateAppearance: vi.fn(), }), })); vi.mock('../hooks/useBackNavigation', () => ({ useBackNavigation: () => undefined, })); vi.mock('@tamagui/avatar', () => ({ Avatar: Object.assign(({ children }: { children: React.ReactNode }) =>
{children}
, { Fallback: ({ children }: { children: React.ReactNode }) =>
{children}
, }), })); vi.mock('@tamagui/card', () => ({ Card: ({ children }: { children: React.ReactNode }) =>
{children}
, })); vi.mock('@tamagui/group', () => ({ YGroup: Object.assign(({ children }: { children: React.ReactNode }) =>
{children}
, { Item: ({ children }: { children: React.ReactNode }) =>
{children}
, }), })); vi.mock('@tamagui/list-item', () => ({ ListItem: ({ title, iconAfter }: { title?: React.ReactNode; iconAfter?: React.ReactNode }) => (
{title} {iconAfter}
), })); 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}
, })); vi.mock('../components/Primitives', () => ({ CTAButton: ({ label }: { label: string }) => , })); vi.mock('../components/FormControls', () => ({ MobileSelect: ({ children }: { children: React.ReactNode }) => , })); vi.mock('../components/colors', () => ({ withAlpha: (color: string) => color, })); vi.mock('../theme', () => ({ useAdminTheme: () => ({ textStrong: '#111827', muted: '#6b7280', border: '#e5e7eb', accentSoft: '#eef2ff', primary: '#ff5a5f', subtle: '#94a3b8', surface: '#ffffff', surfaceMuted: '#f9fafb', shadow: 'rgba(15,23,42,0.12)', danger: '#dc2626', }), })); import MobileProfilePage from '../ProfilePage'; describe('MobileProfilePage', () => { it('renders settings and preferences sections', async () => { render(); expect(await screen.findByText('Settings')).toBeInTheDocument(); expect(screen.getByText('Preferences')).toBeInTheDocument(); expect(screen.getByText('Log out')).toBeInTheDocument(); }); });