Skip to content

Commit 207d714

Browse files
Mihir-MavalankarClaude Opus 4.6
andcommitted
test(seer): Add real-world widget query test for getSearchFiltersForLLM
Verify parsing of an actual dashboard widget conditions string with Contains IN list, single Contains, and negated Contains filters. Co-Authored-By: Claude Opus 4.6 <noreply@example.com>
1 parent e215f55 commit 207d714

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

static/app/views/dashboards/widgetCard/widgetLLMContext.spec.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,4 +100,25 @@ describe('getSearchFiltersForLLM', () => {
100100
it('falls back to raw string when only free text (no key:value filters)', () => {
101101
expect(getSearchFiltersForLLM('just some free text')).toBe('just some free text');
102102
});
103+
104+
it('parses a real dashboard widget query with Contains IN list + single Contains + negated Contains', () => {
105+
// Real query from a dashboard widget — \uf00d markers are invisible but present
106+
const conditions =
107+
'span.description:\uf00dContains\uf00d[sentry.tasks.autofix.generate_issue_summary_only,sentry.tasks.autofix.run_automation_only_task,sentry.tasks.autofix.generate_summary_and_run_automation] span.name:\uf00dContains\uf00dqueue.task.taskworker !trigger_path:\uf00dContains\uf00dold_seer_automation';
108+
expect(getSearchFiltersForLLM(conditions)).toEqual([
109+
{
110+
field: 'span.description',
111+
op: 'contains',
112+
value:
113+
'[sentry.tasks.autofix.generate_issue_summary_only,sentry.tasks.autofix.run_automation_only_task,sentry.tasks.autofix.generate_summary_and_run_automation]',
114+
},
115+
{field: 'span.name', op: 'contains', value: 'queue.task.taskworker'},
116+
{field: 'trigger_path', op: 'NOT contains', value: 'old_seer_automation'},
117+
]);
118+
});
119+
120+
it('handles empty conditions from a widget with no filters', () => {
121+
// First query from the user's example — aggregates only, no conditions
122+
expect(getSearchFiltersForLLM('')).toEqual([]);
123+
});
103124
});

static/app/views/dashboards/widgetCard/widgetLLMContext.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export function getSearchFiltersForLLM(
2929
}
3030
return filters.map(f => ({
3131
field: f.key.text,
32-
op: `${f.negated ? 'NOT ' : ''}${OP_LABELS[f.operator as keyof typeof OP_LABELS] ?? f.operator}`,
32+
op: `${f.negated ? 'NOT ' : ''}${OP_LABELS[f.operator] ?? f.operator}`,
3333
value: f.value.text,
3434
}));
3535
} catch {

0 commit comments

Comments
 (0)