Fix auth translations and admin PWA UI
This commit is contained in:
@@ -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();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user