mirror of
https://github.com/supabase/supabase.git
synced 2026-09-22 13:37:53 +08:00
dfb0603a36
## Context As per PR title - sets up incremental default opt in for the Database Connections feature preview Database Connections preview banner should still only show up if it's never been dismissed before, but the CTA's changed to "Explore" rather than "Enable" if the user's default opted in Related discussion here: https://github.com/orgs/supabase/discussions/48639 <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Database Connections preview is now enabled by default. * Added clearer handling for preview state and initialization. * Banner actions open Database Connections when enabled, or the feature preview when disabled. * **Bug Fixes** * Improved banner and menu visibility while preview settings initialize. * Preserved banner dismissal behavior after a previous preference change. * Improved navigation consistency across Database Connections entry points. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
81 lines
2.1 KiB
TypeScript
81 lines
2.1 KiB
TypeScript
import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
import { render, renderHook, type RenderOptions } from '@testing-library/react'
|
|
import { NuqsTestingAdapter } from 'nuqs/adapters/testing'
|
|
import { TooltipProvider } from 'ui'
|
|
import { CommandProvider } from 'ui-patterns/CommandMenu'
|
|
|
|
// End of third-party imports
|
|
|
|
import { ProfileContext, type ProfileContextType } from '@/lib/profile'
|
|
|
|
type AdapterProps = Partial<Parameters<typeof NuqsTestingAdapter>[0]>
|
|
|
|
export const CustomWrapper = ({
|
|
children,
|
|
queryClient,
|
|
nuqs,
|
|
profileContext,
|
|
}: {
|
|
children: React.ReactNode
|
|
queryClient?: QueryClient
|
|
nuqs?: AdapterProps
|
|
profileContext?: ProfileContextType
|
|
}) => {
|
|
const _queryClient =
|
|
queryClient ??
|
|
new QueryClient({
|
|
defaultOptions: {
|
|
queries: { retry: false },
|
|
mutations: { retry: false },
|
|
},
|
|
})
|
|
|
|
const content = (
|
|
<QueryClientProvider client={_queryClient}>
|
|
<NuqsTestingAdapter {...nuqs}>
|
|
<TooltipProvider>
|
|
<CommandProvider openKey="">{children}</CommandProvider>
|
|
</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 = <T,>(hook: () => T, renderOptions?: CustomRenderOpts) => {
|
|
return renderHook(hook, {
|
|
wrapper: ({ children }) =>
|
|
CustomWrapper({
|
|
children,
|
|
queryClient: renderOptions?.queryClient,
|
|
nuqs: renderOptions?.nuqs,
|
|
profileContext: renderOptions?.profileContext,
|
|
}),
|
|
...renderOptions,
|
|
})
|
|
}
|