queuesLandingPage.spec.tsx 2.2 KB

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