Skip to content

Commit 8b7f09e

Browse files
committed
✅ Add in test for new case
1 parent 5b1d6c9 commit 8b7f09e

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

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

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4429,6 +4429,49 @@ describe('SearchQueryBuilder', () => {
44294429
expect(getLastInput()).toHaveFocus();
44304430
});
44314431
});
4432+
4433+
describe('selecting from filter key suggestions', () => {
4434+
beforeEach(() => {
4435+
MockApiClient.addMockResponse({
4436+
url: '/organizations/org-slug/recent-searches/',
4437+
body: [{query: 'a or b'}, {query: 'some recent query'}],
4438+
});
4439+
});
4440+
4441+
it('should replace the raw search key with the defined key:value', async () => {
4442+
render(
4443+
<SearchQueryBuilder
4444+
{...defaultProps}
4445+
initialQuery=""
4446+
recentSearches={SavedSearchType.ISSUE}
4447+
replaceRawSearchKeys={['span.description']}
4448+
/>,
4449+
{organization: {features: ['search-query-builder-wildcard-operators']}}
4450+
);
4451+
4452+
await userEvent.click(getLastInput());
4453+
4454+
const aOrBOption = await screen.findByRole('option', {name: 'a or b'});
4455+
expect(aOrBOption).toBeInTheDocument();
4456+
4457+
await userEvent.hover(aOrBOption);
4458+
await userEvent.keyboard('{enter}{enter}');
4459+
4460+
expect(
4461+
await screen.findByRole('row', {
4462+
name: `span.description:${WildcardOperators.CONTAINS}a`,
4463+
})
4464+
).toBeInTheDocument();
4465+
4466+
expect(await screen.findByRole('row', {name: 'OR'})).toBeInTheDocument();
4467+
4468+
expect(
4469+
await screen.findByRole('row', {
4470+
name: `span.description:${WildcardOperators.CONTAINS}b`,
4471+
})
4472+
).toBeInTheDocument();
4473+
});
4474+
});
44324475
});
44334476
});
44344477

0 commit comments

Comments
 (0)