mirror of
https://github.com/hanzoai/sentinel.git
synced 2026-10-30 14:49:14 +00:00
54 lines
1.3 KiB
TypeScript
54 lines
1.3 KiB
TypeScript
import {MetricRuleFixture} from 'sentry-fixture/metricRule';
|
|
import {ProjectFixture} from 'sentry-fixture/project';
|
|
|
|
import {Dataset} from 'sentry/views/alerts/rules/metric/types';
|
|
|
|
import {getMetricRuleDiscoverQuery} from './getMetricRuleDiscoverUrl';
|
|
|
|
describe('getMetricRuleDiscoverQuery', () => {
|
|
it('should use metric aggregate in discover query', () => {
|
|
const rule = MetricRuleFixture({
|
|
aggregate: 'failure_rate()',
|
|
dataset: Dataset.TRANSACTIONS,
|
|
});
|
|
const projects = [ProjectFixture()];
|
|
const query = getMetricRuleDiscoverQuery({
|
|
rule,
|
|
projects,
|
|
timePeriod: {
|
|
period: '7d',
|
|
usingPeriod: true,
|
|
start: new Date().toISOString(),
|
|
end: new Date().toISOString(),
|
|
},
|
|
});
|
|
expect(query!.valueOf()).toEqual(
|
|
expect.objectContaining({
|
|
statsPeriod: '7d',
|
|
fields: [
|
|
{
|
|
field: 'transaction',
|
|
width: -1,
|
|
},
|
|
{
|
|
field: 'project',
|
|
width: -1,
|
|
},
|
|
{
|
|
field: 'failure_rate()',
|
|
width: -1,
|
|
},
|
|
{
|
|
field: 'count_unique(user)',
|
|
width: -1,
|
|
},
|
|
{
|
|
field: 'user_misery(300)',
|
|
width: -1,
|
|
},
|
|
],
|
|
})
|
|
);
|
|
});
|
|
});
|