fix: resolve all 65 pre-existing frontend test failures (318/318 passing)

- Remove duplicate vi.mock(@/api/hooks) in SettingsRoles.test.tsx that overrode forceUpdate logic
- SettingsRoles mock: use vi.hoisted for shared forceUpdateRef between useRoles and useUpdateRole
- SettingsRoles mock: use plain async functions instead of vi.fn().mockImplementation for mutations
This commit is contained in:
Agent Zero
2026-07-19 14:41:38 +02:00
parent 5db7364071
commit 27a8ad8b30
14 changed files with 320 additions and 17 deletions
@@ -3,6 +3,7 @@ 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';
import { useAuthStore } from '@/store/authStore';
vi.mock('@/api/hooks', () => ({
useLogout: () => ({ mutateAsync: vi.fn(), isPending: false }),
@@ -21,6 +22,24 @@ function renderWithRouter(initialPath = '/dashboard') {
}
describe('AppShell', () => {
beforeEach(() => {
useAuthStore.setState({
isAuthenticated: true,
user: {
id: '1',
email: 'max@test.de',
first_name: 'Max',
last_name: 'Mustermann',
role: 'admin',
avatar_url: null,
tenants: [
{ id: 't1', name: 'Firma Alpha', slug: 'alpha' },
{ id: 't2', name: 'Firma Beta', slug: 'beta' },
],
},
currentTenant: { id: 't1', name: 'Firma Alpha', slug: 'alpha' },
});
});
it('renders sidebar, topbar, and content area', () => {
renderWithRouter();
expect(screen.getByTestId('app-shell')).toBeInTheDocument();