Fix auth translations and admin PWA UI
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled

This commit is contained in:
Codex Agent
2026-01-16 12:14:53 +01:00
parent 292c8f0b26
commit 918bff08aa
44 changed files with 2504 additions and 677 deletions

View File

@@ -0,0 +1,69 @@
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,
}));
vi.mock('react-i18next', () => ({
useTranslation: () => ({
t: (key: string, fallback?: string | Record<string, unknown>) => {
if (typeof fallback === 'string') {
return fallback;
}
if (fallback && typeof fallback === 'object' && typeof fallback.defaultValue === 'string') {
return fallback.defaultValue;
}
return key;
},
}),
}));
vi.mock('../../auth/context', () => ({
useAuth: () => ({ status: 'loading' }),
}));
vi.mock('../../lib/returnTo', () => ({
decodeReturnTo: () => null,
resolveReturnTarget: () => ({ finalTarget: '/event-admin/mobile/dashboard' }),
}));
vi.mock('@tamagui/card', () => ({
Card: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
vi.mock('@tamagui/stacks', () => ({
YStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
vi.mock('@tamagui/text', () => ({
SizableText: ({ children }: { children: React.ReactNode }) => <span>{children}</span>,
}));
vi.mock('tamagui', () => ({
Spinner: () => <div>spinner</div>,
}));
vi.mock('../theme', () => ({
useAdminTheme: () => ({
textStrong: '#111827',
muted: '#6b7280',
border: '#e5e7eb',
surface: '#ffffff',
shadow: 'rgba(15,23,42,0.12)',
appBackground: 'linear-gradient(180deg, #fff, #f8fafc)',
}),
}));
import AuthCallbackPage from '../AuthCallbackPage';
describe('AuthCallbackPage', () => {
it('renders the processing message', () => {
render(<AuthCallbackPage />);
expect(screen.getByText('Signing you in …')).toBeInTheDocument();
});
});

View File

@@ -38,6 +38,21 @@ vi.mock('../components/Primitives', () => ({
SkeletonCard: () => <div>Loading...</div>,
}));
vi.mock('../components/FormControls', () => ({
MobileField: ({ label, children }: { label: string; children: React.ReactNode }) => (
<div>
<span>{label}</span>
{children}
</div>
),
MobileColorInput: (props: React.InputHTMLAttributes<HTMLInputElement>) => <input {...props} />,
MobileFileInput: (props: React.InputHTMLAttributes<HTMLInputElement>) => <input {...props} />,
MobileInput: (props: React.InputHTMLAttributes<HTMLInputElement>) => <input {...props} />,
MobileSelect: ({ children, ...props }: React.SelectHTMLAttributes<HTMLSelectElement>) => (
<select {...props}>{children}</select>
),
}));
vi.mock('../components/Sheet', () => ({
MobileSheet: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));

View File

@@ -45,6 +45,7 @@ vi.mock('../components/Primitives', () => ({
vi.mock('../components/FormControls', () => ({
MobileField: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
MobileDateTimeInput: (props: React.InputHTMLAttributes<HTMLInputElement>) => <input {...props} />,
MobileInput: (props: React.InputHTMLAttributes<HTMLInputElement>) => <input {...props} />,
MobileSelect: ({ children, ...props }: { children: React.ReactNode }) => <select {...props}>{children}</select>,
MobileTextArea: (props: React.TextareaHTMLAttributes<HTMLTextAreaElement>) => <textarea {...props} />,

View File

@@ -0,0 +1,117 @@
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: () => ({ slug: 'demo-event' }),
}));
vi.mock('react-i18next', () => ({
useTranslation: () => ({
t: (key: string, fallback?: string | Record<string, unknown>) => {
if (typeof fallback === 'string') {
return fallback;
}
if (fallback && typeof fallback === 'object' && typeof fallback.defaultValue === 'string') {
return fallback.defaultValue;
}
return key;
},
i18n: { language: 'de' },
}),
}));
vi.mock('../../context/EventContext', () => ({
useEventContext: () => ({
activeEvent: { slug: 'demo-event' },
selectEvent: vi.fn(),
}),
}));
vi.mock('../../api', () => ({
getEvents: vi.fn().mockResolvedValue([]),
listGuestNotifications: vi.fn().mockResolvedValue([]),
sendGuestNotification: vi.fn(),
}));
vi.mock('react-hot-toast', () => ({
default: {
error: vi.fn(),
success: vi.fn(),
},
}));
vi.mock('../../auth/tokens', () => ({
isAuthError: () => false,
}));
vi.mock('../../lib/apiError', () => ({
getApiErrorMessage: () => 'error',
}));
vi.mock('../guestMessages', () => ({
formatGuestMessageDate: () => '19. Feb. 2026',
}));
vi.mock('../hooks/useBackNavigation', () => ({
useBackNavigation: () => undefined,
}));
vi.mock('../components/MobileShell', () => ({
MobileShell: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
HeaderActionButton: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
vi.mock('../components/Primitives', () => ({
MobileCard: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
CTAButton: ({ label }: { label: string }) => <button type="button">{label}</button>,
PillBadge: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
SkeletonCard: () => <div>Loading...</div>,
}));
vi.mock('../components/FormControls', () => ({
MobileField: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
MobileInput: (props: React.InputHTMLAttributes<HTMLInputElement>) => <input {...props} />,
MobileSelect: ({ children }: { children: React.ReactNode }) => <select>{children}</select>,
MobileTextArea: (props: React.TextareaHTMLAttributes<HTMLTextAreaElement>) => <textarea {...props} />,
}));
vi.mock('@tamagui/react-native-web-lite', () => ({
Pressable: ({ children, onPress }: { children: React.ReactNode; onPress?: () => void }) => (
<button type="button" onClick={onPress}>
{children}
</button>
),
}));
vi.mock('@tamagui/stacks', () => ({
YStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
XStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
vi.mock('@tamagui/text', () => ({
SizableText: ({ children }: { children: React.ReactNode }) => <span>{children}</span>,
}));
vi.mock('../theme', () => ({
useAdminTheme: () => ({
textStrong: '#111827',
text: '#111827',
muted: '#6b7280',
border: '#e5e7eb',
danger: '#dc2626',
}),
}));
import MobileEventGuestNotificationsPage from '../EventGuestNotificationsPage';
describe('MobileEventGuestNotificationsPage', () => {
it('renders the compose section', async () => {
render(<MobileEventGuestNotificationsPage />);
expect(await screen.findByText('Send a message')).toBeInTheDocument();
});
});

View File

@@ -0,0 +1,143 @@
import React from 'react';
import { describe, expect, it, vi } from 'vitest';
import { render, screen } from '@testing-library/react';
const fixtures = vi.hoisted(() => ({
event: {
id: 1,
name: 'Demo Event',
slug: 'demo-event',
event_date: '2026-02-19',
status: 'published',
settings: {
guest_downloads_enabled: true,
guest_sharing_enabled: false,
},
},
stats: {
photo_count: 12,
like_count: 3,
pending_count: 1,
guest_count: 22,
},
invites: [],
addons: [],
}));
vi.mock('react-router-dom', () => ({
useNavigate: () => vi.fn(),
useParams: () => ({ slug: fixtures.event.slug }),
}));
vi.mock('react-i18next', () => ({
useTranslation: () => ({
t: (key: string, fallback?: string | Record<string, unknown>) => {
if (typeof fallback === 'string') {
return fallback;
}
if (fallback && typeof fallback === 'object' && typeof fallback.defaultValue === 'string') {
return fallback.defaultValue;
}
return key;
},
}),
}));
vi.mock('../hooks/useBackNavigation', () => ({
useBackNavigation: () => undefined,
}));
vi.mock('../../api', () => ({
getEvent: vi.fn().mockResolvedValue(fixtures.event),
getEventStats: vi.fn().mockResolvedValue(fixtures.stats),
getEventQrInvites: vi.fn().mockResolvedValue(fixtures.invites),
getAddonCatalog: vi.fn().mockResolvedValue(fixtures.addons),
updateEvent: vi.fn().mockResolvedValue(fixtures.event),
createEventAddonCheckout: vi.fn(),
}));
vi.mock('../../auth/tokens', () => ({
isAuthError: () => false,
}));
vi.mock('../../lib/apiError', () => ({
getApiErrorMessage: () => 'error',
}));
vi.mock('../components/MobileShell', () => ({
MobileShell: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
HeaderActionButton: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
vi.mock('../components/Primitives', () => ({
MobileCard: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
CTAButton: ({ label }: { label: string }) => <button type="button">{label}</button>,
PillBadge: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
SkeletonCard: () => <div>Loading...</div>,
}));
vi.mock('../components/LegalConsentSheet', () => ({
LegalConsentSheet: () => <div />,
}));
vi.mock('@tamagui/stacks', () => ({
YStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
XStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
vi.mock('@tamagui/text', () => ({
SizableText: ({ children }: { children: React.ReactNode }) => <span>{children}</span>,
}));
vi.mock('@tamagui/react-native-web-lite', () => ({
Pressable: ({ children, onPress }: { children: React.ReactNode; onPress?: () => void }) => (
<button type="button" onClick={onPress}>
{children}
</button>
),
}));
vi.mock('@tamagui/switch', () => ({
Switch: Object.assign(
({ children, checked, onCheckedChange, 'aria-label': ariaLabel }: any) => (
<label>
<input
type="checkbox"
aria-label={ariaLabel}
checked={checked}
onChange={(event) => onCheckedChange?.(event.target.checked)}
/>
{children}
</label>
),
{ Thumb: () => <span /> },
),
}));
vi.mock('../theme', () => ({
useAdminTheme: () => ({
text: '#111827',
muted: '#6b7280',
subtle: '#94a3b8',
border: '#e5e7eb',
primary: '#ff5a5f',
successText: '#16a34a',
danger: '#dc2626',
surface: '#ffffff',
surfaceMuted: '#f9fafb',
accentSoft: '#eef2ff',
textStrong: '#0f172a',
}),
}));
import MobileEventRecapPage from '../EventRecapPage';
describe('MobileEventRecapPage', () => {
it('renders recap settings toggles', async () => {
render(<MobileEventRecapPage />);
expect(await screen.findByText('Nachlauf-Optionen')).toBeInTheDocument();
expect(screen.getByLabelText('Gäste dürfen Fotos laden')).toBeInTheDocument();
expect(screen.getByLabelText('Gäste dürfen Fotos teilen')).toBeInTheDocument();
});
});

View File

@@ -89,6 +89,12 @@ vi.mock('@tamagui/scroll-view', () => ({
ScrollView: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
vi.mock('@tamagui/toggle-group', () => ({
ToggleGroup: Object.assign(({ children }: { children: React.ReactNode }) => <div>{children}</div>, {
Item: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}),
}));
vi.mock('@tamagui/group', () => ({
YGroup: Object.assign(({ children }: { children: React.ReactNode }) => <div>{children}</div>, {
Item: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,

View File

@@ -0,0 +1,136 @@
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,
}));
vi.mock('react-i18next', () => ({
useTranslation: () => ({
t: (key: string, fallback?: string | Record<string, unknown>) => {
if (typeof fallback === 'string') {
return fallback;
}
if (fallback && typeof fallback === 'object' && typeof fallback.defaultValue === 'string') {
return fallback.defaultValue;
}
return key;
},
}),
}));
vi.mock('../../api', () => ({
getEvents: vi.fn().mockResolvedValue([
{
id: 1,
name: 'Demo Event',
slug: 'demo-event',
event_date: '2026-02-19',
settings: {},
},
]),
}));
vi.mock('../../auth/tokens', () => ({
isAuthError: () => false,
}));
vi.mock('../../lib/apiError', () => ({
getApiErrorMessage: () => 'error',
}));
vi.mock('../../lib/eventFilters', () => ({
buildEventStatusCounts: () => ({ all: 1, upcoming: 1, draft: 0, past: 0 }),
filterEventsByStatus: (events: any[]) => events,
resolveEventStatusKey: () => 'upcoming',
}));
vi.mock('../../lib/eventListStats', () => ({
buildEventListStats: () => ({ photos: 2, guests: 3, tasks: 4 }),
}));
vi.mock('../hooks/useBackNavigation', () => ({
useBackNavigation: () => undefined,
}));
vi.mock('../components/MobileShell', () => ({
MobileShell: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
HeaderActionButton: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
vi.mock('../components/Primitives', () => ({
PillBadge: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
CTAButton: ({ label }: { label: string }) => <button type="button">{label}</button>,
FloatingActionButton: ({ label }: { label: string }) => <div>{label}</div>,
SkeletonCard: () => <div>Loading...</div>,
}));
vi.mock('../components/FormControls', () => ({
MobileInput: (props: React.InputHTMLAttributes<HTMLInputElement>) => <input {...props} />,
}));
vi.mock('@tamagui/card', () => ({
Card: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
vi.mock('@tamagui/scroll-view', () => ({
ScrollView: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
vi.mock('@tamagui/react-native-web-lite', () => ({
Pressable: ({ children, onPress }: { children: React.ReactNode; onPress?: () => void }) => (
<button type="button" onClick={onPress}>
{children}
</button>
),
}));
vi.mock('@tamagui/toggle-group', () => ({
ToggleGroup: Object.assign(({ children }: { children: React.ReactNode }) => <div>{children}</div>, {
Item: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}),
}));
vi.mock('@tamagui/separator', () => ({
Separator: () => <div />,
}));
vi.mock('@tamagui/stacks', () => ({
YStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
XStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
vi.mock('@tamagui/text', () => ({
SizableText: ({ children }: { children: React.ReactNode }) => <span>{children}</span>,
}));
vi.mock('../theme', () => ({
useAdminTheme: () => ({
text: '#111827',
muted: '#6b7280',
subtle: '#94a3b8',
border: '#e5e7eb',
primary: '#ff5a5f',
danger: '#dc2626',
surface: '#ffffff',
surfaceMuted: '#f9fafb',
accentSoft: '#eef2ff',
accent: '#6366f1',
shadow: 'rgba(15,23,42,0.12)',
}),
}));
import MobileEventsPage from '../EventsPage';
describe('MobileEventsPage', () => {
it('renders filters and event list', async () => {
render(<MobileEventsPage />);
expect(await screen.findByText('Filters & Search')).toBeInTheDocument();
expect(screen.getByText('Status')).toBeInTheDocument();
expect(screen.getByText('Demo Event')).toBeInTheDocument();
});
});

View File

@@ -0,0 +1,61 @@
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,
useLocation: () => ({ search: '' }),
}));
vi.mock('react-i18next', () => ({
useTranslation: () => ({
t: (key: string, fallback?: string | Record<string, unknown>) => {
if (typeof fallback === 'string') {
return fallback;
}
if (fallback && typeof fallback === 'object' && typeof fallback.defaultValue === 'string') {
return fallback.defaultValue;
}
return key;
},
}),
}));
vi.mock('@tamagui/card', () => ({
Card: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
vi.mock('@tamagui/stacks', () => ({
YStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
vi.mock('@tamagui/text', () => ({
SizableText: ({ children }: { children: React.ReactNode }) => <span>{children}</span>,
}));
vi.mock('tamagui', () => ({
Spinner: () => <div>spinner</div>,
}));
vi.mock('../theme', () => ({
useAdminTheme: () => ({
textStrong: '#111827',
muted: '#6b7280',
border: '#e5e7eb',
surface: '#ffffff',
shadow: 'rgba(15,23,42,0.12)',
appBackground: 'linear-gradient(180deg, #fff, #f8fafc)',
}),
}));
import LoginStartPage from '../LoginStartPage';
describe('LoginStartPage', () => {
it('renders the redirect message', () => {
render(<LoginStartPage />);
expect(screen.getByText('Redirecting to login …')).toBeInTheDocument();
});
});

View File

@@ -0,0 +1,48 @@
import React from 'react';
import { describe, expect, it, vi } from 'vitest';
import { render, screen } from '@testing-library/react';
const logoutMock = vi.fn();
vi.mock('../../auth/context', () => ({
useAuth: () => ({
logout: logoutMock,
}),
}));
vi.mock('@tamagui/card', () => ({
Card: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
vi.mock('@tamagui/stacks', () => ({
YStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
vi.mock('@tamagui/text', () => ({
SizableText: ({ children }: { children: React.ReactNode }) => <span>{children}</span>,
}));
vi.mock('tamagui', () => ({
Spinner: () => <div>spinner</div>,
}));
vi.mock('../theme', () => ({
useAdminTheme: () => ({
textStrong: '#111827',
muted: '#6b7280',
border: '#e5e7eb',
surface: '#ffffff',
shadow: 'rgba(15,23,42,0.12)',
appBackground: 'linear-gradient(180deg, #fff, #f8fafc)',
}),
}));
import LogoutPage from '../LogoutPage';
describe('LogoutPage', () => {
it('renders the logout message', () => {
render(<LogoutPage />);
expect(screen.getByText('Abmeldung wird vorbereitet ...')).toBeInTheDocument();
});
});

View File

@@ -0,0 +1,129 @@
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<string, unknown>) => {
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 }) => <div>{children}</div>,
},
useAnimationControls: () => ({ start: vi.fn() }),
}));
vi.mock('@tamagui/react-native-web-lite', () => ({
Pressable: ({ children, onPress }: { children: React.ReactNode; onPress?: () => void }) => (
<button type="button" onClick={onPress}>
{children}
</button>
),
}));
vi.mock('@tamagui/stacks', () => ({
YStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
XStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
vi.mock('@tamagui/text', () => ({
SizableText: ({ children }: { children: React.ReactNode }) => <span>{children}</span>,
}));
vi.mock('../components/MobileShell', () => ({
MobileShell: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
HeaderActionButton: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
vi.mock('../components/Primitives', () => ({
MobileCard: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
PillBadge: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
SkeletonCard: () => <div>Loading...</div>,
CTAButton: ({ label }: { label: string }) => <button type="button">{label}</button>,
}));
vi.mock('../components/FormControls', () => ({
MobileSelect: ({ children }: { children: React.ReactNode }) => <select>{children}</select>,
}));
vi.mock('../components/Sheet', () => ({
MobileSheet: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
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(<MobileNotificationsPage />);
expect(await screen.findByText('All caught up')).toBeInTheDocument();
});
});

View File

@@ -0,0 +1,134 @@
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<string, unknown>) => {
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 }) => <div>{children}</div>, {
Fallback: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}),
}));
vi.mock('@tamagui/card', () => ({
Card: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
vi.mock('@tamagui/group', () => ({
YGroup: Object.assign(({ children }: { children: React.ReactNode }) => <div>{children}</div>, {
Item: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}),
}));
vi.mock('@tamagui/list-item', () => ({
ListItem: ({ title, iconAfter }: { title?: React.ReactNode; iconAfter?: React.ReactNode }) => (
<div>
{title}
{iconAfter}
</div>
),
}));
vi.mock('@tamagui/stacks', () => ({
YStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
XStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
vi.mock('@tamagui/text', () => ({
SizableText: ({ children }: { children: React.ReactNode }) => <span>{children}</span>,
}));
vi.mock('../components/MobileShell', () => ({
MobileShell: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
vi.mock('../components/Primitives', () => ({
CTAButton: ({ label }: { label: string }) => <button type="button">{label}</button>,
}));
vi.mock('../components/FormControls', () => ({
MobileSelect: ({ children }: { children: React.ReactNode }) => <select>{children}</select>,
}));
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(<MobileProfilePage />);
expect(await screen.findByText('Settings')).toBeInTheDocument();
expect(screen.getByText('Preferences')).toBeInTheDocument();
expect(screen.getByText('Log out')).toBeInTheDocument();
});
});

View File

@@ -0,0 +1,173 @@
import React from 'react';
import { describe, expect, it, vi } from 'vitest';
import { render, screen } from '@testing-library/react';
const fixtures = vi.hoisted(() => ({
event: {
id: 1,
name: 'Demo Event',
slug: 'demo-event',
},
invites: [
{
id: 1,
url: 'https://example.test/guest/demo-event',
qr_code_data_url: '',
layouts: [
{
id: 'layout-1',
name: 'Poster Layout',
description: 'Layout description',
paper: 'a4',
orientation: 'portrait',
panel_mode: 'single',
},
],
},
],
}));
vi.mock('react-router-dom', () => ({
useNavigate: () => vi.fn(),
useParams: () => ({ slug: fixtures.event.slug, tokenId: '1' }),
useSearchParams: () => [new URLSearchParams(), vi.fn()],
}));
vi.mock('react-i18next', () => ({
useTranslation: () => ({
t: (key: string, fallback?: string | Record<string, unknown>) => {
if (typeof fallback === 'string') {
return fallback;
}
if (fallback && typeof fallback === 'object' && typeof fallback.defaultValue === 'string') {
return fallback.defaultValue;
}
return key;
},
}),
}));
vi.mock('../hooks/useBackNavigation', () => ({
useBackNavigation: () => undefined,
}));
vi.mock('../../api', () => ({
getEvent: vi.fn().mockResolvedValue(fixtures.event),
getEventQrInvites: vi.fn().mockResolvedValue(fixtures.invites),
updateEventQrInvite: vi.fn(),
}));
vi.mock('../../auth/tokens', () => ({
isAuthError: () => false,
}));
vi.mock('../../lib/apiError', () => ({
getApiErrorMessage: () => 'error',
}));
vi.mock('../../lib/fonts', () => ({
useTenantFonts: () => ({ fonts: [] }),
ensureFontLoaded: vi.fn(),
}));
vi.mock('react-hot-toast', () => ({
default: {
error: vi.fn(),
success: vi.fn(),
},
}));
vi.mock('./invite-layout/export-utils', () => ({
generatePdfBytes: vi.fn(),
generatePngDataUrl: vi.fn().mockResolvedValue('data:image/png;base64,abc'),
triggerDownloadFromBlob: vi.fn(),
triggerDownloadFromDataUrl: vi.fn(),
}));
vi.mock('../components/MobileShell', () => ({
MobileShell: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
HeaderActionButton: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
vi.mock('../components/Primitives', () => ({
MobileCard: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
CTAButton: ({ label }: { label: string }) => <button type="button">{label}</button>,
PillBadge: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
vi.mock('../components/FormControls', () => ({
MobileInput: (props: React.InputHTMLAttributes<HTMLInputElement>) => <input {...props} />,
MobileTextArea: (props: React.TextareaHTMLAttributes<HTMLTextAreaElement>) => <textarea {...props} />,
MobileSelect: ({ children, ...props }: React.SelectHTMLAttributes<HTMLSelectElement>) => (
<select {...props}>{children}</select>
),
}));
vi.mock('@tamagui/accordion', () => ({
Accordion: Object.assign(
({ children }: { children: React.ReactNode }) => <div>{children}</div>,
{
Item: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
Trigger: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
Content: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
},
),
}));
vi.mock('@tamagui/portal', () => ({
Portal: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
vi.mock('@tamagui/stacks', () => ({
YStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
XStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
vi.mock('@tamagui/text', () => ({
SizableText: ({ children }: { children: React.ReactNode }) => <span>{children}</span>,
}));
vi.mock('@tamagui/react-native-web-lite', () => ({
Pressable: ({ children, onPress }: { children: React.ReactNode; onPress?: () => void }) => (
<button type="button" onClick={onPress}>
{children}
</button>
),
}));
vi.mock('../theme', () => ({
ADMIN_COLORS: {
primary: '#ff5a5f',
accent: '#6d28d9',
text: '#0f172a',
backdrop: '#0f172a',
},
ADMIN_GRADIENTS: {
softCard: 'linear-gradient(180deg, #fff, #f3f4f6)',
},
useAdminTheme: () => ({
textStrong: '#0f172a',
muted: '#64748b',
border: '#e2e8f0',
primary: '#ff5a5f',
accentSoft: '#f5f3ff',
successText: '#16a34a',
surface: '#ffffff',
surfaceMuted: '#f8fafc',
overlay: 'rgba(15, 23, 42, 0.5)',
shadow: 'rgba(15, 23, 42, 0.2)',
danger: '#dc2626',
}),
}));
import MobileQrLayoutCustomizePage from '../QrLayoutCustomizePage';
describe('MobileQrLayoutCustomizePage', () => {
it('renders the layout customize stepper', async () => {
render(<MobileQrLayoutCustomizePage />);
expect(await screen.findByText('Hintergrund')).toBeInTheDocument();
expect(screen.getByText('Text')).toBeInTheDocument();
expect(screen.getByText('Vorschau')).toBeInTheDocument();
});
});

View File

@@ -2,77 +2,69 @@ import React from 'react';
import { describe, expect, it, vi } from 'vitest';
import { render, screen } from '@testing-library/react';
const backMock = vi.fn();
const navigateMock = vi.fn();
const fixtures = vi.hoisted(() => ({
event: {
id: 1,
name: 'Demo Event',
slug: 'demo-event',
public_url: 'https://example.test/guest/demo-event',
},
invites: [
{
id: 10,
url: 'https://example.test/guest/demo-event',
qr_code_data_url: 'data:image/png;base64,abc',
is_active: true,
layouts: [
{
id: 'layout-1',
panel_mode: 'single',
orientation: 'portrait',
},
],
},
],
}));
vi.mock('react-router-dom', () => ({
useNavigate: () => navigateMock,
useParams: () => ({ slug: 'demo-event' }),
useNavigate: () => vi.fn(),
useParams: () => ({ slug: fixtures.event.slug }),
}));
vi.mock('react-i18next', () => ({
useTranslation: () => ({
t: (key: string) => key,
t: (key: string, fallback?: string | Record<string, unknown>) => {
if (typeof fallback === 'string') {
return fallback;
}
if (fallback && typeof fallback === 'object' && typeof fallback.defaultValue === 'string') {
return fallback.defaultValue;
}
return key;
},
}),
}));
vi.mock('../hooks/useBackNavigation', () => ({
useBackNavigation: () => backMock,
useBackNavigation: () => undefined,
}));
vi.mock('../../api', () => ({
getEvent: vi.fn().mockResolvedValue({ slug: 'demo-event', name: 'Demo' }),
getEventQrInvites: vi.fn().mockResolvedValue([
{
id: 1,
token: 'demo-token',
url: 'https://example.test/g/demo-token',
label: null,
qr_code_data_url: 'data:image/png;base64,abc',
usage_limit: null,
usage_count: 0,
expires_at: '2026-01-12T12:00:00Z',
revoked_at: null,
is_active: true,
created_at: null,
metadata: {},
layouts_url: null,
layouts: [
{
id: 'layout-1',
name: 'Poster',
description: '',
subtitle: '',
formats: [],
preview: {
background: null,
background_gradient: null,
accent: null,
text: null,
},
paper: 'a4',
orientation: 'portrait',
panel_mode: 'single',
},
],
},
]),
getEvent: vi.fn().mockResolvedValue(fixtures.event),
getEventQrInvites: vi.fn().mockResolvedValue(fixtures.invites),
createQrInvite: vi.fn(),
}));
vi.mock('react-hot-toast', () => ({
default: {
error: vi.fn(),
success: vi.fn(),
},
vi.mock('../../auth/tokens', () => ({
isAuthError: () => false,
}));
vi.mock('@tamagui/react-native-web-lite', () => ({
Pressable: ({ children, onPress }: { children: React.ReactNode; onPress?: () => void }) => (
<button type="button" onClick={onPress}>
{children}
</button>
),
vi.mock('../../lib/apiError', () => ({
getApiErrorMessage: () => 'error',
}));
vi.mock('./qr/utils', () => ({
resolveLayoutForFormat: () => 'layout-1',
}));
vi.mock('../components/MobileShell', () => ({
@@ -82,14 +74,15 @@ vi.mock('../components/MobileShell', () => ({
vi.mock('../components/Primitives', () => ({
MobileCard: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
CTAButton: ({ label, onPress }: { label: string; onPress?: () => void }) => (
<button type="button" onClick={onPress}>
{label}
</button>
),
CTAButton: ({ label }: { label: string }) => <button type="button">{label}</button>,
PillBadge: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
vi.mock('../components/FormControls', () => ({
MobileInput: (props: React.InputHTMLAttributes<HTMLInputElement>) => <input {...props} />,
MobileTextArea: (props: React.TextareaHTMLAttributes<HTMLTextAreaElement>) => <textarea {...props} />,
}));
vi.mock('@tamagui/stacks', () => ({
YStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
XStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
@@ -99,31 +92,37 @@ vi.mock('@tamagui/text', () => ({
SizableText: ({ children }: { children: React.ReactNode }) => <span>{children}</span>,
}));
vi.mock('@tamagui/react-native-web-lite', () => ({
Pressable: ({ children, onPress }: { children: React.ReactNode; onPress?: () => void }) => (
<button type="button" onClick={onPress}>
{children}
</button>
),
}));
vi.mock('../theme', () => ({
useAdminTheme: () => ({
textStrong: '#111827',
text: '#111827',
muted: '#6b7280',
subtle: '#94a3b8',
border: '#e5e7eb',
surfaceMuted: '#fffdfb',
primary: '#ff5a5f',
danger: '#b91c1c',
accentSoft: '#ffe5ec',
glassSurface: 'rgba(255,255,255,0.8)',
glassSurfaceStrong: 'rgba(255,255,255,0.9)',
glassBorder: 'rgba(229,231,235,0.7)',
glassShadow: 'rgba(15,23,42,0.14)',
appBackground: 'linear-gradient(180deg, #f7fafc, #eef3f7)',
danger: '#dc2626',
surface: '#ffffff',
surfaceMuted: '#f9fafb',
accentSoft: '#eef2ff',
textStrong: '#0f172a',
}),
}));
import MobileQrPrintPage from '../QrPrintPage';
describe('MobileQrPrintPage', () => {
it('shows token expiry info when the invite has expires_at', async () => {
it('renders QR overview content', async () => {
render(<MobileQrPrintPage />);
expect(await screen.findByText('events.qr.expiresAt')).toBeInTheDocument();
expect(await screen.findByText('Entrance QR Code')).toBeInTheDocument();
expect(screen.getByText('Schritt 1: Format wählen')).toBeInTheDocument();
expect(screen.getAllByText('Neuen QR-Link erstellen').length).toBeGreaterThan(0);
});
});

View File

@@ -0,0 +1,99 @@
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,
Navigate: ({ to }: { to: string }) => <div>{to}</div>,
}));
vi.mock('react-i18next', () => ({
useTranslation: () => ({
t: (key: string, fallback?: string | Record<string, unknown>) => {
if (typeof fallback === 'string') {
return fallback;
}
if (fallback && typeof fallback === 'object' && typeof fallback.defaultValue === 'string') {
return fallback.defaultValue;
}
return key;
},
i18n: { language: 'de' },
}),
}));
vi.mock('../../context/EventContext', () => ({
useEventContext: () => ({
events: [{ slug: 'demo-event', event_date: '2026-02-19' }],
activeEvent: null,
hasEvents: true,
selectEvent: vi.fn(),
}),
}));
vi.mock('../../lib/events', () => ({
resolveEventDisplayName: () => 'Demo Event',
formatEventDate: () => '19. Feb. 2026',
}));
vi.mock('../components/MobileShell', () => ({
MobileShell: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
vi.mock('../components/Primitives', () => ({
CTAButton: ({ label }: { label: string }) => <button type="button">{label}</button>,
}));
vi.mock('@tamagui/card', () => ({
Card: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
vi.mock('@tamagui/group', () => ({
YGroup: Object.assign(({ children }: { children: React.ReactNode }) => <div>{children}</div>, {
Item: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}),
}));
vi.mock('@tamagui/list-item', () => ({
ListItem: ({ title, iconAfter }: { title?: React.ReactNode; iconAfter?: React.ReactNode }) => (
<div>
{title}
{iconAfter}
</div>
),
}));
vi.mock('@tamagui/stacks', () => ({
YStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
XStack: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
}));
vi.mock('@tamagui/text', () => ({
SizableText: ({ children }: { children: React.ReactNode }) => <span>{children}</span>,
}));
vi.mock('../theme', () => ({
useAdminTheme: () => ({
text: '#111827',
muted: '#6b7280',
border: '#e5e7eb',
primary: '#ff5a5f',
surface: '#ffffff',
surfaceMuted: '#f9fafb',
shadow: 'rgba(15,23,42,0.12)',
}),
}));
import MobileUploadsTabPage from '../UploadsTabPage';
describe('MobileUploadsTabPage', () => {
it('renders the event picker list', () => {
render(<MobileUploadsTabPage />);
expect(screen.getByText('Pick an event to manage uploads')).toBeInTheDocument();
expect(screen.getByText('Demo Event')).toBeInTheDocument();
expect(screen.getByText('Open')).toBeInTheDocument();
});
});