latencyChart.spec.tsx 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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.duration,span.op,queue.publish)',
  28. 'avg_if(span.duration,span.op,queue.process)',
  29. 'avg(messaging.message.receive.latency)',
  30. 'count_op(queue.publish)',
  31. 'count_op(queue.process)',
  32. ],
  33. }),
  34. })
  35. );
  36. await waitForElementToBeRemoved(() => screen.queryAllByTestId('loading-indicator'));
  37. });
  38. });