fix(web): stabilize Vitest suite (auth integration: wrap with QueryClientProvider)
This commit is contained in:
parent
8582be5982
commit
794270597a
1 changed files with 12 additions and 6 deletions
|
|
@ -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(
|
||||
<MemoryRouter initialEntries={initialEntries}>
|
||||
<Routes>
|
||||
<Route path={path} element={component} />
|
||||
</Routes>
|
||||
</MemoryRouter>,
|
||||
<QueryClientProvider client={queryClient}>
|
||||
<MemoryRouter initialEntries={initialEntries}>
|
||||
<Routes>
|
||||
<Route path={path} element={component} />
|
||||
</Routes>
|
||||
</MemoryRouter>
|
||||
</QueryClientProvider>,
|
||||
);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue