queuesLandingPage.spec.tsx 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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 QueuesLandingPage from 'sentry/views/performance/queues/queuesLandingPage';
  7. jest.mock('sentry/utils/useLocation');
  8. jest.mock('sentry/utils/usePageFilters');
  9. jest.mock('sentry/utils/useProjects');
  10. describe('queuesLandingPage', () => {
  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;
  49. beforeEach(() => {
  50. eventsMock = MockApiClient.addMockResponse({
  51. url: `/organizations/${organization.slug}/events/`,
  52. method: 'GET',
  53. body: {data: [{'count()': 1}]},
  54. });
  55. eventsStatsMock = MockApiClient.addMockResponse({
  56. url: `/organizations/${organization.slug}/events-stats/`,
  57. method: 'GET',
  58. body: {data: []},
  59. });
  60. });
  61. it('renders', async () => {
  62. render(<QueuesLandingPage />, {organization});
  63. await screen.findByRole('table', {name: 'Queues'});
  64. await waitForElementToBeRemoved(() => screen.queryAllByTestId('loading-indicator'));
  65. screen.getByPlaceholderText('Search for more destinations');
  66. screen.getByText('Avg Latency');
  67. screen.getByText('Published vs Processed');
  68. expect(eventsStatsMock).toHaveBeenCalled();
  69. expect(eventsMock).toHaveBeenCalled();
  70. });
  71. });