ruvector/studio/tests/lib/custom-render.tsx
rUv 814f595995 feat(studio): Add complete RuVector Studio application
Major additions:
- Complete Next.js studio application with 1600+ components
- Docker support (Dockerfile.combined, docker-compose.yml)
- GCP deployment documentation and benchmarks
- SQL benchmark scripts for performance testing
- Sentry integration for monitoring
- Comprehensive test suite and mocks

Studio features:
- Dashboard and admin interfaces
- Data visualization components
- Authentication and user management
- API integration with RuVector backend
- Static data and public assets

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-06 23:04:48 +00:00

77 lines
2 KiB
TypeScript

import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
import { type RenderOptions, render, renderHook } from '@testing-library/react'
import { NuqsTestingAdapter } from 'nuqs/adapters/testing'
// End of third-party imports
import { ProfileContext, type ProfileContextType } from 'lib/profile'
import { TooltipProvider } from 'ui'
type AdapterProps = Partial<Parameters<typeof NuqsTestingAdapter>[0]>
const CustomWrapper = ({
children,
queryClient,
nuqs,
profileContext,
}: {
children: React.ReactNode
queryClient?: QueryClient
nuqs?: AdapterProps
profileContext?: ProfileContextType
}) => {
const _queryClient =
queryClient ??
new QueryClient({
defaultOptions: {
queries: {
retry: false,
},
},
})
const content = (
<QueryClientProvider client={_queryClient}>
<NuqsTestingAdapter {...nuqs}>
<TooltipProvider>{children}</TooltipProvider>
</NuqsTestingAdapter>
</QueryClientProvider>
)
return profileContext ? (
<ProfileContext.Provider value={profileContext}>{content}</ProfileContext.Provider>
) : (
content
)
}
type CustomRenderOpts = RenderOptions & {
queryClient?: QueryClient
nuqs?: AdapterProps
profileContext?: ProfileContextType
}
export const customRender = (component: React.ReactElement, renderOptions?: CustomRenderOpts) => {
return render(component, {
wrapper: ({ children }) =>
CustomWrapper({
queryClient: renderOptions?.queryClient,
nuqs: renderOptions?.nuqs,
profileContext: renderOptions?.profileContext,
children,
}),
...renderOptions,
})
}
export const customRenderHook = (hook: () => any, renderOptions?: CustomRenderOpts) => {
return renderHook(hook, {
wrapper: ({ children }) =>
CustomWrapper({
children,
queryClient: renderOptions?.queryClient,
nuqs: renderOptions?.nuqs,
profileContext: renderOptions?.profileContext,
}),
...renderOptions,
})
}