Skip to content

fix(test): stabilize flaky MetricsTabContent sidebar toggle test#111909

Closed
JoshuaKGoldberg wants to merge 3 commits intomasterfrom
fix/flaky-metrics-tab-spec-v2
Closed

fix(test): stabilize flaky MetricsTabContent sidebar toggle test#111909
JoshuaKGoldberg wants to merge 3 commits intomasterfrom
fix/flaky-metrics-tab-spec-v2

Conversation

@JoshuaKGoldberg
Copy link
Copy Markdown
Member

@JoshuaKGoldberg JoshuaKGoldberg commented Mar 31, 2026

The test toggles the query builder sidebar with the expand control collapses and re-expands the sidebar, but only waited for the toolbar testId to reappear. The SearchQueryBuilderCombobox inside the toolbar was still running async initialization, so its state updates leaked past the test boundary. This adds an explicit wait afterwards to let that initialization finish.

Fixes ENG-7202

Made with Cursor

@JoshuaKGoldberg JoshuaKGoldberg added Scope: Frontend Automatically applied to PRs that change frontend components Frontend: Rerun Flaky Tests Known flaky tests should be run many times, just to be safe. labels Mar 31, 2026
@JoshuaKGoldberg JoshuaKGoldberg changed the title fix(test): Fix flaky MetricsTabContent sidebar toggle test fix(test): stabilize flaky MetricsTabContent sidebar toggle test Mar 31, 2026
@linear-code
Copy link
Copy Markdown

linear-code bot commented Apr 1, 2026

@JoshuaKGoldberg JoshuaKGoldberg changed the base branch from fix/flaky-test-rerun-infra to master April 7, 2026 14:09
@JoshuaKGoldberg JoshuaKGoldberg removed the Frontend: Rerun Flaky Tests Known flaky tests should be run many times, just to be safe. label Apr 7, 2026
@JoshuaKGoldberg JoshuaKGoldberg force-pushed the fix/flaky-metrics-tab-spec-v2 branch from 9f36ce9 to b294b49 Compare April 8, 2026 18:40
@JoshuaKGoldberg JoshuaKGoldberg force-pushed the fix/flaky-metrics-tab-spec-v2 branch from b294b49 to 453e4da Compare April 8, 2026 18:43
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
@JoshuaKGoldberg JoshuaKGoldberg force-pushed the fix/flaky-metrics-tab-spec-v2 branch from 453e4da to 1f81cb4 Compare April 8, 2026 18:44
@JoshuaKGoldberg JoshuaKGoldberg added the Frontend: Rerun Flaky Tests Known flaky tests should be run many times, just to be safe. label Apr 8, 2026
@JoshuaKGoldberg JoshuaKGoldberg marked this pull request as ready for review April 8, 2026 19:27
@JoshuaKGoldberg JoshuaKGoldberg requested a review from a team as a code owner April 8, 2026 19:27
Comment on lines 737 to 739
await waitFor(() => {
expect(screen.getAllByTestId('metric-toolbar')).toHaveLength(1);
expect(within(metricToolbar).getByRole('combobox')).toBeInTheDocument();
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
await waitFor(() => {
expect(screen.getAllByTestId('metric-toolbar')).toHaveLength(1);
expect(within(metricToolbar).getByRole('combobox')).toBeInTheDocument();
});
const combobox = await within(metricToolbar).findByRole('combobox')
expect(combobox).toBeInTheDocument();

@JoshuaKGoldberg
Copy link
Copy Markdown
Member Author

This test was deleted in #111920.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Frontend: Rerun Flaky Tests Known flaky tests should be run many times, just to be safe. Scope: Frontend Automatically applied to PRs that change frontend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants