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(); vi.mock('react-router-dom', () => ({ useNavigate: () => navigateMock, useParams: () => ({ slug: 'demo-event' }), })); vi.mock('react-i18next', () => ({ useTranslation: () => ({ t: (key: string) => key, }), })); vi.mock('../hooks/useBackNavigation', () => ({ useBackNavigation: () => backMock, })); 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', }, ], }, ]), createQrInvite: vi.fn(), })); vi.mock('react-hot-toast', () => ({ default: { error: vi.fn(), success: vi.fn(), }, })); vi.mock('@tamagui/react-native-web-lite', () => ({ Pressable: ({ children, onPress }: { children: React.ReactNode; onPress?: () => void }) => ( ), })); 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}
, CTAButton: ({ label, onPress }: { label: string; onPress?: () => void }) => ( ), PillBadge: ({ children }: { children: React.ReactNode }) =>
{children}
, })); 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('../theme', () => ({ useAdminTheme: () => ({ textStrong: '#111827', text: '#111827', muted: '#6b7280', subtle: '#94a3b8', border: '#e5e7eb', surfaceMuted: '#fffdfb', primary: '#ff5a5f', danger: '#b91c1c', accentSoft: '#ffe5ec', }), })); import MobileQrPrintPage from '../QrPrintPage'; describe('MobileQrPrintPage', () => { it('shows token expiry info when the invite has expires_at', async () => { render(); expect(await screen.findByText('events.qr.expiresAt')).toBeInTheDocument(); }); });