branchLike?: BranchLike;
component?: Component;
currentUser: CurrentUser;
+ isFetchingBranch?: boolean;
location: Location;
router: Router;
}
addWhitePageClass();
addSideBarClass();
this.attachShortcuts();
- this.fetchFirstIssues(true).catch(() => undefined);
+
+ if (!this.props.isFetchingBranch) {
+ this.fetchFirstIssues(true).catch(() => undefined);
+ }
}
componentDidUpdate(prevProps: Props, prevState: State) {
branchLike?: BranchLike;
currentUser: CurrentUser;
component: Component;
+ isFetchingBranch?: boolean;
location: Location;
router: Router;
}
componentDidMount() {
this.mounted = true;
- this.fetchInitialData();
+ if (!this.props.isFetchingBranch) {
+ this.fetchInitialData();
+ }
this.registerKeyboardEvents();
}
* 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';
`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
}
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}
/>
);