photo visibility for demo events, hardened the demo mode. fixed dark/light mode toggle and notification bell toggle. fixed photo upload page sizes & header visibility.

This commit is contained in:
Codex Agent
2025-12-18 21:14:24 +01:00
parent 7c4067b32b
commit 53ec427e6e
25 changed files with 965 additions and 102 deletions

View File

@@ -0,0 +1,48 @@
import React from 'react';
import { describe, expect, it, vi } from 'vitest';
import { render, screen } from '@testing-library/react';
import { MemoryRouter } from 'react-router-dom';
import GalleryPreview from '../GalleryPreview';
vi.mock('../../polling/usePollGalleryDelta', () => ({
usePollGalleryDelta: () => ({
photos: [],
loading: false,
}),
}));
vi.mock('../../i18n/useTranslation', () => ({
useTranslation: () => ({
locale: 'de',
}),
}));
vi.mock('../../context/EventBrandingContext', () => ({
useEventBranding: () => ({
branding: {
primaryColor: '#f43f5e',
secondaryColor: '#fb7185',
buttons: { radius: 12, linkColor: '#fb7185' },
typography: {},
fontFamily: 'Montserrat',
},
}),
}));
describe('GalleryPreview', () => {
it('renders dark mode-ready surfaces', () => {
render(
<MemoryRouter>
<GalleryPreview token="demo" />
</MemoryRouter>,
);
const card = screen.getByTestId('gallery-preview');
expect(card.className).toContain('bg-[var(--guest-surface)]');
expect(card.className).toContain('dark:bg-slate-950/70');
const emptyState = screen.getByText(/Noch keine Fotos/i).closest('div');
expect(emptyState).not.toBeNull();
expect(emptyState?.className).toContain('dark:bg-slate-950/60');
});
});

View File

@@ -0,0 +1,99 @@
import React from 'react';
import { describe, expect, it, vi } from 'vitest';
import { fireEvent, render, screen } from '@testing-library/react';
import Header from '../Header';
vi.mock('../settings-sheet', () => ({
SettingsSheet: () => <div data-testid="settings-sheet" />,
}));
vi.mock('@/components/appearance-dropdown', () => ({
default: () => <div data-testid="appearance-toggle" />,
}));
vi.mock('../../hooks/useEventData', () => ({
useEventData: () => ({
status: 'ready',
event: {
name: 'Demo Event',
type: { icon: 'heart' },
engagement_mode: 'photo_only',
},
}),
}));
vi.mock('../../context/EventStatsContext', () => ({
useOptionalEventStats: () => null,
}));
vi.mock('../../context/GuestIdentityContext', () => ({
useOptionalGuestIdentity: () => null,
}));
vi.mock('../../context/NotificationCenterContext', () => ({
useOptionalNotificationCenter: () => ({
notifications: [],
unreadCount: 0,
queueItems: [],
queueCount: 0,
totalCount: 0,
loading: false,
refresh: vi.fn(),
setFilters: vi.fn(),
markAsRead: vi.fn(),
dismiss: vi.fn(),
eventToken: 'demo',
lastFetchedAt: null,
isOffline: false,
}),
}));
vi.mock('../../hooks/useGuestTaskProgress', () => ({
useGuestTaskProgress: () => ({
hydrated: false,
completedCount: 0,
}),
TASK_BADGE_TARGET: 10,
}));
vi.mock('../../hooks/usePushSubscription', () => ({
usePushSubscription: () => ({
supported: false,
permission: 'default',
subscribed: false,
loading: false,
error: null,
enable: vi.fn(),
disable: vi.fn(),
refresh: vi.fn(),
}),
}));
vi.mock('../../i18n/useTranslation', () => ({
useTranslation: () => ({
t: (_key: string, fallback?: string | { defaultValue?: string }) => {
if (typeof fallback === 'string') {
return fallback;
}
if (fallback && typeof fallback.defaultValue === 'string') {
return fallback.defaultValue;
}
return _key;
},
}),
}));
describe('Header notifications toggle', () => {
it('closes the panel when clicking the bell again', () => {
render(<Header eventToken="demo" title="Demo" />);
const bellButton = screen.getByLabelText('Benachrichtigungen anzeigen');
fireEvent.click(bellButton);
expect(screen.getByText('Benachrichtigungen')).toBeInTheDocument();
fireEvent.click(bellButton);
expect(screen.queryByText('Benachrichtigungen')).not.toBeInTheDocument();
});
});