11import { OrganizationFixture } from 'sentry-fixture/organization' ;
22import { PageFiltersFixture } from 'sentry-fixture/pageFilters' ;
33
4- import { render , screen , userEvent , within } from 'sentry-test/reactTestingLibrary' ;
4+ import {
5+ render ,
6+ screen ,
7+ userEvent ,
8+ waitFor ,
9+ within ,
10+ } from 'sentry-test/reactTestingLibrary' ;
511
612import type { Organization } from 'sentry/types/organization' ;
713import { DiscoverDatasets } from 'sentry/utils/discover/types' ;
14+ import { FieldKind } from 'sentry/utils/fields' ;
815import { useCustomMeasurements } from 'sentry/utils/useCustomMeasurements' ;
916
1017import { EventsSearchBar } from './eventsSearchBar' ;
@@ -25,6 +32,13 @@ describe('EventsSearchBar', () => {
2532 body : [ ] ,
2633 method : 'POST' ,
2734 } ) ;
35+ MockApiClient . addMockResponse ( {
36+ url : `/organizations/org-slug/tags/` ,
37+ body : [
38+ { key : 'environment' , name : 'environment' , kind : FieldKind . FIELD } ,
39+ { key : 'transaction' , name : 'transaction' , kind : FieldKind . FIELD } ,
40+ ] ,
41+ } ) ;
2842 } ) ;
2943
3044 it . knownFlake ( 'does not show function tags in has: dropdown' , async ( ) => {
@@ -46,24 +60,26 @@ describe('EventsSearchBar', () => {
4660 selectedAggregate : undefined ,
4761 } }
4862 /> ,
49- {
50- organization,
51- }
63+ { organization}
5264 ) ;
5365
5466 const input = await screen . findByRole ( 'combobox' , { name : 'Add a search term' } ) ;
55- await userEvent . click ( input , { delay : null } ) ;
56- await userEvent . paste ( 'has:p' , { delay : null } ) ;
67+ await userEvent . click ( input ) ;
68+ await userEvent . paste ( 'has:p' ) ;
5769
5870 await userEvent . click (
59- screen . getByRole ( 'button' , { name : 'Edit value for filter: has' } )
71+ await screen . findByRole ( 'button' , { name : 'Edit value for filter: has' } )
6072 ) ;
6173
6274 // Assert we actually have has: dropdown options before checking exclusions.
6375 expect ( await screen . findByRole ( 'option' , { name : 'environment' } ) ) . toBeInTheDocument ( ) ;
6476
6577 // p50 is a function and should not be suggested as a has: tag.
6678 expect ( screen . queryByRole ( 'option' , { name : 'p50' } ) ) . not . toBeInTheDocument ( ) ;
79+
80+ await waitFor ( ( ) => {
81+ expect ( screen . getByRole ( 'combobox' ) ) . toBeInTheDocument ( ) ;
82+ } ) ;
6783 } ) ;
6884
6985 it ( 'shows the selected aggregate in the dropdown' , async ( ) => {
@@ -85,18 +101,20 @@ describe('EventsSearchBar', () => {
85101 selectedAggregate : undefined ,
86102 } }
87103 /> ,
88- {
89- organization,
90- }
104+ { organization}
91105 ) ;
92106
93107 const input = await screen . findByRole ( 'combobox' , { name : 'Add a search term' } ) ;
94108 await userEvent . click ( input ) ;
95- await userEvent . paste ( 'count_uni' , { delay : null } ) ;
109+ await userEvent . paste ( 'count_uni' ) ;
96110
97111 expect (
98112 await within ( await screen . findByRole ( 'listbox' ) ) . findByText ( 'count_unique(...)' )
99113 ) . toBeInTheDocument ( ) ;
114+
115+ await waitFor ( ( ) => {
116+ expect ( screen . getByRole ( 'combobox' ) ) . toBeInTheDocument ( ) ;
117+ } ) ;
100118 } ) ;
101119
102120 it ( 'shows normal tags, e.g. transaction, in the dropdown' , async ( ) => {
@@ -118,20 +136,22 @@ describe('EventsSearchBar', () => {
118136 selectedAggregate : undefined ,
119137 } }
120138 /> ,
121- {
122- organization,
123- }
139+ { organization}
124140 ) ;
125141
126142 const input = await screen . findByRole ( 'combobox' , { name : 'Add a search term' } ) ;
127143 await userEvent . clear ( input ) ;
128- await userEvent . click ( input , { delay : null } ) ;
129- await userEvent . paste ( 'transact' , { delay : null } ) ;
144+ await userEvent . click ( input ) ;
145+ await userEvent . paste ( 'transact' ) ;
130146
131147 expect (
132148 await within ( await screen . findByRole ( 'listbox' ) ) . findByRole ( 'option' , {
133149 name : 'transaction' ,
134150 } )
135151 ) . toBeInTheDocument ( ) ;
152+
153+ await waitFor ( ( ) => {
154+ expect ( screen . getByRole ( 'combobox' ) ) . toBeInTheDocument ( ) ;
155+ } ) ;
136156 } ) ;
137157} ) ;
0 commit comments