überarbeitung des event-admins fortgesetzt

This commit is contained in:
Codex Agent
2025-11-25 13:03:42 +01:00
parent fd788ef770
commit 596dcbf18a
20 changed files with 998 additions and 2210 deletions

View File

@@ -2,6 +2,8 @@ import React from 'react';
import { describe, expect, it, afterEach, vi } from 'vitest';
import { render, screen } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { I18nextProvider } from 'react-i18next';
import i18n from '../../i18n';
import WelcomeTeaserPage from '../WelcomeTeaserPage';
const navigateMock = vi.fn();
@@ -14,7 +16,27 @@ vi.mock('../../lib/navigation', () => ({
navigateToHref: (href: string) => navigateMock(href),
}));
vi.mock('../../auth/context', () => ({
useAuth: () => ({ status: 'unauthenticated' }),
}));
vi.mock('@/hooks/use-appearance', async () => {
const ReactImport = await import('react');
return {
useAppearance: () => {
const [appearance, setAppearance] = ReactImport.useState<'light' | 'dark'>('light');
return { appearance, updateAppearance: setAppearance };
},
};
});
describe('WelcomeTeaserPage', () => {
const renderWithI18n = () => render(
<I18nextProvider i18n={i18n}>
<WelcomeTeaserPage />
</I18nextProvider>
);
afterEach(() => {
document.body.classList.remove('tenant-admin-theme', 'tenant-admin-welcome-theme');
vi.clearAllMocks();
@@ -22,7 +44,7 @@ describe('WelcomeTeaserPage', () => {
});
it('applies the tenant admin theme classes while mounted', () => {
const { unmount } = render(<WelcomeTeaserPage />);
const { unmount } = renderWithI18n();
expect(document.body.classList.contains('tenant-admin-theme')).toBe(true);
expect(document.body.classList.contains('tenant-admin-welcome-theme')).toBe(true);
@@ -33,25 +55,25 @@ describe('WelcomeTeaserPage', () => {
expect(document.body.classList.contains('tenant-admin-welcome-theme')).toBe(false);
});
it('shows the hero stats and triggers the login redirect CTA', async () => {
render(<WelcomeTeaserPage />);
expect(screen.getByText('Events begleitet')).toBeInTheDocument();
it('shows the hero CTA and triggers the login redirect', async () => {
renderWithI18n();
const user = userEvent.setup();
await user.click(screen.getByRole('button', { name: /event admin öffnen/i }));
const loginButton = screen.getAllByRole('button', { name: /login/i })[0];
await user.click(loginButton);
expect(navigateMock).toHaveBeenCalledWith(expect.stringContaining('/event-admin/login'));
});
it('allows switching between light and dark presentation modes', async () => {
render(<WelcomeTeaserPage />);
renderWithI18n();
const user = userEvent.setup();
const toggle = screen.getByRole('button', { name: /light mode/i });
const toggle = screen.getByLabelText(/welcome\.theme\.aria|darstellung|appearance/i);
expect(toggle).toHaveTextContent(/hell|light/i);
await user.click(toggle);
expect(toggle).toHaveTextContent(/dark mode/i);
expect(toggle).toHaveTextContent(/dunkel|dark/i);
});
});