Skip to content

Commit e253d22

Browse files
committed
ref(onboarding): Mock virtualizer in repo selector tests
Use the same @tanstack/react-virtual mock as scmPlatformFeatures tests instead of a runtime fallback in the component. Reverts the jsdom fallback in ScmVirtualizedMenuList.
1 parent e69c09d commit e253d22

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

static/app/views/onboarding/components/scmRepoSelector.spec.tsx

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,21 @@ import {
1111

1212
import {ScmRepoSelector} from './scmRepoSelector';
1313

14+
// Mock the virtualizer so all items render in JSDOM (no layout engine).
15+
jest.mock('@tanstack/react-virtual', () => ({
16+
useVirtualizer: jest.fn(({count}) => ({
17+
getVirtualItems: () =>
18+
Array.from({length: count}, (_, i) => ({
19+
key: i,
20+
index: i,
21+
start: i * 36,
22+
size: 36,
23+
})),
24+
getTotalSize: () => count * 36,
25+
measureElement: jest.fn(),
26+
})),
27+
}));
28+
1429
function makeOnboardingWrapper(initialState?: OnboardingSessionState) {
1530
return function OnboardingWrapper({children}: {children?: React.ReactNode}) {
1631
return (

static/app/views/onboarding/components/scmVirtualizedMenuList.tsx

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,6 @@ export function ScmVirtualizedMenuList({
5555
);
5656
}
5757

58-
// Fallback when the virtualizer can't measure the container (e.g. jsdom)
59-
if (virtualItems.length === 0 && items.length > 0) {
60-
return (
61-
<div ref={combinedRef} {...innerProps} style={{maxHeight, overflowY: 'auto'}}>
62-
{children}
63-
</div>
64-
);
65-
}
66-
6758
return (
6859
<div ref={combinedRef} {...innerProps} style={{maxHeight, overflowY: 'auto'}}>
6960
<div style={{height: virtualizer.getTotalSize(), position: 'relative'}}>

0 commit comments

Comments
 (0)