@@ -112,6 +112,7 @@ interface Props extends WithIndexationContextProps { | |||
branchLike?: BranchLike; | |||
component?: Component; | |||
currentUser: CurrentUser; | |||
isFetchingBranch?: boolean; | |||
location: Location; | |||
router: Router; | |||
} | |||
@@ -217,7 +218,10 @@ export class App extends React.PureComponent<Props, State> { | |||
addWhitePageClass(); | |||
addSideBarClass(); | |||
this.attachShortcuts(); | |||
this.fetchFirstIssues(true).catch(() => undefined); | |||
if (!this.props.isFetchingBranch) { | |||
this.fetchFirstIssues(true).catch(() => undefined); | |||
} | |||
} | |||
componentDidUpdate(prevProps: Props, prevState: State) { |
@@ -55,6 +55,7 @@ interface Props { | |||
branchLike?: BranchLike; | |||
currentUser: CurrentUser; | |||
component: Component; | |||
isFetchingBranch?: boolean; | |||
location: Location; | |||
router: Router; | |||
} | |||
@@ -111,7 +112,9 @@ export class SecurityHotspotsApp extends React.PureComponent<Props, State> { | |||
componentDidMount() { | |||
this.mounted = true; | |||
this.fetchInitialData(); | |||
if (!this.props.isFetchingBranch) { | |||
this.fetchInitialData(); | |||
} | |||
this.registerKeyboardEvents(); | |||
} |
@@ -18,7 +18,7 @@ | |||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |||
*/ | |||
import { act, screen } from '@testing-library/react'; | |||
import { act, screen, waitFor } from '@testing-library/react'; | |||
import userEvent from '@testing-library/user-event'; | |||
import React from 'react'; | |||
import { Route } from 'react-router-dom'; | |||
@@ -172,7 +172,10 @@ describe('rendering', () => { | |||
`security_hotspots?id=guillaume-peoch-sonarsource_benflix_AYGpXq2bd8qy4i0eO9ed&files=src%2Findex.js&cwe=foo&inNewCodePeriod=true` | |||
); | |||
expect(ui.filterDropdown.query()).not.toBeInTheDocument(); | |||
await waitFor(() => { | |||
expect(ui.filterDropdown.query()).not.toBeInTheDocument(); | |||
}); | |||
expect(ui.filterToReview.query()).not.toBeInTheDocument(); | |||
// Drop selection |
@@ -324,14 +324,17 @@ export function useRefreshBranches() { | |||
} | |||
export function withBranchLikes<P extends { component?: Component }>( | |||
WrappedComponent: React.ComponentType<P & { branchLikes?: BranchLike[]; branchLike?: BranchLike }> | |||
WrappedComponent: React.ComponentType< | |||
P & { branchLikes?: BranchLike[]; branchLike?: BranchLike; isFetchingBranch?: boolean } | |||
> | |||
): React.ComponentType<Omit<P, 'branchLike' | 'branchLikes'>> { | |||
return function WithBranchLike(p: P) { | |||
const { data } = useBranchesQuery(p.component); | |||
const { data, isFetching } = useBranchesQuery(p.component); | |||
return ( | |||
<WrappedComponent | |||
branchLikes={data?.branchLikes ?? []} | |||
branchLike={data?.branchLike} | |||
isFetchingBranch={isFetching} | |||
{...p} | |||
/> | |||
); |