@@ -435,7 +435,6 @@ describe('SearchQueryBuilder', () => {
435435 expect ( await screen . findByRole ( 'button' , { name : 'All' } ) ) . toBeInTheDocument ( ) ;
436436 expect ( screen . getByRole ( 'button' , { name : 'Category 1' } ) ) . toBeInTheDocument ( ) ;
437437 expect ( screen . getByRole ( 'button' , { name : 'Category 2' } ) ) . toBeInTheDocument ( ) ;
438- expect ( screen . getByRole ( 'button' , { name : 'Conditionals' } ) ) . toBeInTheDocument ( ) ;
439438
440439 const menu = screen . getByRole ( 'listbox' ) ;
441440 const groups = within ( menu ) . getAllByRole ( 'group' ) ;
@@ -717,6 +716,33 @@ describe('SearchQueryBuilder', () => {
717716 ) ;
718717 } ) ;
719718 } ) ;
719+
720+ describe ( 'conditionals category' , ( ) => {
721+ it ( 'does not render conditionals category when on first input' , async ( ) => {
722+ render ( < SearchQueryBuilder { ...defaultProps } initialQuery = "" /> , {
723+ organization : { features : [ 'search-query-builder-conditionals-combobox-menus' ] } ,
724+ } ) ;
725+
726+ await userEvent . click ( getLastInput ( ) ) ;
727+ expect ( await screen . findByRole ( 'button' , { name : 'All' } ) ) . toBeInTheDocument ( ) ;
728+
729+ expect (
730+ screen . queryByRole ( 'button' , { name : 'Conditionals' } )
731+ ) . not . toBeInTheDocument ( ) ;
732+ } ) ;
733+
734+ it ( 'renders conditionals category when not on first input' , async ( ) => {
735+ render ( < SearchQueryBuilder { ...defaultProps } initialQuery = "span.op:test" /> , {
736+ organization : { features : [ 'search-query-builder-conditionals-combobox-menus' ] } ,
737+ } ) ;
738+
739+ await userEvent . click ( getLastInput ( ) ) ;
740+ // Should show conditionals button
741+ expect (
742+ await screen . findByRole ( 'button' , { name : 'Conditionals' } )
743+ ) . toBeInTheDocument ( ) ;
744+ } ) ;
745+ } ) ;
720746 } ) ;
721747
722748 describe ( 'mouse interactions' , ( ) => {
@@ -3740,11 +3766,18 @@ describe('SearchQueryBuilder', () => {
37403766 } ) ;
37413767
37423768 it ( 'should not add the conditionals section to filter key menu' , async ( ) => {
3743- render ( < SearchQueryBuilder { ...defaultProps } disallowLogicalOperators /> , {
3744- organization : { features : [ 'search-query-builder-conditionals-combobox-menus' ] } ,
3745- } ) ;
3769+ render (
3770+ < SearchQueryBuilder
3771+ { ...defaultProps }
3772+ initialQuery = "span.op:test"
3773+ disallowLogicalOperators
3774+ /> ,
3775+ {
3776+ organization : { features : [ 'search-query-builder-conditionals-combobox-menus' ] } ,
3777+ }
3778+ ) ;
37463779
3747- await userEvent . click ( screen . getByRole ( 'combobox' , { name : 'Add a search term' } ) ) ;
3780+ await userEvent . click ( getLastInput ( ) ) ;
37483781 expect ( await screen . findByRole ( 'button' , { name : 'All' } ) ) . toBeInTheDocument ( ) ;
37493782
37503783 await waitFor ( ( ) =>
0 commit comments