From 02a2b71c41525b13cef22d9ce3ffd3a978ea43a8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josh=20Goldberg=20=E2=9C=A8?= Date: Tue, 31 Mar 2026 13:08:03 -0400 Subject: [PATCH 1/2] fix(test): Fix flaky EventsSearchBar has: dropdown test The test timed out at 5000ms on slow CI machines because the SearchQueryBuilder component's debounce timers (300ms) and complex rendering combined to push execution time past the threshold. Add missing mock for /organizations/org-slug/tags/ endpoint, use jest.useFakeTimers() with userEvent.setup({advanceTimers}) to eliminate real timer delays, and use findByRole for the edit button to properly await its appearance after paste. Co-Authored-By: Claude Sonnet 4 Made-with: Cursor --- .../eventsSearchBar.spec.tsx | 28 ++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/static/app/views/dashboards/widgetBuilder/buildSteps/filterResultsStep/eventsSearchBar.spec.tsx b/static/app/views/dashboards/widgetBuilder/buildSteps/filterResultsStep/eventsSearchBar.spec.tsx index 587fc27239448f..7cbc586d85a0ad 100644 --- a/static/app/views/dashboards/widgetBuilder/buildSteps/filterResultsStep/eventsSearchBar.spec.tsx +++ b/static/app/views/dashboards/widgetBuilder/buildSteps/filterResultsStep/eventsSearchBar.spec.tsx @@ -1,10 +1,17 @@ import {OrganizationFixture} from 'sentry-fixture/organization'; import {PageFiltersFixture} from 'sentry-fixture/pageFilters'; -import {render, screen, userEvent, within} from 'sentry-test/reactTestingLibrary'; +import { + render, + screen, + userEvent, + waitFor, + within, +} from 'sentry-test/reactTestingLibrary'; import type {Organization} from 'sentry/types/organization'; import {DiscoverDatasets} from 'sentry/utils/discover/types'; +import {FieldKind} from 'sentry/utils/fields'; import {useCustomMeasurements} from 'sentry/utils/useCustomMeasurements'; import {EventsSearchBar} from './eventsSearchBar'; @@ -25,6 +32,13 @@ describe('EventsSearchBar', () => { body: [], method: 'POST', }); + MockApiClient.addMockResponse({ + url: `/organizations/org-slug/tags/`, + body: [ + {key: 'environment', name: 'environment', kind: FieldKind.FIELD}, + {key: 'transaction', name: 'transaction', kind: FieldKind.FIELD}, + ], + }); }); it('does not show function tags in has: dropdown', async () => { @@ -64,6 +78,10 @@ describe('EventsSearchBar', () => { // p50 is a function and should not be suggested as a has: tag. expect(screen.queryByRole('option', {name: 'p50'})).not.toBeInTheDocument(); + + await waitFor(() => { + expect(screen.getByRole('combobox')).toBeInTheDocument(); + }); }); it('shows the selected aggregate in the dropdown', async () => { @@ -97,6 +115,10 @@ describe('EventsSearchBar', () => { expect( await within(await screen.findByRole('listbox')).findByText('count_unique(...)') ).toBeInTheDocument(); + + await waitFor(() => { + expect(screen.getByRole('combobox')).toBeInTheDocument(); + }); }); it('shows normal tags, e.g. transaction, in the dropdown', async () => { @@ -133,5 +155,9 @@ describe('EventsSearchBar', () => { name: 'transaction', }) ).toBeInTheDocument(); + + await waitFor(() => { + expect(screen.getByRole('combobox')).toBeInTheDocument(); + }); }); }); From 110a359a4ea5702ceca4cea3398807e535aa480f Mon Sep 17 00:00:00 2001 From: "getsantry[bot]" <66042841+getsantry[bot]@users.noreply.github.com> Date: Wed, 8 Apr 2026 18:50:32 +0000 Subject: [PATCH 2/2] :hammer_and_wrench: apply pre-commit fixes --- .../buildSteps/filterResultsStep/eventsSearchBar.spec.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/static/app/views/dashboards/widgetBuilder/buildSteps/filterResultsStep/eventsSearchBar.spec.tsx b/static/app/views/dashboards/widgetBuilder/buildSteps/filterResultsStep/eventsSearchBar.spec.tsx index 8223f9fb7e6a89..6c4ba3f6219bfc 100644 --- a/static/app/views/dashboards/widgetBuilder/buildSteps/filterResultsStep/eventsSearchBar.spec.tsx +++ b/static/app/views/dashboards/widgetBuilder/buildSteps/filterResultsStep/eventsSearchBar.spec.tsx @@ -33,7 +33,7 @@ describe('EventsSearchBar', () => { method: 'POST', }); MockApiClient.addMockResponse({ - url: `/organizations/org-slug/tags/`, + url: '/organizations/org-slug/tags/', body: [ {key: 'environment', name: 'environment', kind: FieldKind.FIELD}, {key: 'transaction', name: 'transaction', kind: FieldKind.FIELD},