Skip to content

Commit b294b49

Browse files
JoshuaKGoldbergClaude Sonnet 4
andcommitted
fix(test): Fix flaky MetricsTabContent sidebar toggle test
Wait for the SearchQueryBuilderCombobox inside the re-expanded sidebar to finish initialising. Without this, its async state updates fire after the test ends and trigger an act() warning that jest-fail-on-console catches, causing flaky failures (4 occurrences in the last 30 days). Co-Authored-By: Claude Sonnet 4 <noreply@example.com> Made-with: Cursor
1 parent d30d0f2 commit b294b49

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

static/app/views/explore/metrics/metricsTab.spec.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,8 +730,14 @@ describe('MetricsTabContent (tracemetrics-ui-refresh)', () => {
730730

731731
await userEvent.click(screen.getByRole('button', {name: 'Expand sidebar'}));
732732

733+
const metricToolbar = await waitFor(() => {
734+
return screen.getByTestId('metric-toolbar');
735+
});
736+
737+
// Wait for the SearchQueryBuilderCombobox inside the re-expanded sidebar to
738+
// finish initialising, otherwise its async state updates fire after test end
733739
await waitFor(() => {
734-
expect(screen.getAllByTestId('metric-toolbar')).toHaveLength(1);
740+
expect(within(metricToolbar).getByRole('combobox')).toBeInTheDocument();
735741
});
736742
}
737743
);

0 commit comments

Comments
 (0)