File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change @@ -208,6 +208,11 @@ beforeAll(() => {
208
208
server . listen ( { onUnhandledRequest : 'warn' } )
209
209
} )
210
210
211
+ beforeEach ( ( ) => {
212
+ vi . resetModules ( )
213
+ vi . restoreAllMocks ( )
214
+ } )
215
+
211
216
afterEach ( ( ) => {
212
217
queryClient . clear ( )
213
218
queryClientV5 . clear ( )
@@ -588,4 +593,27 @@ describe('BaseLayout', () => {
588
593
expect ( errorMainAppUI ) . toBeInTheDocument ( )
589
594
} )
590
595
} )
596
+
597
+ describe ( 'When Header has a network call error' , async ( ) => {
598
+ it ( 'renders nothing for the errored header' , async ( ) => {
599
+ vi . spyOn (
600
+ await import ( 'layouts/Header' ) ,
601
+ 'default'
602
+ ) . mockImplementationOnce ( ( ) => {
603
+ throw new Error ( 'Simulated Header Error' )
604
+ } )
605
+
606
+ setup ( { currentUser : userHasDefaultOrg } )
607
+ render ( < BaseLayout > hello</ BaseLayout > , { wrapper : wrapper ( ) } )
608
+
609
+ const header = screen . queryByText ( / H e a d e r / )
610
+ expect ( header ) . not . toBeInTheDocument ( )
611
+
612
+ const mainAppContent = await screen . findByText ( 'hello' )
613
+ expect ( mainAppContent ) . toBeInTheDocument ( )
614
+
615
+ const footerContent = await screen . findByText ( / F o o t e r / )
616
+ expect ( footerContent ) . toBeInTheDocument ( )
617
+ } )
618
+ } )
591
619
} )
Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import Header from 'layouts/Header'
7
7
import ErrorBoundary from 'layouts/shared/ErrorBoundary'
8
8
import { EmptyErrorComponent } from 'layouts/shared/ErrorBoundary/ErrorBoundary'
9
9
import NetworkErrorBoundary from 'layouts/shared/NetworkErrorBoundary'
10
+ import SilentNetworkErrorWrapper from 'layouts/shared/SilentNetworkErrorWrapper'
10
11
import ToastNotifications from 'layouts/ToastNotifications'
11
12
import { RepoBreadcrumbProvider } from 'pages/RepoPage/context'
12
13
import { useImpersonate } from 'services/impersonate'
@@ -110,7 +111,7 @@ function BaseLayout({ children }: React.PropsWithChildren) {
110
111
{ /* Header */ }
111
112
< Suspense >
112
113
< ErrorBoundary errorComponent = { < EmptyErrorComponent /> } >
113
- < NetworkErrorBoundary >
114
+ < SilentNetworkErrorWrapper >
114
115
{ isFullExperience || isImpersonating ? (
115
116
< >
116
117
< GlobalTopBanners />
@@ -121,7 +122,7 @@ function BaseLayout({ children }: React.PropsWithChildren) {
121
122
{ showDefaultOrgSelector ? < InstallationHelpBanner /> : null }
122
123
</ >
123
124
) }
124
- </ NetworkErrorBoundary >
125
+ </ SilentNetworkErrorWrapper >
125
126
</ ErrorBoundary >
126
127
</ Suspense >
127
128
You can’t perform that action at this time.
0 commit comments