throughputChart.spec.tsx 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 {ThroughputChart} from 'sentry/views/performance/queues/charts/throughputChart';
  5. jest.mock('sentry/utils/useOrganization');
  6. describe('throughputChart', () => {
  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(<ThroughputChart />);
  21. screen.getByText('Published vs Processed');
  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. query: 'span.op:[queue.process,queue.publish]',
  34. }),
  35. })
  36. );
  37. await waitForElementToBeRemoved(() => screen.queryAllByTestId('loading-indicator'));
  38. });
  39. });