1
1
import type { ComponentProps } from 'react' ;
2
2
import { destroyAnnouncer } from '@react-aria/live-announcer' ;
3
+ import { AutofixSetupFixture } from 'sentry-fixture/autofixSetupFixture' ;
3
4
4
5
import {
5
6
act ,
@@ -949,6 +950,16 @@ describe('SearchQueryBuilder', function () {
949
950
950
951
it ( 'displays ask seer button when searching free text' , async function ( ) {
951
952
const mockOnSearch = jest . fn ( ) ;
953
+ MockApiClient . addMockResponse ( {
954
+ url : '/organizations/org-slug/seer/setup-check/' ,
955
+ body : AutofixSetupFixture ( {
956
+ setupAcknowledgement : {
957
+ orgHasAcknowledged : true ,
958
+ userHasAcknowledged : true ,
959
+ } ,
960
+ } ) ,
961
+ } ) ;
962
+
952
963
render (
953
964
< SearchQueryBuilder { ...defaultProps } enableAISearch onSearch = { mockOnSearch } /> ,
954
965
{ organization : { features : [ 'gen-ai-features' , 'gen-ai-explore-traces' ] } }
@@ -960,6 +971,29 @@ describe('SearchQueryBuilder', function () {
960
971
expect ( screen . getByRole ( 'option' , { name : 'Ask Seer' } ) ) . toBeInTheDocument ( ) ;
961
972
} ) ;
962
973
974
+ it ( 'displays enable ai button when searching free text and user has not given consent' , async function ( ) {
975
+ const mockOnSearch = jest . fn ( ) ;
976
+ MockApiClient . addMockResponse ( {
977
+ url : '/organizations/org-slug/seer/setup-check/' ,
978
+ body : AutofixSetupFixture ( {
979
+ setupAcknowledgement : {
980
+ orgHasAcknowledged : false ,
981
+ userHasAcknowledged : false ,
982
+ } ,
983
+ } ) ,
984
+ } ) ;
985
+
986
+ render (
987
+ < SearchQueryBuilder { ...defaultProps } enableAISearch onSearch = { mockOnSearch } /> ,
988
+ { organization : { features : [ 'gen-ai-features' , 'gen-ai-explore-traces' ] } }
989
+ ) ;
990
+
991
+ await userEvent . click ( getLastInput ( ) ) ;
992
+ await userEvent . type ( screen . getByRole ( 'combobox' ) , 'some free text' ) ;
993
+
994
+ expect ( screen . getByRole ( 'option' , { name : 'Enable Gen AI' } ) ) . toBeInTheDocument ( ) ;
995
+ } ) ;
996
+
963
997
it ( 'can add parens by typing' , async function ( ) {
964
998
const mockOnChange = jest . fn ( ) ;
965
999
render ( < SearchQueryBuilder { ...defaultProps } onChange = { mockOnChange } /> ) ;
0 commit comments