transactionsTable.spec.tsx 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {render, screen} from 'sentry-test/reactTestingLibrary';
  3. import useOrganization from 'sentry/utils/useOrganization';
  4. import {TransactionsTable} from 'sentry/views/performance/queues/destinationSummary/transactionsTable';
  5. jest.mock('sentry/utils/useOrganization');
  6. describe('transactionsTable', () => {
  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(<TransactionsTable />);
  43. expect(screen.getByRole('table', {name: 'Transactions'})).toBeInTheDocument();
  44. expect(screen.getByRole('columnheader', {name: 'Transactions'})).toBeInTheDocument();
  45. expect(screen.getByRole('columnheader', {name: 'Type'})).toBeInTheDocument();
  46. expect(
  47. screen.getByRole('columnheader', {name: 'Avg Time in Queue'})
  48. ).toBeInTheDocument();
  49. expect(
  50. screen.getByRole('columnheader', {name: 'Avg Processing Time'})
  51. ).toBeInTheDocument();
  52. expect(screen.getByRole('columnheader', {name: 'Error Rate'})).toBeInTheDocument();
  53. expect(screen.getByRole('columnheader', {name: 'Published'})).toBeInTheDocument();
  54. expect(screen.getByRole('columnheader', {name: 'Processed'})).toBeInTheDocument();
  55. expect(screen.getByRole('columnheader', {name: 'Time Spent'})).toBeInTheDocument();
  56. expect(eventsMock).toHaveBeenCalledWith(
  57. '/organizations/org-slug/events/',
  58. expect.objectContaining({
  59. query: expect.objectContaining({
  60. field: [
  61. 'transaction',
  62. 'count()',
  63. 'count_op(queue.submit.celery)',
  64. 'count_op(queue.task.celery)',
  65. 'sum(span.self_time)',
  66. 'avg(span.self_time)',
  67. 'avg_if(span.self_time,span.op,queue.submit.celery)',
  68. 'avg_if(span.self_time,span.op,queue.task.celery)',
  69. ],
  70. dataset: 'spansMetrics',
  71. }),
  72. })
  73. );
  74. await screen.findByText('celery.backend_cleanup');
  75. expect(screen.getByRole('cell', {name: '3.00ms'})).toBeInTheDocument();
  76. expect(screen.getByRole('cell', {name: '2'})).toBeInTheDocument();
  77. expect(screen.getByRole('cell', {name: '6.00ms'})).toBeInTheDocument();
  78. });
  79. });