fix(web): stabilize Vitest suite (auth integration: wrap with QueryClientProvider)

This commit is contained in:
senke 2026-02-14 14:21:17 +01:00
parent 8582be5982
commit 794270597a

View file

@ -2,6 +2,7 @@ import { describe, it, expect, vi, beforeEach, afterEach } from 'vitest';
import { render, screen, waitFor } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { MemoryRouter, Routes, Route } from 'react-router-dom';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { LoginPage } from '../pages/LoginPage';
import { RegisterPage } from '../pages/RegisterPage';
import { ForgotPasswordPage } from '../pages/ForgotPasswordPage';
@ -100,18 +101,23 @@ vi.mock('react-router-dom', async () => {
};
});
// Helper function to render with router
// Helper function to render with router and QueryClient
const renderWithRouter = (
initialEntries: string[],
path: string,
component: React.ReactElement,
) => {
const queryClient = new QueryClient({
defaultOptions: { queries: { retry: false }, mutations: { retry: false } },
});
return render(
<QueryClientProvider client={queryClient}>
<MemoryRouter initialEntries={initialEntries}>
<Routes>
<Route path={path} element={component} />
</Routes>
</MemoryRouter>,
</MemoryRouter>
</QueryClientProvider>,
);
};