22976abe92
- React 18 + Vite + TypeScript + Tailwind CSS setup - AppShell with Sidebar (plugin menu) + TopBar (tenant switcher, search, notifications, user menu) - Auth pages: Login, PasswordResetRequest, PasswordResetConfirm - Protected routes with auth guard - API client (axios with interceptors: session cookie, 401 redirect, 422 validation) - TanStack Query hooks for auth, users, companies, contacts, notifications - Zustand stores: authStore, uiStore - i18n setup (de/en locales) with react-i18next - UI component library: Button, Input, Select, Modal, Toast, Table, Card, Badge, Avatar, Pagination, EmptyState, Skeleton, ConfirmDialog - Accessibility: ARIA labels, 44px touch targets, keyboard nav, reduced-motion, sr-only - Design tokens from prototype as CSS custom properties - 111 tests passing across 20 test files - tsc --noEmit: 0 errors - npm run build: success (471KB JS, 24KB CSS)
46 lines
1.7 KiB
TypeScript
46 lines
1.7 KiB
TypeScript
import React from 'react';
|
|
import { describe, it, expect } from 'vitest';
|
|
import { render, screen, fireEvent } from '@testing-library/react';
|
|
import { Select } from '@/components/ui/Select';
|
|
|
|
const options = [
|
|
{ value: 'de', label: 'Deutsch' },
|
|
{ value: 'en', label: 'English' },
|
|
];
|
|
|
|
describe('Select', () => {
|
|
it('renders label and options', () => {
|
|
render(<Select label="Sprache" options={options} />);
|
|
expect(screen.getByText('Sprache')).toBeInTheDocument();
|
|
expect(screen.getByText('Deutsch')).toBeInTheDocument();
|
|
expect(screen.getByText('English')).toBeInTheDocument();
|
|
});
|
|
|
|
it('renders error with role=alert', () => {
|
|
render(<Select label="Sprache" options={options} error="Bitte auswählen" />);
|
|
expect(screen.getByRole('alert')).toHaveTextContent('Bitte auswählen');
|
|
});
|
|
|
|
it('renders helper text', () => {
|
|
render(<Select label="Sprache" options={options} helperText="Wählen Sie eine Sprache" />);
|
|
expect(screen.getByText('Wählen Sie eine Sprache')).toBeInTheDocument();
|
|
});
|
|
|
|
it('calls onChange when value changes', () => {
|
|
const onChange = vi.fn();
|
|
render(<Select label="Sprache" options={options} onChange={onChange} />);
|
|
fireEvent.change(screen.getByLabelText(/Sprache/), { target: { value: 'en' } });
|
|
expect(onChange).toHaveBeenCalled();
|
|
});
|
|
|
|
it('has min-h-touch for 44px target', () => {
|
|
render(<Select label="Sprache" options={options} />);
|
|
expect(screen.getByLabelText(/Sprache/).className).toContain('min-h-touch');
|
|
});
|
|
|
|
it('sets aria-required when required', () => {
|
|
render(<Select label="Sprache" options={options} required />);
|
|
expect(screen.getByLabelText(/Sprache/)).toHaveAttribute('aria-required', 'true');
|
|
});
|
|
});
|