destinationSummaryPage.spec.tsx 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {render, screen, waitForElementToBeRemoved} from 'sentry-test/reactTestingLibrary';
  3. import {useLocation} from 'sentry/utils/useLocation';
  4. import usePageFilters from 'sentry/utils/usePageFilters';
  5. import useProjects from 'sentry/utils/useProjects';
  6. import PageWithProviders from 'sentry/views/performance/queues/destinationSummary/destinationSummaryPage';
  7. jest.mock('sentry/utils/useLocation');
  8. jest.mock('sentry/utils/usePageFilters');
  9. jest.mock('sentry/utils/useProjects');
  10. describe('destinationSummaryPage', () => {
  11. const organization = OrganizationFixture({features: ['performance-queues-view']});
  12. jest.mocked(usePageFilters).mockReturnValue({
  13. isReady: true,
  14. desyncedFilters: new Set(),
  15. pinnedFilters: new Set(),
  16. shouldPersist: true,
  17. selection: {
  18. datetime: {
  19. period: '10d',
  20. start: null,
  21. end: null,
  22. utc: false,
  23. },
  24. environments: [],
  25. projects: [],
  26. },
  27. });
  28. jest.mocked(useLocation).mockReturnValue({
  29. pathname: '',
  30. search: '',
  31. query: {statsPeriod: '10d', project: '1'},
  32. hash: '',
  33. state: undefined,
  34. action: 'PUSH',
  35. key: '',
  36. });
  37. jest.mocked(useProjects).mockReturnValue({
  38. projects: [],
  39. onSearch: jest.fn(),
  40. placeholders: [],
  41. fetching: false,
  42. hasMore: null,
  43. fetchError: null,
  44. initiallyLoaded: false,
  45. });
  46. let eventsMock, eventsStatsMock, spanFieldTagsMock;
  47. beforeEach(() => {
  48. eventsMock = MockApiClient.addMockResponse({
  49. url: `/organizations/${organization.slug}/events/`,
  50. method: 'GET',
  51. body: {data: []},
  52. });
  53. eventsStatsMock = MockApiClient.addMockResponse({
  54. url: `/organizations/${organization.slug}/events-stats/`,
  55. method: 'GET',
  56. body: {data: []},
  57. });
  58. spanFieldTagsMock = MockApiClient.addMockResponse({
  59. url: `/organizations/${organization.slug}/spans/fields/`,
  60. method: 'GET',
  61. body: [
  62. {
  63. key: 'api_key',
  64. name: 'Api Key',
  65. },
  66. {
  67. key: 'bytes.size',
  68. name: 'Bytes.Size',
  69. },
  70. ],
  71. });
  72. });
  73. it('renders', async () => {
  74. render(<PageWithProviders />, {organization});
  75. await screen.findByRole('table', {name: 'Transactions'});
  76. await waitForElementToBeRemoved(() => screen.queryAllByTestId('loading-indicator'));
  77. screen.getByText('Avg Latency');
  78. screen.getByText('Published vs Processed');
  79. expect(eventsStatsMock).toHaveBeenCalled();
  80. expect(eventsMock).toHaveBeenCalled();
  81. expect(spanFieldTagsMock).toHaveBeenCalledWith(
  82. `/organizations/${organization.slug}/spans/fields/`,
  83. expect.objectContaining({
  84. method: 'GET',
  85. query: {
  86. project: [],
  87. environment: [],
  88. statsPeriod: '1h',
  89. },
  90. })
  91. );
  92. });
  93. });