@@ -3,31 +3,37 @@ import { type ReactElement, type ReactNode, useMemo } from 'react';
33
44import { BaseStyles , ThemeProvider } from '@primer/react' ;
55
6- import { mockAuth , mockSettings } from '../__mocks__/state-mocks ' ;
6+ import { QueryClient , QueryClientProvider } from '@tanstack/react-query ' ;
77
88import { AppContext , type AppContextState } from '../context/App' ;
99
1010export type DeepPartial < T > = { [ K in keyof T ] ?: DeepPartial < T [ K ] > } ;
1111
12+ const EMPTY_APP_CONTEXT : Partial < AppContextState > = { } ;
13+
14+ /**
15+ * Test context (settings removed as it's no longer in context)
16+ */
17+ type TestAppContext = Partial < AppContextState > ;
18+
1219/**
1320 * Props for the AppContextProvider wrapper
1421 */
1522interface AppContextProviderProps {
1623 readonly children : ReactNode ;
17- readonly value ?: Partial < AppContextState > ;
24+ readonly value ?: TestAppContext ;
1825}
1926
2027/**
2128 * Wrapper component that provides ThemeProvider, BaseStyles, and AppContext
2229 * with sensible defaults for testing.
2330 */
24- function AppContextProvider ( { children, value = { } } : AppContextProviderProps ) {
31+ function AppContextProvider ( {
32+ children,
33+ value = EMPTY_APP_CONTEXT ,
34+ } : AppContextProviderProps ) {
2535 const defaultValue : AppContextState = useMemo ( ( ) => {
2636 return {
27- auth : mockAuth ,
28- settings : mockSettings ,
29- isLoggedIn : true ,
30-
3137 notifications : [ ] ,
3238 notificationCount : 0 ,
3339 unreadNotificationCount : 0 ,
@@ -52,11 +58,6 @@ function AppContextProvider({ children, value = {} }: AppContextProviderProps) {
5258 markNotificationsAsDone : vi . fn ( ) ,
5359 unsubscribeNotification : vi . fn ( ) ,
5460
55- clearFilters : vi . fn ( ) ,
56- resetSettings : vi . fn ( ) ,
57- updateSetting : vi . fn ( ) ,
58- updateFilter : vi . fn ( ) ,
59-
6061 ...value ,
6162 } as AppContextState ;
6263 } , [ value ] ) ;
@@ -82,9 +83,21 @@ export function renderWithAppContext(
8283 ui : ReactElement ,
8384 context : Partial < AppContextState > = { } ,
8485) {
86+ const queryClient = new QueryClient ( {
87+ defaultOptions : {
88+ queries : {
89+ retry : false ,
90+ refetchOnWindowFocus : false ,
91+ refetchInterval : false ,
92+ } ,
93+ } ,
94+ } ) ;
95+
8596 return render ( ui , {
8697 wrapper : ( { children } ) => (
87- < AppContextProvider value = { context } > { children } </ AppContextProvider >
98+ < QueryClientProvider client = { queryClient } >
99+ < AppContextProvider value = { context } > { children } </ AppContextProvider >
100+ </ QueryClientProvider >
88101 ) ,
89102 } ) ;
90103}
0 commit comments