- Break entity shim chain: brokerPositionApi, brokerOperationApi now use shared/api/client directly - Remove all 43 shim re-export files (api/, hooks/, context/, components/, pages/ flat shims, routes.tsx) - Remove entire pages/broker/ dead code directory - Remove api/broker.ts after breaking the shim chain - Switch auth consumers from AuthProvider (shim) to SessionProvider (FSD) - Fix api/screener.ts imports to use @/shared/api - Update frontend hooks.md and routes.md documentation - 2840 lines removed, 71 lines added
44 lines
1.2 KiB
TypeScript
44 lines
1.2 KiB
TypeScript
import { type ReactElement } from 'react';
|
|
import { render, type RenderOptions } from '@testing-library/react';
|
|
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
import { MemoryRouter } from 'react-router-dom';
|
|
import { SessionProvider } from '../app/providers/SessionProvider';
|
|
|
|
interface CustomRenderOptions extends Omit<RenderOptions, 'wrapper'> {
|
|
queryClient?: QueryClient;
|
|
route?: string;
|
|
}
|
|
|
|
function createTestQueryClient() {
|
|
return new QueryClient({
|
|
defaultOptions: {
|
|
queries: { retry: false, gcTime: 0 },
|
|
mutations: { retry: false },
|
|
},
|
|
});
|
|
}
|
|
|
|
export function renderWithProviders(
|
|
ui: ReactElement,
|
|
{
|
|
queryClient = createTestQueryClient(),
|
|
route = '/',
|
|
...renderOptions
|
|
}: CustomRenderOptions = {},
|
|
) {
|
|
function Wrapper({ children }: { children: React.ReactNode }) {
|
|
return (
|
|
<QueryClientProvider client={queryClient}>
|
|
<MemoryRouter
|
|
initialEntries={[route]}
|
|
future={{ v7_startTransition: true, v7_relativeSplatPath: true }}
|
|
>
|
|
<SessionProvider>{children}</SessionProvider>
|
|
</MemoryRouter>
|
|
</QueryClientProvider>
|
|
);
|
|
}
|
|
|
|
return { ...render(ui, { wrapper: Wrapper, ...renderOptions }), queryClient };
|
|
}
|