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 {LatencyChart} from 'sentry/views/insights/queues/charts/latencyChart';
  4. import {Referrer} from 'sentry/views/insights/queues/referrers';
  5. describe('latencyChart', () => {
  6. const organization = OrganizationFixture();
  7. let eventsStatsMock: jest.Mock;
  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(span.duration)',
  29. 'avg(messaging.message.receive.latency)',
  30. 'spm()',
  31. ],
  32. query: 'span.op:queue.process messaging.destination.name:events',
  33. }),
  34. })
  35. );
  36. await waitForElementToBeRemoved(() => screen.queryAllByTestId('loading-indicator'));
  37. });
  38. });