destinationSummaryPage.spec.tsx 2.8 KB

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