123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164 |
- import {OrganizationFixture} from 'sentry-fixture/organization';
- import {PageFiltersFixture} from 'sentry-fixture/pageFilters';
- import {WidgetFixture} from 'sentry-fixture/widget';
- import {WidgetQueryFixture} from 'sentry-fixture/widgetQuery';
- import {DiscoverDatasets} from 'sentry/utils/discover/types';
- import {getSeriesRequestData} from 'sentry/views/dashboards/datasetConfig/utils/getSeriesRequestData';
- import {DisplayType} from 'sentry/views/dashboards/types';
- describe('utils', () => {
- describe('getSeriesRequestData', () => {
- it('returns the correct request data for simple line chart timeseries', () => {
- const widget = WidgetFixture({
- displayType: DisplayType.LINE,
- queries: [
- WidgetQueryFixture({
- fields: ['count()', 'count_unique(user)'],
- aggregates: ['count()', 'count_unique(user)'],
- columns: [],
- }),
- ],
- });
- const pageFilters = PageFiltersFixture();
- const organization = OrganizationFixture();
- const requestData = getSeriesRequestData(
- widget,
- 0,
- organization,
- pageFilters,
- DiscoverDatasets.ERRORS,
- 'test-referrer'
- );
- expect(requestData).toEqual({
- // Baggage
- organization,
- dataset: DiscoverDatasets.ERRORS,
- referrer: 'test-referrer',
- // Meta settings on what should be included in the response
- includePrevious: false,
- includeAllArgs: true,
- partial: true,
- // Page filters
- environment: [],
- project: [],
- start: null,
- end: null,
- period: null,
- // Actual query data
- yAxis: ['count()', 'count_unique(user)'],
- query: 'tag:value',
- orderby: '',
- interval: '30m',
- });
- });
- it('returns the correct request data for line chart timeseries with grouping', () => {
- // This is essentially a TOP_N request because we group by the columns
- // and surface the top results
- const widget = WidgetFixture({
- displayType: DisplayType.LINE,
- queries: [
- WidgetQueryFixture({
- fields: ['title', 'count()'],
- aggregates: ['count()'],
- columns: ['title'],
- }),
- ],
- });
- const pageFilters = PageFiltersFixture();
- const organization = OrganizationFixture();
- const requestData = getSeriesRequestData(
- widget,
- 0,
- organization,
- pageFilters,
- DiscoverDatasets.ERRORS,
- 'test-referrer'
- );
- expect(requestData).toEqual({
- // Baggage
- organization,
- dataset: DiscoverDatasets.ERRORS,
- referrer: 'test-referrer',
- // Meta settings on what should be included in the response
- includePrevious: false,
- includeAllArgs: true,
- partial: true,
- excludeOther: false,
- // Page filters
- environment: [],
- project: [],
- start: null,
- end: null,
- period: null,
- // Actual query data
- field: ['title', 'count()'],
- yAxis: ['count()'],
- query: 'tag:value',
- orderby: '',
- interval: '30m',
- topEvents: 5,
- });
- });
- it('returns the correct request data for top-N chart timeseries with grouping', () => {
- // This is essentially a TOP_N request because we group by the columns
- // and surface the top results
- const widget = WidgetFixture({
- displayType: DisplayType.TOP_N,
- queries: [
- WidgetQueryFixture({
- fields: ['title', 'count()'],
- aggregates: ['count()'],
- columns: ['title'],
- }),
- ],
- });
- const pageFilters = PageFiltersFixture();
- const organization = OrganizationFixture();
- const requestData = getSeriesRequestData(
- widget,
- 0,
- organization,
- pageFilters,
- DiscoverDatasets.ERRORS,
- 'test-referrer'
- );
- expect(requestData).toEqual({
- // Baggage
- organization,
- dataset: DiscoverDatasets.ERRORS,
- referrer: 'test-referrer',
- // Meta settings on what should be included in the response
- includePrevious: false,
- includeAllArgs: true,
- partial: true,
- // Page filters
- environment: [],
- project: [],
- start: null,
- end: null,
- period: null,
- // Actual query data
- field: ['title', 'count()'],
- yAxis: 'count()',
- query: 'tag:value',
- interval: '30m',
- topEvents: 5,
- });
- });
- });
- });
|