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

@@ -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);
});
});