12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- import {OrganizationFixture} from 'sentry-fixture/organization';
- import {PageFiltersFixture} from 'sentry-fixture/pageFilters';
- import {WidgetFixture} from 'sentry-fixture/widget';
- import {render, screen} from 'sentry-test/reactTestingLibrary';
- import SpansWidgetQueries from './spansWidgetQueries';
- describe('spansWidgetQueries', () => {
- const api = new MockApiClient();
- const organization = OrganizationFixture();
- let widget = WidgetFixture();
- const selection = PageFiltersFixture();
- beforeEach(() => {
- MockApiClient.clearMockResponses();
- widget = WidgetFixture();
- });
- it('calculates the confidence for a single series', async () => {
- MockApiClient.addMockResponse({
- url: '/organizations/org-slug/events-stats/',
- body: {
- confidence: [
- [1, [{count: 'low'}]],
- [2, [{count: 'low'}]],
- [3, [{count: 'low'}]],
- ],
- data: [],
- },
- });
- render(
- <SpansWidgetQueries
- api={api}
- organization={organization}
- widget={widget}
- selection={selection}
- dashboardFilters={{}}
- >
- {({confidence}) => <div>{confidence}</div>}
- </SpansWidgetQueries>
- );
- expect(await screen.findByText('low')).toBeInTheDocument();
- });
- it('calculates the confidence for a multi series', async () => {
- widget = WidgetFixture({
- queries: [
- {
- name: '',
- aggregates: ['a', 'b'],
- fields: ['a', 'b'],
- columns: [],
- conditions: '',
- orderby: '',
- },
- ],
- });
- MockApiClient.addMockResponse({
- url: '/organizations/org-slug/events-stats/',
- body: {
- a: {
- confidence: [
- [1, [{count: 'high'}]],
- [2, [{count: 'high'}]],
- [3, [{count: 'high'}]],
- ],
- data: [],
- },
- b: {
- confidence: [
- [1, [{count: 'high'}]],
- [2, [{count: 'high'}]],
- [3, [{count: 'high'}]],
- ],
- data: [],
- },
- },
- });
- render(
- <SpansWidgetQueries
- api={api}
- organization={organization}
- widget={widget}
- selection={selection}
- dashboardFilters={{}}
- >
- {({confidence}) => <div>{confidence}</div>}
- </SpansWidgetQueries>
- );
- expect(await screen.findByText('high')).toBeInTheDocument();
- });
- });
|