queuesLandingPage.spec.tsx 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 useOrganization from 'sentry/utils/useOrganization';
  5. import usePageFilters from 'sentry/utils/usePageFilters';
  6. import useProjects from 'sentry/utils/useProjects';
  7. import QueuesLandingPage from 'sentry/views/performance/queues/queuesLandingPage';
  8. jest.mock('sentry/utils/useLocation');
  9. jest.mock('sentry/utils/usePageFilters');
  10. jest.mock('sentry/utils/useOrganization');
  11. jest.mock('sentry/utils/useProjects');
  12. describe('queuesLandingPage', () => {
  13. const organization = OrganizationFixture({features: ['performance-queues-view']});
  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(useOrganization).mockReturnValue(organization);
  40. jest.mocked(useProjects).mockReturnValue({
  41. projects: [],
  42. onSearch: jest.fn(),
  43. placeholders: [],
  44. fetching: false,
  45. hasMore: null,
  46. fetchError: null,
  47. initiallyLoaded: false,
  48. });
  49. let eventsMock, eventsStatsMock;
  50. beforeEach(() => {
  51. eventsMock = MockApiClient.addMockResponse({
  52. url: `/organizations/${organization.slug}/events/`,
  53. method: 'GET',
  54. body: {data: []},
  55. });
  56. eventsStatsMock = MockApiClient.addMockResponse({
  57. url: `/organizations/${organization.slug}/events-stats/`,
  58. method: 'GET',
  59. body: {data: []},
  60. });
  61. });
  62. it('renders', async () => {
  63. render(<QueuesLandingPage />);
  64. await screen.findByRole('table', {name: 'Queues'});
  65. await waitForElementToBeRemoved(() => screen.queryAllByTestId('loading-indicator'));
  66. screen.getByPlaceholderText('Search for events, users, tags, and more');
  67. screen.getByText('Avg Latency');
  68. screen.getByText('Published vs Processed');
  69. expect(eventsStatsMock).toHaveBeenCalled();
  70. expect(eventsMock).toHaveBeenCalled();
  71. });
  72. });