index.spec.tsx 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. import {OrganizationFixture} from 'sentry-fixture/organization';
  2. import {render, screen} from 'sentry-test/reactTestingLibrary';
  3. import NoGroupsHandler from 'sentry/views/issueList/noGroupsHandler';
  4. describe('NoGroupsHandler', function () {
  5. const defaultProps = {
  6. api: new MockApiClient(),
  7. query: '',
  8. organization: OrganizationFixture(),
  9. groupIds: [],
  10. };
  11. it('displays default empty state when first event has been sent', async function () {
  12. MockApiClient.addMockResponse({
  13. url: '/organizations/org-slug/projects/',
  14. body: [],
  15. });
  16. MockApiClient.addMockResponse({
  17. url: '/organizations/org-slug/sent-first-event/',
  18. body: {sentFirstEvent: true},
  19. });
  20. render(<NoGroupsHandler {...defaultProps} />);
  21. expect(await screen.findByText('No issues match your search')).toBeInTheDocument();
  22. });
  23. it('displays default empty state when an error occurs', async function () {
  24. MockApiClient.addMockResponse({
  25. url: '/organizations/org-slug/projects/',
  26. statusCode: 500,
  27. });
  28. MockApiClient.addMockResponse({
  29. url: '/organizations/org-slug/sent-first-event/',
  30. statusCode: 500,
  31. });
  32. render(<NoGroupsHandler {...defaultProps} />);
  33. expect(await screen.findByText('No issues match your search')).toBeInTheDocument();
  34. });
  35. it('displays waiting for events state when first event has not been sent', async function () {
  36. MockApiClient.addMockResponse({
  37. url: '/organizations/org-slug/projects/',
  38. body: [],
  39. });
  40. MockApiClient.addMockResponse({
  41. url: '/organizations/org-slug/sent-first-event/',
  42. body: {sentFirstEvent: false},
  43. });
  44. render(<NoGroupsHandler {...defaultProps} />);
  45. expect(await screen.findByText(/Waiting for events/i)).toBeInTheDocument();
  46. });
  47. });