54 lines
2.1 KiB
TypeScript
54 lines
2.1 KiB
TypeScript
|
|
import React from 'react';
|
||
|
|
import { describe, it, expect, vi } from 'vitest';
|
||
|
|
import { render, screen, within } from '@testing-library/react';
|
||
|
|
import { MemoryRouter, Route, Routes } from 'react-router-dom';
|
||
|
|
import { AppShell } from '@/components/layout/AppShell';
|
||
|
|
|
||
|
|
vi.mock('@/api/hooks', () => ({
|
||
|
|
useLogout: () => ({ mutateAsync: vi.fn(), isPending: false }),
|
||
|
|
useSwitchTenant: () => ({ mutateAsync: vi.fn(), isPending: false }),
|
||
|
|
}));
|
||
|
|
|
||
|
|
function renderWithRouter(initialPath = '/dashboard') {
|
||
|
|
return render(
|
||
|
|
<MemoryRouter initialEntries={[initialPath]}>
|
||
|
|
<Routes>
|
||
|
|
<Route path="*" element={<AppShell />} />
|
||
|
|
</Routes>
|
||
|
|
</MemoryRouter>
|
||
|
|
);
|
||
|
|
}
|
||
|
|
|
||
|
|
describe('AppShell', () => {
|
||
|
|
it('renders sidebar, topbar, and content area', () => {
|
||
|
|
renderWithRouter();
|
||
|
|
expect(screen.getByTestId('app-shell')).toBeInTheDocument();
|
||
|
|
expect(screen.getByTestId('sidebar')).toBeInTheDocument();
|
||
|
|
expect(screen.getByTestId('topbar')).toBeInTheDocument();
|
||
|
|
expect(screen.getByTestId('content-area')).toBeInTheDocument();
|
||
|
|
});
|
||
|
|
|
||
|
|
it('sidebar contains navigation items', () => {
|
||
|
|
renderWithRouter();
|
||
|
|
const sidebar = screen.getByTestId('sidebar');
|
||
|
|
expect(within(sidebar).getByText('Dashboard')).toBeInTheDocument();
|
||
|
|
expect(within(sidebar).getByText('Firmen')).toBeInTheDocument();
|
||
|
|
expect(within(sidebar).getByText('Kontakte')).toBeInTheDocument();
|
||
|
|
expect(within(sidebar).getByText('Einstellungen')).toBeInTheDocument();
|
||
|
|
});
|
||
|
|
|
||
|
|
it('topbar contains tenant switcher, search, notifications, and user menu', () => {
|
||
|
|
renderWithRouter();
|
||
|
|
const topbar = screen.getByTestId('topbar');
|
||
|
|
expect(within(topbar).getByLabelText('Mandant wechseln')).toBeInTheDocument();
|
||
|
|
expect(within(topbar).getByLabelText('Suchen...')).toBeInTheDocument();
|
||
|
|
expect(within(topbar).getByLabelText('Benachrichtigungen')).toBeInTheDocument();
|
||
|
|
expect(within(topbar).getByLabelText('Benutzermenü')).toBeInTheDocument();
|
||
|
|
});
|
||
|
|
|
||
|
|
it('content area has main role for screen readers', () => {
|
||
|
|
renderWithRouter();
|
||
|
|
expect(screen.getByRole('main')).toBeInTheDocument();
|
||
|
|
});
|
||
|
|
});
|