queuesLandingPage.spec.tsx 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {ProjectFixture} from 'sentry-fixture/project';
  3. import {render, screen} from 'sentry-test/reactTestingLibrary';
  4. import {useLocation} from 'sentry/utils/useLocation';
  5. import usePageFilters from 'sentry/utils/usePageFilters';
  6. import useProjects from 'sentry/utils/useProjects';
  7. import QueuesLandingPage from 'sentry/views/insights/queues/views/queuesLandingPage';
  8. jest.mock('sentry/utils/useLocation');
  9. jest.mock('sentry/utils/usePageFilters');
  10. jest.mock('sentry/utils/useProjects');
  11. describe('queuesLandingPage', () => {
  12. const organization = OrganizationFixture({
  13. features: ['insights-addon-modules'],
  14. });
  15. const project = ProjectFixture();
  16. project.firstTransactionEvent = true;
  17. project.hasInsightsQueues = true;
  18. jest.mocked(usePageFilters).mockReturnValue({
  19. isReady: true,
  20. desyncedFilters: new Set(),
  21. pinnedFilters: new Set(),
  22. shouldPersist: true,
  23. selection: {
  24. datetime: {
  25. period: '10d',
  26. start: null,
  27. end: null,
  28. utc: false,
  29. },
  30. environments: [],
  31. projects: [],
  32. },
  33. });
  34. jest.mocked(useLocation).mockReturnValue({
  35. pathname: '',
  36. search: '',
  37. query: {statsPeriod: '10d', project: '1'},
  38. hash: '',
  39. state: undefined,
  40. action: 'PUSH',
  41. key: '',
  42. });
  43. jest.mocked(useProjects).mockReturnValue({
  44. projects: [project],
  45. onSearch: jest.fn(),
  46. reloadProjects: jest.fn(),
  47. placeholders: [],
  48. fetching: false,
  49. hasMore: null,
  50. fetchError: null,
  51. initiallyLoaded: false,
  52. });
  53. let eventsMock, eventsStatsMock;
  54. beforeEach(() => {
  55. eventsMock = MockApiClient.addMockResponse({
  56. url: `/organizations/${organization.slug}/events/`,
  57. method: 'GET',
  58. body: {data: [{'count()': 1}]},
  59. });
  60. eventsStatsMock = MockApiClient.addMockResponse({
  61. url: `/organizations/${organization.slug}/events-stats/`,
  62. method: 'GET',
  63. body: {data: []},
  64. });
  65. });
  66. it('renders', async () => {
  67. render(<QueuesLandingPage />, {organization});
  68. await screen.findByRole('table', {name: 'Queues'});
  69. screen.getByPlaceholderText('Search for more destinations');
  70. screen.getByText('Avg Latency');
  71. screen.getByText('Published vs Processed');
  72. expect(eventsStatsMock).toHaveBeenCalled();
  73. expect(eventsMock).toHaveBeenCalled();
  74. });
  75. });