latencyChart.spec.tsx 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {render, screen, waitForElementToBeRemoved} from 'sentry-test/reactTestingLibrary';
  3. import {LatencyChart} from 'sentry/views/performance/queues/charts/latencyChart';
  4. import {Referrer} from 'sentry/views/performance/queues/referrers';
  5. describe('latencyChart', () => {
  6. const organization = OrganizationFixture();
  7. let eventsStatsMock;
  8. beforeEach(() => {
  9. eventsStatsMock = MockApiClient.addMockResponse({
  10. url: `/organizations/${organization.slug}/events-stats/`,
  11. method: 'GET',
  12. body: {
  13. data: [],
  14. },
  15. });
  16. });
  17. it('renders', async () => {
  18. render(
  19. <LatencyChart destination="events" referrer={Referrer.QUEUES_SUMMARY_CHARTS} />,
  20. {organization}
  21. );
  22. screen.getByText('Avg Latency');
  23. expect(eventsStatsMock).toHaveBeenCalledWith(
  24. '/organizations/org-slug/events-stats/',
  25. expect.objectContaining({
  26. query: expect.objectContaining({
  27. yAxis: [
  28. 'avg_if(span.duration,span.op,queue.publish)',
  29. 'avg_if(span.duration,span.op,queue.process)',
  30. 'avg(messaging.message.receive.latency)',
  31. 'count_op(queue.publish)',
  32. 'count_op(queue.process)',
  33. ],
  34. query:
  35. 'span.op:[queue.process,queue.publish] messaging.destination.name:events',
  36. }),
  37. })
  38. );
  39. await waitForElementToBeRemoved(() => screen.queryAllByTestId('loading-indicator'));
  40. });
  41. });