T07b: frontend feature pages — companies + contacts + settings + audit + dashboard + search

- 11 new feature pages (CompaniesList/Detail/Form, ContactsList/Detail/Form,
  SettingsProfile/Roles/Users, AuditLog, GlobalSearchResults)
- 3 page updates (Dashboard with StatCard+ActivityFeed, Settings with tree nav+Outlet,
  TopBar with SearchDropdown)
- 13 new routes in routes/index.tsx
- i18n updates (de.json + en.json) with companies/contacts/settings/audit/search keys
- 12 new test files + 2 existing test fixes (TopBar, AppShell)
- 7 shared components (DataGrid, Tabs, SearchDropdown, CsvImportDialog, StatCard,
  ActivityFeed, UnsavedChangesGuard)
- 16 new API hooks in hooks.ts
- Verification: 141 tests pass, build succeeds, tsc --noEmit clean
This commit is contained in:
leocrm-bot
2026-06-29 11:01:39 +02:00
parent 22976abe92
commit 700b7a71ad
47 changed files with 4089 additions and 157 deletions
@@ -0,0 +1,29 @@
import React from 'react';
import { describe, it, expect, vi } from 'vitest';
import { render, screen } from '@testing-library/react';
import { MemoryRouter } from 'react-router-dom';
import { ContactDetailPage } from '@/pages/ContactDetail';
vi.mock('@/api/hooks', () => ({
useContact: () => ({
data: {
id: '1', first_name: 'Max', last_name: 'Mustermann',
email: 'max@example.com', phone: '+49 30 12345678',
position: 'CEO', company_id: '1', company_name: 'TestCorp GmbH',
created_at: '2025-01-01T00:00:00Z', updated_at: '2025-01-01T00:00:00Z',
},
isLoading: false,
}),
}));
describe('ContactDetailPage', () => {
it('renders the detail page', () => {
render(<MemoryRouter initialEntries={['/contacts/1']}><ContactDetailPage /></MemoryRouter>);
expect(screen.getByTestId('contact-detail-page')).toBeInTheDocument();
});
it('renders tabs', () => {
render(<MemoryRouter initialEntries={['/contacts/1']}><ContactDetailPage /></MemoryRouter>);
expect(screen.getByRole('tablist')).toBeInTheDocument();
});
});
@@ -0,0 +1,37 @@
import React from 'react';
import { describe, it, expect, vi } from 'vitest';
import { render, screen } from '@testing-library/react';
import { MemoryRouter } from 'react-router-dom';
import { ContactFormPage } from '@/pages/ContactForm';
vi.mock('@/api/hooks', () => ({
useContact: () => ({ data: undefined, isLoading: false }),
useCreateContact: () => ({ mutateAsync: vi.fn(), isPending: false }),
useUpdateContact: () => ({ mutateAsync: vi.fn(), isPending: false }),
useCompanies: () => ({ data: { items: [{ id: '1', name: 'TestCorp GmbH' }], total: 1 }, isLoading: false }),
}));
vi.mock('@/components/ui/Toast', () => ({
useToast: () => ({ success: vi.fn(), error: vi.fn(), info: vi.fn() }),
}));
vi.mock('@/components/shared/UnsavedChangesGuard', () => ({
UnsavedChangesGuard: () => null,
}));
describe('ContactFormPage', () => {
it('renders form with first name field', () => {
render(<MemoryRouter><ContactFormPage /></MemoryRouter>);
expect(screen.getByLabelText(/Vorname/)).toBeInTheDocument();
});
it('renders form with last name field', () => {
render(<MemoryRouter><ContactFormPage /></MemoryRouter>);
expect(screen.getByLabelText(/Nachname/)).toBeInTheDocument();
});
it('renders email field', () => {
render(<MemoryRouter><ContactFormPage /></MemoryRouter>);
expect(screen.getByLabelText(/E-Mail/)).toBeInTheDocument();
});
});
@@ -0,0 +1,39 @@
import React from 'react';
import { describe, it, expect, vi } from 'vitest';
import { render, screen } from '@testing-library/react';
import { MemoryRouter } from 'react-router-dom';
import { ContactsListPage } from '@/pages/ContactsList';
vi.mock('@/api/hooks', () => ({
useContacts: () => ({
data: {
items: [
{ id: '1', first_name: 'Max', last_name: 'Mustermann', email: 'max@test.de', phone: '+49 30 123', company_name: 'TestCorp GmbH', created_at: '2025-01-01T00:00:00Z', updated_at: '2025-01-01T00:00:00Z' },
],
total: 1,
},
isLoading: false,
}),
useDeleteContact: () => ({ mutateAsync: vi.fn(), isPending: false }),
}));
vi.mock('@/components/ui/Toast', () => ({
useToast: () => ({ success: vi.fn(), error: vi.fn(), info: vi.fn() }),
}));
describe('ContactsListPage', () => {
it('renders the page', () => {
render(<MemoryRouter><ContactsListPage /></MemoryRouter>);
expect(screen.getByTestId('contacts-list-page')).toBeInTheDocument();
});
it('renders DataGrid for contacts', () => {
render(<MemoryRouter><ContactsListPage /></MemoryRouter>);
expect(screen.getByTestId('contacts-grid')).toBeInTheDocument();
});
it('renders contact data in grid', () => {
render(<MemoryRouter><ContactsListPage /></MemoryRouter>);
expect(screen.getByText('Max Mustermann')).toBeInTheDocument();
});
});