queuesTable.spec.tsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {render, screen} from 'sentry-test/reactTestingLibrary';
  3. import useOrganization from 'sentry/utils/useOrganization';
  4. import {QueuesTable} from 'sentry/views/performance/queues/queuesTable';
  5. jest.mock('sentry/utils/useOrganization');
  6. describe('queuesTable', () => {
  7. const organization = OrganizationFixture();
  8. jest.mocked(useOrganization).mockReturnValue(organization);
  9. let eventsMock;
  10. beforeEach(() => {
  11. eventsMock = MockApiClient.addMockResponse({
  12. url: `/organizations/${organization.slug}/events/`,
  13. method: 'GET',
  14. body: {
  15. data: [
  16. {
  17. transaction: 'celery.backend_cleanup',
  18. 'avg_if(span.self_time,span.op,queue.task.celery)': 3,
  19. 'sum(span.self_time)': 6,
  20. 'count_op(queue.submit.celery)': 0,
  21. 'count_op(queue.task.celery)': 2,
  22. 'avg_if(span.self_time,span.op,queue.submit.celery)': 0,
  23. 'count()': 2,
  24. 'avg(span.self_time)': 3,
  25. },
  26. ],
  27. meta: {
  28. fields: {
  29. 'avg_if(span.self_time,span.op,queue.task.celery)': 'duration',
  30. 'count_op(queue.submit.celery)': 'integer',
  31. 'avg_if(span.self_time,span.op,queue.submit.celery)': 'duration',
  32. 'count_op(queue.task.celery)': 'integer',
  33. 'sum(span.self_time)': 'duration',
  34. 'count()': 'integer',
  35. 'avg(span.self_time)': 'duration',
  36. },
  37. },
  38. },
  39. });
  40. });
  41. it('renders', async () => {
  42. render(<QueuesTable />);
  43. expect(screen.getByRole('table', {name: 'Queues'})).toBeInTheDocument();
  44. expect(screen.getByRole('columnheader', {name: 'Destination'})).toBeInTheDocument();
  45. expect(
  46. screen.getByRole('columnheader', {name: 'Avg Time in Queue'})
  47. ).toBeInTheDocument();
  48. expect(
  49. screen.getByRole('columnheader', {name: 'Avg Processing Time'})
  50. ).toBeInTheDocument();
  51. expect(screen.getByRole('columnheader', {name: 'Error Rate'})).toBeInTheDocument();
  52. expect(screen.getByRole('columnheader', {name: 'Published'})).toBeInTheDocument();
  53. expect(screen.getByRole('columnheader', {name: 'Processed'})).toBeInTheDocument();
  54. expect(screen.getByRole('columnheader', {name: 'Time Spent'})).toBeInTheDocument();
  55. expect(eventsMock).toHaveBeenCalledWith(
  56. '/organizations/org-slug/events/',
  57. expect.objectContaining({
  58. query: expect.objectContaining({
  59. field: [
  60. 'transaction',
  61. 'count()',
  62. 'count_op(queue.submit.celery)',
  63. 'count_op(queue.task.celery)',
  64. 'sum(span.self_time)',
  65. 'avg(span.self_time)',
  66. 'avg_if(span.self_time,span.op,queue.submit.celery)',
  67. 'avg_if(span.self_time,span.op,queue.task.celery)',
  68. ],
  69. dataset: 'spansMetrics',
  70. }),
  71. })
  72. );
  73. await screen.findByText('celery.backend_cleanup');
  74. screen.getByText('3.00ms');
  75. screen.getByText(2);
  76. screen.getByText('6.00ms');
  77. });
  78. });