Files
fotospiel-app/resources/js/guest/pages/__tests__/UploadPageDemoMode.test.tsx
Codex Agent 2f9a700e00
Some checks failed
linter / quality (push) Has been cancelled
tests / ci (push) Has been cancelled
tests / ui (push) Has been cancelled
Fix guest demo UX and enforce guest limits
2026-01-21 21:35:40 +01:00

81 lines
1.8 KiB
TypeScript

import React from 'react';
import { describe, expect, it, vi } from 'vitest';
import { render, screen, waitFor } from '@testing-library/react';
import UploadPage from '../UploadPage';
vi.mock('react-router-dom', () => ({
useNavigate: () => vi.fn(),
useParams: () => ({ token: 'demo' }),
useSearchParams: () => [new URLSearchParams(), vi.fn()],
}));
vi.mock('../../demo/demoMode', () => ({
isGuestDemoModeEnabled: () => true,
}));
vi.mock('../../hooks/useGuestTaskProgress', () => ({
useGuestTaskProgress: () => ({
markCompleted: vi.fn(),
}),
}));
vi.mock('../../context/GuestIdentityContext', () => ({
useGuestIdentity: () => ({
name: 'Guest',
}),
}));
vi.mock('../../hooks/useEventData', () => ({
useEventData: () => ({
event: {
guest_upload_visibility: 'immediate',
demo_read_only: false,
engagement_mode: 'photo_only',
},
}),
}));
vi.mock('../../context/EventStatsContext', () => ({
useEventStats: () => ({
latestPhotoAt: null,
onlineGuests: 2,
}),
}));
vi.mock('../../context/EventBrandingContext', () => ({
useEventBranding: () => ({
branding: {
primaryColor: '#FF5A5F',
secondaryColor: '#FFF8F5',
buttons: { radius: 12 },
typography: {},
fontFamily: 'Montserrat',
},
}),
}));
vi.mock('../../i18n/useTranslation', () => ({
useTranslation: () => ({
t: (key: string, fallback?: string) => fallback ?? key,
locale: 'de',
}),
}));
vi.mock('../../services/eventApi', () => ({
getEventPackage: vi.fn().mockResolvedValue(null),
}));
vi.mock('../../services/photosApi', () => ({
uploadPhoto: vi.fn(),
}));
describe('UploadPage demo mode', () => {
it('keeps the UI visible and shows the demo notice', async () => {
render(<UploadPage />);
await waitFor(() => {
expect(screen.getByText('Demo-Modus aktiv')).toBeInTheDocument();
});
});
});