Skip to content

Commit 3d9da9f

Browse files
committed
✅ Update search query builder tests
1 parent f895807 commit 3d9da9f

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

static/app/components/searchQueryBuilder/index.spec.tsx

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import type {ComponentProps} from 'react';
22
import {destroyAnnouncer} from '@react-aria/live-announcer';
3+
import {AutofixSetupFixture} from 'sentry-fixture/autofixSetupFixture';
34

45
import {
56
act,
@@ -949,6 +950,16 @@ describe('SearchQueryBuilder', function () {
949950

950951
it('displays ask seer button when searching free text', async function () {
951952
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+
952963
render(
953964
<SearchQueryBuilder {...defaultProps} enableAISearch onSearch={mockOnSearch} />,
954965
{organization: {features: ['gen-ai-features', 'gen-ai-explore-traces']}}
@@ -960,6 +971,29 @@ describe('SearchQueryBuilder', function () {
960971
expect(screen.getByRole('option', {name: 'Ask Seer'})).toBeInTheDocument();
961972
});
962973

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+
963997
it('can add parens by typing', async function () {
964998
const mockOnChange = jest.fn();
965999
render(<SearchQueryBuilder {...defaultProps} onChange={mockOnChange} />);

0 commit comments

Comments
 (0)