latencyChart.spec.tsx 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {render, screen, waitForElementToBeRemoved} from 'sentry-test/reactTestingLibrary';
  3. import useOrganization from 'sentry/utils/useOrganization';
  4. import {LatencyChart} from 'sentry/views/performance/queues/charts/latencyChart';
  5. jest.mock('sentry/utils/useOrganization');
  6. describe('latencyChart', () => {
  7. const organization = OrganizationFixture();
  8. jest.mocked(useOrganization).mockReturnValue(organization);
  9. let eventsStatsMock;
  10. beforeEach(() => {
  11. eventsStatsMock = MockApiClient.addMockResponse({
  12. url: `/organizations/${organization.slug}/events-stats/`,
  13. method: 'GET',
  14. body: {
  15. data: [],
  16. },
  17. });
  18. });
  19. it('renders', async () => {
  20. render(<LatencyChart />);
  21. screen.getByText('Avg Latency');
  22. expect(eventsStatsMock).toHaveBeenCalledWith(
  23. '/organizations/org-slug/events-stats/',
  24. expect.objectContaining({
  25. query: expect.objectContaining({
  26. yAxis: [
  27. 'avg_if(span.self_time,span.op,queue.submit.celery)',
  28. 'avg_if(span.self_time,span.op,queue.task.celery)',
  29. 'count_op(queue.submit.celery)',
  30. 'count_op(queue.task.celery)',
  31. ],
  32. }),
  33. })
  34. );
  35. await waitForElementToBeRemoved(() => screen.queryAllByTestId('loading-indicator'));
  36. });
  37. });